:root {
  --night: #0a0d12;
  --night-2: #111720;
  --snow: #eeede7;
  --snow-dim: #a9aca8;
  --lantern: #e9b24c;
  --ocean: #2b5468;
  --line: rgba(238, 237, 231, .14);
  --serif: "Instrument Serif", "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --arabic: "Amiri", "Noto Naskh Arabic", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--night); color: var(--snow); scroll-behavior: smooth; }
body { font-family: var(--serif); font-size: clamp(19px, 1.25vw + 12px, 23px); line-height: 1.45; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: inherit; text-decoration-color: var(--lantern); text-underline-offset: .2em; }
a:hover { color: var(--lantern); }
img { display: block; max-width: 100%; }
.mono { font-family: var(--mono); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--snow-dim); }
.ar { font-family: var(--arabic); direction: rtl; }
::selection { background: var(--lantern); color: var(--night); }
:focus-visible { outline: 1px dashed var(--lantern); outline-offset: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
.bar { position: fixed; inset: 0 0 auto 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: 18px clamp(16px, 3vw, 40px); mix-blend-mode: difference; pointer-events: none; }
.bar a, .bar span { pointer-events: auto; text-decoration: none; color: #eeede7; }
.bar nav { display: flex; gap: clamp(10px, 2vw, 28px); }
#tcount { min-width: 9ch; }

/* ---------- hero ---------- */
.hero { position: relative; height: 100svh; min-height: 560px; overflow: hidden; background: var(--night); }
.hero img, .hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero canvas { display: none; }
.hero.gl canvas { display: block; }
.hero.gl img { visibility: hidden; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,13,18,.55) 0%, rgba(10,13,18,0) 30%, rgba(10,13,18,0) 55%, rgba(10,13,18,.85) 100%); pointer-events: none; }
.basmala { position: absolute; top: 64px; left: 0; right: 0; text-align: center; z-index: 2; color: var(--lantern); font-size: 1.05rem; opacity: .9; }
.hero-text { position: absolute; left: clamp(16px, 5vw, 72px); right: clamp(16px, 5vw, 72px); bottom: clamp(28px, 7vh, 80px); z-index: 2; transition: filter .2s linear; }
.hero h1 { font-weight: 400; font-size: clamp(3.4rem, 11vw, 10.5rem); line-height: .88; letter-spacing: -.02em; }
.hero h1 em { color: var(--lantern); }
.hero .lede { max-width: 34ch; margin-top: 1.1rem; font-size: clamp(1.05rem, 1.6vw, 1.45rem); }
.hero .hint { margin-top: 1.4rem; }
.hero .hint b { color: var(--lantern); font-weight: 400; }

/* ---------- sections ---------- */
section { position: relative; padding: clamp(80px, 14vh, 160px) clamp(16px, 5vw, 72px); }
.kicker { display: flex; gap: 1rem; align-items: baseline; border-top: 1px solid var(--line); padding-top: .9rem; margin-bottom: clamp(36px, 7vh, 72px); }
.kicker h2 { font-weight: 400; font-size: clamp(2.2rem, 5vw, 4.2rem); line-height: 1; }
.kicker h2 em { color: var(--lantern); }
.kicker .mono { margin-left: auto; text-align: right; max-width: 34ch; }

/* ---------- readings (surface / latent) ---------- */
.readings { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0; border-left: 1px solid var(--line); }
.reading { position: relative; display: grid; padding: 28px clamp(18px, 2.5vw, 34px) 34px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-height: 15.5rem; cursor: none; outline: none; }
.reading > * { grid-area: 1 / 1; }
.reading .surface, .reading .latent { align-self: start; }
.reading .surface p { font-size: clamp(1.5rem, 2.4vw, 2.1rem); line-height: 1.1; }
.reading .latent p { font-size: 1.02rem; line-height: 1.45; color: var(--snow); }
.reading .latent p em { color: var(--lantern); font-style: italic; }
.reading .tag { display: block; margin-bottom: .8rem; }
.reading .latent .tag { color: var(--lantern); }
.reading { --r: 0px; }
.reading .latent { -webkit-mask-image: radial-gradient(circle at var(--x, -999px) var(--y, -999px), #000 calc(var(--r) - 40px), transparent var(--r)); mask-image: radial-gradient(circle at var(--x, -999px) var(--y, -999px), #000 calc(var(--r) - 40px), transparent var(--r)); }
.reading .surface { -webkit-mask-image: radial-gradient(circle at var(--x, -999px) var(--y, -999px), transparent calc(var(--r) - 40px), #000 var(--r)); mask-image: radial-gradient(circle at var(--x, -999px) var(--y, -999px), transparent calc(var(--r) - 40px), #000 var(--r)); }
.reading.lit { --r: 230px; }
.reading.open .latent, .reading.open .surface { -webkit-mask-image: none; mask-image: none; }
.reading.open .surface { opacity: 0; }
.reading.open .latent { opacity: 1; }
.reading .more { position: absolute; right: 14px; bottom: 10px; }
.readings-note { margin-top: 1.2rem; }

/* lantern cursor */
.lantern { position: fixed; left: 0; top: 0; width: 340px; height: 340px; margin: -170px 0 0 -170px; border-radius: 50%; pointer-events: none; z-index: 15; background: radial-gradient(circle, rgba(233,178,76,.16) 0%, rgba(233,178,76,.05) 40%, transparent 70%); opacity: 0; transition: opacity .3s; }
.lantern.on { opacity: 1; }
.lantern::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--lantern); box-shadow: 0 0 14px 4px rgba(233,178,76,.6); }

/* ---------- dissection (exploded-view drawings) ---------- */
.specimens { display: grid; gap: clamp(60px, 10vh, 110px); }
.specimen { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 clamp(24px, 5vw, 80px); align-items: center; position: relative; }
.spec-id { grid-column: 1 / -1; margin-bottom: 1rem; }
.spec-q { font-size: clamp(2rem, 4.4vw, 3.8rem); line-height: 1.02; filter: blur(var(--blur, 0px)); opacity: var(--op, 1); transition: filter 1.1s ease, opacity 1.1s ease; }
.js .specimen:not(.in) { --blur: 10px; --op: .25; }
.js .specimen:not(.in) .parts li { opacity: 0; transform: translateX(-12px); }
.js .specimen:not(.in) .parts li::before { transform: scaleX(0); }
.js .specimen:not(.in) .parts li::after { opacity: 0; }
.parts { list-style: none; position: relative; border-left: 1px solid var(--line); }
.parts li { position: relative; padding: 14px 0 14px 34px; font-size: 1.08rem; line-height: 1.3; transition: opacity .6s ease, transform .6s ease; }
.parts li::before { content: ""; position: absolute; left: 0; top: 50%; width: 24px; height: 1px; background: var(--lantern); transform-origin: left; transition: transform .5s ease; }
.parts li::after { content: ""; position: absolute; left: -3px; top: calc(50% - 3px); width: 5px; height: 5px; border-radius: 50%; background: var(--lantern); transition: opacity .3s; }
.parts li .mono { display: block; color: var(--lantern); margin-bottom: 2px; }
.specimen.in .parts li:nth-child(1), .specimen.in .parts li:nth-child(1)::before { transition-delay: .5s; }
.specimen.in .parts li:nth-child(2), .specimen.in .parts li:nth-child(2)::before { transition-delay: .8s; }
.specimen.in .parts li:nth-child(3), .specimen.in .parts li:nth-child(3)::before { transition-delay: 1.1s; }
.specimen.in .parts li:nth-child(4), .specimen.in .parts li:nth-child(4)::before { transition-delay: 1.4s; }
.specimen.in .parts li:last-child { color: var(--snow); }

/* ---------- trajectory ---------- */
.trajectory { padding-left: 0; padding-right: 0; }
.trajectory .kicker { margin-left: clamp(16px, 5vw, 72px); margin-right: clamp(16px, 5vw, 72px); }
.place { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr); gap: clamp(20px, 4vw, 64px); align-items: center; padding: 6vh clamp(16px, 5vw, 72px); min-height: 92vh; }
.place:nth-of-type(even) { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.place:nth-of-type(even) .frame { order: -1; }
.place .frame { position: relative; overflow: hidden; background: var(--night-2); aspect-ratio: 4 / 3; }
.place .frame.tall { aspect-ratio: 3 / 4; max-height: 82vh; width: auto; justify-self: center; }
.place .frame img { width: 100%; height: 100%; object-fit: cover; transform: scale(calc(1.02 + var(--n, 1) * .06)); transition: transform .6s ease-out; }
.place .frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }
.place .coord { display: block; margin-bottom: .9rem; }
.place h3 { font-weight: 400; font-size: clamp(2.4rem, 5.5vw, 5rem); line-height: .95; }
.place h3 small { display: block; font-size: .32em; color: var(--snow-dim); margin-top: .4rem; letter-spacing: .01em; }
.place p { margin-top: 1rem; max-width: 30ch; }
.place .frame .stamp { position: absolute; left: 12px; bottom: 10px; color: #fff; mix-blend-mode: difference; }
.place.memory .frame { aspect-ratio: 4 / 3; }

/* ---------- latent space ---------- */
.space { padding-bottom: 60px; }
.space-wrap { position: relative; height: min(82vh, 780px); border: 1px solid var(--line); background: radial-gradient(ellipse at 50% 40%, #121a24 0%, var(--night) 70%); }
#map { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: pan-y; }
.space-tip { position: absolute; pointer-events: none; padding: 10px 12px; background: rgba(10,13,18,.92); border: 1px solid var(--line); max-width: 260px; font-size: .95rem; line-height: 1.3; opacity: 0; transition: opacity .15s; }
.space-tip .mono { display: block; margin-bottom: 4px; }
.space-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; }
.space-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---------- instrument readings strip ---------- */
.gauges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.gauge { padding: 22px 22px 26px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.gauge .v { font-size: clamp(2rem, 3.6vw, 3rem); line-height: 1; margin: .5rem 0 .4rem; }
.gauge .v sup { font-size: .4em; color: var(--lantern); font-family: var(--mono); vertical-align: super; margin-left: .2em; }
.gauge p { font-size: .95rem; color: var(--snow-dim); }

/* ---------- work ---------- */
.work-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: clamp(28px, 5vw, 80px); }
.now-card { border: 1px solid var(--line); padding: clamp(22px, 3vw, 36px); position: sticky; top: 90px; align-self: start; }
.now-card h3 { font-weight: 400; font-size: clamp(1.9rem, 3vw, 2.6rem); line-height: 1; margin: .6rem 0 1rem; }
.now-card p + p { margin-top: .8rem; }
.now-card .links { margin-top: 1.2rem; display: flex; gap: 18px; flex-wrap: wrap; }
.pubs { list-style: none; }
.pubs li { display: grid; grid-template-columns: 4.5ch 1fr auto; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.pubs .yr { font-family: var(--mono); font-size: .66rem; color: var(--snow-dim); }
.pubs .ti { font-size: 1.08rem; line-height: 1.25; }
.pubs .ti small { display: block; font-family: var(--mono); font-size: .6rem; letter-spacing: .06em; color: var(--snow-dim); margin-top: 4px; text-transform: uppercase; }
.pubs .ci { font-family: var(--mono); font-size: .7rem; color: var(--lantern); white-space: nowrap; }
.sub { margin: 48px 0 10px; }
.repos { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 0; border-top: 1px solid var(--line); }
.repos li { padding: 16px 16px 18px 0; border-bottom: 1px solid var(--line); }
.repos a { font-size: 1.15rem; }
.repos p { font-size: .92rem; color: var(--snow-dim); margin-top: 4px; }

/* ---------- closing ---------- */
.closing { text-align: center; padding-top: clamp(120px, 20vh, 220px); }
.verse { font-size: clamp(2.2rem, 6vw, 4.6rem); color: var(--lantern); line-height: 1.6; }
.verse-tr { max-width: 30ch; margin: 1rem auto 0; font-style: italic; }
.verse-ref { margin-top: .6rem; }
.spine { list-style: none; max-width: 760px; margin: clamp(70px, 12vh, 120px) auto 0; text-align: left; counter-reset: s; }
.spine li { counter-increment: s; display: grid; grid-template-columns: 3ch 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 1.15rem; }
.spine li::before { content: counter(s, decimal-leading-zero); font-family: var(--mono); font-size: .62rem; color: var(--lantern); padding-top: .45em; }
.contact { margin-top: clamp(70px, 12vh, 120px); }
.contact h2 { font-weight: 400; font-size: clamp(2.4rem, 6vw, 5rem); line-height: 1; }
.contact .links { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px 30px; margin-top: 1.4rem; }
footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 28px clamp(16px, 5vw, 72px); border-top: 1px solid var(--line); }
.door { background: none; border: 0; color: var(--snow-dim); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font: inherit; }
.door svg { width: 16px; height: 22px; }
.door:hover { color: var(--lantern); }
.door-note { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); max-width: min(92vw, 460px); padding: 18px 20px; background: var(--snow); color: var(--night); z-index: 30; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; font-size: 1.02rem; }
.door-note.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.door-note .chalk { font-family: "Comic Sans MS", "Chalkboard SE", cursive; font-size: 1.5rem; display: block; margin-bottom: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .bar nav a:not(.keep) { display: none; }
  .place, .place:nth-of-type(even) { grid-template-columns: 1fr; min-height: auto; padding-top: 5vh; padding-bottom: 5vh; }
  .place:nth-of-type(even) .frame { order: 0; }
  .place .frame.tall { max-height: 70vh; }
  .work-grid { grid-template-columns: 1fr; }
  .gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .specimen { grid-template-columns: 1fr; }
  .spec-q { margin-bottom: 1.2rem; }
  .now-card { position: static; }
  .kicker { flex-wrap: wrap; }
  .kicker .mono { margin-left: 0; text-align: left; }
  .reading { cursor: pointer; }
}
@media (hover: none) { .lantern { display: none; } .reading { cursor: pointer; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .place .frame img { transform: none; transition: none; }
  .hero-text { transition: none; }
  .spec-q, .parts li, .parts li::before { transition: none !important; }
  .js .specimen:not(.in) { --blur: 0px; --op: 1; }
}
