/* ==========================================================================
   Core shell: header, tabs, curtain transition, lightbox, shared utilities.
   Project pages set their own look in projects/<id>/project.css, scoped to
   .page-<id>. The core only reads these theme vars (set from project meta):
   --bg --fg --accent --on-accent
   ========================================================================== */

:root {
  --bg: #09090d;
  --fg: #f2f2f5;
  --accent: #8b8bff;
  --on-accent: #09090d;
  --muted: color-mix(in srgb, var(--fg) 62%, var(--bg));
  --line: color-mix(in srgb, var(--fg) 12%, transparent);
  --header-h: 64px;
  --gutter: clamp(16px, 4vw, 48px);
  --maxw: 1200px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.76, 0, .24, 1);
  --font-ui: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}
:root[data-scheme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .5s ease, color .5s ease;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--on-accent); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; left: 12px; top: -200px; z-index: 200; padding: 10px 14px; background: var(--accent); color: var(--on-accent); border-radius: 8px; text-decoration: none; }
.skip-link:focus { top: 12px; }

/* ---------- Header ---------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: clamp(10px, 2vw, 24px);
  padding: 0 var(--gutter);
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
  transition: background-color .5s ease, border-color .5s ease;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; font-weight: 800; letter-spacing: -.02em; font-size: 19px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: conic-gradient(from 210deg, #ffd60a, #6c6cff, #7fd1c0, #ffd60a);
  box-shadow: inset 0 0 0 5px var(--bg);
  transition: transform .6s var(--ease-out), box-shadow .5s ease;
}
.brand:hover .brand-mark { transform: rotate(180deg); }

.tabs {
  flex: 1; min-width: 0; display: flex; justify-content: center;
  overflow-x: auto; scrollbar-width: none;
  mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs-track { position: relative; display: flex; gap: 4px; padding: 6px 16px; }
.tab {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px;
  text-decoration: none; white-space: nowrap; font-weight: 600; font-size: 15px;
  color: var(--muted);
  transition: color .3s ease;
}
.tab:hover { color: var(--fg); }
.tab[aria-current="page"] { color: var(--on-accent); }
.tab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 25%, transparent); transition: box-shadow .3s; }
.tab[aria-current="page"] .tab-dot { background: var(--on-accent); box-shadow: none; }
.tabs-pill {
  position: absolute; z-index: 0; top: 6px; bottom: 6px; left: 0; width: 0;
  border-radius: 999px; background: var(--accent);
  box-shadow: 0 6px 24px -6px color-mix(in srgb, var(--accent) 70%, transparent);
  opacity: 0;
  transition: transform .55s var(--ease-out), width .55s var(--ease-out), opacity .3s, background-color .5s;
}
.gh-link { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--muted); transition: color .2s, background-color .2s; }
.gh-link:hover { color: var(--fg); background: var(--line); }

@media (max-width: 640px) {
  :root { --header-h: 58px; }
  .brand-name { display: none; }
  .tabs { justify-content: flex-start; }
  .tab { padding: 7px 13px; font-size: 14px; }
}

/* ---------- View & page ---------------------------------------------- */
.view { min-height: calc(100dvh - var(--header-h)); }
.page { position: relative; overflow-x: clip; }
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

/* Scroll reveal: add data-reveal to any element; optional style="--d:2" stagger */
[data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity .8s var(--ease-out), transform .9s var(--ease-out); transition-delay: calc(var(--d, 0) * 80ms); }
[data-reveal].is-in { opacity: 1; transform: none; }
[data-reveal="left"] { transform: translateX(-40px); }
[data-reveal="right"] { transform: translateX(40px); }
[data-reveal="zoom"] { transform: scale(.94); }
[data-reveal].is-in { transform: none; }

/* ---------- Next-project band & site footer --------------------------- */
.next-band {
  display: block; position: relative; overflow: hidden; text-decoration: none;
  padding: clamp(56px, 10vw, 120px) var(--gutter);
  background: var(--next-bg); color: var(--next-fg);
  border-top: 1px solid var(--line);
}
.next-band::before {
  content: ""; position: absolute; inset: 0;
  background: var(--next-accent);
  transform: translateX(-101%); transition: transform .7s var(--ease-io);
}
.next-band:hover::before, .next-band:focus-visible::before { transform: none; }
.next-inner { position: relative; max-width: var(--maxw); margin: 0 auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.next-kicker { font-family: var(--font-mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; opacity: .7; transition: color .5s; }
.next-name { font-size: clamp(44px, 9vw, 120px); line-height: .95; font-weight: 800; letter-spacing: -.04em; margin: 8px 0 0; transition: color .5s; }
.next-tag { max-width: 34ch; opacity: .8; transition: color .5s; }
.next-arrow { font-size: clamp(40px, 7vw, 88px); line-height: 1; transition: transform .6s var(--ease-out), color .5s; }
.next-band:hover .next-arrow { transform: translateX(16px); }
.next-band:hover :is(.next-kicker, .next-name, .next-tag, .next-arrow) { color: var(--next-on-accent); }

.site-footer { background: var(--bg); border-top: 1px solid var(--line); padding: 28px var(--gutter) calc(28px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 14px; }
.site-footer .wrap { padding: 0; display: flex; gap: 16px 28px; flex-wrap: wrap; justify-content: space-between; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--fg); }
.kbd-hint { font-family: var(--font-mono); font-size: 12px; }
.kbd-hint kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font: inherit; }

/* ---------- Curtain transition ---------------------------------------- */
.curtain { position: fixed; inset: 0; z-index: 100; pointer-events: none; overflow: hidden; visibility: hidden; }
.curtain.is-active { visibility: visible; pointer-events: auto; }
.curtain-a, .curtain-b {
  position: absolute; top: -10vh; bottom: -10vh; left: -40vw; width: 180vw;
  transform: translateX(150vw) skewX(-12deg);
  will-change: transform;
}
.curtain-a { background: var(--c-accent, #fff); }
.curtain-b { background: var(--c-bg, #000); }
.curtain-label {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  font-weight: 800; letter-spacing: -.045em; line-height: .9;
  font-size: clamp(48px, 13vw, 180px);
  color: var(--c-fg, #fff); opacity: 0; padding: 0 var(--gutter);
}
.curtain-label small { display: block; font-family: var(--font-mono); font-weight: 400; font-size: clamp(12px, 1.4vw, 15px); letter-spacing: .2em; text-transform: uppercase; color: var(--c-accent); margin-bottom: 18px; }

/* ---------- Lightbox -------------------------------------------------- */
.lightbox { position: fixed; inset: 0; z-index: 150; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 24px; background: rgb(5 5 8 / .92); backdrop-filter: blur(10px); color: #fff; }
.lightbox[hidden] { display: none; }
.lb-figure { margin: 0; display: grid; gap: 12px; justify-items: center; min-width: 0; animation: lb-in .4s var(--ease-out); }
.lb-figure img { max-height: calc(100dvh - 120px); width: auto; border-radius: 10px; box-shadow: 0 30px 80px rgb(0 0 0 / .6); object-fit: contain; }
.lb-figure figcaption { font-family: var(--font-mono); font-size: 13px; opacity: .75; }
.lb-nav, .lb-close { border: 0; background: rgb(255 255 255 / .08); width: 48px; height: 48px; border-radius: 50%; font-size: 28px; line-height: 1; cursor: pointer; transition: background .2s; }
.lb-nav:hover, .lb-close:hover { background: rgb(255 255 255 / .2); }
.lb-close { position: absolute; top: 16px; right: 16px; font-size: 18px; }
@keyframes lb-in { from { opacity: 0; transform: scale(.96); } }
@media (max-width: 640px) {
  .lightbox { grid-template-columns: 1fr; padding: 12px; }
  .lb-nav { position: absolute; bottom: 20px; }
  .lb-prev { left: 20px; } .lb-next { right: 20px; }
}
[data-zoom] { cursor: zoom-in; }

/* ---------- Shared bits projects may use ------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform .25s var(--ease-out), box-shadow .25s, background-color .25s, border-color .25s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-ghost { border-color: var(--line); }
.btn small { font-weight: 500; opacity: .7; font-family: var(--font-mono); font-size: .78em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  [data-reveal] { opacity: 1; transform: none; }
}
