/* Homepage: one fixed stage. Nothing scrolls; the layout changes in place between
   Home, About and Contact as you scroll, swipe or use the menu. */
:root {
  --bg: #f5f3eb; --text: #1a1a18; --muted: #76746c; --line: #dcd9cd;
  --ease: cubic-bezier(.22, .8, .18, 1);
  --dur: .9s;
  --pad: 16px;
  --draw-time: 2.5s;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #141413; --text: #ecebe4; --muted: #8d8b83; --line: #2d2c29; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #141413; --text: #ecebe4; --muted: #8d8b83; --line: #2d2c29; color-scheme: dark; }
@media (min-width: 900px) { :root { --pad: 28px; } }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; line-height: 1.5;
  -webkit-text-size-adjust: 100%; transition: background-color .3s, color .3s;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.stage { position: fixed; inset: 0; height: 100dvh; touch-action: none; user-select: none; -webkit-user-select: none; }

/* ---------- Top bar ---------- */
.top { position: absolute; inset: 0 0 auto 0; z-index: 7; display: flex; justify-content: space-between; align-items: flex-start;
       padding: calc(var(--pad) + env(safe-area-inset-top, 0px)) var(--pad) 0; pointer-events: none; }
.top > * { pointer-events: auto; }
.intro { margin: 0; max-width: 34ch; font-size: clamp(11px, 3vw, 13.2px); line-height: 1.4; font-weight: 300;
         transition: opacity .6s var(--ease), transform var(--dur) var(--ease); }
.top-right { display: flex; align-items: center; gap: 22px; margin-top: 2px; }

.mode-ico { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.mode-ico.i-sun { display: none; }
:root[data-theme="dark"] .mode-ico.i-sun { display: block; }
:root[data-theme="dark"] .mode-ico.i-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mode-ico.i-sun { display: block; } :root:not([data-theme="light"]) .mode-ico.i-moon { display: none; } }
.mode { padding: 4px 0; margin: -4px 0; }

.burger { position: relative; width: 24px; height: 14px; }
.burger i { position: absolute; left: 0; right: 0; height: 1.5px; background: currentColor; transition: transform .45s var(--ease), top .45s var(--ease); }
.burger i:nth-child(1) { top: 2px; } .burger i:nth-child(2) { top: 10px; }
.menu-open .burger i:nth-child(1) { top: 6px; transform: rotate(45deg); }
.menu-open .burger i:nth-child(2) { top: 6px; transform: rotate(-45deg); }
.mode:focus-visible, .burger:focus-visible, a:focus-visible { outline: 1px solid currentColor; outline-offset: 5px; }

/* ---------- Signature: centred on Home, shrinks to the top-left everywhere else ---------- */
.sig { position: absolute; left: 0; top: 0; z-index: 6; width: var(--sig-w, 80vw); transform-origin: 0 0;
       transform: translate(var(--x, 0px), var(--y, 0px)) scale(var(--k, 1)); transition: transform var(--dur) var(--ease); will-change: transform; display: block; }
.signature { display: block; width: 100%; height: auto; overflow: visible; color: var(--text); }
.signature :is(path, rect, polygon, circle) { fill: currentColor; stroke: none; }
.signature mask polyline {
  fill: none; stroke: #fff; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1 2; stroke-dashoffset: 1.02; stroke-opacity: 0;
}
/* First visit in a session: the signature is written on the spot */
.splash-active .signature mask polyline {
  animation: sig-write calc(var(--t) * var(--draw-time)) linear calc(var(--d) * var(--draw-time)) both;
}
@keyframes sig-write {
  0% { stroke-opacity: 0; stroke-dashoffset: 1.02; }
  0.01% { stroke-opacity: 1; stroke-dashoffset: 1.02; }
  100% { stroke-opacity: 1; stroke-dashoffset: 0; }
}
/* Later visits: already written */
.sig-done .signature mask polyline { stroke-dashoffset: 0; stroke-opacity: 1; }

/* Everything else waits for the signature on the first visit */
.top, .bottom { transition: transform 1s var(--ease); }
.wait .top { transform: translateY(-140%); pointer-events: none; }
.wait .bottom { transform: translateY(140%); pointer-events: none; }
.wait .panel, .wait .scene-vinyl { visibility: hidden !important; }

.scrub .intro, .scrub .panel-about, .scrub .panel-contact, .scrub .sig { transition: none !important; }

/* ---------- Panels ---------- */
.panel { position: absolute; left: var(--pad); right: calc(var(--pad) + 22px); top: 50%; z-index: 3; max-width: 46ch;
         opacity: 0; visibility: hidden; transform: translateY(calc(-50% + 90px));
         transition: opacity .55s var(--ease), transform var(--dur) var(--ease), visibility 0s linear .9s; }
.panel .label { margin: 0 0 18px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-size: 10.5px; }
.panel p { margin: 0 0 1.1em; font-size: clamp(15px, 4.4vw, 20px); line-height: 1.45; font-weight: 500; }
.panel-about p:nth-of-type(n+3) { font-size: clamp(12.5px, 3.5vw, 16px); font-weight: 300; line-height: 1.55; }
.panel .more { display: flex; gap: 22px; margin-top: 26px; color: var(--muted); }
.panel .more a { border-bottom: 1px solid var(--line); padding-bottom: 2px; transition: color .2s, border-color .2s; }
.panel .more a:hover { color: var(--text); border-color: currentColor; }
.contact-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.contact-list a { display: inline-block; font-size: clamp(20px, 6.4vw, 34px); line-height: 1.15; font-weight: 500; letter-spacing: -.01em;
                  border-bottom: 1px solid transparent; transition: border-color .25s; }
.contact-list a:hover { border-color: currentColor; }
.contact-list small { display: block; margin-bottom: 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-size: 10.5px; }
.panel .social { display: flex; gap: 22px; margin: 34px 0 0; }
.social a { display: block; width: 30px; height: 30px; color: inherit; opacity: .85; transition: opacity .2s, transform .2s; }
.social a:hover { opacity: 1; transform: translateY(-2px); }
.social svg { display: block; width: 100%; height: 100%; }
@media (min-width: 900px) {
  .panel { left: calc(var(--pad) + 4vw); max-width: 52ch; }
  .panel p { font-size: clamp(18px, 1.7vw, 24px); }
    .panel-about p:nth-of-type(n+3) { font-size: clamp(14px, 1.3vw, 18px); }
  .contact-list a { font-size: clamp(28px, 3.4vw, 48px); }
}

/* Which panel shows in which state */
[data-state="0"] .intro { opacity: 1; }
[data-state="1"] .intro, [data-state="2"] .intro, [data-state="3"] .intro { opacity: 0; transform: translateY(-70px); pointer-events: none; }
[data-state="1"] .panel-about, [data-state="3"] .panel-contact {
  opacity: 1; visibility: visible; transform: translateY(-50%); transition-delay: .18s, .18s, 0s;
}
[data-state="2"] .panel-about, [data-state="3"] .panel-about { transform: translateY(calc(-50% - 30px)); }
@media (min-width: 900px) { [data-state="2"] .panel-about, [data-state="3"] .panel-about { transform: translateY(calc(-50% - 90px)); } }

/* ---------- Records scene: big sleeves that bleed off the screen while they stack; the last one rests above the word ---------- */
.scene-vinyl { position: absolute; inset: 0; z-index: 3; pointer-events: none; visibility: hidden; will-change: transform; overflow: hidden; 
  --w: min(100vw, 520px); --peek: 94px; --word: min(14vw, 9dvh, 64px); }
@media (min-width: 900px) { .scene-vinyl { --w: min(520px, 40vw); --peek: 80px; --word: min(6vw, 9dvh, 88px); } }
.stack { list-style: none; margin: 0; padding: 0; position: absolute; left: 50%; width: var(--w); top: 22dvh; transform: translateX(-50%); will-change: transform; }
.cv { position: absolute; left: 0; top: calc(var(--i) * var(--peek)); width: 100%; z-index: calc(var(--i) + 1); visibility: hidden; will-change: transform; }
.cv { padding: 18px 20px calc(26px + 100dvh);   /* the extra 100dvh is the folder running off the bottom of the screen; later folders sit on top of it */
      border: 1px solid var(--muted); border-bottom: 0; border-radius: 12px 12px 0 0;
      background: var(--bg); }
/* the last folder runs off the bottom of the screen; extra padding keeps its text clear of the footer labels */
.cv:last-child { padding-bottom: calc(62px + 100dvh); }
.cv .tab { position: absolute; top: -23px; left: calc(var(--t) * 31% - 1px); width: 31%; height: 23px; box-sizing: border-box; padding: 5px 0 0 12px;
           border: 1px solid var(--muted); border-bottom: 0; border-radius: 9px 9px 0 0; background: var(--bg); color: var(--muted);
           font-size: 10.5px; letter-spacing: .12em; }
.cv .tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 3px; background: var(--bg); }
/* flap flush with the left edge: square off the folder corner under it so the lines join cleanly */
.cv[style*="--t: 0"], .cv[style*="--t:0"] { border-top-left-radius: 0; }
.cv h2 { margin: 0; height: calc(var(--peek) - 18px); overflow: hidden; font-size: clamp(15px, 4.3vw, 18px); line-height: 1.2; font-weight: 500; letter-spacing: -.01em; }
.cv p { margin: 0; color: var(--muted); font-size: clamp(12px, 3.4vw, 13.5px); line-height: 1.5; }
.band { position: absolute; left: 0; right: 0; top: 0; z-index: 19; background: var(--bg); pointer-events: none; }
.word { position: absolute; left: 0; right: 0; top: 70%; overflow: hidden; display: block; text-align: center; pointer-events: none; z-index: 20;
        font-size: var(--word); line-height: 1; font-weight: 500; letter-spacing: -.045em; padding: .06em 0 .1em; }
.word span { display: block; will-change: transform; }

/* ---------- Bottom bar and position dots ---------- */
.bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; justify-content: space-between; align-items: baseline;
          padding: 0 var(--pad) calc(var(--pad) + env(safe-area-inset-bottom, 0px)); color: var(--muted); font-size: 11px;
          text-transform: uppercase; letter-spacing: .12em; pointer-events: none; }
.bottom .hint { transition: opacity .5s; pointer-events: auto; cursor: pointer; }

/* ---------- Menu ---------- */
.menu { position: absolute; inset: 0; z-index: 5; display: grid; align-content: center; padding: 0 var(--pad);
        background: var(--bg); opacity: 0; visibility: hidden; transition: opacity .45s var(--ease), visibility 0s linear .45s; }
.menu-open .menu { opacity: 1; visibility: visible; transition-delay: 0s; }
.menu-open .intro { opacity: 0 !important; }
.menu ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.menu li { overflow: hidden; }
.menu li a, .menu li button { display: block; width: 100%; text-align: left; font-size: clamp(22px, 6vw, 34px); line-height: 1.15; font-weight: 500; letter-spacing: -.015em;
  transform: translateY(105%); transition: transform .7s var(--ease); }
.menu-open .menu li a, .menu-open .menu li button { transform: none; }
.menu-open .menu li:nth-child(2) a, .menu-open .menu li:nth-child(2) button { transition-delay: .05s; }
.menu-open .menu li:nth-child(3) a, .menu-open .menu li:nth-child(3) button { transition-delay: .1s; }
.menu-open .menu li:nth-child(4) a { transition-delay: .15s; }
.menu-open .menu li:nth-child(5) a { transition-delay: .2s; }
.menu-open .menu li:nth-child(6) a { transition-delay: .25s; }
.menu-open .menu li:nth-child(7) a, .menu-open .menu li:nth-child(7) button { transition-delay: .3s; }
.menu-open .menu li:nth-child(8) a, .menu-open .menu li:nth-child(8) button { transition-delay: .35s; }
.menu li.sep { margin-top: 18px; }
.menu li a:hover, .menu li button:hover { opacity: .55; }
@media (min-width: 900px) { .menu { padding-left: calc(var(--pad) + 4vw); } }

@media (prefers-reduced-motion: reduce) {
  :root { --dur: .01s; }
  .panel, .intro, .sig, .cv, .word span, .menu, .menu li a, .menu li button { transition-duration: .01s !important; transition-delay: 0s !important; }
}
.noscript-note { position: absolute; bottom: 60px; left: var(--pad); }

/* About background: soft, faded depth portrait behind the text */
.about-bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; visibility: hidden; opacity: .42; mix-blend-mode: multiply; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .about-bg { mix-blend-mode: screen; opacity: .28; } }
:root[data-theme="dark"] .about-bg { mix-blend-mode: screen; opacity: .28; }

/* ---------- About text: each line fades and rises in as you scroll (progress --r set by about-text.js) ---------- */
.panel-about.words .w { display: inline-block; opacity: var(--r, 0); transform: translateY(calc((1 - var(--r, 0)) * .8em)); filter: blur(calc((1 - var(--r, 0)) * 5px)); will-change: opacity, transform; }

/* credits sit in the middle of the bottom bar, only on Contact */
.bottom .credits { position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); text-align: center; white-space: nowrap;
  font-size: 9px; line-height: 1.6; letter-spacing: .06em; text-transform: none; color: var(--muted); opacity: 0; pointer-events: none; transition: opacity .5s; }
[data-state="3"] .bottom .credits { opacity: 1; transition-delay: .3s; }
@media (max-width: 370px) { .bottom .credits { bottom: calc(46px + env(safe-area-inset-bottom, 0px)); } }

/* ---------- Menu as a folder that slides down from above; its upside-down flap says CLOSE ---------- */
.menu { inset: 0 0 auto 0; height: calc(100dvh - 28px); overflow: visible; align-content: center; box-sizing: border-box;
  padding: calc(70px + env(safe-area-inset-top, 0px)) var(--pad, 18px) 30px;
  background: var(--room, var(--bg)); border: 1px solid var(--muted, var(--dim)); border-top: 0; border-radius: 0 0 12px 12px;
  opacity: 1; visibility: hidden; transform: translateY(calc(-100% - 48px));
  transition: transform .85s cubic-bezier(.22,.8,.18,1), visibility 0s linear .85s; }
.menu-open .menu { transform: none; visibility: visible; transition-delay: 0s; }
.menu .menu-close { position: absolute; top: 100%; left: calc(62% - 1px); width: min(31%, 240px); height: 26px; margin-top: -1px; padding: 0;
  border: 1px solid var(--muted, var(--dim)); border-top: 0; border-radius: 0 0 9px 9px; background: var(--room, var(--bg)); color: var(--muted, var(--dim));
  font: 400 10.5px/26px "JetBrains Mono", ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; text-align: center; cursor: pointer; }
.menu .menu-close::before { content: ""; position: absolute; left: 0; right: 0; top: -2px; height: 3px; background: var(--room, var(--bg)); }
.menu .menu-close:hover { color: var(--ink, var(--text)); }
.fold-veil { position: absolute; inset: 0; z-index: 4; background: color-mix(in srgb, var(--bg) 55%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden; transition: opacity .6s cubic-bezier(.22,.8,.18,1), visibility 0s linear .6s; }
.menu-open .fold-veil { opacity: 1; visibility: visible; transition-delay: 0s; }
@media (prefers-reduced-motion: reduce) { .menu, .fold-veil { transition-duration: .01s !important; } }

/* thin lines between the menu pages, like the project lists */
.sm ul, .menu ul { gap: 0; }
.sm li, .menu li { border-bottom: 1px solid color-mix(in srgb, currentColor 22%, transparent); padding: 9px 0; }
.sm li:first-child, .menu li:first-child { border-top: 1px solid color-mix(in srgb, currentColor 22%, transparent); }
.sm li.sep, .menu li.sep { margin-top: 0; }

/* About: same layout as the Art page text (header, line, Description / Explore rows) */
.panel-about { max-width: 640px; }
.panel-about .a-sub { margin: 6px 0 22px; font-size: 14px; line-height: 1.35; font-weight: 400; opacity: .75; color: var(--text); }
.a-row { display: grid; grid-template-columns: 24% 1fr; gap: 12px; align-items: start; margin-bottom: 22px; }
.a-row h3 { margin: 0; font-size: 10px; font-weight: 400; letter-spacing: .12em; text-transform: uppercase; opacity: .7; color: var(--text); }
.panel-about .a-desc p { margin: 0 0 .7em; font-size: 12.5px; line-height: 1.5; font-weight: 300; }
.panel-about .a-desc p:last-child { margin-bottom: 0; }
.panel-about .a-desc .a-more { margin-top: 1em; }
.panel-about .a-desc .a-more a { text-decoration: underline; text-underline-offset: 3px; }
.panel-about .a-row .more { margin-top: 0; font-size: 12.5px; }
@media (min-width: 900px) { .a-row { grid-template-columns: 22% 1fr; } .panel-about .a-desc p, .panel-about .a-row .more { font-size: 14px; } }

/* Desktop: the skill folders stand side by side across the screen (each one rises in turn, running off the bottom) */
@media (min-width: 900px) {
  .stack { --gap: -1px; width: calc(100vw - 2 * var(--pad) - 24px); top: calc(88px + var(--word) * 1.16 + 62px); }
  .cv { top: 0; width: calc((100% - (var(--n) - 1) * var(--gap)) / var(--n)); left: calc(var(--i) * ((100% - (var(--n) - 1) * var(--gap)) / var(--n) + var(--gap))); border-top-left-radius: 0 !important; }
  .cv .tab { left: -1px; width: 46px; padding-left: 10px; }
  .cv h2 { height: auto; margin-bottom: 16px; font-size: clamp(16px, 1.45vw, 28px); }
  .cv p { font-size: clamp(12.5px, 1.05vw, 19px); }
}

/* Desktop About: the text moves in towards the centre so it just overlaps the portrait */
@media (min-width: 900px) { .panel-about { left: 12vw; right: auto; width: min(560px, 44vw); max-width: none; } }

/* ---------- Header buttons: bigger, with a generous tap area that takes priority over the page underneath ---------- */
.burger { width: 32px; height: 18px; }
.burger i:nth-child(1) { top: 3px; } .burger i:nth-child(2) { top: 14px; }
.menu-open .burger i:nth-child(1) { top: 8px; transform: rotate(45deg); }
.menu-open .burger i:nth-child(2) { top: 8px; transform: rotate(-45deg); }
.top :is(.mode, .burger) { position: relative; }
.top :is(.mode, .burger)::before { content: ""; position: absolute; inset: -18px -10px -14px; }
.top-right > :last-child::before { right: -14px; }
