/* ============================================================
   THE MOAT — The Doom Squad
   Design system: Occult Codex Brutalism
   Obsidian ground · parchment ink · molten gold · ember
   Cinzel Decorative (display) · IBM Plex Mono (body) · Caveat (margin notes)
   Zero radius. Scan lines. The moat ring.
   ============================================================ */

@import url('/assets/fonts/fonts.css');

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --obsidian: oklch(0.09 0.012 285);
  --obsidian-mid: oklch(0.125 0.016 285);
  --obsidian-light: oklch(0.16 0.018 285);
  --parchment: oklch(0.92 0.02 85);
  --parchment-dim: oklch(0.92 0.02 85 / 0.62);
  --parchment-faint: oklch(0.92 0.02 85 / 0.38);
  --gold: oklch(0.78 0.13 85);
  --gold-bright: oklch(0.86 0.15 90);
  --gold-deep: oklch(0.62 0.12 80);
  --ember: oklch(0.64 0.18 45);
  --hairline: oklch(1 0 0 / 0.09);
  --hairline-soft: oklch(1 0 0 / 0.055);

  --font-display: 'Cinzel Decorative', serif;
  --font-body: 'IBM Plex Mono', monospace;
  --font-note: 'Caveat', cursive;

  --dock-h: 76px;
  --pad: clamp(1.1rem, 4vw, 2.5rem);
  --measure: 68ch;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  background: var(--obsidian);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 0.875rem;
  line-height: 1.65;
}
body.has-dock { padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom)); }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.12; margin: 0; }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration: none; }
img, video { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }

::selection { background: oklch(0.78 0.13 85 / 0.35); color: var(--parchment); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--obsidian); }
::-webkit-scrollbar-thumb { background: oklch(0.3 0.02 285); }
::-webkit-scrollbar-thumb:hover { background: oklch(0.78 0.13 85 / 0.55); }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.container { max-width: 1100px; margin: 0 auto; padding-left: var(--pad); padding-right: var(--pad); }

/* Film grain + scan lines over everything painterly */
.plate { position: relative; overflow: hidden; }
.plate::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom,
    transparent 0 2px, oklch(0 0 0 / 0.055) 2px 4px);
}

/* ── Type utilities ─────────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-body);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
}
.note { font-family: var(--font-note); font-size: 1.05rem; color: var(--parchment-faint); }
.badge {
  display: inline-block;
  padding: 0.22rem 0.65rem;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid oklch(0.78 0.13 85 / 0.45);
  background: oklch(0.78 0.13 85 / 0.07);
}
.badge--ember { color: var(--ember); border-color: oklch(0.64 0.18 45 / 0.5); background: oklch(0.64 0.18 45 / 0.08); }

/* Section heading rail */
.rail { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.8rem; }
.rail::before { content: ''; width: 2rem; height: 1px; background: var(--gold); flex: none; }
.rail::after { content: ''; flex: 1; height: 1px; background: var(--hairline-soft); }
.rail h2 { font-size: 0.8rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.rail .note { flex: none; }
.rail--ember::before { background: var(--ember); }
.rail--ember h2 { color: var(--ember); }

.divider { display: flex; align-items: center; gap: 0.9rem; padding: 0.4rem 0; color: oklch(0.78 0.13 85 / 0.4); font-size: 0.6rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; }
.divider::before { background: linear-gradient(to right, transparent, oklch(0.78 0.13 85 / 0.28)); }
.divider::after { background: linear-gradient(to left, transparent, oklch(0.78 0.13 85 / 0.28)); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 48px;
  padding: 0.8rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border: 1px solid transparent;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.985); }
.btn--gold { background: var(--gold); color: var(--obsidian); }
.btn--gold:hover { background: var(--gold-bright); }
.btn--line { border-color: oklch(1 0 0 / 0.22); color: var(--parchment-dim); }
.btn--line:hover { border-color: var(--gold); color: var(--gold); }
.btn svg { flex: none; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  color: var(--parchment-dim);
  transition: color 140ms ease;
  -webkit-tap-highlight-color: transparent;
}
.iconbtn:hover { color: var(--gold); }

/* ── Site header ────────────────────────────────────────────── */
.site-head {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem var(--pad);
  padding-top: calc(0.6rem + env(safe-area-inset-top));
  background: linear-gradient(to bottom, oklch(0.09 0.012 285 / 0.92), oklch(0.09 0.012 285 / 0));
  pointer-events: none;
}
.site-head > * { pointer-events: auto; }
.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.06em;
  color: var(--parchment);
}
.wordmark span { color: var(--gold); }
.site-head .note { font-size: 0.95rem; }

/* ── Hero ───────────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}
.hero-media { position: absolute; inset: 0; }
.hero-media video, .hero-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 60%;
  filter: brightness(0.62) saturate(1.05);
}
.hero-media::after {
  content: '';
  position: absolute; inset: 0;
  background:
    linear-gradient(to top, var(--obsidian) 4%, oklch(0.09 0.012 285 / 0.55) 38%, oklch(0.09 0.012 285 / 0.15) 70%, oklch(0.09 0.012 285 / 0.4)),
    repeating-linear-gradient(to bottom, transparent 0 3px, oklch(0 0 0 / 0.05) 3px 6px);
}
.hero-body {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--pad) clamp(2rem, 6vh, 4.5rem);
}
.hero-title {
  font-size: clamp(3.4rem, 16vw, 9rem);
  font-weight: 900;
  color: var(--parchment);
  letter-spacing: 0.02em;
  margin: 0.7rem 0 0.4rem;
}
.hero-title em {
  font-style: normal;
  color: var(--gold);
  text-shadow: 0 0 46px oklch(0.78 0.13 85 / 0.45);
}
.hero-sub {
  max-width: 34rem;
  color: var(--parchment-dim);
  font-size: 0.9rem;
  margin-bottom: 1.6rem;
}
.hero-actions { display: flex; flex-direction: column; gap: 0.7rem; }
.hero-actions .btn { width: 100%; }
@media (min-width: 640px) {
  .hero-actions { flex-direction: row; }
  .hero-actions .btn { width: auto; }
}
.hero-meta { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }

/* staged entrance */
.rise { opacity: 0; transform: translateY(18px); animation: rise 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards; }
.rise-2 { animation-delay: 130ms; }
.rise-3 { animation-delay: 260ms; }
.rise-4 { animation-delay: 390ms; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ── The Ledger (tracklist) ─────────────────────────────────── */
.ledger { border-top: 1px solid var(--hairline); }
.ledger-row {
  display: grid;
  grid-template-columns: auto 56px 1fr auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--hairline-soft);
  transition: background 160ms ease;
}
.ledger-row:hover { background: oklch(1 0 0 / 0.025); }
.ledger-no {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--parchment-faint);
  width: 2.2ch;
  text-align: right;
}
.ledger-row.is-current .ledger-no, .ledger-row.is-current .ledger-title { color: var(--gold); }
.ledger-thumb { position: relative; width: 56px; height: 56px; overflow: hidden; background: var(--obsidian-mid); }
.ledger-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ledger-main { min-width: 0; }
.ledger-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.98rem, 2.6vw, 1.2rem);
  color: var(--parchment);
  transition: color 140ms ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.ledger-title:hover { color: var(--gold); }
.ledger-sub { display: flex; gap: 0.7rem; align-items: baseline; margin-top: 0.15rem; }
.ledger-char { font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--parchment-faint); }
.ledger-dur { font-family: var(--font-note); font-size: 1rem; color: var(--parchment-faint); }
.ledger-acts { display: flex; align-items: center; }
.ledger-acts .iconbtn { width: 42px; height: 42px; }
@media (max-width: 520px) {
  .ledger-row { grid-template-columns: auto 48px 1fr; grid-template-areas: 'no thumb main' 'no thumb acts'; row-gap: 0.15rem; }
  .ledger-no { grid-area: no; }
  .ledger-thumb { grid-area: thumb; width: 48px; height: 48px; align-self: start; }
  .ledger-main { grid-area: main; }
  .ledger-acts { grid-area: acts; margin-left: -0.6rem; }
}

/* ── Sections ───────────────────────────────────────────────── */
.section { padding: clamp(3rem, 9vw, 5.5rem) 0 0; }
.section:last-of-type { padding-bottom: clamp(3rem, 9vw, 5.5rem); }

/* Album panel */
.album-panel { display: grid; gap: 2rem; align-items: center; }
@media (min-width: 880px) { .album-panel { grid-template-columns: 1.1fr 1fr; gap: 3rem; } }
.covers { display: flex; gap: 0.9rem; align-items: flex-end; }
.covers .front { flex: 1; box-shadow: 0 24px 70px oklch(0 0 0 / 0.65); border: 1px solid var(--hairline); }
.covers .back { width: 34%; opacity: 0.75; border: 1px solid var(--hairline); transition: opacity 200ms ease; }
.covers .back:hover { opacity: 1; }
.covers figcaption {
  position: absolute; bottom: 0.45rem; left: 0.55rem;
  font-size: 0.58rem; letter-spacing: 0.22em; color: oklch(1 0 0 / 0.4);
}
.covers figure { position: relative; margin: 0; }
.album-panel h2 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); }
.album-panel h2 em { font-style: normal; color: var(--gold); }

/* Squad strip */
.squad { display: grid; gap: 1.6rem; }
@media (min-width: 880px) { .squad { grid-template-columns: 1fr 1.15fr; align-items: center; } }
.squad-img { border: 1px solid var(--hairline); }
.squad-names { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 1rem 0 1.2rem; }
.squad-names a {
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--hairline);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--parchment-dim);
  transition: border-color 140ms ease, color 140ms ease;
}
.squad-names a:hover { border-color: var(--gold); color: var(--gold); }

/* Downloads ledger */
.dl-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 1rem;
  align-items: center;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--hairline-soft);
}
.dl-title { font-family: var(--font-display); font-weight: 700; font-size: 0.98rem; }
.dl-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.42rem 0.85rem;
  border: 1px solid oklch(1 0 0 / 0.16);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--parchment-dim);
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--gold); color: var(--gold); background: oklch(0.78 0.13 85 / 0.05); }
.chip b { font-weight: 600; color: var(--gold-deep); }
.chip:hover b { color: var(--gold); }
@media (max-width: 640px) {
  .dl-row { grid-template-columns: 1fr; }
}

/* ── Track page ─────────────────────────────────────────────── */
.track-hero { padding-top: clamp(4.6rem, 12vh, 7rem); }
.track-hero-grid { display: grid; gap: 1.8rem; }
@media (min-width: 880px) { .track-hero-grid { grid-template-columns: minmax(0, 420px) 1fr; gap: 3rem; align-items: end; } }
.track-cover {
  position: relative;
  border: 1px solid var(--hairline);
  box-shadow: 0 26px 80px oklch(0 0 0 / 0.6);
  aspect-ratio: 1;
  background: var(--obsidian-mid);
}
.track-cover video, .track-cover img { width: 100%; height: 100%; object-fit: cover; }
.track-title { font-size: clamp(2rem, 7.5vw, 3.6rem); font-weight: 900; margin: 0.6rem 0 0.5rem; }
.track-epigraph { font-family: var(--font-note); font-size: 1.25rem; color: var(--gold); margin: 0 0 1.4rem; }
.track-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.9rem; }
.track-actions { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1.5rem; }
@media (min-width: 640px) { .track-actions { flex-direction: row; flex-wrap: wrap; } }

/* character file */
.charfile {
  border: 1px solid var(--hairline);
  background: var(--obsidian-mid);
  padding: 1.3rem 1.4rem 0.6rem;
}
.charfile dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.55rem 1.4rem; margin: 0; }
.charfile dt {
  font-size: 0.62rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--gold-deep);
  padding-top: 0.12rem;
}
.charfile dd { margin: 0 0 0.55rem; font-size: 0.82rem; color: var(--parchment-dim); }

/* story */
.story { max-width: var(--measure); }
.story p { color: var(--parchment-dim); font-size: 0.9rem; margin-bottom: 1.25em; }
.story p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 3.1em;
  line-height: 0.82;
  float: left;
  padding: 0.08em 0.12em 0 0;
  color: var(--gold);
}

/* gallery */
.gallery {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(78vw, 430px);
  gap: 0.9rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 0.6rem;
  -webkit-overflow-scrolling: touch;
}
.gallery figure { margin: 0; scroll-snap-align: start; }
.gallery img, .gallery video { width: 100%; aspect-ratio: 1; object-fit: cover; border: 1px solid var(--hairline); background: var(--obsidian-mid); }
.gallery figure.wide img, .gallery figure.wide video { aspect-ratio: 16 / 9; }
.gallery figcaption { margin-top: 0.5rem; font-family: var(--font-note); font-size: 1rem; color: var(--parchment-faint); }

/* lyrics */
.lyrics { max-width: var(--measure); }
.lyrics-body { font-size: 0.86rem; line-height: 1.9; color: var(--parchment-dim); }
.lyrics-body .stanza { margin: 0 0 1.6em; }
.lyrics-body .mark {
  display: block;
  margin: 2.2em 0 0.9em;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.lyrics-body .mark:first-child { margin-top: 0; }

/* prev / next folio */
.folio { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--hairline); }
.folio a {
  padding: 1.4rem var(--pad);
  display: flex; flex-direction: column; gap: 0.3rem;
  transition: background 160ms ease;
}
.folio a:hover { background: oklch(1 0 0 / 0.03); }
.folio a + a { border-left: 1px solid var(--hairline); text-align: right; align-items: flex-end; }
.folio .eyebrow { color: var(--parchment-faint); }
.folio strong { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; }
.folio a:hover strong { color: var(--gold); }

/* ── Footer ─────────────────────────────────────────────────── */
.site-foot { border-top: 1px solid var(--hairline); padding: 2.4rem 0 2.8rem; }
.credits { display: flex; flex-wrap: wrap; gap: 0.4rem 2rem; margin: 0 0 1.4rem; padding: 0; list-style: none; }
.credits .eyebrow { display: block; color: var(--parchment-faint); margin-bottom: 0.15rem; }
.credits li { font-size: 0.8rem; color: var(--parchment-dim); }
.foot-motto { font-family: var(--font-note); font-size: 1.15rem; color: var(--gold); }

/* ── The moat ring + player dock ────────────────────────────── */
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  height: calc(var(--dock-h) + env(safe-area-inset-bottom));
  padding: 0 0.9rem env(safe-area-inset-bottom);
  display: none;
  align-items: center;
  gap: 0.75rem;
  background: oklch(0.11 0.014 285 / 0.92);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--hairline);
}
.dock.is-open { display: flex; }
.dock-seek {
  position: absolute;
  top: -2px; left: 0; right: 0;
  height: 4px;
  cursor: pointer;
  touch-action: none;
}
.dock-seek::before { content: ''; position: absolute; inset: 0; background: oklch(1 0 0 / 0.1); }
.dock-seek i {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 0;
  background: linear-gradient(to right, var(--gold-deep), var(--gold));
  pointer-events: none;
}
.dock-art { width: 46px; height: 46px; flex: none; object-fit: cover; border: 1px solid var(--hairline); }
.dock-main { min-width: 0; flex: 1; }
.dock-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.86rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
a.dock-title:hover { color: var(--gold); }
.dock-times { font-size: 0.64rem; letter-spacing: 0.08em; color: var(--parchment-faint); font-variant-numeric: tabular-nums; }
.dock-btns { display: flex; align-items: center; gap: 0.1rem; flex: none; }

/* the moat ring — circular progress around play/pause */
.ring {
  position: relative;
  width: 52px; height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--parchment);
  -webkit-tap-highlight-color: transparent;
}
.ring svg.ring-track { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring svg.ring-track circle { fill: none; stroke-width: 2.5; }
.ring .ring-bg { stroke: oklch(1 0 0 / 0.14); }
.ring .ring-fill {
  stroke: var(--gold);
  stroke-linecap: butt;
  stroke-dasharray: 144.5; /* 2π·23 */
  stroke-dashoffset: 144.5;
}
.ring:hover { color: var(--gold); }

/* ── Theater (visualizer overlay) ───────────────────────────── */
.theater {
  position: fixed; inset: 0;
  z-index: 80;
  display: none;
  flex-direction: column;
  background: oklch(0.05 0.008 285 / 0.985);
}
.theater.is-open { display: flex; }
.theater-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  padding-top: calc(0.55rem + env(safe-area-inset-top));
}
.theater-title { flex: 1; min-width: 0; }
.theater-title strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.theater-title span { font-size: 0.62rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--parchment-faint); }
.theater-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding-bottom: env(safe-area-inset-bottom); }
.theater-stage video { width: 100%; height: 100%; object-fit: contain; }

/* ── Soft-nav fade ──────────────────────────────────────────── */
#main { animation: pagein 0.45s cubic-bezier(0.23, 1, 0.32, 1); }
@keyframes pagein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* in-view reveals — only hidden when JS is running (progressive enhancement) */
.js .reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.65s cubic-bezier(0.23, 1, 0.32, 1), transform 0.65s cubic-bezier(0.23, 1, 0.32, 1); }
.js .reveal.is-in { opacity: 1; transform: none; }

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rise, #main { animation: none; opacity: 1; transform: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .ambient { display: none; }
  .ambient + img.ambient-poster { display: block !important; }
}
