/* Melliye — sleeve & liner notes.
   A dim room lit by the cover itself. Warm ink ground, paper-cream text,
   film grain, glass sheet. Type: Libre Caslon Display for titles, system UI for the rest. */

@font-face {
  font-family: "Libre Caslon Display";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/caslon-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Libre Caslon Display";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/caslon-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;

  --ink: #0e0b0a;
  --paper: #efe8da;
  --paper-2: #cfc5b4;   /* secondary text, 9:1 on ink */
  --paper-3: #a99e8e;   /* tertiary, 6.3:1 on ink */
  --line: rgba(239, 232, 218, 0.13);
  --fill: rgba(239, 232, 218, 0.07);
  --fill-hover: rgba(239, 232, 218, 0.12);
  --fill-press: rgba(239, 232, 218, 0.18);

  --glass: linear-gradient(180deg, rgba(36, 29, 25, 0.62), rgba(17, 13, 11, 0.82));
  --glass-solid: #1b1512;
  --glass-edge: rgba(255, 243, 222, 0.17);

  --serif: "Libre Caslon Display", "Baskerville", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --cover: min(72vw, 44dvh, 420px);
  --peek: 252px;            /* set from JS to the measured peek height */
  --swap: 1;                /* 0 mid-swipe, 1 at rest: drives text crossfade */
  --gutter: 16px;
  --bar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  height: 100%;
  background: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font: 400 1rem/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; -webkit-user-drag: none; user-select: none; }

::selection { background: rgba(239, 232, 218, 0.88); color: #1a1411; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
  border-radius: 10px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ───────── Ambient light: a darkened, blurred copy of each cover ───────── */

.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--ink);
}
.ambient img {
  position: absolute;
  inset: -25%;
  width: 150%;
  height: 150%;
  max-width: none;
  object-fit: cover;
  filter: blur(36px) saturate(1.7) brightness(0.46);
  opacity: 0;
  will-change: opacity;
}
.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 38%, transparent 0%, rgba(10, 7, 6, 0.55) 100%),
    linear-gradient(180deg, rgba(10, 7, 6, 0.35) 0%, transparent 22%, transparent 60%, rgba(10, 7, 6, 0.7) 100%);
}

/* Film grain, generated once on a canvas by app.js */
.grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: var(--grain, none);
  background-size: 192px 192px;
  opacity: 0.55;
  pointer-events: none;
  animation: grain 0.9s steps(1) infinite;
}
@keyframes grain {
  0%   { transform: translate3d(0, 0, 0); }
  20%  { transform: translate3d(-3%, 2%, 0); }
  40%  { transform: translate3d(2%, -4%, 0); }
  60%  { transform: translate3d(-4%, -1%, 0); }
  80%  { transform: translate3d(3%, 3%, 0); }
}

/* ───────── Layout ───────── */

.app {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.bar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--bar-h) + var(--safe-top));
  padding: var(--safe-top) calc(var(--gutter) - 6px) 0 var(--gutter);
}
.wordmark {
  font: 400 1.25rem/1 var(--serif);
  letter-spacing: 0.26em;
  color: var(--paper);
}
.bar-links { display: flex; gap: 2px; }

.icon-link {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--paper-2);
  transition: color 120ms ease-out, background-color 120ms ease-out, transform 120ms ease-out;
}
.icon-link svg { width: 20px; height: 20px; fill: currentColor; }
.icon-link:hover { color: var(--paper); background: var(--fill); }
.icon-link:active { transform: scale(0.92); background: var(--fill-press); }

.stage {
  position: absolute;
  z-index: 1; /* own stacking context: slide z-indexes must never outrank the sheet */
  inset: calc(var(--bar-h) + var(--safe-top)) 0 var(--peek) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 0;
}

/* ───────── Cover pager ───────── */

.pager {
  position: relative;
  width: 100%;
  height: calc(var(--cover) + 40px);
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  border-radius: 0;
}
.pager.dragging { cursor: grabbing; }
.pager:focus-visible { outline-offset: -4px; border-radius: 18px; }

.slides { position: absolute; inset: 0; }
.slide {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--cover);
  height: var(--cover);
  margin: calc(var(--cover) / -2) 0 0 calc(var(--cover) / -2);
  pointer-events: none;
  will-change: transform, opacity;
}
.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  box-shadow:
    0 34px 60px -24px rgba(0, 0, 0, 0.7),
    0 10px 22px -6px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 244, 226, 0.07);
}

.pager-btn {
  display: none;
  position: absolute;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  border-radius: 50%;
  place-items: center;
  color: var(--paper);
  background: rgba(24, 19, 16, 0.5);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  box-shadow: inset 0 1px 0 var(--glass-edge), 0 8px 20px rgba(0, 0, 0, 0.3);
  transition: opacity 160ms ease-out, transform 120ms ease-out, background-color 120ms ease-out;
  z-index: 3;
}
.pager-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pager-btn:hover { background: rgba(40, 32, 27, 0.65); }
.pager-btn:active { transform: scale(0.92); }
.pager-btn[aria-disabled="true"] { opacity: 0.3; pointer-events: none; }
.pager-prev { left: clamp(8px, 3vw, 28px); }
.pager-next { right: clamp(8px, 3vw, 28px); }

/* ───────── Title block ───────── */

.info {
  width: 100%;
  padding: 0 var(--gutter);
  text-align: center;
  min-height: calc(2 * 1.14 * var(--title-size, 2rem) + 1.9rem);
  opacity: var(--swap);
  filter: blur(calc((1 - var(--swap)) * 6px));
}
.title {
  --title-size: clamp(1.65rem, 7vw, 2.5rem);
  font: 400 var(--title-size)/1.14 var(--serif);
  letter-spacing: 0.075em;
  text-wrap: balance;
  max-width: 18ch;
  margin-inline: auto;
}
.meta {
  margin-top: 10px;
  font: 500 0.8125rem/1.3 var(--sans);
  letter-spacing: 0.035em;
  color: var(--paper-2);
  font-variant-numeric: tabular-nums;
}

/* The dots double as a scrubber: a quiet glass track under the thumb. */
.dots {
  display: flex;
  justify-content: center;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(239, 232, 218, 0.07);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  transition: background-color 200ms ease-out, transform 320ms var(--ease-out);
}
.dots:hover { background: rgba(239, 232, 218, 0.1); }
.dots.scrubbing {
  background: rgba(239, 232, 218, 0.16);
  transform: scale(1.14);
  cursor: grabbing;
}
.dot {
  position: relative;
  width: 40px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 4px;
  background: rgba(239, 232, 218, 0.45);
  transition: width 320ms var(--ease-out), background-color 200ms ease-out;
}
.dot:hover::before { background: rgba(239, 232, 218, 0.75); }
.dot[aria-current="true"]::before { width: 22px; background: var(--paper); }

/* ───────── The sheet: bottom drawer on phones, standing panel on wide screens ───────── */

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  height: min(88dvh, 780px);
  max-width: 640px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  -webkit-backdrop-filter: blur(34px) saturate(155%);
  backdrop-filter: blur(34px) saturate(155%);
  border-radius: 26px 26px 0 0;
  box-shadow:
    inset 0 1px 0 var(--glass-edge),
    0 -24px 70px rgba(0, 0, 0, 0.45);
  will-change: transform;
}

.sheet-head {
  flex: none;
  padding: 0 var(--gutter);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.grabber {
  display: grid;
  place-items: center;
  width: 100%;
  height: 28px;
  border-radius: 14px;
}
.grabber-bar {
  width: 38px;
  height: 5px;
  border-radius: 3px;
  background: rgba(239, 232, 218, 0.34);
  transition: background-color 120ms ease-out, width 220ms var(--ease-out);
}
.grabber:hover .grabber-bar { background: rgba(239, 232, 218, 0.6); }
.sheet-title, .s-title {
  font: 400 1.125rem/1.2 var(--serif);
  letter-spacing: 0.12em;
  color: var(--paper);
}
.sheet-title { padding: 2px 4px 12px; }

.sheet-body {
  flex: 1;
  min-height: 0;
  padding: 0 var(--gutter) calc(20px + var(--safe-bottom));
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(239, 232, 218, 0.28) transparent;
}
.sheet.open .sheet-body { overflow-y: auto; touch-action: pan-y; }
.sheet-body::-webkit-scrollbar { width: 8px; }
.sheet-body::-webkit-scrollbar-thumb { background: rgba(239, 232, 218, 0.26); border-radius: 4px; }
.sheet-body > * { opacity: var(--swap); }
/* At rest the sheet shows exactly two rows; nothing below them leaks into the margin. */
.sheet.peeking .sheet-body {
  -webkit-mask-image: linear-gradient(to bottom, #000 var(--peek-clip, 100%), transparent var(--peek-clip, 100%));
  mask-image: linear-gradient(to bottom, #000 var(--peek-clip, 100%), transparent var(--peek-clip, 100%));
}

.platforms, .follow { display: grid; gap: 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 0 14px 0 16px;
  border-radius: 14px;
  background: var(--fill);
  font: 500 1.0625rem/1.2 var(--sans);
  letter-spacing: 0.005em;
  color: var(--paper);
  transition: background-color 120ms ease-out, transform 120ms ease-out;
}
.row:hover { background: var(--fill-hover); }
.row:active { background: var(--fill-press); transform: scale(0.985); }
.row-icon { display: grid; place-items: center; width: 24px; height: 24px; flex: none; }
.row-icon svg { width: 22px; height: 22px; fill: currentColor; }
.row-name { flex: 1; min-width: 0; }
.row-go svg {
  width: 18px; height: 18px;
  fill: none; stroke: var(--paper-3); stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  transition: stroke 120ms ease-out, transform 220ms var(--ease-out);
}
.row:hover .row-go svg { stroke: var(--paper); transform: translate(2px, -2px); }

.row.compact { min-height: 48px; font-size: 1rem; }

.s-block { margin-top: 28px; }
.s-title { padding: 0 4px 10px; }

.tracks li {
  display: grid;
  grid-template-columns: 2.4ch minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 12px;
  padding: 11px 4px;
  border-top: 1px solid var(--line);
  font-size: 0.96875rem;
  line-height: 1.3;
}
.tracks li:last-child { border-bottom: 1px solid var(--line); }
.tracks .n, .tracks .d {
  font-variant-numeric: tabular-nums;
  color: var(--paper-3);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
}
.tracks .n { text-align: right; }
.tracks .t { overflow-wrap: anywhere; }

/* ───────── Wide layout: cover stage left, glass panel right ───────── */

@media (min-width: 820px), (min-width: 600px) and (orientation: landscape) {
  :root {
    --cover: min(40vw, 62dvh, 560px);
    --gutter: 20px;
    --bar-h: 72px;
    --peek: 0px;
  }
  .bar { padding: var(--safe-top) 22px 0 32px; }
  .wordmark { font-size: 1.4rem; }

  .app {
    grid-template-columns: minmax(0, 1fr) clamp(340px, 34vw, 440px);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .bar { grid-column: 1 / -1; }

  .stage {
    position: relative;
    inset: auto;
    min-width: 0;
    grid-column: 1;
    grid-row: 2;
    padding-bottom: 12px;
  }
  .title { --title-size: clamp(1.9rem, 3.2vw, 3rem); }
  .pager-btn { display: grid; }

  .sheet {
    position: relative;
    grid-column: 2;
    grid-row: 2;
    left: auto; right: auto; bottom: auto;
    height: auto;
    max-width: none;
    margin: 0 clamp(16px, 2.4vw, 36px) clamp(16px, 3dvh, 32px) 0;
    border-radius: 24px;
    transform: none !important;
    box-shadow:
      inset 0 1px 0 var(--glass-edge),
      inset 0 0 0 1px rgba(255, 243, 222, 0.05),
      0 30px 80px rgba(0, 0, 0, 0.45);
    overflow: hidden;
  }
  .sheet-head { cursor: default; padding-top: 22px; }
  .grabber { display: none; }
  .sheet-title { padding-bottom: 14px; }
  .sheet-body { overflow-y: auto; touch-action: pan-y; padding-bottom: 24px; }
}

/* Short, wide screens (landscape phones, small laptops) */
@media (min-width: 600px) and (max-height: 520px) {
  :root { --cover: min(40vw, 56dvh, 560px); --bar-h: 52px; }
  .title { --title-size: 1.5rem; }
  .dots { display: none; }
}

/* Small phones: give the cover a little more air under the header */
@media (max-height: 700px) and (max-width: 819px) {
  :root { --cover: min(66vw, 38dvh, 420px); }
}

/* ───────── Preferences ───────── */

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .dot::before, .dots, .row, .row-go svg, .icon-link, .grabber-bar { transition: none; }
}
.reduced .slide, .reduced .ambient img { transition: opacity 220ms ease-out; }
.reduced .info, .reduced .sheet-body > * { transition: opacity 220ms ease-out; }

@media (prefers-reduced-transparency: reduce) {
  .sheet, .pager-btn {
    background: var(--glass-solid);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .grain { display: none; }
}

@media (prefers-contrast: more) {
  :root { --paper-2: #e4dccd; --paper-3: #cfc5b4; --fill: rgba(239, 232, 218, 0.12); }
  .sheet { background: var(--glass-solid); box-shadow: inset 0 0 0 1px var(--paper-3); }
  .row { box-shadow: inset 0 0 0 1px var(--paper-3); }
}

/* No-JS fallback: plain list of links */
.plain {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: auto;
  padding: 32px var(--gutter);
  background: var(--ink);
  line-height: 1.7;
}
.plain h1 { font: 400 1.5rem var(--serif); letter-spacing: 0.24em; margin-bottom: 24px; }
.plain h2 { font: 400 1.25rem var(--serif); letter-spacing: 0.07em; margin-top: 20px; }
.plain a { text-decoration: underline; text-underline-offset: 3px; }
