:root { color-scheme: dark; --bg: #000; --veil: #000; --fade-bg: #000; --display: "Space Grotesk", "IBM Plex Sans", system-ui, sans-serif; --body: "IBM Plex Sans", system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: #fff; font-family: var(--body); -webkit-text-size-adjust: 100%; }
body.detail-open { overflow: hidden; }
#scroll-space { height: 950vh; pointer-events: none; }
body.fallback #scroll-space { display: none; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; touch-action: pan-y; }
#flash, #blackout { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 5; }
#flash { background: #fff; }
#blackout { background: var(--veil); z-index: 6; }
#themefade { position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: 0; background: var(--fade-bg); transition: opacity .22s ease; }
#themefade.on { opacity: 1; }

/* HUD */
#hud { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: max(16px, env(safe-area-inset-top)) 20px 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-right { display: flex; align-items: center; gap: 8px; }
#theme { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border-radius: 50%; color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background .2s; }
#theme:hover { background: rgba(255,255,255,.22); }
#theme svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
#theme .i-moon { display: none; }
html[data-theme="light"] #theme .i-sun { display: none; }
html[data-theme="light"] #theme .i-moon { display: block; }
.brand { font: 700 15px/1 var(--display); letter-spacing: -0.01em; opacity: 0; transition: opacity .4s; }
#hud.show-brand .brand { opacity: .9; }
#replay { font: 500 13px/1 var(--body); color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); border-radius: 999px; padding: 9px 15px; cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background .2s; }
#replay:hover { background: rgba(255,255,255,.22); }
#replay:focus-visible, #theme:focus-visible, .detail-close:focus-visible, .pill:focus-visible, .fb-card:focus-visible, #access button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Intro */
#intro { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; justify-content: flex-start; padding-top: clamp(84px, 15vh, 170px); align-items: flex-start; padding-left: clamp(22px, 7vw, 110px); padding-right: clamp(22px, 7vw, 110px); pointer-events: none; text-shadow: 0 2px 30px rgba(20,5,40,.55); }
#intro h1 { font: 700 clamp(28px, 5vw, 64px)/1 var(--display); letter-spacing: -0.03em; margin: 0; }
#intro p { font-size: clamp(15px, 1.7vw, 20px); line-height: 1.45; margin: 14px 0 0; max-width: 34ch; color: rgba(255,255,255,.82); }
.scroll-hint { position: absolute; bottom: max(26px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 13px; letter-spacing: .02em; color: rgba(255,255,255,.85); text-align: center; white-space: nowrap; }
.scroll-hint i { display: block; width: 1px; height: 38px; background: linear-gradient(#fff, rgba(255,255,255,0)); animation: drip 1.8s ease-in-out infinite; transform-origin: top; }
@keyframes drip { 0% { transform: scaleY(0); opacity: 1 } 60% { transform: scaleY(1); opacity: 1 } 100% { transform: scaleY(1); opacity: 0 } }

/* Narration: regular-weight text fading in across the sky; the fall line is DOM text too */
#narr { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
#narr p { margin: 0; opacity: 0; will-change: opacity, transform; color: #fff; text-shadow: 0 2px 26px rgba(12,2,34,.6), 0 0 2px rgba(12,2,34,.25); }
#narr p.sky { position: absolute; left: 0; right: 0; margin: 0 auto; top: clamp(64px, 11vh, 120px); width: min(88vw, 860px); text-align: center; font: 700 clamp(18px, 2.2vw, 30px)/1.28 var(--display); letter-spacing: -0.012em; }
#narr p.sky.big { font-size: clamp(26px, 3.6vw, 48px); line-height: 1.12; }
#narr a { color: #fff; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; pointer-events: none; }
#narr p.doom { position: fixed; left: 50%; bottom: clamp(70px, 14vh, 140px); transform: translateX(-50%); width: min(88vw, 30ch); text-align: center; font: 700 clamp(22px, 3.4vw, 40px)/1.12 var(--display); letter-spacing: -0.02em; }
@media (max-width: 640px) { #narr p.doom { bottom: auto; top: 26vh; } #narr p.sky { top: clamp(64px, 10vh, 100px); } }

#hint { position: fixed; z-index: 12; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0; font-size: 14px; color: rgba(255,255,255,.88); background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); padding: 9px 16px; border-radius: 999px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); opacity: 0; pointer-events: none; transition: opacity .5s; white-space: nowrap; }

/* keyboard access to the orbiting cards: hidden until focused */
#access { position: fixed; z-index: 14; left: 50%; bottom: 70px; transform: translateX(-50%); display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: min(92vw, 640px); opacity: 0; pointer-events: none; }
#access:focus-within { opacity: 1; pointer-events: auto; }
#access button { font: 500 13px var(--body); color: #fff; background: rgba(20,20,30,.85); border: 1px solid rgba(255,255,255,.3); border-radius: 999px; padding: 8px 14px; cursor: pointer; }

/* Finale: "Why this?" pops after the crash */
#finale { position: fixed; inset: 0; top: 0; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; place-items: center; padding: 20px; pointer-events: none; visibility: hidden; }
#finale.show { visibility: visible; }
.fin-card { width: min(100%, 580px); max-height: 88dvh; overflow-y: auto; border-radius: 30px; padding: clamp(24px, 4vw, 40px); background: linear-gradient(155deg, #3a3a42, #2a2a2f 55%, #1b1b20); box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.1) inset; transform: scale(.3) rotate(-9deg); opacity: 0; pointer-events: none; }
#finale.show .fin-card { animation: pop .75s cubic-bezier(.2,1.1,.3,1) .1s forwards; pointer-events: auto; }
@keyframes pop { 0% { transform: scale(.3) rotate(-9deg); opacity: 0 } 55% { transform: scale(1.06) rotate(1.2deg); opacity: 1 } 100% { transform: none; opacity: 1 } }
.fin-num { font: 500 15px var(--display); opacity: .7; }
.fin-card h2 { font: 700 clamp(30px, 6vw, 46px)/1.04 var(--display); letter-spacing: -0.025em; margin: 10px 0 20px; }

/* Detail card: compact, sized to its content */
#detail { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,0); visibility: hidden; transition: background .35s, visibility 0s .45s; }
#detail.open { visibility: visible; background: rgba(0,0,0,.6); transition: background .35s; }
.detail-sheet { position: relative; width: min(100%, 540px); max-height: min(80vh, 640px); max-height: min(80dvh, 640px); border-radius: 28px; background: var(--c); background: linear-gradient(160deg, color-mix(in srgb, var(--c) 100%, #fff 10%), var(--c) 55%, color-mix(in srgb, var(--c) 100%, #000 22%)); transform: translateY(22px) scale(.94); opacity: 0; transition: transform .42s cubic-bezier(.2,.9,.25,1), opacity .3s; box-shadow: 0 26px 70px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.08) inset; overflow: hidden; display: flex; }
#detail.open .detail-sheet { transform: none; opacity: 1; }
.detail-close { position: absolute; top: 14px; right: 14px; z-index: 2; width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; background: rgba(0,0,0,.28); display: grid; place-items: center; }
.detail-close svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; }
.detail-scroll { width: 100%; max-height: inherit; overflow-y: auto; overscroll-behavior: contain; padding: 26px 26px 28px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.35) transparent; }
.detail-num { font: 500 15px var(--display); opacity: .7; color: var(--t); }
#detail-title { font: 700 clamp(24px, 5.2vw, 32px)/1.08 var(--display); letter-spacing: -0.025em; margin: 6px 44px 16px 0; color: var(--t); }
.detail-body { font-size: 15.5px; line-height: 1.6; color: #fff; }
.detail-body p { margin: 0 0 12px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; object-position: 50% 15%; border: 2px solid rgba(255,255,255,.25); margin-bottom: 18px; display: block; }
.tech { display: flex; flex-wrap: wrap; gap: 12px 14px; margin-top: 16px; align-items: center; }
.ti { width: 28px; height: 28px; background: #fff; -webkit-mask: var(--icon) no-repeat center / contain; mask: var(--icon) no-repeat center / contain; opacity: .92; }
.ti.wide { width: 66px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 10px; }
.pill { display: inline-flex; align-items: center; gap: 10px; font: 500 16px var(--body); color: #14141a; background: #fff; border: 0; border-radius: 999px; padding: 13px 20px; cursor: pointer; text-decoration: none; transition: transform .2s, box-shadow .2s; }
.pill:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.35); }
.pill svg { width: 20px; height: 20px; stroke: #14141a; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pill img { width: 20px; height: 20px; }
.mail-line { font-size: 14px; opacity: .75; margin: 0 0 6px; user-select: all; }
.credit { font-size: 14px; opacity: .75; margin: 14px 0 0; }
.credit a { color: #fff; text-underline-offset: 3px; }
.contact { display: flex; gap: 14px; margin-top: 14px; }
.contact a { width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; transition: background .2s, transform .2s; }
.contact a:hover { background: rgba(255,255,255,.22); transform: translateY(-2px); }
.contact img { width: 24px; height: 24px; }

/* No-WebGL / reduced-motion fallback */
#fallback { min-height: 100dvh; padding: 64px 22px 48px; max-width: 640px; margin: 0 auto; }
#fallback h1 { font: 700 clamp(30px, 7vw, 44px)/1 var(--display); letter-spacing: -0.03em; margin: 0; }
#fallback > p { color: rgba(255,255,255,.75); margin: 12px 0 28px; max-width: 34ch; line-height: 1.5; }
.fb-list { display: grid; gap: 12px; }
.fb-card { text-align: left; border: 0; border-radius: 22px; padding: 22px; color: var(--t); background: var(--c); background: linear-gradient(150deg, color-mix(in srgb, var(--c) 100%, #fff 10%), var(--c)); cursor: pointer; display: grid; gap: 14px; font-family: var(--display); }
.fb-card span { font-weight: 500; font-size: 14px; opacity: .72; }
.fb-card strong { font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }

#loader { position: fixed; inset: 0; z-index: 100; background: var(--fade-bg); display: grid; place-items: center; font: 500 14px var(--body); color: rgba(255,255,255,.6); letter-spacing: .04em; transition: opacity .6s .1s, visibility 0s .7s; }
#loader.done { opacity: 0; visibility: hidden; }


/* ---------- Light mode (the original look above is dark mode) ---------- */
html[data-theme="light"] { color-scheme: light; --bg: #dbe8f8; --veil: #eaf2fe; --fade-bg: #eaf2ff; }
html[data-theme="light"] #replay, html[data-theme="light"] #theme { background: rgba(10,28,72,.36); border-color: rgba(255,255,255,.38); }
html[data-theme="light"] #replay:hover, html[data-theme="light"] #theme:hover { background: rgba(10,28,72,.5); }
html[data-theme="light"] body.veil .brand { color: #10224d; }
html[data-theme="light"] body.veil #replay, html[data-theme="light"] body.veil #theme { color: #10224d; background: rgba(255,255,255,.7); border-color: rgba(16,34,77,.2); }
html[data-theme="light"] #intro { text-shadow: 0 2px 22px rgba(8,26,80,.55); }
html[data-theme="light"] #narr p { text-shadow: none; }
html[data-theme="light"] #hint { background: rgba(10,28,72,.5); border-color: rgba(255,255,255,.3); }
html[data-theme="light"] .scroll-hint { text-shadow: 0 1px 10px rgba(8,26,80,.7); }
html[data-theme="light"] .fin-card { background: linear-gradient(155deg, #ffffff, #f2f6fd 58%, #e5ecf8); color: #12172b; box-shadow: 0 30px 80px rgba(20,40,90,.3), 0 0 0 1px rgba(16,34,77,.1) inset; }
html[data-theme="light"] .fin-card .detail-body, html[data-theme="light"] .fin-card .fin-num { color: #1c2340; }
html[data-theme="light"] .fin-card .pill { background: #12172b; color: #fff; }
html[data-theme="light"] .fin-card .pill svg { stroke: #fff; }
html[data-theme="light"] .fin-card .credit a { color: #12172b; }
html[data-theme="light"] .fin-card .contact a { background: rgba(18,23,43,.08); }
html[data-theme="light"] .fin-card .contact a:hover { background: rgba(18,23,43,.16); }
html[data-theme="light"] #fallback h1 { color: #12172b; }
html[data-theme="light"] #fallback > p { color: #3b4668; }
html[data-theme="light"] #fallback .avatar { border-color: rgba(18,23,43,.2); }
html[data-theme="light"] #loader { color: rgba(18,23,43,.6); }

@media (max-width: 560px) {
  #detail { padding: 12px; }
  .detail-sheet { max-height: 84vh; max-height: 84dvh; border-radius: 24px; }
  .detail-scroll { padding: 22px 20px 24px; }
  .fin-card { border-radius: 26px; }
  .pill { font-size: 15px; padding: 12px 16px; }
  #hint { font-size: 13px; padding: 8px 14px; }
  #narr p.doom { width: min(90vw, 26ch); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .detail-sheet { max-height: 92vh; max-height: 92dvh; }
  .fin-card { max-height: 92dvh; }
  #intro h1 { font-size: clamp(24px, 4.2vw, 40px); }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-hint i { animation: none; }
  .detail-sheet { transition-duration: .01s; }
  #finale.show .fin-card { animation-duration: .01s; }
}
