/* ==========================================================================
   Shared design system — tokens, glass, buttons, motion, template mode
   ========================================================================== */

:root {
  --bg: #f6f5f2;
  --ink: #0b0b0f;
  --ink-2: #3a3a44;
  --muted: #6e6e7a;
  --line: rgba(12, 12, 24, 0.08);
  --glass: rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.7);
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.03), 0 10px 30px -12px rgba(20, 20, 40, 0.18), 0 40px 80px -40px rgba(20, 20, 40, 0.25);
  --radius: 28px;
  --radius-sm: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: "Inter Tight", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  --tm-ink: #5b5bd6;
  --tm-bg: rgba(91, 91, 214, 0.06);
  --maxw: 1200px;
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip; /* clip, not hidden: hidden would make body a scroll container and break position: sticky */
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: #1b1b22; color: #fff; }

.container { width: min(var(--maxw), 100% - 2 * var(--gutter)); margin-inline: auto; }
.muted { color: var(--muted); }

/* ---------- Type scale ---------- */
.display {
  font-size: clamp(48px, 8.4vw, 128px);
  line-height: 0.95;
  letter-spacing: -0.045em;
  font-weight: 600;
}
.h2 {
  font-size: clamp(36px, 5.2vw, 72px);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 600;
}
.h3 { font-size: clamp(22px, 2.2vw, 28px); letter-spacing: -0.02em; font-weight: 600; line-height: 1.15; }
.lead { font-size: clamp(17px, 1.6vw, 21px); color: var(--ink-2); line-height: 1.5; max-width: 40ch; }

/* ---------- Glass ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
}

/* ---------- Chips + section tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 500; letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip .dot.live { background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: ping 2s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }

.section-tag {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(12, 12, 24, 0.05);
  font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em;
}
.section-tag b { font-weight: 500; color: var(--muted); }
.section-tag i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- Buttons ---------- */
.btn {
  --b-bg: var(--ink); --b-fg: #fff;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 52px; padding: 0 26px; border-radius: 999px;
  background: var(--b-bg); color: var(--b-fg);
  font-weight: 500; font-size: 16px; white-space: nowrap;
  transition: transform 0.5s var(--ease), background 0.25s, color 0.25s;
  box-shadow: none;
}
/* Buttons are flat, solid colors: no gradients, glows or inner highlights. */
.btn:hover { background: color-mix(in srgb, var(--b-bg) 86%, #000); }
.btn .ico { display: inline-flex; font-size: 15px; transition: transform 0.5s var(--ease); }
.btn:hover .ico { transform: translateX(3px); }
.btn-light { --b-bg: #ffffff; --b-fg: var(--ink); border: 1px solid rgba(0, 0, 0, 0.1); }
.btn-light:hover { background: #f2f2f4; }
.btn-sm { height: 40px; padding: 0 18px; font-size: 14px; }
.arrow-circle {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--ink); color: #fff; font-size: 14px;
  transition: transform 0.6s var(--ease);
}
.ico { display: inline-flex; line-height: 1; }
.ico svg { width: 1em; height: 1em; }
.ico.solid svg { fill: currentColor; }

/* ---------- Motion primitives ---------- */
[data-reveal]:not(.in) { opacity: 0; transform: translateY(28px); filter: blur(6px); }
html [data-reveal] {
  transition: opacity 1.1s var(--ease), transform 1.1s var(--ease), filter 1.1s var(--ease), box-shadow 0.6s var(--ease), border-color 0.5s, background-color 0.5s;
  transition-delay: var(--d, 0ms), var(--d, 0ms), var(--d, 0ms), 0ms, 0ms, 0ms;
}

/* Room below the baseline so descenders (g, p, y) are not clipped while words rise in */
/* Extra room on each side (cancelled by negative margins) so tight letter-spacing doesn't clip the first or last letter */
.split-word { display: inline-block; overflow: hidden; vertical-align: top; padding: 0 0.1em 0.24em; margin: 0 -0.1em -0.24em; }
.split-word > span {
  display: inline-block;
  transform: translateY(105%);
  transition: transform 1.2s var(--ease);
  transition-delay: var(--d, 0ms);
}
.split-ready .split-word > span { transform: none; }

[data-tilt] { transform-style: preserve-3d; transition: transform 0.7s var(--ease); will-change: transform; }

.spot { position: relative; isolation: isolate; }
.spot::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.45), transparent 45%);
  opacity: 0; transition: opacity 0.4s;
  mix-blend-mode: soft-light;
}
.spot:hover::after { opacity: 1; }

/* ---------- Marquee ---------- */
.marquee { overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.marquee-track { display: flex; gap: 14px; width: max-content; animation: marquee var(--speed, 40s) linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Media (photos with gradient fallback) ---------- */
.media { position: relative; overflow: hidden; background: linear-gradient(135deg, #e9e4dc, #d9dfe8); }
.media > img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.4s var(--ease), opacity 0.4s; }

/* ---------- Attribution footer ---------- */
.credits { font-size: 13px; color: var(--muted); }
.credits a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(0, 0, 0, 0.2); }

/* ==========================================================================
   Template mode — ?view=template
   ========================================================================== */
.tm-toggle {
  position: fixed; left: var(--gutter); bottom: calc(16px + var(--safe-b)); z-index: 1000;
  display: flex; align-items: center; gap: 4px; padding: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.35);
  font: 500 13px/1 var(--sans); color: #0b0b0f;
}
.tm-toggle a.tm-back { display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px 9px 10px; border-radius: 999px; transition: background 0.3s; }
.tm-toggle a.tm-back:hover { background: rgba(0, 0, 0, 0.06); }
.tm-seg { position: relative; display: flex; background: rgba(0, 0, 0, 0.06); border-radius: 999px; padding: 3px; }
.tm-seg button { position: relative; z-index: 1; padding: 7px 14px; border-radius: 999px; font-weight: 500; color: #55555f; transition: color 0.3s; }
.tm-seg button[aria-pressed="true"] { color: #0b0b0f; }
.tm-seg .tm-pill { position: absolute; top: 3px; bottom: 3px; left: 3px; border-radius: 999px; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); transition: transform 0.5s var(--ease), width 0.5s var(--ease); }

.is-template [data-section] { position: relative; outline: 1.5px dashed color-mix(in srgb, var(--tm-ink) 45%, transparent); outline-offset: -10px; }
.tm-tag {
  position: absolute; top: 18px; left: 18px; z-index: 50;
  padding: 5px 10px; border-radius: 8px;
  background: var(--tm-ink); color: #fff;
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.04em; text-transform: uppercase;
  pointer-events: none;
}
.is-template .media > img, .is-template .media > video { opacity: 0 !important; }
.is-template .media {
  background:
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--tm-ink) 14%, transparent) 0 1px, transparent 1px 12px),
    var(--tm-bg) !important;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tm-ink) 35%, transparent);
}
.is-template .media::before {
  content: attr(data-media);
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--tm-ink); color: #fff;
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.04em;
}
.is-template .media > :not(img):not(video) { visibility: hidden; }
.is-template .tm-text:not(.btn):not(.chip) { opacity: 0.55; }
.is-template .tm-hide-in-template { display: none !important; }

/* ---------- Fluid scaling: small phones up to large desktops ---------- */
@media (max-width: 420px) {
  body { font-size: 16px; }
  .btn { height: 48px; padding: 0 20px; font-size: 15px; }
  .btn-sm { height: 38px; padding: 0 14px; font-size: 13px; }
  .tm-back-label { display: none; }
  .tm-toggle a.tm-back { padding: 9px 10px; }
  .tm-seg button { padding: 7px 11px; }
}
@media (min-width: 1680px) {
  :root { --maxw: 1360px; }
  body { font-size: 18px; }
  .display { font-size: clamp(48px, 8.4vw, 150px); }
  .h2 { font-size: clamp(36px, 4.6vw, 84px); }
  .lead { font-size: 22px; }
}
@media (min-width: 2200px) {
  :root { --maxw: 1560px; }
  body { font-size: 19px; }
  .display { font-size: 176px; }
  .h2 { font-size: 100px; }
  .lead { font-size: 24px; }
  .btn { height: 58px; padding: 0 30px; font-size: 17px; }
}

/* ---------- Reduced motion ---------- */
/* ---------- Page transition: rounded squares fill in, then fade out (assets/transition.js) ---------- */
html.tx-cover { background: #f1f0ec; }
html.tx-cover body { visibility: hidden; }
.tx { position: fixed; inset: 0; z-index: 2147483000; display: grid; grid-auto-rows: var(--cell); overflow: hidden; pointer-events: none; visibility: visible; }
.tx span { position: relative; opacity: 0; background: #f1f0ec; }
.tx span::after { content: ""; position: absolute; inset: 13%; border-radius: 22%; background: rgba(40, 34, 24, 0.14); transform: scale(0); }
.tx.in span { opacity: 1; transition: opacity 0.25s; }
.tx.in span::after { transform: none; transition: transform 0.45s var(--ease) calc(var(--k) * 520ms); }
.tx.full span { opacity: 1; }
.tx.full span::after { transform: none; }
.tx.out span { opacity: 0; transition: opacity 0.5s ease calc(var(--k) * 820ms); }
.tx.out span::after { transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  html [data-reveal]:not(.in) { opacity: 1; transform: none; filter: none; }
  .split-word > span { transform: none; }
  html { scroll-behavior: auto; }
}
