/* =========================================================================
   Vexel — shared foundation
   Design tokens for both themes, plus the theme toggler and tabs.

   The token NAMES are roles, not literal colours: --walnut is always the page
   canvas, --cream is always the text on it, --bark is always the elevated
   surface. Swapping the values under [data-theme="light"] therefore flips the
   whole system without touching a single component rule.

   Contrast, dark (text on #100904):
     cream #ffedd7        16.3:1
     cream @ 70% muted     8.8:1
     ember #dc5000         4.9:1
     cream on the CTA     12.8:1
   Contrast, light (text on #fdf6ea):
     ink   #1a0f07        17.9:1
     ink @ 70% muted       7.0:1
     ember #b33f00         5.5:1   <- darkened; #dc5000 is only 3.8:1 here
     canvas on the CTA    15.4:1
   ========================================================================= */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --walnut:    #100904;   /* canvas */
  --bark:      #382416;   /* elevated surface */
  --cork:      #40372e;   /* hairlines */
  --driftwood: #6c5f51;   /* structural mid-tone, never text */
  --cream:     #ffedd7;   /* text */
  --ember:     #dc5000;   /* credit accent only */

  --cta-bg:    #382416;
  --cta-text:  #ffedd7;

  --star:      #ffedd7;
  --sky-near:  #241a12;
  --sky-far:   #100904;

  /* The 3D scene reads these rather than the text tokens, because light and
     illumination are not the same thing as type colour. */
  --scene-line:      #ffedd7;
  --scene-structure: #6c5f51;
  --scene-key:       #ffedd7;
  --scene-fill:      #6c5f51;
  --scene-ambient:   #382416;

  --vitrine-near: rgba(36, 26, 18, 0.40);
  --vitrine-far:  rgba(16, 9, 4, 0.80);
}

:root[data-theme="light"] {
  color-scheme: light;

  --walnut:    #fdf6ea;
  --bark:      #f0e3d0;
  --cork:      rgba(36, 26, 18, 0.20);
  --driftwood: #6c5f51;
  --cream:     #1a0f07;
  --ember:     #b33f00;   /* the dark-theme orange fails 4.5:1 on cream */

  --cta-bg:    #241a12;
  --cta-text:  #fdf6ea;

  --star:      #241a12;
  --sky-near:  #f2e6d4;
  --sky-far:   #fdf6ea;

  --scene-line:      #241a12;
  --scene-structure: #9a8a76;
  --scene-key:       #ffffff;
  --scene-fill:      #d8c9b4;
  --scene-ambient:   #efe4d4;

  --vitrine-near: rgba(255, 253, 248, 0.55);
  --vitrine-far:  rgba(240, 227, 208, 0.78);
}

:root {
  --font-display: "Inter", "Söhne", "Neue Haas Grotesk", system-ui, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --ease-tab: cubic-bezier(.42, 0, .58, 1);   /* the tabs' easeInOut, 0.5s */
}

/* Colour changes are eased so a theme switch reads as a dissolve, not a cut.
   Guarded by a class the script removes only after first paint, so the page
   never animates its way in from the wrong theme. */
.theme-ready body,
.theme-ready body * {
  transition:
    background-color 420ms var(--ease),
    border-color 420ms var(--ease),
    color 420ms var(--ease),
    fill 420ms var(--ease);
}

/* ---------- Starfield backdrop ---------- */

.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at bottom, var(--sky-near) 0%, var(--sky-far) 72%);
}
.stars canvas { display: block; width: 100%; height: 100%; }

/* ---------- Intro ----------
   Sits above everything, then hands the wordmark to the corner mark. */

/* Hidden unless the page has armed its animations. If the script fails to
   load, this overlay must not be left covering the site. */
.intro { display: none; }

.js-arming .intro {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  /* Opaque, so the swipe has something to take away. The starfield is
     revealed by the wipe rather than shown through it. */
  background: var(--walnut);
  transform: translateX(0);
  transition: transform 760ms var(--ease);
}

/* The swipe: the whole panel leaves to the left, uncovering the site. */
.intro[data-phase="swipe"] { transform: translateX(-100%); }

.intro[data-phase="done"] {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* A thin ember edge rides the trailing side of the swipe. */
.js-arming .intro::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  height: 100%;
  background: var(--ember);
  opacity: 0;
  transition: opacity 180ms var(--ease);
}
.intro[data-phase="swipe"]::after { opacity: 1; }

.intro-mark {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 17vw, 13rem);
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  color: var(--cream);
  white-space: nowrap;
}

/* The full stop is the one accent, echoing the brand mark. */
.intro-dot { color: var(--ember); }

.intro-caret {
  display: inline-block;
  width: 0.055em;
  height: 0.72em;
  margin-left: 0.08em;
  background: var(--ember);
  animation: caret-blink 900ms steps(1, end) infinite;
}

.intro-caret[data-done="true"] {
  opacity: 0;
  animation: none;
  transition: opacity 200ms var(--ease);
}

@keyframes caret-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.intro[data-phase="enter"] .intro-mark {
  animation: intro-fade 380ms var(--ease) both;
}

@keyframes intro-fade { from { opacity: 0; } to { opacity: 1; } }

/* Reduced motion: no travel. The panel cross-fades away instead of swiping. */
[data-motion="reduced"] .intro-caret { display: none; }

[data-motion="reduced"] .js-arming .intro {
  transition: opacity 420ms var(--ease);
}
[data-motion="reduced"] .intro[data-phase="swipe"] {
  transform: none;
  opacity: 0;
}
[data-motion="reduced"] .intro[data-phase="done"] { transform: none; }

/* ---------- Entry pop ----------
   Everything after the intro slides up and scales in, staggered. */

/* Visible by default: only a live script hides these to animate them in. */
.js-arming [data-pop] {
  opacity: 0;
  transform: translateY(22px) scale(0.965);
}

.js-arming [data-pop].is-in {
  opacity: 1;
  transform: none;
  transition:
    opacity 620ms var(--ease),
    transform 720ms var(--ease);
  transition-delay: calc(var(--pop-delay, 0) * 85ms);
}

/* Last resort: transition removed so the value applies instantly, for a
   browser that cannot complete the fade. */
.pops-settled [data-pop] {
  opacity: 1;
  transform: none;
  transition: none;
}

[data-motion="reduced"] .js-arming [data-pop] { transform: none; }
[data-motion="reduced"] .js-arming [data-pop].is-in {
  transition: opacity 560ms var(--ease);
  transition-delay: calc(var(--pop-delay, 0) * 70ms);
}

/* ---------- Theme toggler ----------
   A port of Animate UI's <ThemeTogglerButton />. Icons are stacked and slide
   along the axis given by data-direction; only the active one is on screen. */

.theme-toggler {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--cork);
  border-radius: 9999px;
  background: transparent;
  color: var(--cream);
  cursor: pointer;
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease);
}
.theme-toggler:hover { border-color: var(--cream); background: var(--surface, transparent); }

.theme-toggler[data-size="sm"] { width: 32px; height: 32px; }
.theme-toggler[data-size="lg"] { width: 46px; height: 46px; }

.theme-toggler[data-variant="outline"] { border-color: var(--cream); }
.theme-toggler[data-variant="ghost"]   { border-color: transparent; }
.theme-toggler[data-variant="accent"]  { background: var(--cta-bg); border-color: var(--cta-bg); color: var(--cta-text); }

.theme-toggler .tt-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transition:
    transform 420ms var(--ease),
    opacity 260ms var(--ease);
}
.theme-toggler .tt-icon svg { width: 17px; height: 17px; display: block; }
.theme-toggler[data-size="lg"] .tt-icon svg { width: 20px; height: 20px; }

.theme-toggler .tt-icon[data-state="active"] { opacity: 1; transform: none; }

/* Resting positions for the inactive icons, per direction. */
.theme-toggler[data-direction="ltr"] .tt-icon[data-state="before"] { transform: translateX(-100%); }
.theme-toggler[data-direction="ltr"] .tt-icon[data-state="after"]  { transform: translateX(100%); }
.theme-toggler[data-direction="rtl"] .tt-icon[data-state="before"] { transform: translateX(100%); }
.theme-toggler[data-direction="rtl"] .tt-icon[data-state="after"]  { transform: translateX(-100%); }
.theme-toggler[data-direction="btt"] .tt-icon[data-state="before"] { transform: translateY(100%); }
.theme-toggler[data-direction="btt"] .tt-icon[data-state="after"]  { transform: translateY(-100%); }
.theme-toggler[data-direction="ttb"] .tt-icon[data-state="before"] { transform: translateY(-100%); }
.theme-toggler[data-direction="ttb"] .tt-icon[data-state="after"]  { transform: translateY(100%); }

.theme-toggler:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; }

/* ---------- Tabs ----------
   A port of Animate UI's headless tabs: a highlight that travels between tabs,
   and a panel box whose height springs to the new content. */

.tabs { display: grid; gap: 20px; }

.tab-list {
  position: relative;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--cork);
  border-radius: 9999px;
  isolation: isolate;
}

.tab-highlight {
  position: absolute;
  top: 4px;
  left: 0;
  height: calc(100% - 8px);
  border-radius: 9999px;
  background: var(--cta-bg);
  z-index: -1;
  transition:
    transform 500ms var(--ease-tab),
    width 500ms var(--ease-tab);
}

.tab {
  flex: 1;
  padding: 9px 20px;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: normal;
  color: var(--cream);
  opacity: 0.6;
  cursor: pointer;
  white-space: nowrap;
  transition: color 300ms var(--ease), opacity 300ms var(--ease);
}
.tab[aria-selected="true"] { color: var(--cta-text); opacity: 1; }
.tab:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; }

/* Height is driven frame by frame from a spring, so the box settles the way
   the component's { stiffness: 200, damping: 25 } does. */
.tab-panels { position: relative; overflow: hidden; }

.tab-panel {
  position: absolute;
  inset: 0 0 auto 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms var(--ease-tab), transform 320ms var(--ease-tab);
  transform: translateY(6px);
}
.tab-panel[data-active="true"] {
  position: relative;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Reduced motion keeps the cross-fades and drops only the travel. */
[data-motion="reduced"] .tab-highlight {
  transition: opacity 300ms var(--ease-tab);
}
[data-motion="reduced"] .tab-panel {
  transform: none;
  transition: opacity 300ms var(--ease-tab);
}
[data-motion="reduced"] .theme-toggler .tt-icon {
  transform: none !important;
  transition: opacity 260ms var(--ease);
}
