/* niasa storage — visual system taken from niasa.io dark mode.
   page #070a14 · surface #0d1221 · brand #3e65ff · Geist + Geist Mono
   Tokens are semantic; components never carry raw hex. */

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/geist.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/geist-mono.woff2') format('woff2');
}

:root {
  /* surfaces */
  --page:        #070a14;
  --surface:     #0d1221;
  --surface-2:   #10182c;
  --line:        #1e2740;
  --line-strong: #2f3f70;
  --line-input:  #2a3350;

  /* text — each pair checked against its own surface for 4.5:1 */
  --ink-900: #eef1fa;   /* primary   ~17:1 on page */
  --ink-700: #cdd3e6;   /* secondary ~12:1 */
  --ink-600: #98a2bf;   /* muted      ~6.9:1 */
  --ink-400: #6f7998;   /* faint      ~4.1:1 — meta only, never body */

  /* brand */
  --brand:      #3e65ff;   /* fill, always with white text */
  --brand-lit:  #7d9bff;   /* text/links on dark */
  --brand-soft: #9db3ff;   /* emphasis text on dark */
  --brand-tint: #14204a;   /* tinted surface */

  --radius-chip:  12px;
  --radius-input: 16px;
  --radius-card:  20px;
  --radius-panel: 32px;

  --shadow-card:  0 30px 60px #00000073;
  --shadow-modal: 0 49px 144px #0009;

  --ease-out-expo: cubic-bezier(.16, 1, .3, 1);
}

html { scroll-behavior: smooth; scrollbar-gutter: stable; }

body {
  background-color: var(--page);
  color: var(--ink-700);
  font-family: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}

.mono {
  font-family: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* ambient depth — subtle, and switched off for reduced-motion users */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora span { position: absolute; border-radius: 9999px; filter: blur(130px); }
.aurora .a1 { width: 42rem; height: 42rem; top: -16rem; left: -12rem; background: #3e65ff; opacity: .16; }
.aurora .a2 { width: 34rem; height: 34rem; bottom: -14rem; right: -10rem; background: #0f3fff; opacity: .13; }
.aurora .a3 { width: 26rem; height: 26rem; top: 34%; right: 26%; background: #7d9bff; opacity: .06; }

/* surfaces */
.glass {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}
@supports not (background: color-mix(in srgb, red, blue)) {
  .glass { background: rgba(13, 18, 33, .88); }
}
.glass-bar {
  background: color-mix(in srgb, var(--page) 78%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.sidebar-surface {
  background: linear-gradient(180deg, #0b1120 0%, #080c18 60%, #060911 100%);
  border-right: 1px solid var(--line);
}
.nav-active {
  background: linear-gradient(90deg, color-mix(in srgb, var(--brand) 26%, transparent), transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand-lit) 22%, transparent);
}

.card-hover { transition: border-color .2s var(--ease-out-expo), transform .2s var(--ease-out-expo); }
.card-hover:hover { border-color: color-mix(in srgb, var(--brand-lit) 38%, var(--line)); }

.text-gradient {
  background: linear-gradient(90deg, #9db3ff, #7d9bff 50%, #3e65ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* focus is never removed — only restyled (WCAG 2.4.7) */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand-lit);
  outline-offset: 2px;
  border-radius: 6px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #04060e; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid #04060e; }
::-webkit-scrollbar-thumb:hover { background: var(--brand); }

input, select, textarea, button { font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; }

/* honour the system setting rather than animating regardless */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .aurora { display: none; }
}

/* ---------------------------------------------------------------------------
   Form controls. The native checkbox/radio cannot be styled consistently
   across browsers, so the real input stays (keyboard, screen readers, form
   semantics) and only its appearance is replaced.
   --------------------------------------------------------------------------- */

.ctl {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  cursor: pointer;
  background-color: var(--page);
  border: 1.5px solid var(--line-input);
  border-radius: 0.45rem;
  transition: background-color .16s var(--ease-out-expo),
              border-color .16s var(--ease-out-expo),
              box-shadow .16s var(--ease-out-expo);
  display: inline-block;
  position: relative;
}
.ctl:hover:not(:disabled)  { border-color: var(--brand-lit); }
.ctl:focus-visible         { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent); }
.ctl:disabled              { opacity: .4; cursor: not-allowed; }

.ctl:checked {
  background-color: var(--brand);
  border-color: var(--brand);
  /* the tick is drawn, not a font glyph, so it stays crisp at any zoom */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5 6.5 11.5 12.5 5'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}
.ctl:checked:hover:not(:disabled) { background-color: var(--brand-lit); border-color: var(--brand-lit); }

/* radio variant */
.ctl-radio { border-radius: 50%; }
.ctl-radio:checked {
  background-color: var(--page);
  border-color: var(--brand);
  border-width: 5px;
  background-image: none;
}
.ctl-radio:checked:hover:not(:disabled) { background-color: var(--page); border-color: var(--brand-lit); }

/* a row that reads as one target: the whole thing highlights with the box */
.ctl-row { transition: background-color .16s var(--ease-out-expo); }
.ctl-row:hover { background-color: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.ctl-row:has(.ctl:checked) {
  background-color: color-mix(in srgb, var(--brand) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand-lit) 22%, transparent);
}
.ctl-row:has(.ctl:focus-visible) { box-shadow: inset 0 0 0 1px var(--brand-lit); }

/* card-shaped choice (role, mode, module) */
.ctl-card { transition: border-color .16s var(--ease-out-expo), background-color .16s var(--ease-out-expo); }
.ctl-card:has(input:checked) {
  border-color: color-mix(in srgb, var(--brand-lit) 55%, transparent);
  background-color: color-mix(in srgb, var(--brand) 12%, transparent);
}
.ctl-card:has(input:focus-visible) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent); }

/* segmented control */
.seg { display: inline-flex; padding: .25rem; gap: .25rem;
       background: var(--page); border: 1px solid var(--line); border-radius: .85rem; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: .375rem .9rem; border-radius: .6rem;
  font-size: .75rem; font-weight: 500; color: var(--ink-400);
  transition: background-color .16s var(--ease-out-expo), color .16s var(--ease-out-expo);
}
.seg label:hover span { color: var(--ink-700); }
.seg input:checked + span { background: var(--brand); color: #fff; }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent); }

/* :has() is well supported now, but keep a usable fallback */
@supports not selector(:has(*)) {
  .ctl-row:hover { background-color: var(--surface-2); }
}

/* ---------------------------------------------------------------------------
   Persian: Vazirmatn, and the handful of physical-direction rules that have
   to flip. Tailwind utilities here are physical (left/right), so rather than
   rewriting every class the layout-critical ones are mirrored under [dir=rtl].
   --------------------------------------------------------------------------- */

@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/vazirmatn.woff2') format('woff2');
}

[dir="rtl"] body {
  /* Latin still renders from Geist for identifiers inside Persian text */
  font-family: 'Vazirmatn', 'Geist', system-ui, sans-serif;
}
/* paths, sizes, snapshot ids and commands stay LTR so they remain readable
   and copy-pasteable inside an RTL page */
[dir="rtl"] .mono,
[dir="rtl"] pre,
[dir="rtl"] code,
[dir="rtl"] input[type="search"],
[dir="rtl"] .ltr { direction: ltr; text-align: left; unicode-bidi: isolate; }
[dir="rtl"] .tabular-nums { direction: ltr; unicode-bidi: isolate; }

/* shell */
[dir="rtl"] #sidebar { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--line); }
[dir="rtl"] #sidebar.-translate-x-full { transform: translateX(100%); }
[dir="rtl"] .lg\:pl-64 { padding-left: 0; }
@media (min-width: 1024px) { [dir="rtl"] .lg\:pl-64 { padding-right: 16rem; } }
[dir="rtl"] .nav-active {
  background: linear-gradient(270deg, color-mix(in srgb, var(--brand) 26%, transparent), transparent);
}
[dir="rtl"] .aurora .a1 { left: auto; right: -12rem; }
[dir="rtl"] .aurora .a2 { right: auto; left: -10rem; }

/* common physical utilities that carry layout meaning */
[dir="rtl"] .ml-auto  { margin-left: 0; margin-right: auto; }
[dir="rtl"] .mr-auto  { margin-right: 0; margin-left: auto; }
[dir="rtl"] .text-left  { text-align: right; }
[dir="rtl"] .text-right { text-align: left; }
[dir="rtl"] .-rotate-90 { transform: rotate(90deg); }

/* arrows in links point the other way when the text does */
[dir="rtl"] .flip-x { display: inline-block; transform: scaleX(-1); }
