@import "tokens.css";

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--step-0);
  line-height: 1.6;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* Long unbreakable strings (filenames, URLs) wrap instead of forcing the page
     wider than the viewport. Inherited, so it applies to all text by default. */
  overflow-wrap: break-word;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
a { color: var(--link); text-decoration: none; }
/* Links with no visual cue — look like the surrounding text (e.g. homepage aliases). */
.alias-link { color: inherit; text-decoration: none; }

/* ---------- atmosphere: film grain + faint scanlines ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.05;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.35;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 3px,
    rgba(0, 0, 0, 0.25) 3px 4px
  );
  mix-blend-mode: multiply;
}

/* ---------- layout ---------- */
.wrap { width: min(100% - var(--gutter) * 2, 1320px); margin-inline: auto; }
.prose { max-width: var(--measure); }
/* Fills the available width instead of capping at the readability measure (e.g.
   a resource description). Still bounded by its wrap, so it shrinks with the
   viewport; long tokens break so it never pushes the page wider. */
.prose--full { max-width: none; overflow-wrap: anywhere; }
.prose > * + * { margin-top: 1em; }
/* The bundled display/mono fonts ship no italic face, and the global
   `font-synthesis: none` (see body) would otherwise leave editor-authored
   <em>/<i> (and the italic blockquote below) rendering upright. Re-enable
   *style* synthesis for emphasis in prose only, so faux-italic shows; weight
   synthesis stays off (the fonts carry real bold). */
.prose em, .prose i, .prose cite, .prose blockquote { font-synthesis: style; }
.prose a { color: var(--link); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 2px; }
/* Blockquotes: indented, with a red bar down the left. box-sizing:border-box
   keeps the padding inside the width, so it never pushes past the viewport;
   overflow-wrap breaks any long token inside. */
.prose blockquote {
  margin-left: 0; padding: 0.1rem 0 0.1rem clamp(1rem, 4vw, 1.75rem);
  border-left: 3px solid var(--accent); color: var(--muted);
  font-style: italic; overflow-wrap: anywhere;
}
.prose blockquote > * + * { margin-top: 0.8em; }

/* ---------- skip link ---------- */
.skip-link {
  position: fixed; top: 0; left: 0; z-index: 10000;
  background: var(--accent); color: var(--accent-ink);
  padding: 0.6rem 1rem; font-weight: 600; transform: translateY(-120%);
}
.skip-link:focus { transform: translateY(0); }

/* ---------- focus ---------- */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.8rem var(--gutter);
  border-bottom: var(--rule) solid var(--hairline);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
}
/* The nav links + theme switcher; inline on desktop, a dropdown on mobile. */
.nav-group { display: flex; align-items: center; gap: clamp(0.8rem, 2vw, 2rem); flex-wrap: wrap; justify-content: flex-end; }

/* Hamburger button — hidden unless JS is available AND the viewport is narrow. */
.nav-toggle {
  display: none; align-self: center;
  width: 2.7rem; height: 2.3rem;
  align-items: center; justify-content: center;
  background: transparent; color: var(--fg);
  border: var(--rule) solid var(--hairline); border-radius: var(--radius);
  cursor: pointer;
}
.nav-toggle:hover { border-color: var(--accent); }
.nav-toggle__bars { position: relative; }
.nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
  display: block; width: 1.2rem; height: 2px; background: currentColor;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}
.nav-toggle__bars::before, .nav-toggle__bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle__bars::before { top: -6px; }
.nav-toggle__bars::after { top: 6px; }
/* Morph into an X when the menu is open. */
.nav-toggle[aria-expanded="true"] .nav-toggle__bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after { top: 0; transform: rotate(-45deg); }
.site-header .brand {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: var(--step-1);
  text-transform: lowercase;
}
.site-header .brand::after { content: "."; color: var(--accent); }
.site-nav { display: flex; gap: clamp(0.8rem, 2vw, 2rem); text-transform: uppercase; letter-spacing: 0.18em; font-size: var(--step--1); }
.site-nav a { position: relative; padding-block: 0.2rem; color: var(--muted); }
.site-nav a:hover, .site-nav a:focus-visible { color: var(--fg); }
.site-nav a::after { content: ""; position: absolute; left: 0; right: 100%; bottom: -0.25rem; height: 2px; background: var(--accent); transition: right 0.3s var(--ease); }
.site-nav a:hover::after, .site-nav a:focus-visible::after { right: 0; }

/* ---------- theme toggle ---------- */
.theme-toggle {
  align-self: center;
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.6rem;
  font: inherit; font-size: var(--step--1);
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--muted);
  background: transparent;
  border: var(--rule) solid var(--hairline);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.theme-toggle:hover { color: var(--fg); border-color: var(--accent); }
.theme-toggle__glyph { width: 1em; height: 1em; line-height: 1; }
/* Sun while light (the default); moon while dark. */
.theme-toggle__glyph::before { content: "\2600"; } /* ☀ */
:root[data-theme="dark"] .theme-toggle__glyph::before { content: "\263E"; } /* ☾ */
/* Mobile: collapse the nav links + theme switcher into the hamburger dropdown so
   the header can never overflow the viewport. (.js gates this so no-JS visitors
   keep visible, wrapping links rather than an untoggleable hidden menu.) */
@media (max-width: 40rem) {
  .js .nav-toggle { display: inline-flex; }
  .js .nav-group {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 0.4rem var(--gutter) 1.2rem;
    background: var(--bg); border-bottom: var(--rule) solid var(--hairline);
    display: none;
  }
  .js .nav-group.open { display: flex; }
  .js .site-nav { flex-direction: column; align-items: stretch; gap: 0; }
  .js .site-nav a { padding-block: 0.8rem; border-top: var(--rule) solid var(--hairline); }
  .js .site-nav a::after { display: none; }
  .js .theme-toggle { align-self: flex-start; margin-top: 0.9rem; }
}

/* ---------- section heading: numbered mono kicker + big display title ---------- */
.kicker {
  font-size: var(--step--1); letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--accent-text); display: flex; align-items: center; gap: 0.8rem;
}
.kicker::before { content: ""; width: 2.4rem; height: 2px; background: var(--accent); display: inline-block; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; line-height: 0.95; letter-spacing: -0.02em; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

.section { padding-block: clamp(3rem, 8vw, 7rem); border-top: var(--rule) solid var(--hairline); }

/* Pages: give the body breathing room below the title (it was too tight). */
.page-standard .section > h1,
.page-full .section > h1 { margin-bottom: clamp(1.5rem, 4vw, 2.75rem); }

/* ---------- heading helpers ---------- */
/* A heading with a rule beneath it and breathing room before the content that follows. */
.ruled-heading {
  border-bottom: var(--rule) solid var(--hairline);
  padding-bottom: clamp(0.6rem, 2vw, 1rem);
  margin-bottom: clamp(1.2rem, 3vw, 2rem);
}
/* Nudge a clickable byline (e.g. the artist) a shade below its title. */
.byline { margin-top: 0.6rem; }

/* ---------- hero ---------- */
.hero { min-height: 86vh; display: grid; align-content: center; padding-block: 4rem; position: relative; }
.hero__mark {
  font-family: var(--font-display); font-weight: 800;
  font-size: var(--display); line-height: 0.82; letter-spacing: -0.04em;
  text-transform: uppercase; margin: 0; overflow-wrap: anywhere;
}
.hero__mark em { font-style: normal; color: var(--accent); }
.hero__sub { margin-top: 1.4rem; max-width: 40ch; color: var(--muted); font-size: var(--step-1); }
.hero__scrim { position: absolute; inset: auto 0 0 0; height: 1px; background: linear-gradient(90deg, var(--accent), transparent 70%); }

/* ---------- entry rows (news / resources / releases) ---------- */
.entries { list-style: none; padding: 0; }
.entry {
  /* minmax(0, 1fr) lets the title column shrink below its content's intrinsic
     width (grid items otherwise have min-width: auto), so long titles wrap
     rather than widening the row past the viewport. */
  display: grid; grid-template-columns: 4ch minmax(0, 1fr) auto; gap: 1rem; align-items: baseline;
  padding: clamp(0.9rem, 2vw, 1.4rem) 0; border-top: var(--rule) solid var(--hairline);
  position: relative;
}
.entry:last-child { border-bottom: var(--rule) solid var(--hairline); }
.entry__index { font-size: var(--step--1); color: var(--accent-text); }
.entry__title { font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); letter-spacing: -0.01em; min-width: 0; overflow-wrap: anywhere; }
.entry__title a { color: var(--fg); }
/* Right-aligned so the year/date stays flush right even when a taller stacked
   value (e.g. a contributor) makes the column wider than the date itself. */
.entry__meta { color: var(--muted); font-size: var(--step--1); text-transform: uppercase; letter-spacing: 0.1em; min-width: 0; overflow-wrap: anywhere; text-align: right; }
/* One-line resource description under the title (resources list + homepage). */
.entry__snippet { display: block; margin-top: 0.25rem; color: var(--muted); font-family: var(--font-mono); font-weight: 400; font-size: var(--step--1); letter-spacing: 0; }
/* Prominent content year in a listing's meta column, with the contributor beneath. */
.entry__date { display: block; font-family: var(--font-display); font-weight: 800; font-size: var(--step-1); line-height: 1; letter-spacing: 0; color: var(--accent-text); }
.entry__by { display: block; margin-top: 0.3rem; }
/* Download size after a file name — quieter and smaller than the file name. */
.entry__size { font-family: var(--font-mono); font-weight: 400; font-size: var(--step--1); letter-spacing: 0; color: var(--muted); }
.entry::after { content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; background: var(--accent); transition: width 0.4s var(--ease); }
.entry:hover::after, .entry:focus-within::after { width: 100%; }
.entry:hover .entry__title a { color: var(--accent-text); }

/* ---------- discography ---------- */
.disco-section + .disco-section { margin-top: clamp(2rem, 5vw, 4rem); }
/* Resources index: a little more air after the page title, before each kind
   heading (Official/Fan) and before each subcategory heading. */
.resources-index .disco-section { margin-top: clamp(2.5rem, 5vw, 4rem); }
.resources-index .disco-section h3 { margin-top: clamp(1.6rem, 3.5vw, 2.6rem); }
details.edition { border-top: var(--rule) solid var(--hairline); }
details.edition > summary {
  cursor: pointer; list-style: none; padding: 1rem 0; display: flex; gap: 1rem;
  align-items: baseline; font-family: var(--font-display); font-weight: 700; font-size: var(--step-1);
}
details.edition > summary::-webkit-details-marker { display: none; }
/* Name + meta flow together as one wrapping text block (a single flex child),
   so the "· 2x12" · 2002 · …" pieces wrap at word boundaries. Without this each
   meta piece is its own flex child and gets squeezed to ~1ch wide on mobile,
   stacking its text vertically. min-width:0 lets the block shrink to fit. */
.edition__info { min-width: 0; }
.edition__info .entry__meta { text-align: left; }
/* Free-text notes about an edition, shown under its heading when expanded.
   Indented (padding-left) to line up with the covers and tracklist; full width
   (overrides .prose's max-width), with overflow-wrap so long links/words can't
   push past the viewport on mobile. */
.edition__notes {
  margin: 0 0 1rem; padding-left: 2rem; max-width: none;
  color: var(--muted); font-size: var(--step--1); overflow-wrap: anywhere;
}
details.edition > summary::before { content: "+"; color: var(--accent); font-weight: 800; }
details.edition[open] > summary::before { content: "\2013"; }
/* "Purchase" link pushed to the far right of the edition's summary line. */
.edition__buy {
  margin-left: auto; align-self: center;
  font-family: var(--font-mono); font-weight: 600; font-size: var(--step--1);
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent-text);
  text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 0.18em;
}
.edition__buy:hover { color: var(--fg); }
/* Row-major 2-column grid: 01 left, 02 right, 03 under 01 — predictable, unlike
   balanced CSS columns which reflow oddly when track lines wrap. */
.tracklist { list-style: none; padding: 0 0 1rem 2rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2.5rem; }
.tracklist li { padding: 0.2rem 0; color: var(--muted); }
.tracklist li span { color: var(--fg); }
/* Per-track performing artist (e.g. on Various Artists comps), before the title. */
.track__artist { color: var(--fg); font-weight: 600; }
.track__artist:hover { color: var(--accent-text); }
.covers { display: flex; flex-wrap: wrap; gap: 0.8rem; list-style: none; padding: 0 0 1rem 2rem; }
.covers img { width: clamp(80px, 16vw, 150px); aspect-ratio: 1; object-fit: cover; border: var(--rule) solid var(--hairline); filter: grayscale(0.2) contrast(1.05); cursor: zoom-in; }
.covers img:hover { filter: none; }

/* Cover lightbox / modal gallery (built by gallery.js). */
.lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(8, 8, 10, 0.94); padding: clamp(1rem, 5vw, 4rem); }
.lightbox[hidden] { display: none; }
.lightbox__img { max-width: 100%; max-height: 100%; object-fit: contain; border: var(--rule) solid var(--hairline); }
.lightbox button { background: none; border: 0; color: var(--fg); cursor: pointer; line-height: 1; padding: 0.1em 0.35em; }
.lightbox button:hover, .lightbox button:focus-visible { color: var(--accent); }
.lightbox__close { position: absolute; top: 0.5rem; right: 0.75rem; font-size: 2.4rem; }
.lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: clamp(2.5rem, 7vw, 4rem); }
.lightbox__nav--prev { left: 0.5rem; }
.lightbox__nav--next { right: 0.5rem; }

/* ---------- lyrics ---------- */
.lyric-body { margin-top: 1.5rem; line-height: 1.7; }
.lyric-source { margin-top: 1.5rem; font-style: italic; color: var(--muted); }

/* ---------- resource detail: inline metadata line under the title ---------- */
.resource-meta {
  list-style: none; padding: 0; margin-top: clamp(0.9rem, 2vw, 1.3rem);
  display: flex; flex-wrap: wrap; align-items: baseline;
  font-family: var(--font-mono); font-size: var(--step--1);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.resource-meta > li { display: flex; align-items: baseline; gap: 0.5ch; }
/* Pipe separators between items. */
.resource-meta > li:not(:last-child)::after { content: "|"; color: var(--hairline); margin: 0 0.9rem; }
.resource-meta__label { color: var(--accent-text); }
.resource-meta__label::after { content: ":"; }
.resource-meta a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 0.18em; }

/* ---------- article ---------- */
/* Sized so the readable prose measure plus the side rail fill the width, and the
   heading above no longer dwarfs the (narrower) body text. */
.article { width: min(100% - var(--gutter) * 2, 60rem); margin-inline: auto; }
.article-head { padding-block: clamp(2.5rem, 6vw, 5rem); }
time { font-variant-numeric: tabular-nums; }

/* Body: prose column + a related-links rail. Stacked by default; two columns
   with a vertical separator once there's room. The minmax(0,1fr) column and
   min-width:0 items let the grid shrink with the viewport instead of being held
   open by a long token, so text always wraps to fit (the viewport never grows). */
.article__body { display: grid; gap: 2.5rem; grid-template-columns: minmax(0, 1fr); }
.article__main, .article__rail { min-width: 0; }
.article__main .prose { max-width: var(--measure); overflow-wrap: anywhere; }
.article__rail {
  display: grid; gap: clamp(1.5rem, 4vw, 2.5rem); align-content: start;
  border-top: var(--rule) solid var(--hairline); padding-top: 1.75rem;
}
.rail__title {
  font-family: var(--font-mono); font-weight: 600; font-size: var(--step--1);
  text-transform: uppercase; letter-spacing: 0.18em; color: var(--accent-text);
  margin-bottom: 0.6rem;
}
.rail__list { list-style: none; padding: 0; display: grid; gap: 0.4rem; }
.rail__list a, .rail__back { color: var(--fg); }
.rail__list a:hover, .rail__back:hover { color: var(--accent-text); }
/* Richer rail items (e.g. related resources): a link with a concise meta line. */
.rail__list--rich { gap: 0.9rem; }
.rail__meta { display: block; margin-top: 0.15rem; font-size: var(--step--1); line-height: 1.4; color: var(--muted); }
.rail__back {
  font-size: var(--step--1); text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--muted);
}
/* "Thanks for this post to …" note pinned at the top of the rail. */
.rail__credit {
  font-size: var(--step--1); line-height: 1.5; color: var(--muted);
  border-left: 3px solid var(--accent); padding-left: 0.9rem;
}

@media (min-width: 60rem) {
  .article__body {
    grid-template-columns: minmax(0, var(--measure)) minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 4rem); align-items: start;
  }
  /* Vertical separator bar between the prose and the rail. */
  .article__rail {
    border-top: 0; padding-top: 0;
    border-left: var(--rule) solid var(--hairline);
    padding-left: clamp(1.5rem, 4vw, 3rem);
    position: sticky; top: 2rem;
  }
}

/* ---------- related blog post pulled into a resource ---------- */
.related-post { border-top: var(--rule) solid var(--hairline); padding-top: 1.5rem; border-left: 3px solid var(--accent); padding-left: clamp(1rem, 3vw, 2rem); }
.related-post > .prose { color: var(--muted); }
.related-post__cover { margin: 1.25rem 0; border: var(--rule) solid var(--hairline); }

/* ---------- footer ---------- */
.site-footer { border-top: var(--rule) solid var(--hairline); padding: 2.5rem var(--gutter); color: var(--muted); font-size: var(--step--1); text-transform: uppercase; letter-spacing: 0.14em; }

/* ---------- responsive ---------- */
@media (max-width: 40rem) {
  /* One tracklist column on narrow screens so long track names have full width
     to wrap into rather than being squeezed (and overflowing) in two columns. */
  .tracklist { grid-template-columns: 1fr; }
  /* Discography listing rows: drop the type-name meta below the title on narrow
     screens. The meta column is auto-sized to its content, so a long type like
     "Compilation Appearances" would otherwise steal the row width and crush the
     title into a one-word-per-line sliver. Direct child only, so the inline
     .entry__meta spans in release_detail (alias/edition notes) stay put. */
  .discography .entry { grid-template-columns: 4ch minmax(0, 1fr); }
  .discography .entry > .entry__meta { grid-column: 2; text-align: left; margin-top: 0.25rem; }
  /* Resource listing rows: cap the meta column so a long contributor name (e.g.
     "Martin Paul Eve") wraps onto its own lines instead of auto-sizing the column
     to its full width and crushing the title. The prominent year stays pinned
     top-right, and year-only rows keep a tight meta (so their title stays wide).
     Direct child only, to leave the snippet's own .entry__meta usages untouched. */
  .resources-index .entry > .entry__meta { max-width: 7rem; }
  /* Homepage listing rows (Latest news / Latest resources): the kind label
     ("Fan remixes & resources") auto-sizes its column and crushes the title into
     a one-word-per-line sliver on narrow screens. Drop the meta below the title
     at full width, left-aligned and quieter, so the title gets the whole row. */
  .home .entry { grid-template-columns: 4ch minmax(0, 1fr); }
  .home .entry > .entry__meta {
    grid-column: 2; text-align: left; margin-top: 0.35rem;
    font-size: 0.7rem; letter-spacing: 0.08em;
  }
}

@media print { body::before, body::after, .site-nav { display: none; } body { color: #000; background: #fff; } }

.entry__lock { color: var(--accent-text); font-size: 0.85em; }
.entry__preview { display: block; max-width: 320px; margin-top: 0.5rem; border-radius: 4px; }
/* Per-file purchase link: a quiet, mono accent link sitting after the filename. */
.entry__buy { font-family: var(--font-mono); font-weight: 400; font-size: var(--step--1); color: var(--accent-text); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 0.18em; }
.entry__title a.entry__buy { color: var(--accent-text); }
