/* ==========================================================================
   v2 — signature layer. Loaded last on every page.
   Living type · full-screen menu · WebGL image layer · product-themed case studies
   ========================================================================== */

/* ---------- Living headline: each letter carries its own weight/width ---------- */
.h-title .ch {
  display: inline-block;
  font-variation-settings: "wght" var(--w, 800), "wdth" var(--wd, 100);
  will-change: font-variation-settings;
}
.h-title .sp { display: inline-block; width: 0.22em; }

/* ---------- Nav: minimal, with a Menu trigger ---------- */
.w-nav .w-menu {
  appearance: none; background: none; border: 0; color: inherit; cursor: pointer; font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; gap: 10px; padding: 0;
}
.w-nav .w-menu i { position: relative; width: 22px; height: 10px; display: inline-block; }
.w-nav .w-menu i::before, .w-nav .w-menu i::after { content: ""; position: absolute; left: 0; right: 0; height: 1.5px; background: currentColor; transition: transform 0.5s var(--ease); }
.w-nav .w-menu i::before { top: 0; } .w-nav .w-menu i::after { bottom: 0; }
.menu-open .w-nav .w-menu i::before { transform: translateY(4.25px) rotate(45deg); }
.menu-open .w-nav .w-menu i::after { transform: translateY(-4.25px) rotate(-45deg); }
.w-nav nav ul { align-items: center; }
@media (max-width: 760px) { .w-nav .nav-links { display: none; } }
.menu-open .w-nav { mix-blend-mode: normal; color: var(--fg); }

/* ---------- Full-screen menu ---------- */
.mn {
  position: fixed; inset: 0; z-index: 55; background: #0b0b0a; color: var(--fg);
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 72px);
  padding: clamp(96px, 14vh, 140px) var(--pad) clamp(24px, 4vh, 40px);
  clip-path: inset(0 0 100% 0); visibility: hidden; transition: clip-path 0.9s var(--ease), visibility 0s linear 0.9s;
}
.menu-open .mn { clip-path: inset(0 0 0% 0); visibility: visible; transition: clip-path 0.9s var(--ease); }
.mn-main { display: flex; flex-direction: column; justify-content: space-between; min-height: 0; }
.mn-links { list-style: none; margin: 0; padding: 0; }
.mn-links li { overflow: hidden; }
.mn-links a {
  display: flex; align-items: baseline; gap: 18px; text-decoration: none;
  font-family: var(--display); font-weight: 800; letter-spacing: -0.05em; font-size: clamp(2.6rem, 1rem + 6vw, 6.6rem); line-height: 0.98;
  transform: translateY(105%); transition: transform 0.9s var(--ease), color 0.3s;
}
.mn-links a sup { font: 500 0.8rem var(--mono); letter-spacing: 0; color: var(--fg-3); transform: translateY(-1.8em); }
.mn-links a:hover, .mn-links a:focus-visible { color: var(--accent); }
.menu-open .mn-links a { transform: none; }
.menu-open .mn-links li:nth-child(1) a { transition-delay: 0.18s; } .menu-open .mn-links li:nth-child(2) a { transition-delay: 0.23s; }
.menu-open .mn-links li:nth-child(3) a { transition-delay: 0.28s; } .menu-open .mn-links li:nth-child(4) a { transition-delay: 0.33s; }
.menu-open .mn-links li:nth-child(5) a { transition-delay: 0.38s; }
.mn-foot { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; color: var(--fg-2); font-size: 0.95rem; opacity: 0; transform: translateY(12px); transition: opacity 0.6s, transform 0.6s var(--ease); }
.menu-open .mn-foot { opacity: 1; transform: none; transition-delay: 0.5s; }
.mn-foot a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--hair); }
.mn-foot a:hover { border-color: var(--accent); }
.mn-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.mn-side .k { font: 0.8rem var(--mono); color: var(--fg-3); margin-bottom: 6px; }
.mn-case {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 42%; gap: 16px; align-items: center; min-height: 0; flex: 1;
  padding: 18px; border-radius: 18px; text-decoration: none; color: #fff; overflow: hidden;
  opacity: 0; transform: translateX(40px); transition: opacity 0.7s var(--ease), transform 0.9s var(--ease);
}
.menu-open .mn-case { opacity: 1; transform: none; }
.menu-open .mn-case:nth-of-type(2) { transition-delay: 0.3s; } .menu-open .mn-case:nth-of-type(3) { transition-delay: 0.38s; } .menu-open .mn-case:nth-of-type(4) { transition-delay: 0.46s; }
.mn-case.tk { background: var(--tk); } .mn-case.vl { background: var(--vl); } .mn-case.pw { background: var(--pw); color: #0b0b0a; }
.mn-case b { font-family: var(--display); font-weight: 800; letter-spacing: -0.04em; font-size: clamp(1.5rem, 1rem + 1.4vw, 2.4rem); line-height: 1; display: block; }
.mn-case span { font-size: 0.88rem; opacity: 0.8; display: block; margin-top: 6px; }
.mn-case img { width: 100%; height: 100%; max-height: 150px; object-fit: cover; object-position: top left; border-radius: 10px; transition: transform 0.8s var(--ease); }
.mn-case:hover img { transform: scale(1.06) rotate(-1.5deg); }
@media (max-width: 860px) {
  .mn { grid-template-columns: 1fr; overflow-y: auto; align-content: start; }
  .mn-side { flex-direction: column; }
  .mn-case { grid-template-columns: 1fr 34%; padding: 14px; flex: none; }
  .mn-case img { max-height: 90px; }
}

/* ---------- WebGL image layer ---------- */
.gl-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 3; pointer-events: none; }
[data-gl].gl-ready > img { visibility: hidden; }
.menu-open .gl-canvas { visibility: hidden; }

/* ---------- Case studies: one cinematic system, themed per product ---------- */
html.cs2 { background: var(--bg); color-scheme: dark; }
.cs2 body { background: var(--bg); }
.cs2[data-product="tk"] { --prod: #3730a3; --prod-ink: #fff; }
.cs2[data-product="vl"] { --prod: #0d3b2b; --prod-ink: #fff; }
.cs2[data-product="pw"] { --prod: #f06a2c; --prod-ink: #0b0b0a; }
.cs2 .cs-cover {
  background: var(--prod); color: var(--prod-ink); padding: clamp(120px, 18vh, 170px) 0 clamp(150px, 24vh, 260px);
  border-radius: 0 0 clamp(22px, 3vw, 44px) clamp(22px, 3vw, 44px); position: relative; overflow: hidden;
}
.cs2 .cs-cover .wrap { position: relative; }
.cs2 .cs-cover .crumb, .cs2 .cs-cover .crumb a { color: color-mix(in oklab, var(--prod-ink) 70%, transparent); }
.cs2 .cs-title { color: var(--prod-ink); font-size: clamp(3.6rem, 1rem + 13vw, 15rem); }
.cs2 .cs-title em { color: inherit; opacity: 0.55; }
.cs2 .cs-strap .pitch { color: var(--prod-ink); }
.cs2 .cs-strap .pitch em { color: inherit; opacity: 0.62; }
.cs2 .cs-cover .spec div { border-color: color-mix(in oklab, var(--prod-ink) 22%, transparent); }
.cs2 .cs-cover .spec dt { color: color-mix(in oklab, var(--prod-ink) 62%, transparent); }
.cs2 .cs-cover .spec dd, .cs2 .cs-cover .spec dd a { color: var(--prod-ink); }
.cs2 .cs-cover .inshort { border-color: color-mix(in oklab, var(--prod-ink) 30%, transparent); }
.cs2 .cs-cover .inshort div + div { border-color: color-mix(in oklab, var(--prod-ink) 22%, transparent); }
.cs2 .cs-cover .inshort dt { color: color-mix(in oklab, var(--prod-ink) 70%, transparent); }
.cs2 .cs-cover .inshort dd { color: var(--prod-ink); }
.cs2 .cs-hero-art { margin-top: calc(-1 * clamp(110px, 18vh, 200px)); position: relative; z-index: 2; }
.cs2 .cs-hero-art .browser, .cs2 .cs-hero-art .shot { box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.75); }

.cs2 .chapter { border-top-color: var(--hair); }
.cs2 .chapter > .side .n { color: var(--accent); }
.cs2 .pull em, .cs2 .chapter .big em { color: var(--accent); }
.cs2 .visit { background: var(--prod); color: var(--prod-ink); border: 0; border-radius: 24px; }
.cs2 .visit .mono { color: color-mix(in oklab, var(--prod-ink) 70%, transparent); }
.cs2 .visit .btn { background: var(--prod-ink); color: var(--prod); border-color: var(--prod-ink); }

/* Chapter locator: where you are in the story */
.ch-pill {
  position: fixed; left: var(--pad); bottom: 22px; z-index: 50; display: inline-flex; align-items: center; gap: 12px;
  padding: 10px 16px 10px 12px; border-radius: 999px; background: rgba(20, 20, 18, 0.82); backdrop-filter: blur(10px);
  border: 1px solid var(--hair); color: var(--fg); font-size: 0.88rem; font-weight: 500;
  opacity: 0; transform: translateY(16px); transition: opacity 0.4s, transform 0.5s var(--ease);
}
.ch-pill.on { opacity: 1; transform: none; }
.ch-pill .n { font: 0.78rem var(--mono); color: var(--accent); }
.ch-pill .ring { width: 18px; height: 18px; border-radius: 50%; background: conic-gradient(var(--accent) var(--p, 0turn), rgba(255,255,255,.14) 0); }
@media (max-width: 640px) { .ch-pill { left: 12px; bottom: 12px; font-size: 0.8rem; } }

/* Next project: a full product-coloured block */
.cs2 .next-sheet {
  display: block; text-decoration: none; margin-top: clamp(40px, 5vw, 72px); border: 0; border-radius: clamp(22px, 3vw, 40px);
  padding: clamp(36px, 6vw, 88px) clamp(24px, 4vw, 64px); color: #fff; position: relative; overflow: hidden;
}
.cs2 .next-sheet.to-tk { background: #3730a3; } .cs2 .next-sheet.to-vl { background: #0d3b2b; } .cs2 .next-sheet.to-pw { background: #f06a2c; color: #0b0b0a; }
.cs2 .next-sheet .mono { color: inherit; opacity: 0.7; }
.cs2 .next-sheet .serif { color: inherit; font-size: clamp(3.4rem, 1rem + 11vw, 13rem); line-height: 0.85; display: block; letter-spacing: -0.06em; font-weight: 800; }
.cs2 .next-sheet .arr { position: absolute; right: clamp(24px, 4vw, 64px); top: clamp(30px, 5vw, 80px); color: inherit; font-size: 2.4rem; }
.cs2 .foot { background: transparent; border-top: 0; }

/* Shared-element morph: product panel → case-study cover */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: 0.85s; animation-timing-function: cubic-bezier(0.77, 0, 0.18, 1); }
::view-transition-old(root) { animation: 0.4s ease both vt2-out; }
::view-transition-new(root) { animation: 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both vt2-in; }
@keyframes vt2-out { to { opacity: 0; } }
@keyframes vt2-in { from { opacity: 0; transform: translateY(24px); } }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

.mn-main { gap: clamp(28px, 5vh, 48px); }
@media (max-width: 860px) { .mn { padding-bottom: 32px; gap: 32px; } }

/* Case studies are always the dark cinematic palette, whatever theme a visitor saved earlier.
   (Higher specificity than :root[data-theme="light"] in site.css / bold.css.) */
:root.cs2[data-product] {
  --paper: #0f0f0d; --paper-2: #181815; --paper-3: #23221e;
  --ink: #f4f2ed; --ink-2: #cfcbc1; --muted: #8f8b81;
  --line: rgba(244, 242, 237, 0.1); --line-strong: rgba(244, 242, 237, 0.24);
  --signal: #ff6a3d; --signal-soft: rgba(255, 106, 61, 0.14); --card: #181815; --grid: transparent;
  color-scheme: dark;
}
:root.cs2[data-product] body { color: var(--ink); }

/* ---------- Spacing pass: case studies ---------- */
.cs2 .pull { border-top: 0; max-width: 20ch; padding-block: clamp(40px, 5vw, 80px); }
.cs2 .decisions, .cs2 .learned { border-top: 0; }
.cs2 .decisions li:first-child { padding-top: 4px; }
.cs2 .learned li { padding-top: 4px; }
.cs2 .tech-divide + .chapter { border-top: 0; }
.cs2 .tech-divide { padding-block: clamp(40px, 4.5vw, 64px) 0; }
.cs2 .chapter .wide > .big { margin-bottom: clamp(20px, 2.4vw, 32px); }
.cs2 .chapter .body > .big + p { margin-top: 0; }
.cs2 .next-sheet { margin-top: clamp(48px, 6vw, 96px); }
.cs2 .foot { padding-block: clamp(28px, 3vw, 40px) clamp(36px, 4vw, 56px); }

/* ---------- Nav legible over any background (no colour-inverting blend) ---------- */
.w-nav { mix-blend-mode: normal; transition: background 0.4s, color 0.4s, padding 0.4s, border-color 0.4s; border-bottom: 1px solid transparent; }
.w-nav .w-logo i { background: currentColor; }
.cs2 .w-nav { color: var(--prod-ink); }
.w-nav.is-solid {
  color: #f2efe8; background: rgba(11, 11, 10, 0.78); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  padding-block: 12px; border-bottom-color: rgba(255, 255, 255, 0.06);
}
.menu-open .w-nav { background: transparent; border-bottom-color: transparent; }

/* ---------- Mobile menu: scrollable, and compact enough to mostly fit ---------- */
.mn { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
@media (max-width: 860px) {
  .mn {
    height: 100dvh; overflow-y: auto; align-content: start; gap: 28px;
    padding: 84px 18px calc(28px + env(safe-area-inset-bottom));
  }
  .mn-main { gap: 20px; }
  .mn-links a { font-size: clamp(2.2rem, 10.5vw, 3.4rem); line-height: 1.02; gap: 12px; }
  .mn-links a sup { transform: translateY(-1.2em); }
  .mn-foot { gap: 8px 16px; font-size: 0.9rem; }
  .mn-side { gap: 10px; }
  .mn-case { grid-template-columns: minmax(0, 1fr) 30%; padding: 12px 14px; border-radius: 14px; }
  .mn-case b { font-size: 1.35rem; }
  .mn-case span { font-size: 0.8rem; margin-top: 3px; }
  .mn-case img { max-height: 64px; border-radius: 8px; }
}
@media (max-width: 860px) { .mn-side { padding-bottom: calc(28px + env(safe-area-inset-bottom)); } }
@media (max-width: 860px) { .mn-main, .mn-side { min-height: auto; } .mn-case { flex: none; } }
