/* ═══════════════════════════════════════════════════════════════════
   HEAVY METAL THUNDER — site theme

   The only stylesheet every page loads. Page-specific CSS (timeline
   bars, D3 tree nodes, map markers) stays with its page.

   RESTYLING LATER: change the tokens in :root below and the whole site
   follows. That is the entire point of this file. The 13 family colours
   are NOT here — they come from the database via hmt_palette_css(), so
   editing hmt_families.json is enough.

   ── Where the base values came from ───────────────────────────────────
   The five old pages disagreed with each other: three backgrounds
   (#111, #08080f, #0d0d0d), three text colours (#ddd, #ccc, #e0e0e0)
   and three font stacks. There was no single "current look" to preserve,
   so this file standardises on the two most recently styled pages —
   Genre Cards and Genre Evolution: #08080f, #ccc, 'Segoe UI'.
   If you'd rather it matched the World Map instead, change --hmt-bg to
   #0d0d0d and --hmt-text to #e0e0e0 and you're done.

   ── Deliberate accessibility changes ──────────────────────────────────
   Everything else is reproduced as it was. These four were measured as
   failing WCAG AA and are changed on purpose:

   1. Nav link size .58rem (~9px) → .7rem (~11px). Uppercase text with
      wide letter-spacing at 9px is very hard to read.
   2. Nav border #444 on #08080f was 2.05:1. WCAG needs 3:1 for a UI
      boundary. Now --hmt-line at 3.08:1.
   3. Nav hover #cc0000 was 3.39:1, under the 4.5:1 needed for small
      text. Now --hmt-accent-ink.
   4. Focus outlines added. There were none, which makes the site
      unusable by keyboard.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --hmt-bg:          #08080f;
  --hmt-surface:     #101018;
  --hmt-surface-2:   #16161f;

  /* Text — all comfortably past 4.5:1 on --hmt-bg */
  --hmt-text:        #ccc;      /* 12.43:1 */
  --hmt-text-strong: #e8e8e8;   /* 15.9:1  */
  --hmt-text-muted:  #aaa;      /*  8.59:1 */
  --hmt-text-faint:  #8a8a8a;   /*  5.7:1  — was #666 at 3.48:1 */

  /* Lines and edges — 3:1 minimum for UI boundaries */
  --hmt-line:        #5e5e5e;   /* 3.08:1 — was #444 at 2.05:1 */
  --hmt-line-soft:   #2a2a33;   /* decorative only, never a boundary */

  /* Accent */
  --hmt-accent:      #cc0000;   /* graphics and large text only, 3.39:1 */
  --hmt-accent-ink:  #f50000;   /* small text, 4.64:1 */

  /* Type */
  --hmt-font:        'Segoe UI', Arial, Helvetica, sans-serif;
  --hmt-font-mono:   ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace;

  /* Spacing and shape */
  --hmt-gap:         8px;
  --hmt-pad:         14px;
  --hmt-radius:      3px;
  --hmt-radius-lg:   6px;

  /* Motion — set to 0s wholesale by prefers-reduced-motion below */
  --hmt-speed:       .2s;
}

/* ─── Reset ───────────────────────────────────────────────────────── */

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

html { -webkit-text-size-adjust: 100%; }

body.hmt-body {
  background: var(--hmt-bg);
  color: var(--hmt-text);
  font-family: var(--hmt-font);
  min-height: 100vh;
}

/* Pages whose charts own the viewport and must not scroll the document.
   The old pages set `overflow:hidden` on body directly; this makes it
   opt-in so ordinary pages can still scroll. */
body.hmt-fixed {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

img, svg { max-width: 100%; }

/* …but not the Genre Timeline, which is deliberately 2286px wide and is
   meant to be scrolled sideways inside #outer. `max-width:100%` shrank the
   <svg> viewport to the width of the window, so the chart was clipped at
   the right-hand edge and #outer had nothing to scroll to. The year header
   is pinned to the same 2286px coordinate space and is exempted with it,
   so the two can never drift apart. */
body[data-hmt-page="timeline"] #timeline-svg,
body[data-hmt-page="timeline"] #year-header-inner svg { max-width: none; }

a { color: var(--hmt-accent-ink); }
a:hover { color: var(--hmt-text-strong); }

/* ─── Keyboard access ─────────────────────────────────────────────── */

/* There was no focus style at all before, which meant a keyboard user
   could not see where they were. :focus-visible keeps it invisible for
   mouse users, so nothing looks different day to day. */
:focus-visible {
  outline: 2px solid var(--hmt-accent-ink);
  outline-offset: 2px;
  border-radius: 2px;
}

.hmt-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--hmt-surface);
  color: var(--hmt-text-strong);
  border: 1px solid var(--hmt-line);
  border-radius: var(--hmt-radius);
  font-size: .85rem;
  text-decoration: none;
}
.hmt-skip:focus {
  left: 8px;
  top: 8px;
}

/* ─── Masthead ────────────────────────────────────────────────────── */

.hmt-masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--hmt-gap);
  padding: 10px 16px;
  border-bottom: 1px solid var(--hmt-line-soft);
  flex-shrink: 0;
}

.hmt-masthead-titles {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.hmt-wordmark {
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--hmt-text-faint);
  white-space: nowrap;
}
.hmt-wordmark a { color: inherit; text-decoration: none; }
.hmt-wordmark a:hover { color: var(--hmt-accent-ink); }

.hmt-page-title {
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--hmt-text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Navigation ──────────────────────────────────────────────────── */

.hmt-nav {
  display: flex;
  align-items: center;
  gap: var(--hmt-gap);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.hmt-nav-link {
  color: var(--hmt-text-muted);
  text-decoration: none;
  font-size: .7rem;                 /* was .58rem — too small to read */
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 5px 10px;
  border: 1px solid var(--hmt-line);
  border-radius: var(--hmt-radius);
  transition: color var(--hmt-speed), border-color var(--hmt-speed);
  white-space: nowrap;
}

.hmt-nav-link:hover,
.hmt-nav-link:focus-visible {
  color: var(--hmt-accent-ink);
  border-color: var(--hmt-accent-ink);
}

/* The page you're on. Marked by more than colour — it also carries
   aria-current in the markup, so it isn't colour-only information. */
.hmt-nav-link.is-current {
  color: var(--hmt-text-strong);
  border-color: var(--hmt-text-faint);
  background: var(--hmt-surface);
  cursor: default;
}

.hmt-nav-short { display: none; }

/* The emoji icons the old navs used. Decorative — aria-hidden in the
   markup — and dropped on very narrow screens where space is tight. */
.hmt-nav-icon { margin-right: .35em; font-style: normal; }

/* ─── Main and footer ─────────────────────────────────────────────── */

.hmt-main { flex: 1 1 auto; min-height: 0; }

body:not(.hmt-fixed) .hmt-main { padding: 20px 16px 40px; }

.hmt-footer {
  padding: 14px 16px 20px;
  border-top: 1px solid var(--hmt-line-soft);
  color: var(--hmt-text-faint);
  font-size: .72rem;
  flex-shrink: 0;
}
body.hmt-fixed .hmt-footer { display: none; }
.hmt-footer-counts { white-space: nowrap; }

/* ─── Footer sitemap ───────────────────────────────────────────────────
   Three columns that collapse to one on a phone with no breakpoint —
   auto-fit and a min width does it. Set at .78rem rather than the
   footer's .72rem because these are 30-odd tap targets, not small print,
   and the padding on each <a> is there to make them thumb-sized. */

.hmt-sitemap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.4rem 2rem;
  max-width: 74rem;
  margin: .4rem 0 1.6rem;
}
.hmt-sitemap-h {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 700;
  color: var(--hmt-text-faint);
  margin: 0 0 .5rem;
}
.hmt-sitemap-h a { color: inherit; text-decoration: none; }
.hmt-sitemap-h a:hover, .hmt-sitemap-h a:focus-visible { color: var(--hmt-text-strong); }

.hmt-sitemap ul { list-style: none; margin: 0; padding: 0; }
.hmt-sitemap li { margin: 0; }
.hmt-sitemap li a {
  display: flex;
  align-items: center;
  gap: .45em;
  padding: .28rem 0;
  font-size: .78rem;
  color: var(--hmt-text-muted);
  text-decoration: none;
}
.hmt-sitemap li a:hover,
.hmt-sitemap li a:focus-visible { color: var(--hmt-text-strong); text-decoration: underline; }

/* A 9px square is decorative, so the raw brand colour is fine here — the
   family name next to it carries the meaning. */
.hmt-sitemap-swatch {
  width: 9px; height: 9px;
  border-radius: 2px;
  flex: 0 0 auto;
}
.hmt-sitemap-n { color: var(--hmt-text-faint); font-size: .7rem; margin-left: auto; }

.hmt-footer-line { margin: 0; }

/* ─── 404 and other centred pages ─────────────────────────────────── */

body.hmt-centred {
  background: var(--hmt-bg);
  color: var(--hmt-text);
  font-family: var(--hmt-font);
  display: grid;
  place-items: center;
  min-height: 100vh;
  text-align: center;
  padding: 1rem;
}
body.hmt-centred h1 { font-size: 3rem; color: var(--hmt-text-faint); }

/* ─── Content warning badges (reproduced as-is) ───────────────────── */

.content-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.content-badges--large { margin: 8px 0 4px; }
.content-badges--small { margin: 6px 0 4px; justify-content: center; }

/* ─── Album cover popup mode (reproduced as-is) ───────────────────── */

.album-mode {
  width: 530px !important;
  height: 530px !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: #000 !important;
  border: none !important;
  border-radius: 4px !important;
  max-height: none !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .75) !important;
}

/* ─── Shared building blocks ──────────────────────────────────────── */

.hmt-card {
  display: block;
  background: var(--hmt-surface);
  border: 1px solid var(--hmt-line-soft);
  border-left: 3px solid var(--hmt-line);
  border-radius: var(--hmt-radius-lg);
  padding: var(--hmt-pad);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--hmt-speed), background var(--hmt-speed);
}
.hmt-card:hover,
.hmt-card:focus-visible {
  background: var(--hmt-surface-2);
  border-color: var(--hmt-line);
}

.hmt-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* A family colour swatch. Use this next to a label rather than colouring
   the label itself: lightened to be legible, the three reds (origins,
   thrash, core) become indistinguishable from one another, so colour
   alone can never identify a family. */
.hmt-swatch {
  display: inline-block;
  width: .72em;
  height: .72em;
  border-radius: 2px;
  vertical-align: baseline;
  margin-right: .4em;
  /* The two darkest families are invisible against the background
     without an edge; --hmt-fam-*-edge exists for exactly those. */
  outline: 1px solid rgba(255, 255, 255, .28);
  outline-offset: -1px;
}

.hmt-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ─── Narrow screens ──────────────────────────────────────────────── */

@media (max-width: 720px) {
  .hmt-masthead { padding: 8px 12px; }
  .hmt-page-title { font-size: .92rem; }
  .hmt-nav { gap: 5px; }
  .hmt-nav-link { padding: 5px 7px; letter-spacing: .06em; }
  .hmt-nav-full { display: none; }
  .hmt-nav-short { display: inline; }
}

/* ─── Reduced motion ──────────────────────────────────────────────── */

/* The map's pulsing hotspot rings and every transition here. Respecting
   this is not optional for people who get motion sickness. */
@media (prefers-reduced-motion: reduce) {
  :root { --hmt-speed: 0s; }
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
