:root {
  --night: #120d0a;
  --night-2: #1c1511;
  --paper: #efe6d6;
  --paper-2: #e6dbc6;
  --ink: #241a14;
  --ink-soft: #6b5b4e;
  --accent: #c2662d;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --turn: 1.15s;
  --ease: cubic-bezier(.65, .02, .3, 1);
}

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

html, body { height: 100%; }

body {
  background: radial-gradient(120% 90% at 50% 0%, #2a1d15 0%, var(--night) 60%) fixed, var(--night);
  color: var(--paper);
  font-family: var(--serif);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* film grain over everything */
.grain {
  position: fixed; inset: -50%;
  pointer-events: none; z-index: 50; opacity: .07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); } 60% { transform: translate(-2%, -1%); }
  80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

/* ---------- the book ---------- */
.book {
  position: fixed; inset: 0;
  bottom: calc(76px + env(safe-area-inset-bottom));
}

.page {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  perspective: 2600px;
  padding: 28px 24px 8px;
  pointer-events: none;
}
.page.current { pointer-events: auto; }

.sheet {
  position: relative;
  width: min(1120px, 100%);
  height: min(700px, 100%);
  display: grid;
  grid-template-columns: 1.12fr 1fr;
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px 10px 10px 4px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.4) inset,
    0 30px 60px -20px rgba(0,0,0,.75),
    0 12px 24px -12px rgba(0,0,0,.6);
  transform-origin: left center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform var(--turn) var(--ease), filter var(--turn) var(--ease);
  overflow: hidden;
  will-change: transform;
}
/* spine shading */
.sheet::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 26px; z-index: 3;
  background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(0,0,0,0));
  pointer-events: none;
}
/* light sweep while turning */
.sheet::after {
  content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.45));
  opacity: 0; transition: opacity var(--turn) var(--ease);
}
.page.turned .sheet { transform: rotateY(-178deg); }
.page.turned .sheet::after { opacity: 1; }
.page.ahead .sheet { filter: brightness(.82); }

/* photo side */
.photo {
  position: relative; overflow: hidden;
  background: #000;
}
.photo img {
  width: 100%; height: 100%; display: block;
  object-fit: cover;
  transform: scale(1.06);
  transition: transform 9s ease-out;
}
.page.current .photo img { transform: scale(1); }
.photo figcaption {
  position: absolute; left: 18px; bottom: 16px; z-index: 2;
  font: 500 10.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255,255,255,.88);
  padding: 7px 10px; background: rgba(10,7,5,.42); backdrop-filter: blur(6px);
  border-radius: 2px;
}

/* paper side */
.paper {
  position: relative;
  display: flex; flex-direction: column;
  padding: clamp(26px, 4.2vw, 56px) clamp(24px, 4vw, 54px);
  background:
    radial-gradient(140% 100% at 100% 0%, rgba(255,255,255,.35), transparent 60%),
    linear-gradient(180deg, var(--paper), var(--paper-2));
  overflow-y: auto;
  scrollbar-width: none;
}
.paper::-webkit-scrollbar { display: none; }

.meta {
  display: flex; justify-content: space-between; gap: 12px;
  font: 500 11px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft);
  padding-bottom: 14px; border-bottom: 1px solid rgba(36,26,20,.18);
}
.meta b { color: var(--accent); font-weight: 500; }

.num {
  font: 300 italic clamp(64px, 8vw, 104px)/.8 var(--serif);
  color: var(--accent);
  margin: 26px 0 6px -4px;
  font-variation-settings: "opsz" 144;
}
.title {
  font: 500 clamp(30px, 3.4vw, 44px)/1.02 var(--serif);
  letter-spacing: -.015em;
  font-variation-settings: "opsz" 144;
}
.artist {
  margin-top: 10px;
  font: 400 12px/1.5 var(--mono); letter-spacing: .06em;
  color: var(--ink-soft);
}
.artist i { font-style: normal; color: var(--ink); }

.note {
  margin-top: 24px;
  font: 400 clamp(16px, 1.35vw, 18.5px)/1.62 var(--serif);
  color: #3a2c22;
  max-width: 34em;
}
.note p + p { margin-top: .8em; }
.note em { font-style: italic; color: var(--accent); }

/* ---------- player ---------- */
.player {
  margin-top: auto;
  padding-top: 26px;
  display: flex; align-items: center; gap: 18px;
}
.disc {
  --size: 66px;
  flex: none; position: relative;
  width: var(--size); height: var(--size); border-radius: 50%;
  background:
    radial-gradient(circle, var(--accent) 0 17%, #111 17.5% 19%, transparent 19.5%),
    repeating-radial-gradient(circle, #191919 0 1.2px, #0c0c0c 1.4px 2.6px);
  box-shadow: 0 6px 16px -6px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.06);
  transition: transform .3s ease;
}
.disc::before { /* sheen */
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 30deg, transparent 0 20%, rgba(255,255,255,.14) 25%, transparent 32% 70%, rgba(255,255,255,.1) 75%, transparent 82%);
}
.disc::after { /* spindle */
  content: ""; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px; border-radius: 50%; background: var(--paper);
}
.disc:hover { transform: scale(1.05); }
.disc .icon {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 2;
  opacity: 0; transition: opacity .2s;
}
.disc:hover .icon, .disc:focus-visible .icon { opacity: 1; }
.disc .icon svg { width: 22px; height: 22px; fill: var(--paper); filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.disc .i-pause { display: none; }
.playing .disc { animation: spin 1.8s linear infinite; }
.playing .disc .i-play { display: none; }
.playing .disc .i-pause { display: block; }
.playing .disc .icon { transform: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.track-state { flex: 1; min-width: 0; }
.state-label {
  font: 500 10.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft);
}
.bar {
  position: relative; height: 3px; margin: 11px 0 9px;
  background: rgba(36,26,20,.15); border-radius: 3px; overflow: hidden;
}
.bar span {
  position: absolute; inset: 0; transform-origin: left; transform: scaleX(0);
  background: var(--accent); border-radius: 3px;
}
.times {
  display: flex; justify-content: space-between;
  font: 400 10.5px/1 var(--mono); color: var(--ink-soft); letter-spacing: .06em;
}
.fallback {
  display: none; margin-top: 8px;
  font: 400 11px/1.4 var(--mono); color: var(--accent);
}
.fallback a { color: inherit; }
.failed .fallback { display: block; }

.bandcamp-frame {
  width: 100%; height: 42px; border: 0; margin-top: 8px; display: block;
  border-radius: 3px;
}

/* ---------- cover ---------- */
.cover .sheet { background: #17110d; color: var(--paper); }
.cover .art {
  position: relative; overflow: hidden;
  display: grid; place-items: center;
  background:
    radial-gradient(70% 70% at 50% 50%, rgba(194,102,45,.28), transparent 70%),
    #0f0b08;
}
.cover .art img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: .32; filter: grayscale(.3) contrast(1.05) blur(1px);
  object-position: 50% 22%;
}
.big-disc {
  --size: min(78%, 420px);
  position: relative; width: var(--size); aspect-ratio: 1; border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 33%, #0b0b0b 33.4% 35%, transparent 35.4%),
    repeating-radial-gradient(circle, #1a1a1a 0 1.4px, #0b0b0b 1.6px 3px);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.9), inset 0 0 0 1px rgba(255,255,255,.05);
  animation: spin 9s linear infinite;
}
.big-disc::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 10deg, transparent 0 18%, rgba(255,255,255,.12) 24%, transparent 30% 68%, rgba(255,255,255,.08) 74%, transparent 80%);
}
.label {
  position: absolute; inset: 33%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d77a3c, #a44f1f 70%);
  display: grid; place-items: center; text-align: center;
  color: #f6ead8;
}
.label::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 8%; height: 8%;
  transform: translate(-50%, -50%); border-radius: 50%; background: #0f0b08;
}
.label span {
  position: absolute; top: 16%; left: 0; right: 0;
  font: 500 italic clamp(13px, 1.7vw, 22px)/1 var(--serif);
}
.label small {
  position: absolute; bottom: 18%; left: 0; right: 0;
  font: 500 clamp(6px, .65vw, 8.5px)/1 var(--mono); letter-spacing: .2em; text-transform: uppercase;
}

.cover .paper {
  background: linear-gradient(180deg, #1b1410, #140f0c);
  color: var(--paper);
}
.cover .meta { color: rgba(239,230,214,.6); border-color: rgba(239,230,214,.16); }
.cover h1 {
  margin-top: 26px;
  font: 300 italic clamp(64px, 9vw, 128px)/.86 var(--serif);
  letter-spacing: -.035em;
  font-variation-settings: "opsz" 144;
}
.cover .lede {
  margin-top: 16px; max-width: 26em;
  font: 400 clamp(15px, 1.3vw, 17.5px)/1.55 var(--serif);
  color: rgba(239,230,214,.78);
}
.tracklist {
  list-style: none; margin-top: 22px;
  font: 400 12px/1 var(--mono); letter-spacing: .03em;
  border-top: 1px solid rgba(239,230,214,.14);
}
.tracklist li {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid rgba(239,230,214,.08);
  cursor: pointer; transition: color .2s, padding .2s;
  color: rgba(239,230,214,.86);
}
.tracklist li:hover { color: #fff; padding-left: 4px; }
.tracklist li .n { color: var(--accent); }
.tracklist li .a { color: rgba(239,230,214,.45); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 16ch; }
.tracklist li .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.needle {
  margin-top: 26px; align-self: flex-start;
  display: inline-flex; align-items: center; gap: 12px;
  padding: 14px 22px 14px 18px;
  border: 1px solid rgba(239,230,214,.35); border-radius: 999px;
  font: 500 12px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--paper);
  transition: background .25s, color .25s, border-color .25s;
}
.needle:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.needle svg { width: 14px; height: 14px; fill: currentColor; }
.hint {
  margin-top: 12px;
  font: 400 10.5px/1.4 var(--mono); letter-spacing: .08em; color: rgba(239,230,214,.45);
}

/* ---------- back cover ---------- */
.credits {
  margin-top: 22px; list-style: none;
  font: 400 12px/1.5 var(--mono); color: var(--ink-soft);
  border-top: 1px solid rgba(36,26,20,.16);
}
.credits li {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 8px 0; border-bottom: 1px dashed rgba(36,26,20,.16);
}
.credits li span:last-child { color: var(--ink); text-align: right; }
.sign {
  margin-top: 22px;
  font: 400 italic clamp(24px, 2.6vw, 34px)/1.15 var(--serif);
  color: var(--accent);
}
.sign small {
  display: block; margin-top: 8px;
  font: 400 12px/1.5 var(--mono); font-style: normal; color: var(--ink-soft); letter-spacing: .04em;
}
.again {
  margin-top: 22px; align-self: flex-start;
  font: 500 11px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft); border-bottom: 1px solid currentColor; padding-bottom: 4px;
}
.again:hover { color: var(--accent); }

/* ---------- deck (bottom nav) ---------- */
.deck {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(76px + env(safe-area-inset-bottom));
  padding: 0 max(16px, env(safe-area-inset-left)) env(safe-area-inset-bottom);
  display: flex; align-items: center; justify-content: center; gap: clamp(10px, 3vw, 28px);
}
.deck-btn {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(239,230,214,.2);
  transition: background .2s, border-color .2s, opacity .2s;
}
.deck-btn:hover { background: rgba(239,230,214,.08); border-color: rgba(239,230,214,.45); }
.deck-btn:disabled { opacity: .25; cursor: default; }
.deck-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--paper); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#sound .i-off { display: none; }
#sound[data-on="false"] .i-on { display: none; }
#sound[data-on="false"] .i-off { display: block; }
#sound svg path:first-child { fill: var(--paper); stroke: none; }

.deck-mid { display: flex; flex-direction: column; align-items: center; gap: 9px; min-width: 150px; }
.deck-count {
  font: 500 10.5px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase;
  color: rgba(239,230,214,.7);
}
.deck-dots { display: flex; gap: 7px; }
.deck-dots button {
  width: 6px; height: 6px; border-radius: 50%; padding: 0;
  background: rgba(239,230,214,.22); transition: background .3s, transform .3s;
}
.deck-dots button.on { background: var(--paper); transform: scale(1.35); }

/* hidden YouTube player (kept rendered so it can play) */
.yt-holder {
  /* must stay inside the viewport: Spotify's iframe is lazy-loaded */
  position: fixed; left: 0; bottom: 0; width: 300px; height: 200px;
  overflow: hidden; opacity: 0; pointer-events: none; z-index: -1;
}

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .book { bottom: calc(68px + env(safe-area-inset-bottom)); }
  .page { padding: 12px 12px 4px; }
  .sheet {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 47%) minmax(0, 1fr);
    height: 100%;
    border-radius: 3px 8px 8px 3px;
  }
  .paper { padding: 20px 20px 18px; }
  .meta { font-size: 10px; padding-bottom: 11px; }
  .num { font-size: 52px; margin: 14px 0 2px; }
  .title { font-size: 27px; }
  .artist { font-size: 11px; margin-top: 7px; }
  .note { margin-top: 14px; font-size: 15.5px; line-height: 1.55; }
  .player { padding-top: 16px; gap: 14px; }
  .disc { --size: 54px; }
  .disc .icon { opacity: 1; }
  .photo figcaption { left: 12px; bottom: 12px; font-size: 9.5px; }

  .cover .sheet { grid-template-rows: minmax(0, 40%) minmax(0, 1fr); }
  .big-disc { --size: min(64%, 260px); }
  .cover h1 { margin-top: 14px; font-size: 68px; }
  .cover .lede { font-size: 15px; margin-top: 10px; }
  .tracklist { margin-top: 14px; font-size: 11px; }
  .tracklist li { padding: 6px 0; }
  .needle { margin-top: 16px; padding: 12px 18px 12px 15px; }

  .deck { height: calc(68px + env(safe-area-inset-bottom)); gap: 12px; }
  .deck-btn { width: 42px; height: 42px; }
  .deck-mid { min-width: 0; flex: 1; max-width: 170px; }
}

@media (max-width: 760px) {
  /* keep the player / main button visible while the text scrolls */
  .paper { padding-bottom: 0; }
  .player {
    position: sticky; bottom: 0; z-index: 2;
    margin: auto -20px 0; padding: 14px 20px 16px;
    background: linear-gradient(180deg, rgba(230,219,198,0), var(--paper-2) 22%);
  }
  .cover .needle {
    position: sticky; bottom: 14px; z-index: 2;
    background: #1b1410; margin-bottom: 14px;
    box-shadow: 0 -14px 18px 6px #150f0c;
  }
  .cover .hint { display: none; }
  .back .paper { padding-bottom: 18px; }
  .credits li { font-size: 11px; }
}

@media (max-width: 760px) and (max-height: 760px) {
  .sheet { grid-template-rows: minmax(0, 42%) minmax(0, 1fr); }
  .cover .sheet { grid-template-rows: minmax(0, 30%) minmax(0, 1fr); }
  .cover h1 { font-size: 56px; margin-top: 10px; }
  .tracklist li { padding: 5px 0; }
  .tracklist li .a { display: none; }
  .tracklist li { grid-template-columns: 28px 1fr; }
  .num { font-size: 44px; margin-top: 10px; }
  .note { font-size: 14.5px; }
}

/* short desktop windows */
@media (min-width: 761px) and (max-height: 760px) {
  .num { font-size: 64px; margin-top: 16px; }
  .cover h1 { font-size: 88px; margin-top: 16px; }
  .note { margin-top: 16px; }
  .tracklist li { padding: 6px 0; }
  .player { padding-top: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --turn: .01s; }
  .grain, .big-disc, .playing .disc { animation: none; }
  .photo img { transition: none; transform: none; }
}
