/*
 * Layout: one pinned scene that scrolls from night to day. Text sits in a left column,
 * the mountain on the right. A short light section follows. The look is deliberate and
 * single: night at the top of the page, day at the bottom.
 */
:root {
  --night: #070B09; --day: #D3D6D0;
  --ink: #161D1A; --ink2: #46524C; --paper: #E7EAE3; --paper2: #8E9F96;
  --rule: rgba(22, 29, 26, .22); --lamp: #F0C36B; --wind: #E2702B;
  --term: #101714; --term-fg: #C9D3CB; --term-dim: #6F877B;
  --f-text: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --gut: clamp(20px, 4.6vw, 88px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--night); color: var(--paper); font-family: var(--f-text); font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--wind); outline-offset: 3px; }
.gut { padding-left: max(var(--gut), env(safe-area-inset-left, 0px)); padding-right: max(var(--gut), env(safe-area-inset-right, 0px)); }

/* ---------- the pinned scene ---------- */

/* --bg, --fg, --fg2 and --acc are driven from scene.js as the scene moves from night to day */
.stage { position: relative; height: 640vh; --bg: #070B09; --fg: #E7EAE3; --fg2: #8E9F96; --acc: #F0C36B; background: var(--bg); color: var(--fg); }
.view { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }
.view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.shade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(7, 11, 9, .86) 0%, rgba(7, 11, 9, .55) 38%, rgba(7, 11, 9, 0) 64%); }

.nav { position: absolute; inset: 0 0 auto 0; z-index: 3; padding-block: 26px; display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.mark { display: flex; flex-direction: column; gap: 9px; color: inherit; text-decoration: none; }
/* the wordmark: four drawn letters on one arch, and two umlaut tiles. The right tile carries the accent. */
.logo { display: block; height: 36px; width: 76px; overflow: visible; } /* 220:104, the viewBox */
.logo-type { fill: none; stroke: currentColor; stroke-width: 10; }
.dot { transform-box: fill-box; transform-origin: center; }
.dot-a { fill: currentColor; }
.dot-b { fill: var(--acc); }
.mark span { font-family: var(--f-mono); font-size: .7rem; color: var(--fg2); }
/* --fgr: daylight reaches the right of the frame first, so these turn to ink before the mark does */
.links { display: flex; gap: 30px; align-items: center; font-size: .95rem; color: var(--fgr, var(--fg2)); padding-top: 6px; }
.links a { color: inherit; text-decoration: none; }
.links a:hover { color: var(--fg); }

/* --ty centres a panel on wide screens. scene.js adds `on` while a panel is showing and `past` once it is behind. */
.panel { position: absolute; z-index: 2; left: 0; top: 50%; --ty: -50%; transform: translateY(var(--ty)); width: calc(min(34rem, 36vw) + var(--gut)); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.panel.hero { width: calc(min(46rem, 50vw) + var(--gut)); }
.panel.on { pointer-events: auto; }
/* each line of a panel moves on its own: it rises in from below with a short stagger and leaves upward, quickly */
.panel > * { opacity: 0; transform: translateY(22px); transition: opacity .2s ease, transform .22s ease; }
.panel.past > * { transform: translateY(-16px); }
.panel.on > * { opacity: 1; transform: none; transition: opacity .6s cubic-bezier(.2, .8, .2, 1), transform .85s cubic-bezier(.16, 1, .3, 1); }
.panel.on > :nth-child(1) { transition-delay: .12s; }
.panel.on > :nth-child(2) { transition-delay: .19s; }
.panel.on > :nth-child(3) { transition-delay: .26s; }
.panel.on > :nth-child(4) { transition-delay: .33s; }
.panel.layer { gap: 18px; }
.panel h1, .panel h2, .panel .lead { font-weight: 300; font-size: clamp(1.7rem, 3.1vw, 3rem); line-height: 1.17; letter-spacing: -.018em; text-wrap: balance; }
.panel .lead { color: var(--fg2); }
.panel.layer h2 { font-size: clamp(1.6rem, 2.6vw, 2.5rem); }
.panel.layer p { font-size: 1.06rem; color: var(--fg2); max-width: 30em; }
.kicker { font-family: var(--f-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--fg2); display: flex; align-items: center; gap: 10px; }
.kicker::before { content: ""; width: 7px; height: 7px; background: var(--acc); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--f-mono); font-size: .7rem; color: var(--fg2); }
.tags span { border: 1px solid currentColor; padding: 2px 8px; opacity: .8; }
.btn { display: inline-block; font-family: var(--f-text); font-weight: 500; font-size: 1rem; line-height: 1.2; text-decoration: none; background: var(--acc); color: #17130A; border: 0; padding: .9em 1.5em; cursor: pointer; align-self: flex-start; }
.panel.hero .btn, .panel.done .btn { margin-top: 28px; }
.hint { position: absolute; z-index: 2; left: 0; bottom: 5%; font-family: var(--f-mono); font-size: .72rem; color: var(--fg2); display: flex; align-items: center; gap: 10px; }
.hint i { width: 7px; height: 7px; background: var(--acc); }

/* ---------- after the scene ---------- */

.after { background: var(--day); color: var(--ink); }
.sec { padding-block: clamp(72px, 10vw, 140px); display: flex; flex-direction: column; gap: clamp(32px, 4vw, 52px); }
.sec + .sec { border-top: 1px solid var(--rule); }
.sec h2 { font-weight: 300; font-size: clamp(1.7rem, 3.1vw, 3rem); line-height: 1.17; letter-spacing: -.018em; max-width: 22em; text-wrap: balance; }
.sec h2 span { color: var(--ink2); }
.term-box { background: var(--term); max-width: 980px; min-width: 0; }
.term-bar { font-family: var(--f-mono); font-size: .7rem; letter-spacing: .06em; color: var(--term-dim); padding: 10px 20px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.term { margin: 0; padding: 18px 20px 22px; color: var(--term-fg); font-family: var(--f-mono); font-size: 13px; line-height: 1.75; overflow-x: auto; }
.term .d { color: var(--term-dim); }
.term .h { color: var(--lamp); }
.term.wait .ln { opacity: 0; }
.after .btn { background: var(--wind); }
/* the address is also shown as text, because a mailto link does nothing where no mail app is set up */
.soon { font-family: var(--f-mono); font-size: .8rem; letter-spacing: .06em; color: var(--ink2); display: flex; align-items: center; gap: 10px; user-select: all; }
.soon::before { content: ""; width: 7px; height: 7px; background: var(--wind); }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 32px; font-family: var(--f-mono); font-size: .72rem; color: var(--ink2); padding-block: 22px; border-top: 1px solid var(--rule); }

/* ---------- motion ---------- */

/* The entrance moves text but never hides it: a throttled or background page can stall an
   animation on its first frame, and stalled text must still be readable. */
@keyframes rise { from { transform: translateY(16px); } to { transform: none; } }
@keyframes blink { 50% { opacity: 0; } }
/* the umlaut tiles drop onto the wordmark and settle, the right one a beat late; afterwards it winks like the summit beacon */
@keyframes land { 0% { transform: translateY(-34px); } 55% { transform: translateY(3px); } 78% { transform: translateY(-1.5px); } 100% { transform: none; } }
@keyframes wink { 0%, 88%, 100% { opacity: 1; } 92% { opacity: .2; } }
@keyframes hop { 0%, 100% { transform: none; } 40% { transform: translateY(-9px); } }

@media (prefers-reduced-motion: no-preference) {
  .panel.hero > * { animation: rise 1s cubic-bezier(.2, .7, .2, 1) backwards; }
  .panel.hero > :nth-child(2) { animation-delay: .08s; }
  .panel.hero > :nth-child(3) { animation-delay: .16s; }
  .hint i, .term .cur { animation: blink 1.2s steps(1) infinite; }
  .dot-a { animation: land .7s .25s cubic-bezier(.3, .6, .3, 1) backwards; }
  .dot-b { animation: land .7s .37s cubic-bezier(.3, .6, .3, 1) backwards, wink 4.8s 2.4s infinite; }
  .mark:hover .dot-a { animation: hop .45s; }
  .mark:hover .dot-b { animation: hop .45s .08s; }
  .term .ln { transition: opacity .25s; }
}

/* ---------- compact: phones and portrait screens. Keep in step with `compact` in scene.js ---------- */

@media (max-width: 759px), (max-aspect-ratio: 21/20) {
  .panel, .panel.hero { width: auto; right: 0; top: auto; bottom: 7%; --ty: 0px; }
  .panel.hero, .panel.thesis { top: max(14%, 104px); bottom: auto; }
  .panel h1, .panel h2, .panel .lead { font-size: clamp(1.5rem, 5.6vw, 2.4rem); }
  .shade { background: linear-gradient(180deg, rgba(7, 11, 9, .82) 0%, rgba(7, 11, 9, .5) 40%, rgba(7, 11, 9, 0) 58%); }
  .hint { display: none; }
}
@media (max-width: 759px) {
  .links a:not(:last-child) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .panel > *, .panel.on > * { transition: none; }
}
@media (max-height: 560px) {
  .panel h1, .panel h2, .panel .lead, .panel.layer h2 { font-size: clamp(1.25rem, 2.4vw, 1.8rem); }
  .panel.layer { gap: 10px; }
  .panel.layer p { font-size: .95rem; }
  .panel.hero .btn, .panel.done .btn { margin-top: 14px; }
}

/* ---------- fallback: no script, or the scene could not start. The pinned frame becomes a plain column. ---------- */

html:not(.scene) .stage { height: auto; }
html:not(.scene) .view { position: static; height: auto; overflow: visible; padding-block: 32px 48px; }
html:not(.scene) .view canvas, html:not(.scene) .shade, html:not(.scene) .hint { display: none; }
html:not(.scene) .nav { position: static; padding-block: 0 96px; }
html:not(.scene) .panel { position: static; transform: none; pointer-events: auto; width: auto; max-width: 46rem; margin-bottom: 88px; }
html:not(.scene) .panel > * { opacity: 1; transform: none; }
