/* ------------------------------------------------------------------ *
 *  Abyssal Ledger — design system.                                    *
 *  Three voices: Syne (display), Instrument Sans (prose),             *
 *  JetBrains Mono (machine metadata). Strict roles, no exceptions.    *
 * ------------------------------------------------------------------ */

@font-face {
  font-family: 'Syne';
  src: url('fonts/Syne.woff2') format('woff2');
  font-weight: 700 800;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans';
  src: url('fonts/InstrumentSans.woff2') format('woff2');
  font-weight: 400 500;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/JetBrainsMono.woff2') format('woff2');
  font-weight: 400 500;
  font-display: swap;
}

:root {
  --abyss: #04100f;
  --depth: #0a1d20;
  --line: #1e4a50;
  --glass: #8fb0b2;
  --foam: #e6f2ee;
  --biolum: #57f2c5;

  --sans: 'Instrument Sans', 'Helvetica Neue', Arial, sans-serif;
  --disp: 'Syne', var(--sans);
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --frame: 1100px;
  --gap-section: clamp(14rem, 36vh, 24rem);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--abyss);
  color: var(--foam);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--biolum); color: var(--abyss); }

:focus-visible {
  outline: 1px solid var(--biolum);
  outline-offset: 3px;
  border-radius: 2px;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--glass); }

.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

/* ---------- the ocean ---------- */

#field {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 2.5s ease;
}
#field.on { opacity: 1; }

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 90% at 50% 42%, transparent 55%, rgba(1, 6, 6, 0.55) 100%);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: var(--abyss);
  opacity: 0;
  pointer-events: none;
}

main, .nav, footer { position: relative; z-index: 2; }

/* ---------- hairlines: light falling off underwater ---------- */

.rule {
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 82%, transparent);
}

/* ---------- nav ---------- */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.4rem clamp(1.2rem, 4vw, 3rem);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: lowercase;
}
.nav::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line) 25%, var(--line) 75%, transparent);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.nav.scrolled::after { opacity: 1; }
.nav.scrolled { background: color-mix(in srgb, var(--abyss) 88%, transparent); }
.nav a, .nav .brand { padding: 0.6rem 0.4rem; margin: -0.6rem -0.4rem; }
.nav .brand { color: var(--foam); text-decoration: none; }
.nav .brand em { color: var(--biolum); font-style: normal; }
.nav ul { display: flex; gap: 1.8rem; list-style: none; }
.nav a { color: var(--glass); text-decoration: none; transition: color 0.3s ease; }
.nav a:hover { color: var(--foam); }

/* ---------- links (prose + footer) ---------- */

.link {
  color: var(--foam);
  text-decoration: none;
  background-image: linear-gradient(var(--biolum), var(--biolum));
  background-repeat: no-repeat;
  background-size: 0% 1px;
  background-position: left calc(100% + 2px);
  transition: background-size 0.3s ease, color 0.3s ease;
}
.link:hover { color: #fff; background-size: 100% 1px; }

/* ---------- hero ---------- */

/* the hero globe is grabbable: horizontal drags spin it, vertical still scrolls */
.hero { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
html.globe-grab .hero { cursor: grab; }
html.globe-grabbing .hero, html.globe-grabbing .hero * { cursor: grabbing !important; }

.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 0 1.5rem;
  /* text floats directly in the water */
  text-shadow: 0 0 24px var(--abyss), 0 0 8px var(--abyss);
}
.hero .eyebrow {
  color: var(--glass);
  text-transform: lowercase;
  margin-bottom: 1.6rem;
}
.hero .eyebrow .tick { color: var(--biolum); font-variant-numeric: tabular-nums; }
.hero h1 {
  font-family: var(--disp);
  font-weight: 800;
  font-size: clamp(3.4rem, 11vw, 7.5rem);
  letter-spacing: -0.02em;
  line-height: 1;
  text-transform: lowercase;
}
.hero h1 .dot { color: var(--biolum); }
.hero .tagline {
  max-width: 34rem;
  margin-top: 1.8rem;
  color: var(--foam);
  font-size: 1.1rem;
}
.hero .dive {
  margin-top: 3.2rem;
  color: var(--glass);
  text-decoration: none;
  transition: color 0.3s ease;
}
.hero .dive:hover { color: var(--biolum); }

/* load choreography: surface from depth, line by line */
.hero-line { opacity: 0; }
body.loaded .hero-line { animation: surface 1.1s cubic-bezier(0.2, 0.6, 0.2, 1) both; }
body.loaded .hero-line:nth-child(1) { animation-delay: 0.9s; }
body.loaded .hero-line:nth-child(2) { animation-delay: 1.15s; }
body.loaded .hero-line:nth-child(3) { animation-delay: 1.45s; }
body.loaded .hero-line:nth-child(4) { animation-delay: 1.8s; }
@keyframes surface {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- sections ---------- */

section { padding: 0 clamp(1.2rem, 4vw, 3rem); }
.section {
  max-width: var(--frame);
  margin: var(--gap-section) auto 0;
}
.section:last-of-type { margin-bottom: var(--gap-section); }

.section-head { margin-bottom: 3.5rem; }
.section-head .eyebrow {
  color: var(--glass);
  text-transform: lowercase;
  display: block;
  margin-bottom: 0.8rem;
}
.section-head h2 {
  font-family: var(--disp);
  font-weight: 700;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.01em;
  text-transform: lowercase;
}

.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.9s ease, transform 0.9s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- about ---------- */

.about-grid {
  display: grid;
  grid-template-columns: 38% 1fr;
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}
.meta-table { font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.06em; }
.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  background: linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 82%, transparent) bottom / 100% 1px no-repeat;
}
.meta-row dt { color: var(--glass); text-transform: lowercase; }
.meta-row dd { color: var(--foam); text-align: right; }

.about-prose { max-width: 68ch; }
.about-prose p { margin-bottom: 1.4rem; color: var(--foam); }
.about-prose p:last-of-type { margin-bottom: 0; }

.toml {
  margin-top: 2.4rem;
  padding: 1.2rem 1.4rem;
  background: var(--depth);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.8;
  color: var(--glass);
  overflow-x: auto;
}
.toml .k { color: var(--foam); }
.toml .v { color: var(--biolum); }
.toml .h { color: var(--glass); }

/* ---------- writing ---------- */

#post-list { list-style: none; }
.post {
  background: linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 82%, transparent) bottom / 100% 1px no-repeat;
}
.post:first-child {
  background:
    linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 82%, transparent) top / 100% 1px no-repeat,
    linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 82%, transparent) bottom / 100% 1px no-repeat;
}
.post-row {
  display: grid;
  grid-template-columns: minmax(15rem, 24rem) 1fr auto;
  gap: 1.5rem;
  align-items: baseline;
  width: 100%;
  padding: 1.6rem 0.4rem;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: background-color 0.4s ease;
}
.post-row:hover { background-color: color-mix(in srgb, var(--depth) 55%, transparent); }
.post-meta { color: var(--glass); font-variant-numeric: tabular-nums; }
.post-title {
  font-weight: 500;
  font-size: 1.12rem;
  transition: color 0.3s ease;
}
.post-row:hover .post-title { color: #fff; }
.post-side { color: var(--glass); white-space: nowrap; }
.post-side .hash { color: var(--line); transition: color 0.3s ease; }
.post-row:hover .hash { color: var(--biolum); }
.post-row[aria-expanded='true'] .post-title { color: var(--biolum); }

.post-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.45s ease; }
.post-body[hidden] { display: none; }   /* keep closed posts out of the a11y tree */
.post.open .post-body { grid-template-rows: 1fr; }
.post-inner { overflow: hidden; min-height: 0; }
.post-inner .prose {
  max-width: 68ch;
  margin: 0.4rem 0 2.2rem;
  padding: 1.8rem 2rem;
  background: var(--depth);
  border-radius: 6px;
}
.prose p { margin-bottom: 1.2rem; }
.prose p:last-child { margin-bottom: 0; }
.prose em { color: var(--glass); }
.prose code {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--biolum);
  background: color-mix(in srgb, var(--abyss) 65%, transparent);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.prose pre {
  margin: 1.2rem 0;
  padding: 1rem 1.2rem;
  background: var(--abyss);
  border-radius: 6px;
  overflow-x: auto;
}
.prose pre code { background: none; padding: 0; color: var(--glass); }

/* ---------- proof of acquaintance ---------- */

.quiz-panel {
  max-width: 44rem;
  padding: 2.2rem clamp(1.4rem, 4vw, 2.6rem) 1.8rem;
  background: var(--depth);
  border-radius: 8px;
}
.q-progress { color: var(--glass); text-transform: lowercase; margin-bottom: 1.1rem; }
.q-text {
  font-family: var(--disp);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0;
  margin-bottom: 1.6rem;
}
.q-opts { display: grid; gap: 0.6rem; }
.q-opt {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.85rem 1.1rem;
  background: color-mix(in srgb, var(--abyss) 55%, transparent);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--foam);
  font: inherit;
  font-size: 0.98rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.3s ease, color 0.3s ease, opacity 0.4s ease, box-shadow 0.4s ease;
}
.q-opt:hover { border-color: var(--line); }
.q-key { color: var(--glass); }
.q-opt.rejected { opacity: 0.32; cursor: default; }
.q-opt.confirmed {
  border-color: var(--biolum);
  color: var(--biolum);
  box-shadow: 0 0 22px color-mix(in srgb, var(--biolum) 22%, transparent);
}
.q-opt.confirmed .q-key { color: var(--biolum); }
.q-log { margin-top: 1.3rem; color: var(--glass); min-height: 1.2em; }
.q-meta { margin-top: 1.2rem; color: var(--glass); }
/* once finalized, the stamp is on screen — keep the announcement SR-only */
.quiz-panel.done .q-log {
  position: absolute; width: 1px; height: 1px; margin: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.quiz-panel.done .q-text { font-family: var(--mono); font-weight: 400; font-size: 1.05rem; letter-spacing: 0.04em; }
.stamp { color: var(--biolum); }
.finalized { color: var(--biolum); letter-spacing: 0.18em; text-transform: uppercase; font-size: 0.85em; }
.q-note { margin: 1.2rem 0 0.4rem; color: var(--foam); }
.q-replay {
  background: none; border: 0; cursor: pointer;
  color: var(--glass); font: inherit; margin-left: 0.6rem;
  padding: 0.6rem; margin-top: -0.6rem; margin-bottom: -0.6rem;
  transition: color 0.3s ease;
}
.q-text[tabindex='-1']:focus { outline: none; }
.q-replay:hover { color: var(--biolum); }

/* ---------- footer ---------- */

footer { padding: 0 clamp(1.2rem, 4vw, 3rem) 3rem; }
.footer-inner {
  max-width: var(--frame);
  margin: 0 auto;
  padding-top: 2.2rem;
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  color: var(--glass);
}
.footer-inner .mono a { color: var(--glass); }
.footer-inner .mono a:hover { color: var(--biolum); }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .about-grid { grid-template-columns: 1fr; }
  .meta-table { display: flex; gap: 0; overflow-x: auto; padding-bottom: 0.6rem; }
  .meta-row {
    flex-direction: column;
    gap: 0.2rem;
    padding: 0 1.4rem 0 0;
    background: none;
    border-right: 1px solid var(--line);
    margin-right: 1.4rem;
    white-space: nowrap;
  }
  .meta-row:last-child { border-right: 0; }
  .meta-row dd { text-align: left; }
  .post-row { grid-template-columns: 1fr auto; grid-template-areas: 'title side' 'meta meta'; gap: 0.5rem 1rem; }
  .post-meta { grid-area: meta; }
  .post-title { grid-area: title; }
  .post-side { grid-area: side; }
}

@media (max-width: 600px) {
  :root { --gap-section: clamp(9rem, 26vh, 14rem); }
  .nav ul { gap: 1.1rem; }
  .hero .tagline { font-size: 1rem; }
}

/* ---------- ?insta=1: skip choreography (screenshot/og-image hook) ---------- */

html.insta { scroll-behavior: auto; }
.insta *, .insta *::before, .insta *::after {
  animation-duration: 0.001s !important;
  animation-delay: 0s !important;
  transition-duration: 0.001s !important;
}
.insta #field { opacity: 1; }
.insta .hero-line, .insta .reveal { opacity: 1; transform: none; }

/* ---------- reduced motion: the ocean holds still ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #field { opacity: 1; }
  .hero-line, .reveal { opacity: 1 !important; transform: none !important; }
}
