/* =====================================================================
   Sales Blitz v3 — base styles
   Resets, type, film grain, vignettes, shell, shared primitives.
   Assumes tokens.css is loaded first.
   ===================================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  background: var(--bg-base);
  /* Opt into View Transitions cross-document & same-document */
  view-transition-name: none;
}

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background var(--dur-med) var(--ease-smooth), color var(--dur-med) var(--ease-smooth);
}

/* ----- Film grain overlay ----- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.09 0 0 0 0 0.08 0 0 0 0.25 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  transition: opacity var(--dur-med) var(--ease-smooth);
}
[data-theme="dark"] body::before {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.95 0 0 0 0 0.88 0 0 0 0 0.75 0 0 0 0.4 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ----- Warm corner vignettes ----- */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background:
    radial-gradient(ellipse 80% 40% at 50% 100%, var(--vignette-bottom), transparent 70%),
    radial-gradient(ellipse 60% 30% at 100% 0%, var(--vignette-top), transparent 70%);
  transition: opacity var(--dur-med) var(--ease-smooth);
}

a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ----- Shell ----- */
.shell { max-width: var(--shell); margin: 0 auto; padding: 0 32px; }
.shell-wide { max-width: var(--shell-wide); margin: 0 auto; padding: 0 32px; }
@media (max-width: 640px) {
  .shell, .shell-wide { padding: 0 20px; }
}

/* =====================================================================
   TYPE SYSTEM
   ===================================================================== */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-quiet);
  font-weight: 500;
}
.eyebrow .dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  margin-right: 10px;
  margin-bottom: 2px;
}

.caption {
  font-family: var(--sans);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-quiet);
  font-weight: 400;
}

.display {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.02;
  color: var(--ink);
}
.display .flow {
  font-family: var(--sans);
  font-style: italic;
  font-weight: 400;
  color: var(--ink-mid);
  letter-spacing: -0.015em;
}
.display .mark { color: var(--accent); }
.display .sage-mark { color: var(--accent-sage); }

h1.display { font-size: clamp(44px, 7.5vw, 104px); }
h2.display { font-size: clamp(34px, 5vw, 64px); line-height: 1.04; }
h3.display { font-size: clamp(22px, 2.4vw, 30px); letter-spacing: -0.015em; line-height: 1.12; }

.lede {
  font-family: var(--sans);
  font-size: clamp(17px, 1.5vw, 20px);
  line-height: 1.55;
  color: var(--ink-mid);
  max-width: 56ch;
}

/* =====================================================================
   MODE TOGGLE
   Two-state pill that switches data-theme on <html>. View Transitions
   animates the swap. Sits top-right in the nav on every page.
   ===================================================================== */
.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--ink-line);
  background: var(--bg-panel);
  position: relative;
  overflow: hidden;
}
.mode-toggle button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border-radius: 999px;
  color: var(--ink-quiet);
  transition: color var(--dur-fast) var(--ease-smooth);
  z-index: 2;
}
.mode-toggle button svg { width: 14px; height: 14px; }
.mode-toggle button:hover { color: var(--ink); }
.mode-toggle button.active { color: var(--ink); }
.mode-toggle .thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 30px;
  height: 26px;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-soft);
  transition: transform var(--dur-med) var(--ease-smooth);
  z-index: 1;
}
[data-theme="dark"] .mode-toggle .thumb { transform: translateX(34px); }

/* =====================================================================
   View Transitions
   - Theme swap cross-fade (same-document).
   - Cross-document navigation between marketing pages (index ↔ sage ↔
     onboarding) cross-fades instead of hard-flashing. Chrome 126+.
     Browsers without support fall back to normal nav.
   - Named transitions on the nav brand-mark let it morph between pages
     so the identity stays anchored while the page body dissolves.
   ===================================================================== */
@view-transition { navigation: auto; }

@supports (view-transition-name: root) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 520ms;
    animation-timing-function: var(--ease-smooth);
  }
  ::view-transition-old(root) { animation-name: fade-out; }
  ::view-transition-new(root) { animation-name: fade-in; }

  /* Morph the brand-mark across page boundaries */
  ::view-transition-old(sb-brand),
  ::view-transition-new(sb-brand) {
    animation-duration: 420ms;
    animation-timing-function: var(--ease-smooth);
    mix-blend-mode: normal;
  }

  /* Morph the primary CTA if both pages have one in the same position */
  ::view-transition-old(sb-cta),
  ::view-transition-new(sb-cta) {
    animation-duration: 380ms;
    animation-timing-function: var(--ease-smooth);
  }
}
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in  { from { opacity: 0; } }

/* ----- Named transition targets ----- */
.sb-brand-mark { view-transition-name: sb-brand; }
.nav-cta       { view-transition-name: sb-cta; }

/* =====================================================================
   PRIMITIVES
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 10px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.005em;
  transition: transform var(--dur-fast) var(--ease-smooth), background var(--dur-fast) var(--ease-smooth), color var(--dur-fast) var(--ease-smooth);
  cursor: pointer;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--cta-bg);
  color: var(--cta-text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 8px 22px -10px rgba(0, 0, 0, 0.3);
}
.btn-primary:hover { background: var(--cta-hover); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink-line-strong);
}
.btn-ghost:hover { background: var(--ink-tint); }
.btn-warm {
  background: var(--accent-warm);
  color: var(--espresso);
}
.btn-warm:hover { background: var(--accent-warm-deep); color: var(--cream); }

/* Panels that work in both modes */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  transition: background var(--dur-med) var(--ease-smooth), border-color var(--dur-med) var(--ease-smooth);
}

.paper {
  background: linear-gradient(to bottom, var(--paper), var(--cream));
  color: var(--espresso);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-inset);
}

/* =====================================================================
   Motion staging
   Hides revealable elements pre-GSAP so there's no flash of visible
   content before the cascade runs. Activates only when html has the
   .motion-js class, added inline in <head> on pages that load motion.js.
   ===================================================================== */
.motion-js [data-hero] > *,
.motion-js [data-reveal]:not([data-reveal="children"]),
.motion-js [data-reveal="children"] > * {
  opacity: 0;
  will-change: opacity, transform;
}

@media (prefers-reduced-motion: reduce) {
  .motion-js [data-hero] > *,
  .motion-js [data-reveal]:not([data-reveal="children"]),
  .motion-js [data-reveal="children"] > * {
    opacity: 1 !important;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =====================================================================
   Hero film, play-once-then-freeze
   Videos play through a single time & crossfade to a static still
   (injected by shared/motion.js from the video's poster attribute).
   Any page-level .hero-film-video filter (saturate, brightness) is
   mirrored onto the still so the final frame matches the graded clip.
   ===================================================================== */
.hero-film-video {
  transition: opacity 1.6s cubic-bezier(0.33, 1, 0.68, 1);
}
.hero-film-still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.6s cubic-bezier(0.33, 1, 0.68, 1);
  will-change: opacity;
}
.hero-film.is-ended .hero-film-video { opacity: 0; }
.hero-film.is-ended .hero-film-still { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  /* Skip the video entirely, show the still from frame one. */
  .hero-film-video { opacity: 0 !important; }
  .hero-film-still { opacity: 1 !important; }
}

/* =====================================================================
   Hero cinematic stage card
   The Claude Design title-card layer per /cinematic skill. Editorial
   chapter identifier that fades in for the first 1-2s, holds briefly
   and releases. Gives every hero film a cold-scrubber anchor and an
   arrival moment. Lives above the hero-film, below hero-inner copy.
   Must be paired with a .hero-filmstamp persistent signature bottom-right.
   ===================================================================== */
.hero-stagecard {
  position: absolute;
  top: 98px; left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 36px 16px;
  min-width: 300px;
  max-width: 560px;
  pointer-events: none;
  opacity: 0;
  animation: hero-stagecard-cycle 4.2s cubic-bezier(0.22, 1, 0.36, 1) 0.2s forwards;
}
.hero-stagecard::before,
.hero-stagecard::after {
  content: "";
  position: absolute;
  left: 50%; transform: translateX(-50%);
  width: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(143, 174, 127, 0.8) 50%, transparent 100%);
  animation: hero-stagecard-rule 3.6s cubic-bezier(0.22, 1, 0.36, 1) 0.35s forwards;
}
.hero-stagecard::before { top: 0; }
.hero-stagecard::after { bottom: 0; }
.hero-stagecard .chapter {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--sage-glow);
  font-weight: 500;
  margin-bottom: 8px;
  display: inline-flex; align-items: center; gap: 10px;
}
.hero-stagecard .chapter::before,
.hero-stagecard .chapter::after {
  content: ""; width: 18px; height: 1px;
  background: rgba(143, 174, 127, 0.45);
}
.hero-stagecard .thesis {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(18px, 1.6vw, 22px);
  line-height: 1.14;
  letter-spacing: -0.008em;
  color: rgba(245, 238, 225, 0.92);
  max-width: 28ch;
}
@keyframes hero-stagecard-cycle {
  0%   { opacity: 0; transform: translate(-50%, -4px); }
  12%  { opacity: 1; transform: translate(-50%, 0); }
  70%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -2px); }
}
@keyframes hero-stagecard-rule {
  0%   { width: 0; opacity: 0; }
  20%  { width: 48%; opacity: 1; }
  85%  { width: 48%; opacity: 1; }
  100% { width: 48%; opacity: 0; }
}

/* Film signature — persistent bottom-right of hero, editorial stamp.
   Reads as the credits line at the bottom of a film frame. Does not
   fade out. Sits above the hero-film gradient veil. */
.hero-filmstamp {
  position: absolute;
  right: 32px; bottom: 28px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: rgba(16, 14, 12, 0.4);
  border: 1px solid rgba(245, 238, 225, 0.08);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(245, 238, 225, 0.56);
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  animation: hero-filmstamp-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) 2.4s forwards;
}
.hero-filmstamp .rec {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--sage);
  box-shadow: 0 0 0 2px rgba(143, 174, 127, 0.22);
  animation: filmstamp-pulse 2.4s ease-in-out 2.4s infinite;
}
.hero-filmstamp .divider {
  width: 1px; height: 10px;
  background: rgba(245, 238, 225, 0.14);
}
@keyframes hero-filmstamp-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes filmstamp-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(143, 174, 127, 0.22); }
  50%      { box-shadow: 0 0 0 6px rgba(143, 174, 127, 0); }
}
@media (max-width: 820px) {
  .hero-stagecard {
    top: 86px;
    min-width: 240px;
    padding: 12px 22px 14px;
  }
  .hero-stagecard .thesis { font-size: 17px; }
  .hero-filmstamp { right: 20px; bottom: 20px; font-size: 9px; letter-spacing: 0.14em; padding: 5px 10px 5px 9px; }
  .hero-filmstamp .brand-short { display: none; }
}
@media (max-width: 560px) {
  .hero-stagecard { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-stagecard { animation: none; opacity: 0; pointer-events: none; }
  .hero-stagecard::before, .hero-stagecard::after { animation: none; opacity: 0; }
  .hero-filmstamp { animation: none; opacity: 1; }
  .hero-filmstamp .rec { animation: none; }
}
