/* ==========================================================================
   IVAS — design tokens
   Colours marked "sampled" were read off assets/images/ivas-logo.png with
   Pillow (median of tile / letter pixels), not eyeballed.
   ========================================================================== */

:root {
  /* ---- brand ---------------------------------------------------------- */
  --navy-900: #07173F;   /* derived deepest navy — used instead of any near-black */
  --navy-800: #041F55;
  --navy-700: #002874;   /* sampled: wordmark strokes (n=96 658) */
  --navy-600: #123C8C;
  --blue-500: #1766C0;   /* business-card blue — links on light, energy gradient */
  --blue-300: #6E9BD8;
  --yellow-400: #FFD500; /* sampled: top lattice tile */
  --yellow-300: #FFE45C;
  --haze-300: #8E97AD;   /* derived cool midtone */
  --haze-200: #B6BDCB;

  /* ---- concrete neutrals (cool, never cream) --------------------------- */
  --concrete-50:  #F3F4F2;
  --concrete-100: #E6E8E6;
  --concrete-300: #C9CCCB;
  --concrete-500: #8A908E;
  --white: #FFFFFF;

  /* channel triplets, for rgba() with a variable alpha */
  --navy-rgb:      7, 23, 63;
  --navy-700-rgb:  0, 40, 116;
  --white-rgb:     255, 255, 255;
  --accent-rgb:    255, 213, 0;

  /* ---- semantic: LIGHT theme (rev3 §5) ---------------------------------
     Components read only these. The dark theme below redefines the same
     names; nothing outside this file names a palette colour. */
  --bg:            var(--concrete-50);
  --bg-elev:       var(--white);
  --bg-sunken:     var(--concrete-100);
  --fg:            var(--navy-900);
  --fg-strong:     var(--navy-700);
  --fg-muted:      #4A5570;
  /* Darkened from #6B7590, which measured 4.16:1 on --concrete-50 and failed AA.
     #5E667E clears 4.5:1 on all three light surfaces (5.18 / 5.71 / 4.64). */
  --fg-faint:      #5E667E;
  --line:          rgba(var(--navy-rgb), .08);
  --line-strong:   rgba(var(--navy-rgb), .16);
  --card:          var(--white);
  --card-hover:    var(--white);
  --accent:        var(--yellow-400);
  --accent-hi:     var(--yellow-300);
  --accent-fg:     var(--navy-900);
  --link:          var(--blue-500);
  --focus:         var(--navy-700);
  --focus-ring:    rgba(var(--navy-700-rgb), .12);
  --sel-bg:        rgba(var(--navy-700-rgb), .05);
  --danger:        #C42B27;            /* 5.6:1 on white */
  --ok:            #2BB24C;  --ok-ring:  rgba(43, 178, 76, .2);
  --bad:           #E3312D;  --bad-ring: rgba(227, 49, 45, .18);
  --shadow-1:      0 2px 10px rgba(var(--navy-rgb), .06);
  --shadow-2:      0 24px 64px rgba(var(--navy-rgb), .18);
  --shadow-hover:  0 12px 28px rgba(var(--navy-rgb), .14);
  --shadow-edge:   rgba(var(--navy-rgb), .16);
  --bg-zebra:      rgba(var(--navy-rgb), .035);
  --grid-line:     rgba(var(--navy-rgb), .07);
  --skel:          var(--concrete-300);
  /* buttons: primary is filled, outline is the secondary, ghost is quiet */
  --btn-primary:       var(--navy-700);
  --btn-primary-hover: var(--navy-900);
  --btn-primary-fg:    var(--white);
  --btn-outline:       var(--navy-700);
  /* the inverted pill on a page surface (navy on light, light on dark) */
  --inv-bg:        var(--navy-900);
  --inv-fg:        var(--white);
  --packshot:      #fff;               /* product photos shot on white */
  --plate:         var(--packshot);    /* the tile behind a packshot */
  --plate-pad:     0px;
  --plate-r:       0px;
  --scrim:         0;                  /* extra photo scrim; dark theme raises it */
  --theme-color:   #F3F4F2;

  /* ---- chrome: navbar, footer, CTA band, mobile menu, preloader ----------
     Navy in both themes. */
  --chrome:          var(--navy-900);
  --chrome-2:        var(--navy-800);
  --chrome-hover:    var(--navy-700);
  --chrome-fg:       var(--white);
  --chrome-icon:     var(--haze-300);
  --chrome-pill:     var(--white);
  --chrome-pill-fg:  var(--navy-900);
  --chrome-edge:     transparent;      /* dark theme: a hairline so chrome still reads */
  --accent-on-chrome: var(--yellow-400);
  --navy-chrome:     var(--chrome);

  /* material textures stand in for photographs: same in both themes */
  --tex-hi: #fff; --tex-1: #DCE0E4; --tex-2: #D6D8D4; --tex-3: #BFC2BD; --tex-4: #D7DAD8;
  --tex-line: rgba(0, 0, 0, .09);
  --tex-s1: var(--navy-700); --tex-s2: var(--blue-500); --tex-s3: var(--haze-300); --tex-s4: var(--yellow-400);

  /* rev1/rev2 names, kept as aliases */
  --bg-raised:     var(--bg-elev);
  --ink:           var(--fg);
  --ink-strong:    var(--fg-strong);
  --ink-muted:     var(--fg-muted);
  --ink-faint:     var(--fg-faint);

  --ease-panel:    cubic-bezier(.2, .8, .2, 1);
  --dur-panel:     260ms;
  color-scheme: light;

  /* On dark surfaces. Rev1 raised both translucent tiers: measured against the
     rendered photograph (qa/rev1-contrast.js) 12px text at .72 white came in
     at 3.2-4.3:1 over the brighter slides, and the .52 breadcrumb as low as
     2.6:1. These land the same copy at 4.5:1+ without going fully opaque and
     flattening the hierarchy. */
  --on-dark:        #FFFFFF;
  --on-dark-muted:  rgba(255, 255, 255, .86);
  --on-dark-faint:  rgba(255, 255, 255, .72);
  --line-dark:      rgba(255, 255, 255, .16);

  /* ---- energy scale (energy widget only) -------------------------------- */
  --e-a: #1E9E4A; --e-b: #5DB947; --e-c: #B5D334; --e-d: #F4E21B;
  --e-e: #F7B52C; --e-f: #EF7D22; --e-g: #E3312D;

  /* ---- type ------------------------------------------------------------- */
  --font-sans: 'Manrope', 'Manrope Fallback', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Plex Fallback', ui-monospace, SFMono-Regular, Menlo, monospace;

  --fs-body:    clamp(1rem, .4vw + .9rem, 1.125rem);
  --fs-small:   clamp(.85rem, .2vw + .8rem, .9375rem);
  --fs-micro:   .78rem;
  --fs-h3:      clamp(1.15rem, 1.1vw + .9rem, 1.45rem);
  --fs-h2:      clamp(1.8rem, 3.2vw + .6rem, 3rem);
  --fs-display: clamp(2.4rem, 6vw, 5rem);
  --lh-body: 1.6;
  --lh-tight: 1.12;
  --measure: 68ch;

  /* ---- layout ----------------------------------------------------------- */
  --maxw: 1440px;
  --gutter: clamp(16px, 2.5vw, 32px);
  /* Rev2 §5. The gap between two neighbouring blocks is the bottom padding of one
     section plus the top padding of the next, so sections pad by half this value
     and the gap between blocks is --section-y itself. */
  --section-y: clamp(48px, 7vw, 96px);
  --section-head-gap: clamp(20px, 3vw, 36px);
  --frame: 10px;            /* hero card inset */

  /* ---- radii (hierarchy, not one value) ---------------------------------- */
  --r-card: 28px;
  --r-glass: 18px;
  --r-tile: 14px;
  --r-input: 12px;
  --r-pill: 999px;

  /* ---- motion ------------------------------------------------------------ */
  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --ease-in-out: cubic-bezier(.65, .05, .36, 1);
  --ease-back: cubic-bezier(.34, 1.56, .64, 1);
  /* §8 — one band, 180-450ms. The hero crossfade (1200ms) and the marquee sit
     outside it deliberately: they are ambient, not responses to an action. */
  --dur-fast: 180ms;
  --dur: 320ms;
  --dur-slow: 440ms;

  /* ---- header controls (rev2 §3.2) --------------------------------------- */
  --pill-fs: 1rem; --pill-h: 42px; --pill-px: 18px; --pill-gap: 6px;
  --circle: 42px;
  --cta-h: 48px; --cta-fs: 1rem; --cta-i: 40px; --cta-pl: 20px;

  /* ---- chrome ------------------------------------------------------------ */
  /* Rev1 §3.2 — one source of truth for how much room the fixed bottom UI
     occupies. Anything that could sit under the AI FAB, the back-to-top button
     or the mobile dock reserves --bottom-ui-h at its foot. */
  --fab-size: 56px;
  --fab-inset: 24px;
  --bottom-ui-h: calc(var(--fab-size) + var(--fab-inset) + 16px);   /* 96px */
  --bottom-row-h: 64px;     /* mobile fixed bottom row */
  --z-header: 60;
  --z-dock: 70;
  --z-fab: 71;
  --z-sheet: 90;
  --z-overlay: 95;
  --z-transition: 98;
  --z-preloader: 100;
}

/* ---- DARK theme (rev3 §5) ------------------------------------------------
   Chosen with the toggle (data-theme="dark"), or by the system when the
   visitor has not chosen (data-theme absent). The two rule sets are identical;
   CSS has no way to share one declaration block between a selector and a
   media query without a preprocessor. Contrast ratios are in IZVESTAJ_REV3.md. */
:root[data-theme='dark'] {
  --bg:            #0B1430;
  --bg-elev:       #13204A;
  --bg-sunken:     #07173F;
  --fg:            #EEF1F7;
  --fg-strong:     #FFFFFF;
  --fg-muted:      rgba(238, 241, 247, .72);
  --fg-faint:      rgba(238, 241, 247, .62);
  --line:          rgba(var(--white-rgb), .10);
  --line-strong:   rgba(var(--white-rgb), .18);
  --card:          #13204A;
  --card-hover:    #182859;
  --link:          #8DB4EC;
  --focus:         var(--yellow-400);
  --focus-ring:    rgba(var(--accent-rgb), .28);
  --sel-bg:        rgba(var(--white-rgb), .06);
  --danger:        #FF8A80;
  --shadow-1:      0 2px 10px rgba(0, 0, 0, .28);
  --shadow-2:      0 24px 64px rgba(0, 0, 0, .5);
  --shadow-hover:  0 12px 28px rgba(0, 0, 0, .4);
  --shadow-edge:   rgba(0, 0, 0, .45);
  --bg-zebra:      rgba(var(--white-rgb), .03);
  --grid-line:     rgba(var(--white-rgb), .05);
  --skel:          rgba(var(--white-rgb), .08);
  --btn-primary:       #EEF1F7;
  --btn-primary-hover: #FFFFFF;
  --btn-primary-fg:    var(--navy-900);
  --btn-outline:       #EEF1F7;
  --inv-bg:        #EEF1F7;
  --inv-fg:        var(--navy-900);
  --plate:         var(--bg-elev);
  --plate-pad:     8px;
  --plate-r:       6px;
  --scrim:         .08;
  --theme-color:   #0B1430;
  --chrome-edge:   rgba(var(--white-rgb), .12);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg:            #0B1430;
    --bg-elev:       #13204A;
    --bg-sunken:     #07173F;
    --fg:            #EEF1F7;
    --fg-strong:     #FFFFFF;
    --fg-muted:      rgba(238, 241, 247, .72);
    --fg-faint:      rgba(238, 241, 247, .62);
    --line:          rgba(var(--white-rgb), .10);
    --line-strong:   rgba(var(--white-rgb), .18);
    --card:          #13204A;
    --card-hover:    #182859;
    --link:          #8DB4EC;
    --focus:         var(--yellow-400);
    --focus-ring:    rgba(var(--accent-rgb), .28);
    --sel-bg:        rgba(var(--white-rgb), .06);
    --danger:        #FF8A80;
    --shadow-1:      0 2px 10px rgba(0, 0, 0, .28);
    --shadow-2:      0 24px 64px rgba(0, 0, 0, .5);
    --shadow-hover:  0 12px 28px rgba(0, 0, 0, .4);
    --shadow-edge:   rgba(0, 0, 0, .45);
    --bg-zebra:      rgba(var(--white-rgb), .03);
    --grid-line:     rgba(var(--white-rgb), .05);
    --skel:          rgba(var(--white-rgb), .08);
    --btn-primary:       #EEF1F7;
    --btn-primary-hover: #FFFFFF;
    --btn-primary-fg:    var(--navy-900);
    --btn-outline:       #EEF1F7;
    --inv-bg:        #EEF1F7;
    --inv-fg:        var(--navy-900);
    --plate:         var(--bg-elev);
    --plate-pad:     8px;
    --plate-r:       6px;
    --scrim:         .08;
    --theme-color:   #0B1430;
    --chrome-edge:   rgba(var(--white-rgb), .12);
    color-scheme: dark;
  }
}

/* Theme switch: colours only, 200ms, never under reduced motion. The class is
   added by theme.js for the length of one switch, so page loads and hover
   states are not slowed by a blanket transition. */
:root.theme-anim, :root.theme-anim *, :root.theme-anim *::before, :root.theme-anim *::after {
  transition: background-color 200ms linear, color 200ms linear, border-color 200ms linear, fill 200ms linear, stroke 200ms linear !important;
}
@media (prefers-reduced-motion: reduce) {
  :root.theme-anim, :root.theme-anim * { transition: none !important; }
}

/* Rev1 §2 — per-slide scrim strength. Registering it lets the value animate,
   so the scrim crossfades with the photograph instead of stepping. Browsers
   without @property still honour the value, they just do not tween it. */
@property --scrim-strength {
  syntax: '<number>';
  inherits: true;
  initial-value: 1;
}
@property --scrim-top {
  syntax: '<number>';
  inherits: true;
  initial-value: 1;
}
:root { --scrim-strength: 1; --scrim-top: 1; }

@media (max-width: 1023px) {
  /* Below 1024 the fixed bottom UI is the whole dock row, not just the FAB. */
  :root {
    --fab-size: 52px;
    --fab-inset: 16px;
    --bottom-row-h: 72px;
    --bottom-ui-h: calc(var(--bottom-row-h) + 16px);   /* 88px */
  }
}

@media (max-width: 767px) {
  :root { --frame: 8px; --r-card: 22px; }
}

/* Rev4 §4.3 — paper is white whatever theme is on screen. The light values are
   restated here so a page printed from dark mode is still dark-on-white. */
@media print {
  :root, :root[data-theme='dark'], :root:not([data-theme='light']) {
    --bg: #FFFFFF; --bg-elev: #FFFFFF; --bg-sunken: var(--concrete-100);
    --fg: var(--navy-900); --fg-strong: var(--navy-700); --fg-muted: #4A5570; --fg-faint: #5E667E;
    --line: rgba(var(--navy-rgb), .16); --line-strong: rgba(var(--navy-rgb), .3);
    --card: #FFFFFF; --card-hover: #FFFFFF; --link: var(--blue-500); --danger: #C42B27;
    --bg-zebra: rgba(var(--navy-rgb), .035); --grid-line: transparent; --sel-bg: transparent;
    --btn-primary: var(--navy-700); --btn-primary-fg: #FFFFFF; --btn-outline: var(--navy-700);
    --inv-bg: var(--navy-900); --inv-fg: #FFFFFF;
    --plate: #FFFFFF; --plate-pad: 0px; --scrim: 0;
    color-scheme: light;
  }
}
