/* Navbar, footer, page layouts. */

/* ---------- Navbar ---------- */
.nav { position: fixed; inset: 0 0 auto 0; z-index: 50; height: var(--nav-h); background: rgba(11, 12, 14, 0.55); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(255,255,255,0.08); }
.nav__inner { height: 100%; display: flex; align-items: center; gap: 32px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--accent); }
.brand svg { width: 26px; height: 26px; }
.brand__word { font-family: var(--font-display); font-weight: 300; font-size: 14px; letter-spacing: 0.42em; text-transform: uppercase; color: var(--text); }
.nav__links { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav__links a { position: relative; padding: 8px 18px; font-family: var(--font-display); font-weight: 300; font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--text-muted); transition: color var(--ease); }
.nav__links a:hover { color: var(--text); }
.nav__links a[aria-current="page"] { color: var(--text); }
.nav__links a[aria-current="page"]::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 2px; height: 1px; background: var(--accent); }
.nav .btn-x { margin-left: auto; }
.nav__toggle { display: none; margin-left: auto; width: 40px; height: 40px; position: relative; }
.nav__toggle span { position: absolute; left: 10px; right: 10px; height: 1px; background: var(--text); transition: transform var(--ease), top var(--ease); }
.nav__toggle span:first-child { top: 16px; }
.nav__toggle span:last-child { top: 23px; }
.nav__toggle[aria-expanded="true"] span:first-child { top: 20px; transform: rotate(45deg); }
.nav__toggle[aria-expanded="true"] span:last-child { top: 20px; transform: rotate(-45deg); }

@media (max-width: 820px) {
  .nav__inner { gap: 12px; }
  .nav .btn-x { margin-left: auto; }
  .nav__toggle { display: block; margin-left: 0; }
  .nav__links { position: fixed; inset: var(--nav-h) 0 auto 0; flex-direction: column; align-items: stretch; gap: 0; margin: 0; padding: 8px 24px 20px; background: rgba(10, 10, 10, 0.97); border-bottom: 1px solid var(--border); transform: translateY(-8px); opacity: 0; visibility: hidden; transition: opacity var(--ease), transform var(--ease), visibility var(--ease); }
  .nav__links.is-open { opacity: 1; transform: none; visibility: visible; }
  .nav__links a { padding: 16px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
  .nav__links a[aria-current="page"]::after { left: 0; right: auto; width: 24px; bottom: 12px; }
}
@media (max-width: 420px) { .brand__word { letter-spacing: 0.22em; } }

main { padding-top: var(--nav-h); }

/* ---------- Hero (index) ---------- */
.hero { position: relative; border-bottom: 1px solid var(--border); overflow: hidden; }
.hero__grid { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 48px; align-items: center; min-height: min(86vh, 820px); padding-block: 72px; }
.hero__copy { display: flex; flex-direction: column; gap: 28px; align-items: flex-start; }
.hero__sub { font-size: clamp(16px, 1.5vw, 18px); color: var(--text-muted); max-width: 46ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero__canvas { position: relative; height: 60vh; min-height: 340px; border: 1px solid var(--border); background: rgba(17, 17, 17, 0.4); }
.hero__canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero__canvas .hero__tag { position: absolute; left: 14px; bottom: 12px; z-index: 2; pointer-events: none; }
@media (max-width: 900px) {
  .hero__grid { grid-template-columns: 1fr; gap: 40px; min-height: 0; padding-block: 48px; }
  .hero__canvas { height: 46vh; }
}

/* ---------- Sections ---------- */
.section__head { display: flex; flex-direction: column; gap: 16px; max-width: 760px; margin-bottom: 48px; }
.section__head--center { margin-inline: auto; text-align: center; align-items: center; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }

.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; position: relative; }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr; } }

/* ---------- Page header (tools / docs / about) ---------- */
.page-head { padding-block: 72px 56px; display: flex; flex-direction: column; gap: 20px; }
.page-head h1 { font-size: clamp(40px, 6vw, 72px); letter-spacing: -0.04em; font-weight: 300; }

.page-head--tight { padding: 48px 0 0; gap: 16px; }
.page-head--tight + .pills { margin-top: 24px; }

/* ---------- Footer ---------- */
.footer { position: relative; z-index: 2; background: var(--bg); border-top: 1px solid var(--border); padding-block: 64px 32px; margin-top: 0; }
.footer__grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; }
.footer__brand { display: flex; flex-direction: column; gap: 16px; }
.footer__brand p { color: var(--text-muted); font-size: 14px; max-width: 28ch; }
.footer h3 { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 16px; font-weight: 400; }
.footer li + li { margin-top: 10px; }
.footer li a { font-size: 14px; color: var(--text); transition: color var(--ease); }
.footer li a:hover { color: var(--accent); }
.footer__bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; color: var(--text-muted); }
@media (max-width: 820px) { .footer__grid { grid-template-columns: 1fr 1fr; } .footer__brand { grid-column: 1 / -1; } }

/* ---------- Docs ---------- */
.docs { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 56px; padding-block: 48px var(--section-y); align-items: start; }
.docs__nav { position: sticky; top: calc(var(--nav-h) + 24px); max-height: calc(100vh - var(--nav-h) - 48px); overflow-y: auto; padding-right: 8px; }
.docs__nav summary { display: none; }
.docs__nav h4 { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted); font-weight: 400; margin: 24px 0 8px; }
.docs__nav h4:first-of-type { margin-top: 0; }
.docs__nav a { display: block; padding: 5px 0 5px 14px; border-left: 1px solid var(--border); font-size: 14px; color: var(--text-muted); transition: color var(--ease), border-color var(--ease); }
.docs__nav a:hover { color: var(--text); }
.docs__nav a.is-active { color: var(--text); border-left-color: var(--accent); }
.docs__body { max-width: 760px; min-width: 0; }
@media (max-width: 900px) {
  .docs { grid-template-columns: 1fr; gap: 24px; padding-top: 24px; }
  .docs__nav { position: static; max-height: none; border: 1px solid var(--border); background: var(--bg-2); padding: 0; }
  .docs__nav summary { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
  .docs__nav summary::after { content: "+"; color: var(--accent); }
  .docs__nav[open] summary::after { content: "–"; }
  .docs__nav .docs__links { padding: 0 16px 16px; }
}

/* ---------- Home: scroll story over a fixed 3D scene ---------- */
body.page-home::before { display: none; }
body.page-home main { padding-top: 0; }
.scene { position: fixed; inset: 0; z-index: 0; }
.scene canvas { display: block; width: 100%; height: 100%; }
.scene-scrim { position: fixed; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(90deg, rgba(11,12,14,0.78) 0%, rgba(11,12,14,0.42) 38%, rgba(11,12,14,0) 62%), linear-gradient(0deg, rgba(11,12,14,0.55) 0%, rgba(11,12,14,0) 30%); }
.story { position: relative; z-index: 2; }
.chapter { min-height: 100vh; display: flex; align-items: center; padding-block: 96px 64px; }
.chapter__text { max-width: 480px; display: flex; flex-direction: column; gap: 22px; align-items: flex-start; }
.chapter--hero .chapter__text { max-width: 640px; }
.chapter h2 { font-size: clamp(32px, 4vw, 54px); letter-spacing: -0.03em; font-weight: 300; }
.chapter p { color: var(--text-muted); font-size: clamp(16px, 1.3vw, 18px); line-height: 1.7; max-width: 44ch; }
.chapter .label { color: var(--text-muted); }
.chapter__code { width: min(100%, 520px); }
.chapter__steps { display: grid; gap: 10px; margin-top: 4px; color: var(--text-muted); font-size: 14px; counter-reset: s; }
.chapter__steps li { counter-increment: s; display: flex; gap: 14px; }
.chapter__steps li::before { content: "0" counter(s); font-family: var(--font-display); font-size: 11px; letter-spacing: 0.2em; color: var(--text); padding-top: 3px; }
.chapter__actions { display: flex; flex-wrap: wrap; gap: 22px; align-items: center; }

/* Each chapter's text slides up and fades in when it becomes the active one */
.js .chapter__text > * { opacity: 0; transform: translateY(22px); transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.js .chapter__text > :nth-child(2) { transition-delay: 90ms; }
.js .chapter__text > :nth-child(3) { transition-delay: 180ms; }
.js .chapter__text > :nth-child(4) { transition-delay: 270ms; }
.js .chapter__text > :nth-child(5) { transition-delay: 360ms; }
.js .chapter.is-active .chapter__text > * { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js .chapter__text > * { opacity: 1; transform: none; transition: none; } }

/* Chapter dots (right edge) */
.story-dots { position: fixed; right: 22px; top: 50%; z-index: 20; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; }
.story-dots button { position: relative; width: 22px; height: 22px; }
.story-dots button::before { content: ""; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; margin: -2.5px; background: rgba(255,255,255,0.28); transition: background var(--ease), transform var(--ease); }
.story-dots button[aria-current="true"]::before { background: #fff; transform: scale(1.5); }
.story-dots button:hover::before { background: rgba(255,255,255,0.7); }
.scroll-cue { position: absolute; left: 24px; bottom: 28px; display: flex; align-items: center; gap: 14px; font-family: var(--font-display); font-weight: 300; font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--text-muted); }
.scroll-cue::after { content: ""; width: 44px; height: 1px; background: linear-gradient(90deg, rgba(255,255,255,0.6), transparent); transform-origin: left; animation: cue 2.4s ease-in-out infinite; }
@keyframes cue { 0%, 100% { transform: scaleX(0.3); } 50% { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .scroll-cue::after { animation: none; } }
.chapter--hero { position: relative; }
@media (max-width: 767px) {
  .chapter { align-items: flex-end; padding-block: 96px 14vh; }
  .scene-scrim { background: linear-gradient(0deg, rgba(11,12,14,0.9) 0%, rgba(11,12,14,0.55) 45%, rgba(11,12,14,0.1) 75%); }
  .story-dots { right: 8px; }
  .scroll-cue { display: none; }
}

/* The mascot: a black-background illustration screened over the scene, so its black disappears and only the white ink shows */
.hero-figure { position: fixed; z-index: 1; right: max(-2vw, calc(50vw - 800px)); bottom: 0; height: min(86vh, 940px); width: auto; aspect-ratio: 1; pointer-events: none; mix-blend-mode: screen; opacity: calc(var(--fig, 1) * 0.95); -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 36%); mask-image: linear-gradient(90deg, transparent 0%, #000 36%); }
@media (max-width: 900px) { .hero-figure { height: 70vh; right: -12vw; opacity: calc(var(--fig, 1) * 0.4); } }
.about-figure { width: 100%; max-width: 520px; height: auto; mix-blend-mode: screen; margin-inline: auto; }
.about-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 520px); gap: 56px; align-items: center; }
@media (max-width: 900px) { .about-split { grid-template-columns: 1fr; gap: 32px; } }
