/* ═══════════════════════════════════════════════════════════════════════
   {{BRAND}} · ATELIER — the premium skin for the whole ad system.

   One idea: this is a screening room. The ads are ivory, gold and ice —
   they are the light source. The interface is the dark theatre around
   them: an ink-blue night canvas (Nocturne), two temperatures of ambient
   light (Frost high-left · Champagne low-right — the brand's DAY/NIGHT
   duality), fine film grain, and Fraunces as the display voice.

   Loaded LAST in every page's <head>, after the page's inline styles, so
   equal-specificity rules here win the cascade. Token selectors are
   prefixed with `html` for two reasons:
   1. specificity — html:root (0,1,1) outranks the pages' :root (0,1,0),
      and html:root[data-theme] / html:root:not(...) (0,2,1) outrank the
      pages' (0,2,0) blocks.
   2. EXPORT SAFETY — the Builder serialises every stylesheet into an SVG
      foreignObject when exporting ad PNGs. Inside that SVG there is no
      <html> element, so nothing in this file can restyle an exported ad.

   Dark is the default. data-theme="light" (gv_theme key) = Daylight.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 1 · TOKENS · Atelier Noir (default) ─────────────────────────────── */
html:root,
html:root[data-theme="dark"] {
  --ink:   #EFEDE8;   /* Bone */
  --ink-2: #C6C4BE;
  --mute:  #8B8D94;
  --faint: #565962;
  --line:  #232936;   /* Seam */
  --line-2:#1A1F29;
  --paper: #12151D;   /* Onyx */
  --wash:  #0B0D12;   /* Nocturne */
  --sink:  #080A0E;   /* Undertow */
  --gold:  #C7A45B;   /* Champagne · locked brand gold */
  --frost: #A9C6DC;   /* ambience only · never interactive */
  --win:   #57A47E;  --win-bg:#12281D;
  --ok:    #C9A94E;  --ok-bg: #2A2416;
  --bad:   #D97A66;  --bad-bg:#2A1815;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  html:root:not([data-theme="light"]) {
    --ink:#EFEDE8; --ink-2:#C6C4BE; --mute:#8B8D94; --faint:#565962;
    --line:#232936; --line-2:#1A1F29;
    --paper:#12151D; --wash:#0B0D12; --sink:#080A0E;
    --gold:#C7A45B; --frost:#A9C6DC;
    --win:#57A47E; --win-bg:#12281D; --ok:#C9A94E; --ok-bg:#2A2416;
    --bad:#D97A66; --bad-bg:#2A1815;
    color-scheme: dark;
  }
}

/* ── 1b · TOKENS · Daylight (data-theme="light") ─────────────────────── */
html:root[data-theme="light"] {
  --ink:   #14130F;
  --ink-2: #3D3A35;
  --mute:  #8A8378;
  --faint: #B5AEA3;
  --line:  #E7E2D9;
  --line-2:#F0EDE6;
  --paper: #FFFFFF;
  --wash:  #F7F5F0;
  --sink:  #F1EEE7;
  --gold:  #C7A45B;
  --frost: #7FA5BF;
  --win:   #1F6B4A;  --win-bg:#E8F2EC;
  --ok:    #8A6D1F;  --ok-bg: #FBF4E2;
  --bad:   #A33A2E;  --bad-bg:#FBECE9;
  color-scheme: light;
}

/* ── 2 · ARTBOARD / EXPORT GUARD ─────────────────────────────────────────
   The Builder's #ad artboard IS the ad · a fixed ivory 1080×1350 static.
   It must render identically in both themes and in the SVG export dump.
   Pinning the custom properties ON #ad locks the whole subtree, in the
   live page and inside the serialised export (this rule rides along).
   This also fixes a pre-existing bug: dark-OS users previously exported
   ads with warm-dark token values leaking through the pages' own
   prefers-color-scheme block. */
#ad {
  --ink:#14130F; --ink-2:#3D3A35; --mute:#8A8378; --faint:#B5AEA3;
  --line:#E8E4DC; --line-2:#F1EEE8; --paper:#FFFFFF; --wash:#FAF8F4;
  --sink:#F4F1EB; --gold:#C7A45B;
  --win:#1F6B4A; --win-bg:#E8F2EC; --ok:#8A6D1F; --ok-bg:#FBF4E2;
  --bad:#A33A2E; --bad-bg:#FBECE9;
  color:#14130F;
  color-scheme: light;
}

/* ── 3 · ATMOSPHERE · the signature ──────────────────────────────────────
   A fixed two-temperature light field behind everything: Frost breathes
   high-left, Champagne blooms low-right. Transform-only drift, 110s —
   felt, never watched. Film grain above everything at 4%. */
html { background: var(--wash); }
body { background: transparent; position: relative; }

body::before {
  content:""; position: fixed; inset:-20%; z-index:-1; pointer-events:none;
  background:
    radial-gradient(42% 38% at 18% 8%,  color-mix(in srgb, var(--frost) 13%, transparent) 0%, transparent 70%),
    radial-gradient(46% 42% at 86% 92%, color-mix(in srgb, var(--gold)  10%, transparent) 0%, transparent 72%),
    radial-gradient(60% 55% at 50% 42%, color-mix(in srgb, var(--paper) 55%, transparent) 0%, transparent 100%);
  will-change: transform;
}
@media (prefers-reduced-motion: no-preference) {
  body::before { animation: atelierDrift 110s ease-in-out infinite alternate; }
}
@keyframes atelierDrift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to   { transform: translate3d( 1.5%,  1.5%, 0) scale(1.06); }
}

body::after {
  content:""; position: fixed; inset:0; z-index:9999; pointer-events:none;
  opacity:.04; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
html:root[data-theme="light"] body::after { opacity:.028; }

/* retune the existing shine.js hero blobs to the two-temperature system ·
   shine injects its <style> at runtime (after this link), so these carry
   the extra `html` for specificity, not decoration */
html .shine-blob {
  background: radial-gradient(circle, color-mix(in srgb, var(--frost) 50%, transparent), transparent 64%);
}
html .shine-blob.b2 {
  background: radial-gradient(circle, color-mix(in srgb, var(--gold) 48%, transparent), transparent 64%);
}

/* ── 4 · TYPE · Fraunces becomes the display voice ───────────────────── */
.hero h1 {
  font: 340 clamp(38px, 5.6vw, 66px)/1.06 var(--serif);
  letter-spacing: -.015em;
  font-variation-settings: "opsz" 72, "SOFT" 30;
  max-width: 18ch;
}
.hero h1 em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 340;
  color: color-mix(in srgb, var(--gold) 88%, var(--ink));
}
.hero .kick { letter-spacing:.3em; font-weight:600; }
.hero .sub  { font-size:15px; line-height:1.65; color: var(--ink-2); }

.shead h2   { font: 520 22px/1.2 var(--serif); letter-spacing:-.01em; }
.draw-h h2  { font: 500 27px/1.15 var(--serif); letter-spacing:-.012em; }

/* small utility headings stay Inter — the serif voice is for display only */

::selection { background: color-mix(in srgb, var(--gold) 32%, transparent); }

/* ── 5 · SURFACES · gallery lighting ─────────────────────────────────────
   Cards read as lit objects: a 1px light seam on top of each surface, deep
   soft shadow underneath, imagery lifts slightly under the hover light. */
:root:not([data-theme="light"]) .tile,
:root:not([data-theme="light"]) .fc {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.055),
    inset 0 0 0 1px rgba(255,255,255,.025),
    0 24px 60px -28px rgba(0,0,0,.55);
}
:root:not([data-theme="light"]) .tile:hover,
:root:not([data-theme="light"]) .fc:hover {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.08),
    inset 0 0 0 1px color-mix(in srgb, var(--gold) 22%, transparent),
    0 34px 80px -30px rgba(0,0,0,.72),
    0 0 40px -18px color-mix(in srgb, var(--gold) 30%, transparent);
}
.tile .im img, .fc img, .fc video { transition: transform .5s var(--spring), filter .4s var(--ease); }
:root:not([data-theme="light"]) .tile:hover .im img { filter: brightness(1.07); }
:root:not([data-theme="light"]) .fc:hover img,
:root:not([data-theme="light"]) .fc:hover video { filter: brightness(1.06); }

/* the composer becomes glass over the light field */
:root:not([data-theme="light"]) #mkbar {
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.07),
    0 24px 70px -30px rgba(0,0,0,.65);
}

/* drawers · lux.js injects its chrome at runtime with a light-mode shadow
   that vanishes on dark — restore their depth */
html:root:not([data-theme="light"]) .draw.on {
  box-shadow:
    -1px 0 0 rgba(255,255,255,.05),
    -40px 0 110px rgba(0,0,0,.6) !important;
}

/* ── 6 · PRESS FEEDBACK · every control answers the hand ─────────────── */
.exs button, .filters button, #strip .sc, .cnum,
#mkgo, #thm, .tile, .fc {
  -webkit-tap-highlight-color: transparent;
}
.exs button:active, .filters button:active, #strip .sc:active, #thm:active {
  transform: scale(.96);
  transition-duration: .1s;
}
#mkgo:active { transform: scale(.97); transition-duration: .1s; }
.tile:active { transform: translateY(-1px) scale(.995); }
.fc:active   { transform: translateY(-1px) scale(.99); }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ── 7 · DETAILS ─────────────────────────────────────────────────────── */
/* scrollbars tuned for the night canvas */
:root:not([data-theme="light"]) *::-webkit-scrollbar-thumb { background:#232936; }
:root:not([data-theme="light"]) *::-webkit-scrollbar-thumb:hover { background:#39404f; }

/* the theme toggle floats as a quiet glass disc */
:root:not([data-theme="light"]) #thm {
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 10px 30px -12px rgba(0,0,0,.6);
}

/* keyboard hints on dark read as etched keys */
:root:not([data-theme="light"]) .tile .tt kbd {
  background: var(--sink);
  border-color: var(--line);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,.04);
}

/* ── 8 · PER-PAGE REPAIRS · places a token flip alone can't reach ────── */

/* Builder · the stage drops its ivory checkerboard for a studio spotlight —
   the artboard is the one lit object in a dark screening room */
:root:not([data-theme="light"]) .stage {
  background:
    radial-gradient(56% 46% at 50% 44%, rgba(255,255,255,.05) 0%, transparent 72%),
    var(--wash);
}
:root:not([data-theme="light"]) .frame {
  box-shadow:
    0 0 0 1px rgba(255,255,255,.08),
    0 60px 160px -40px rgba(0,0,0,.9);
}

/* Performance · the hero KPI card was ink-on-ink inverted; on dark it
   becomes the champagne card (its #fff value text is hardcoded, so restate) */
:root:not([data-theme="light"]) .kpi.hero {
  background: color-mix(in srgb, var(--gold) 9%, var(--paper));
  border-color: color-mix(in srgb, var(--gold) 42%, var(--line));
}
:root:not([data-theme="light"]) .kpi.hero .l { color: color-mix(in srgb, var(--ink) 62%, transparent); }
:root:not([data-theme="light"]) .kpi.hero .v { color: var(--ink); }

/* Library · the compare pill inverts correctly via tokens, but its close
   button hardcodes white — restate against the inverted (bone) surface */
:root:not([data-theme="light"]) #cmpBar .cl { color: color-mix(in srgb, var(--paper) 55%, transparent); }

/* ── 9 · THE VERDICT VOICE · one banner style for every system judgement ──
   The Ops rule banner and the lux drawer verdicts share it: champagne wash,
   the 3px gold rule, and the verdict sentence spoken in Fraunces italic.
   (lux injects its styles at runtime — the html prefix outranks them.) */
.rulebanner, html .lxverdict {
  background:
    linear-gradient(115deg, color-mix(in srgb, var(--gold) 14%, var(--paper)) 0%,
                            color-mix(in srgb, var(--gold) 5%,  var(--paper)) 55%,
                            var(--paper) 100%);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--gold) 22%, transparent),
    0 18px 50px -28px color-mix(in srgb, var(--gold) 38%, transparent);
}
.rulebanner .big, html .lxverdict .big {
  font: italic 500 19px/1.4 var(--serif);
  letter-spacing: 0;
}
.rulebanner .sub, html .lxverdict .sub { color: var(--ink-2); }

/* ── 10 · FILMS ANNOUNCE THEMSELVES · play-glint on hover ─────────────────
   Any card holding a video (gens .gt, home .fc) gets a quiet glass play disc
   and one light-sweep across the frame when the cursor arrives. */
.gt:has(video), .fc:has(video) { overflow: hidden; }
.gt:has(video)::before, .fc:has(video)::before {
  content:""; position:absolute; left:50%; top:50%; z-index:3;
  width:48px; height:48px; margin:-24px 0 0 -24px; border-radius:50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M20 16.5v15l12-7.5z' fill='%23EFEDE8'/%3E%3C/svg%3E") center/100% no-repeat,
    color-mix(in srgb, var(--wash) 55%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  backdrop-filter: blur(10px) saturate(1.4);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 8px 28px -8px rgba(0,0,0,.5);
  opacity:0; transform: scale(.88);
  transition: opacity .22s var(--spring), transform .22s var(--spring);
  pointer-events:none;
}
@media (hover:hover) and (pointer:fine) {
  .gt:has(video):hover::before, .fc:has(video):hover::before { opacity:1; transform:scale(1); }
}
.gt:has(video)::after, .fc:has(video)::after {
  content:""; position:absolute; inset:-40% -60%; z-index:2; pointer-events:none;
  background: linear-gradient(115deg, transparent 44%, rgba(255,255,255,.10) 50%, transparent 56%);
  transform: translate3d(-120%,0,0); opacity:0;
  transition: transform .7s var(--spring), opacity .7s var(--ease);
}
@media (hover:hover) and (pointer:fine) and (prefers-reduced-motion: no-preference) {
  .gt:has(video):hover::after, .fc:has(video):hover::after { transform: translate3d(120%,0,0); opacity:1; }
}

/* ── 11 · DAYLIGHT ATELIER · the light theme, taken seriously ─────────────
   Same screening-room logic in reverse: warm gallery daylight, layered warm
   shadows (ink-brown, never grey), the same glass and spotlight language. */
:root[data-theme="light"] body::before {
  background:
    radial-gradient(44% 40% at 16% 6%,  color-mix(in srgb, var(--frost) 22%, transparent) 0%, transparent 70%),
    radial-gradient(48% 44% at 88% 94%, color-mix(in srgb, var(--gold) 18%, transparent) 0%, transparent 72%),
    radial-gradient(60% 55% at 50% 40%, rgba(255,255,255,.65) 0%, transparent 100%);
}
:root[data-theme="light"] .tile,
:root[data-theme="light"] .fc,
:root[data-theme="light"] .gt {
  box-shadow:
    0 1px 2px rgba(48,40,26,.05),
    0 14px 40px -22px rgba(48,40,26,.22);
}
:root[data-theme="light"] .tile:hover,
:root[data-theme="light"] .fc:hover,
:root[data-theme="light"] .gt:hover {
  box-shadow:
    0 1px 2px rgba(48,40,26,.06),
    0 26px 60px -26px rgba(48,40,26,.32),
    0 0 0 1px color-mix(in srgb, var(--gold) 35%, transparent),
    0 0 44px -20px color-mix(in srgb, var(--gold) 45%, transparent);
}
:root[data-theme="light"] #mkbar {
  background: color-mix(in srgb, #fff 78%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.85),
    0 20px 55px -28px rgba(48,40,26,.35);
}
:root[data-theme="light"] .stage {
  background:
    radial-gradient(56% 46% at 50% 44%, rgba(255,255,255,.9) 0%, transparent 74%),
    var(--sink);
}
:root[data-theme="light"] .frame {
  box-shadow:
    0 0 0 1px rgba(48,40,26,.08),
    0 44px 110px -38px rgba(48,40,26,.4);
}
:root[data-theme="light"] .gt:has(video)::before,
:root[data-theme="light"] .fc:has(video)::before {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M20 16.5v15l12-7.5z' fill='%23FFFFFF'/%3E%3C/svg%3E") center/100% no-repeat,
    rgba(20,19,15,.38);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.28), 0 8px 28px -8px rgba(48,40,26,.35);
}

/* the rail's cryo frost-dot texture reads busy at large window sizes on
   dark — keep the tint, quiet the dots (lux injects at runtime; outrank it) */
html:root:not([data-theme="light"]) .nv2-rail::before { opacity:.16; }

/* ── 12 · THE WATERMARK · giant cropped display type behind each hero ─────
   The Rouge move: the product name at architectural scale, cropped by the
   frame, barely there. content comes from data-wm on the hero so each page
   speaks its own word (home {{BRAND}} · gens MADE · socials STYLE). */
.hero { position: relative; }
.hero::before {
  content: attr(data-wm);
  position: absolute; inset: -.14em 0 0 0; z-index: -1;
  overflow: hidden; pointer-events: none;
  font: 340 clamp(150px, 21vw, 310px)/1 var(--serif);
  letter-spacing: -.02em; text-align: center; white-space: nowrap;
  color: color-mix(in srgb, var(--ink) 4.5%, transparent);
}

/* ── 13 · THE SPEC LINE · Onyx's "FOUR METALS · ONE STANDARD" voice ────── */
.specline {
  margin-top: 26px;
  font: 600 9.5px/1.8 var(--sans);
  letter-spacing: .3em; text-transform: uppercase;
  color: var(--mute);
}
.specline i { font-style: normal; color: var(--gold); }
@media (prefers-reduced-motion: no-preference) {
  .specline { animation: hmrise .55s var(--spring) .26s backwards; }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none !important; }
}
