/* ==========================================================================
   Base: reset, typography, RTL helpers, utilities, motion primitives
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scrollbar-color: var(--scrollbar) transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  line-height: var(--lh-base);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 100% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, var(--bg-glow-2), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01";
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  color: var(--text);
}
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }
table { border-collapse: collapse; width: 100%; }
hr { border: 0; border-top: 1px solid var(--divider); margin: var(--sp-4) 0; }
code, kbd, samp, pre { font-family: var(--font-mono); }
::selection { background: var(--indigo-soft); color: var(--text); }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-xs); }

/* Thin scrollbars inside the app */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Icons — sprite symbols inherit stroke styling from here */
.icon {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
/* Directional icons flip in RTL so "forward" points left */
[dir="rtl"] .icon--flip { transform: scaleX(-1); }

/* ---------- RTL & technical text ---------- */
/* Technical values (IP, host, port, username, keys) are LTR and Latin-digit. */
.ltr { direction: ltr; unicode-bidi: isolate; text-align: start; }
[dir="rtl"] .ltr { text-align: right; }
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: -0.01em;
  direction: ltr;
  unicode-bidi: isolate;
}
.num { font-variant-numeric: tabular-nums; }

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.fw-medium { font-weight: var(--fw-medium); }
.fw-semibold { font-weight: var(--fw-semibold); }

.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--sp-4)); }
.stack--sm { --stack-gap: var(--sp-2); }
.stack--lg { --stack-gap: var(--sp-6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--sp-2)); }
.row { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.row--between { justify-content: space-between; }
.spacer { flex: 1; }

.grid { display: grid; gap: var(--grid-gap, var(--sp-4)); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-min, 280px), 100%), 1fr)); }

[x-cloak] { display: none !important; }
.skip-link {
  position: fixed; top: var(--sp-3); right: var(--sp-3); z-index: var(--z-tooltip);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-full);
  background: var(--accent); color: var(--accent-ink); font-weight: var(--fw-semibold);
  transform: translateY(-200%); transition: transform var(--dur-2) var(--ease-out);
}
.skip-link:focus-visible { transform: none; }

/* ---------- Motion primitives ---------- */
@keyframes iv-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes iv-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes iv-pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes iv-spin { to { transform: rotate(360deg); } }
@keyframes iv-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes iv-ping { 0% { transform: scale(1); opacity: 0.7; } 80%, 100% { transform: scale(2.4); opacity: 0; } }
@keyframes iv-shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

/* Children rise in sequence on page load / navigation */
/* fill-mode backwards (not both): a finished entrance must not keep a transform, or every block stays its own
   stacking context and traps dropdowns/hover cards beneath the blocks that follow it. */
.stagger > * { animation: iv-rise var(--dur-4) var(--ease-out) backwards; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
.stagger > *:nth-child(7) { animation-delay: 240ms; }
.stagger > *:nth-child(n + 8) { animation-delay: 280ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
