/* ==========================================================================
   DONO STREAM (دونو استریم) — Design Tokens
   Brand: vivid violet + neon orchid on deep purple-black; flat surfaces, hairline borders, RTL/Persian-first.
   Font: Iran Sans (self-hosted, static weights).
     - 'IRANSansFaNum' (Persian-style digit glyphs) is the default UI font —
       feels native for Persian body text, labels, and headings.
     - 'IRANSans' (plain Western digit glyphs) is used only where a number
       must read as a precise, always-Western-Arabic-numeral value — see
       .num-tabular below — so amounts stay unambiguous in tables/exports.
   Each weight ships as its own static TTF file (not a variable font), so
   font-weight below maps to the nearest shipped weight file by design:
   100/200 -> UltraLight, 300 -> Light, 400 -> Regular, 500 -> Medium, 700 -> Bold.
   ========================================================================== */

@font-face{font-family:'IRANSansFaNum';src:url('/static/fonts/IRANSANS_FANUM__ULTRALIGHT.TTF') format('truetype');font-weight:100 200;font-style:normal;font-display:swap}
@font-face{font-family:'IRANSansFaNum';src:url('/static/fonts/IRANSANS_FANUM__LIGHT.TTF') format('truetype');font-weight:300;font-style:normal;font-display:swap}
@font-face{font-family:'IRANSansFaNum';src:url('/static/fonts/IRANSANS_FANUM_.TTF') format('truetype');font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:'IRANSansFaNum';src:url('/static/fonts/IRANSANS_FANUM__MEDIUM.TTF') format('truetype');font-weight:500;font-style:normal;font-display:swap}
@font-face{font-family:'IRANSansFaNum';src:url('/static/fonts/IRANSANS_FANUM__BOLD.TTF') format('truetype');font-weight:600 900;font-style:normal;font-display:swap}

@font-face{font-family:'IRANSans';src:url('/static/fonts/IRANSANS_ULTRALIGHT.TTF') format('truetype');font-weight:100 200;font-style:normal;font-display:swap}
@font-face{font-family:'IRANSans';src:url('/static/fonts/IRANSANS_LIGHT.TTF') format('truetype');font-weight:300;font-style:normal;font-display:swap}
@font-face{font-family:'IRANSans';src:url('/static/fonts/IRANSANS.TTF') format('truetype');font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:'IRANSans';src:url('/static/fonts/IRANSANS_MEDIUM.TTF') format('truetype');font-weight:500;font-style:normal;font-display:swap}
@font-face{font-family:'IRANSans';src:url('/static/fonts/IRANSANS_BOLD.TTF') format('truetype');font-weight:600 900;font-style:normal;font-display:swap}


/* ==========================================================================
   LAYER 1 — PRIMITIVES (raw values; never used directly in components)
   ========================================================================== */
:root{
  /* Violet / orchid: the existing Dono Stream brand hues, kept as-is. */
  --violet-300:#C3A0FF; --violet-500:#9B5CFF; --violet-600:#6D2FD9;
  --orchid-200:#E6BBFF; --orchid-400:#D07BFF; --orchid-500:#A84FE0;
  /* Cool "signal" hue used sparingly for live / goal / info states. */
  --signal-400:#3FD2FF;
  /* Ink: deep purple-black neutrals (page → raised → elevated → hover). */
  --ink-950:#07050D; --ink-900:#110B1C; --ink-800:#1A1229; --ink-700:#241A38;
  --ink-100:#F6F2FC; --ink-300:#B3A8C9; --ink-400:#9A8FB2;
  --gold-400:#FFC94A;
  --green-400:#2FD37B; --amber-400:#F5B93D; --red-400:#F0476B; --red-300:#FF6B8A;
}

/* ==========================================================================
   LAYER 2 — SEMANTIC TOKENS (purpose aliases; names kept backwards-compatible)
   Contrast verified (WCAG, on --color-surface-raised unless noted):
     text-primary 16:1 · text-secondary 8.6:1 · text-muted 6.4:1
     on-brand text on action-primary 7.0:1 · link 11.9:1 · error 5.4:1
     form-control border on elevated 3.8:1 (≥3:1 for UI components)
   ========================================================================== */
:root{
  /* ---- Brand ---- */
  --color-brand-primary:      var(--violet-500);
  --color-brand-primary-dim:  var(--violet-600);
  --color-brand-primary-tint: var(--violet-300);
  --color-brand-accent:       var(--orchid-400);
  --color-brand-accent-dim:   var(--orchid-500);
  --color-brand-accent-tint:  var(--orchid-200);
  --color-signal:             var(--signal-400);

  /* ---- Surfaces: flat, solid, separated by hairlines (no blur/glass) ---- */
  --color-surface-page:      var(--ink-950);
  --color-surface-raised:    var(--ink-900);
  --color-surface-elevated:  var(--ink-800);
  --color-surface-hover:     var(--ink-700);
  --color-surface-inverse:   #F7F3FD;
  --color-surface-glass:        rgba(255,255,255,.05);   /* subtle tint (chips, hovers) */
  --color-surface-glass-strong: rgba(255,255,255,.09);

  /* ---- Content ---- */
  --color-text-primary:    var(--ink-100);
  --color-text-secondary:  var(--ink-300);
  --color-text-muted:      var(--ink-400);
  --color-text-on-brand:   #1B0B33;
  --color-text-on-inverse: #150A24;
  --color-text-link:       var(--orchid-200);

  /* ---- Actions ---- */
  --color-action-primary:        var(--orchid-400);
  --color-action-primary-hover:  var(--orchid-200);
  --color-action-primary-active: #BE62F5;
  --color-action-primary-text:   var(--color-text-on-brand);
  --color-action-secondary:      transparent;
  --color-action-secondary-border: rgba(195,160,255,.55);
  --color-focus-ring:  var(--orchid-200);

  /* ---- State ---- */
  --color-success: var(--green-400);
  --color-warning: var(--amber-400);
  --color-error:   var(--red-300);       /* lighter red keeps ≥7:1 for small text */
  --color-error-solid: var(--red-400);
  --color-info:    var(--signal-400);
  --color-success-bg: rgba(47,211,123,.10);  --color-success-border: rgba(47,211,123,.35);
  --color-warning-bg: rgba(245,185,61,.10);  --color-warning-border: rgba(245,185,61,.35);
  --color-error-bg:   rgba(240,71,107,.12);  --color-error-border:   rgba(255,107,138,.40);

  /* ---- Top-performers podium (rank colours, not literal metals) ---- */
  --color-podium-gold:   var(--gold-400);
  --color-podium-silver: #B06BFF;
  --color-podium-bronze: var(--signal-400);

  /* ---- Borders / dividers ---- */
  --color-border-hair:   rgba(190,160,255,.16);   /* decorative separators */
  --color-border-strong: rgba(190,160,255,.32);
  --color-border-control:#7B6BA0;                 /* inputs: ≥3:1 against surfaces */
  --color-divider:       rgba(255,255,255,.08);

  /* ---- Typography ---- */
  --font-family-base: 'IRANSansFaNum', 'IRANSans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-family-tabular: 'IRANSans', 'IRANSansFaNum', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fs-display: clamp(2rem, 1.4rem + 2.8vw, 3.5rem);
  --fs-h1:      clamp(1.65rem, 1.3rem + 1.5vw, 2.4rem);
  --fs-h2:      clamp(1.35rem, 1.1rem + 1vw, 1.8rem);
  --fs-h3:      1.2rem;
  --fs-body-lg: 1.125rem;
  --fs-body:    1rem;
  --fs-small:   .9rem;
  --fs-caption: .8125rem;      /* 13px floor — nothing smaller than this */
  --lh-tight:  1.35;           /* Persian headings need >1.3 so marks don't clip */
  --lh-normal: 1.75;           /* Persian body text reads best 1.7–1.8 */

  /* ---- Spacing (8px base) ---- */
  --space-1: .25rem;  --space-2: .5rem;  --space-3: .75rem;
  --space-4: 1rem;    --space-5: 1.5rem; --space-6: 2rem;
  --space-7: 2.5rem;  --space-8: 3rem;   --space-9: 4rem;  --space-10: 6rem;

  /* ---- Radius / elevation (flat: shadows are for overlays only) ---- */
  --radius-sm: 10px; --radius-md: 14px; --radius-lg: 20px; --radius-pill: 999px;
  --shadow-card:    0 1px 0 rgba(255,255,255,.04) inset;
  --shadow-overlay: 0 18px 44px rgba(3,1,8,.6);
  /* Legacy names kept so nothing referencing them breaks; intentionally subtle now. */
  --shadow-glow-brand:  none;
  --shadow-glow-accent: none;

  /* ---- Motion: 150–320ms, ease-out in, shorter out ---- */
  --ease-out-expo: cubic-bezier(.16,1,.3,1);
  --ease-soft:     cubic-bezier(.25,.8,.35,1);
  --dur-fast: .16s; --dur-normal: .28s; --dur-slow: .5s;
  --rise: 10px;

  /* ---- Layout ---- */
  --container-max: 1200px;
  --container-pad: clamp(16px, 4vw, 40px);
  --header-h: 72px;
  --tap-min: 44px;               /* minimum touch target */
}

/* ==========================================================================
   LAYER 3 — COMPONENT TOKENS
   ========================================================================== */
:root{
  --button-radius: var(--radius-pill);
  --button-h: 48px;  --button-h-sm: 40px;  --button-h-lg: 56px;
  --button-primary-bg: var(--color-action-primary);
  --button-primary-bg-hover: var(--color-action-primary-hover);
  --button-primary-bg-active: var(--color-action-primary-active);
  --button-primary-fg: var(--color-action-primary-text);
  --input-h: 48px;
  --input-bg: var(--color-surface-elevated);
  --input-border: var(--color-border-control);
  --input-border-focus: var(--color-brand-accent);
  --input-radius: var(--radius-sm);
  --card-bg: var(--color-surface-raised);
  --card-border: var(--color-border-hair);
  --card-radius: var(--radius-md);
  --card-pad: var(--space-5);
}

/* ---- Base reset ---- */
*,*::before,*::after{box-sizing:border-box}
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%}
body{
  margin:0;
  background:var(--color-surface-page);
  color:var(--color-text-primary);
  font-family:var(--font-family-base);
  font-size:var(--fs-body);
  line-height:var(--lh-normal);
  direction:rtl;
  text-align:start;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
img,svg{display:block;max-width:100%}
a{color:inherit;text-decoration:none}
ul{list-style:none;margin:0;padding:0}
button{font:inherit;color:inherit}
h1,h2,h3,p{margin:0}
h1,h2,h3{line-height:var(--lh-tight);text-wrap:balance}
:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:3px;border-radius:6px}
::selection{background:rgba(208,123,255,.35)}

/* Numerals: monetary/stat amounts always render with plain Western digits
   (the non-FaNum face) for unambiguous alignment in tables/exports, even
   though the rest of the UI uses the Persian-digit face by default. */
.num-tabular{font-family:var(--font-family-tabular);font-variant-numeric:tabular-nums;direction:ltr;unicode-bidi:isolate;display:inline-block}

.container{max-width:var(--container-max);margin-inline:auto;padding-inline:var(--container-pad)}
.text-muted{color:var(--color-text-secondary)}
.text-faint{color:var(--color-text-muted)}
.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.skip-link{position:absolute;inset-inline-start:var(--space-4);top:-100px;z-index:100;padding:var(--space-3) var(--space-4);border-radius:var(--radius-sm);background:var(--color-action-primary);color:var(--color-action-primary-text);font-weight:700}
.skip-link:focus{top:var(--space-3)}

/* ---- Surface: ".glass" is kept as a class name for template compatibility
   but is now a flat, solid surface — no backdrop blur, no gradient border. ---- */
.glass,.card{
  background:var(--card-bg);
  border:1px solid var(--card-border);
  border-radius:var(--card-radius);
}
.glass{border-radius:var(--radius-lg)}
.card{box-shadow:var(--shadow-card)}

/* ---- Brand motif: "capture frame" corner brackets (stream-overlay nod) ---- */
.frame{position:relative}
.frame::before{
  content:"";position:absolute;inset:-1px;border-radius:inherit;pointer-events:none;
  --c:var(--color-brand-accent); --l:22px; --w:2px;
  background:
    linear-gradient(var(--c),var(--c)) top left/var(--l) var(--w) no-repeat,
    linear-gradient(var(--c),var(--c)) top left/var(--w) var(--l) no-repeat,
    linear-gradient(var(--c),var(--c)) top right/var(--l) var(--w) no-repeat,
    linear-gradient(var(--c),var(--c)) top right/var(--w) var(--l) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom left/var(--l) var(--w) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom left/var(--w) var(--l) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom right/var(--l) var(--w) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom right/var(--w) var(--l) no-repeat;
}

/* ---- Buttons ---- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:var(--space-2);
  min-height:var(--button-h);padding:.6em 1.5em;border-radius:var(--button-radius);
  font-size:var(--fs-body);font-weight:600;line-height:1.2;cursor:pointer;
  border:1px solid transparent;background:transparent;
  transition:background-color var(--dur-fast) var(--ease-soft),border-color var(--dur-fast) var(--ease-soft),transform var(--dur-fast) var(--ease-soft),opacity var(--dur-fast);
  white-space:nowrap;text-align:center;-webkit-tap-highlight-color:transparent;
}
.btn:active{transform:scale(.98)}
.btn[disabled],.btn[aria-disabled="true"]{opacity:.45;cursor:not-allowed;pointer-events:none}
.btn-primary{background:var(--button-primary-bg);color:var(--button-primary-fg)}
.btn-primary:hover{background:var(--button-primary-bg-hover)}
.btn-primary:active{background:var(--button-primary-bg-active)}
.btn-ghost{color:var(--color-text-primary);border-color:var(--color-action-secondary-border)}
.btn-ghost:hover{background:var(--color-surface-glass-strong);border-color:var(--color-brand-primary-tint)}
.btn-sm{min-height:var(--button-h-sm);padding:.4em 1.1em;font-size:var(--fs-small)}
.btn-lg{min-height:var(--button-h-lg);padding:.7em 2em;font-size:var(--fs-body-lg)}
.btn-block{width:100%}
@media (pointer:coarse){.btn-sm{min-height:var(--tap-min)}}
/* Loading: add aria-busy="true" (and class .is-loading) while a request is in flight. */
.btn.is-loading,.btn[aria-busy="true"]{position:relative;color:transparent;pointer-events:none}
.btn.is-loading::after,.btn[aria-busy="true"]::after{content:"";position:absolute;width:1.1em;height:1.1em;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;color:var(--button-primary-fg);animation:btn-spin .7s linear infinite}
.btn-ghost.is-loading::after{color:var(--color-text-primary)}
@keyframes btn-spin{to{transform:rotate(360deg)}}

/* ---- Entrance motion (respects reduced motion) ---- */
@media (prefers-reduced-motion:no-preference){
  @keyframes en-lift{from{opacity:0;translate:0 var(--rise)}}
  .en-lift{animation:en-lift var(--dur-slow) var(--ease-soft) both}
  .en-wipe{animation:en-lift .6s var(--ease-out-expo) both}
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}
}

/* ---- Scroll-triggered reveal (IntersectionObserver-driven; see nav.js) ---- */
@media (prefers-reduced-motion:no-preference){
  .scroll-reveal{opacity:0;translate:0 18px;transition:opacity .6s var(--ease-out-expo), translate .6s var(--ease-out-expo)}
  .scroll-reveal.is-visible{opacity:1;translate:0 0}
}
