:root {
  --font-display: display, Georgia, "Times New Roman", serif;
  --font-mono: mono, ui-monospace, "SF Mono", Menlo, monospace;
  /* Interface chrome only — pills and the chords/numerals switch. Web-only:
     the EPUB ships just the display and mono faces. */
  --font-ui: ui, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --rule: #e5e5e5;
  --accent: #7a1f2b;
  --chord: #2c7a7b;
  --section: #9a9a9a;
  --paper: #fff;
  --fill: #f1f1f1;
  /* Shared by the solid meta pills and the chords/numerals switch, which should
     read as the same family of control. Tags stay fully round, so shape alone
     separates what a song is from how it's filed. */
  --pill-radius: 0.35rem;
  --tag-radius: 1rem;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0 auto;
  max-width: 46rem;
  padding: 0 1.25rem 4rem;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Site header */
.site {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.site .brand {
  font-style: italic;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--ink);
}

.site nav a {
  margin-left: 1rem;
  color: var(--muted);
  font-variant: small-caps;
  letter-spacing: 0.03em;
}

h1, h2, h3 {
  font-style: italic;
  font-weight: 700;
  line-height: 1.15;
}

/* Song page */
.song header h1 {
  margin-bottom: 0.2rem;
}

.song header h2 {
  margin-top: 0;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--muted);
}

.song .meta {
  color: var(--muted);
  margin: 0.2rem 0;
}

/* Key, recordings and tags share one wrapping row. Solid pills are what the
   song IS and what you can DO with it; hollow pills are how it's filed. The
   fill/outline split carries the distinction on its own, so it survives
   greyscale and colour-blindness rather than leaning on hue. */
.song .meta.pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.song .pill {
  display: inline-block;
  font-family: var(--font-ui);
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: var(--pill-radius);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.song .pill:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.song .pill.solid {
  border-color: transparent;
  background: var(--fill);
  color: var(--ink);
}

.song .pill.solid:hover {
  color: var(--accent);
}

.song .pill.tag {
  border-radius: var(--tag-radius);
}

.chart {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.35;
  overflow-x: auto;
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin: 1.25rem 0;
}

/* Each section/stanza block preserves its hand-aligned spacing. The gap
   between blocks is a margin (not a trailing blank line, which wouldn't render
   at a block's end): it shows between sections within a column but collapses
   at the top of a column, since it belongs to the preceding block. */
.chart .cb {
  white-space: pre;
}
.chart .cb:not(:last-child) {
  margin-bottom: 1lh;
}

.chart .chord {
  color: var(--chord);
}

.chart .section {
  color: var(--section);
}

.crosslinks {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 1.5rem;
}

/* Listings & indexes */
.songlist {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.songlist li {
  padding: 0.15rem 0;
}

.songlist .by {
  color: var(--muted);
}

.songlist .key {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0 0.4rem;
  border: 1px solid var(--rule);
  border-radius: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.artist-group {
  margin: 1.5rem 0;
}

.artist-group h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.intro {
  color: var(--muted);
}

.indexlist {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.indexlist li {
  padding: 0.15rem 0;
}

.indexlist .count {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: 0.4rem;
}

/* --- Header: content nav (left) vs settings cog (right) --- */
.site .left {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
}

details.settings {
  position: relative;
}

details.settings > summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
}
details.settings > summary::-webkit-details-marker {
  display: none;
}
details.settings > summary:hover {
  color: var(--ink);
}

details.settings .menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 10;
  min-width: 14rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 0.5rem;
  padding: 0.35rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0.55rem;
  border-radius: 0.35rem;
  cursor: pointer;
}
.setting:hover {
  background: #f6f6f6;
}

/* --- Wide-screen view --- */
/* Pre-paint bridge: the head script sets .pre-wide on <html> before <body>
   exists; settings.js moves it to body.wide on load. Both must read as wide. */
html.pre-wide body {
  max-width: none;
}

body.wide {
  max-width: none;
}

body.wide .chart {
  column-width: var(--col-width);
  column-gap: 2rem;
}
body.wide .chart .cb {
  break-inside: avoid;
}

body.wide .songlist,
body.wide .indexlist {
  column-width: 18rem;
  column-gap: 2rem;
}
body.wide .songlist li,
body.wide .indexlist li {
  break-inside: avoid;
}

/* Transpose control. Server-rendered `hidden`; song.js reveals it, so a
   no-JS page simply shows the chart in its original key.

   Layout is one flex row that wraps. Narrow: readout and mode switch share the
   top line, the track drops to its own full-width line below. Wide: the track
   stops growing at --track-max and the readout and switch sit either side of
   it, rather than a slider stretched across the whole window. */
.transposer {
  --track-max: 26rem;
  --thumb-w: 0.85rem;
  --thumb-h: 1.05rem;
  --track-h: 2px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1.75rem;
  margin: 1.25rem 0;
}

/* Only earns its place on narrow screens, where the tick labels are hidden and
   this is the sole indication of the current key. The wide layout drops it —
   see the media query below — because the highlighted tick already says it. */
.transposer .readout {
  order: 1;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.transposer .track {
  order: 3;
  flex: 1 1 100%;
}

@media (min-width: 34.01rem) {
  .transposer {
    justify-content: center;
  }
  /* Redundant here: the tick rail is visible and marks the current key. */
  .transposer .readout {
    display: none;
  }
  .transposer .track {
    order: 2;
    flex: 1 1 auto;
    max-width: var(--track-max);
  }
  .transposer .modes {
    order: 3;
  }
}

.transposer-rail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.transposer .slider-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
}

/* Drawn at the same stop the tick labels use, so the two cannot disagree.
   `--current` is the rail index 0-12, set by song.js on every render. */
.transposer .pointer {
  position: absolute;
  left: calc(var(--current, 6) * 100% / 12);
  top: 50%;
  width: var(--thumb-w);
  height: var(--thumb-h);
  transform: translate(-50%, -50%);
  background: var(--chord);
  clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%);
  pointer-events: none;
}

.transposer input[type="range"]:focus-visible ~ .pointer {
  background: var(--accent);
}

.transposer input[type="range"] {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background: none;
  height: var(--thumb-h);
  cursor: pointer;
}

/* A uniform track, deliberately not a filled one. The browser default fills in
   behind the thumb, which reads as a magnitude — a volume or a progress bar.
   This slider picks one of thirteen keys, so every stop is equal and the bar
   stays the same weight end to end. */
.transposer input[type="range"]::-webkit-slider-runnable-track {
  height: var(--track-h);
  background: var(--rule);
  border-radius: 1px;
}

.transposer input[type="range"]::-moz-range-track {
  height: var(--track-h);
  background: var(--rule);
  border-radius: 1px;
}

/* Firefox paints this segment left of the thumb; match it to the track so the
   fill disappears there too. */
.transposer input[type="range"]::-moz-range-progress {
  height: var(--track-h);
  background: var(--rule);
}

/* Invisible: `.pointer` is what you see. This keeps the native hit area, drag
   behaviour and keyboard stepping intact. */
.transposer input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--thumb-w);
  height: var(--thumb-h);
  margin-top: calc((var(--track-h) - var(--thumb-h)) / 2);
  background: transparent;
  border: 0;
}

.transposer input[type="range"]::-moz-range-thumb {
  width: var(--thumb-w);
  height: var(--thumb-h);
  background: transparent;
  border: 0;
  border-radius: 0;
}

.transposer input[type="range"]:focus-visible {
  outline: none;
}

/* Not dimmed here — see `.numerals-on .track`, which fades the whole rail as a
   unit so the hairline, pointer and labels lighten by the same amount. */

/* Segmented switch: two radios, one mutually exclusive choice. The inputs are
   visually hidden but still focusable, so keyboard and screen-reader behaviour
   is the native radio-group behaviour. */
.transposer .modes {
  order: 2;
  display: flex;
  border: 1px solid var(--rule);
  border-radius: var(--pill-radius);
  overflow: hidden;
}

/* The interface face, not the mono one: these are labels, not musical content.
   Mono belongs to the chart, the chord spans and the key names on the tick
   rail. Matches the meta pills, at their size. */
.transposer .mode {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  padding: 0.2rem 0.7rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.transposer .mode input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.transposer .mode:hover {
  color: var(--ink);
}

/* Monochrome on purpose: this switch picks how to read the chart, so it should
   sit quieter than the chord colour, which marks the selected key. */
.transposer .mode:has(input:checked) {
  background: var(--muted);
  color: var(--paper);
}

.transposer .mode:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Each label sits at its own stop, using the same expression as `.pointer`
   above. Flex `space-between` can't do this — it aligns the outer two labels by
   their outer edges rather than their centres — and matching the native thumb's
   travel didn't work either, because the browser's real thumb width differs
   from any value we can declare. Sharing one formula sidesteps both. */
.transposer .ticks {
  position: relative;
  height: 1.5em;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.transposer .ticks button {
  position: absolute;
  left: calc(var(--i) * 100% / 12);
  transform: translateX(-50%);
  background: none;
  border: 0;
  padding: 0.15rem 0.1rem;
  color: inherit;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}

.transposer .ticks button.current {
  color: var(--chord);
  font-weight: 700;
}

/* Numeral view locks the rail — the numerals are key-relative, so every stop
   renders the same. Fading the whole track as one unit keeps the hairline,
   pointer and labels at the same weight; dimming them separately left the
   pointer reading as heavier than everything around it. The pointer also drops
   the chord colour, which means "this is your key" — exactly the claim that
   stops holding here. */
.transposer.numerals-on .track,
.transposer.numerals-on .readout {
  opacity: 0.4;
}

/* The chord colour means "this is your key" on both of these. Numeral view is
   key-relative, so neither should keep asserting it — the pointer alone left
   the tick label, which is the more prominent of the two on wide screens,
   still coloured. */
.transposer.numerals-on .pointer {
  background: var(--muted);
}

.transposer.numerals-on .ticks button.current {
  color: inherit;
  font-weight: 400;
}

/* Visible only below the breakpoint, which is why these went unstyled: without
   them the browser's default button (Arial, outset border, grey fill) is the
   one control on the page ignoring the site's faces. */
.transposer .step {
  flex: none;
  width: 1.75rem;
  padding: 0.1rem 0;
  border: 1px solid var(--rule);
  border-radius: var(--pill-radius);
  background: none;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  line-height: 1.2;
  color: var(--muted);
  cursor: pointer;
}

.transposer .step:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--ink);
}

.transposer .step:disabled,
.transposer .ticks button:disabled {
  cursor: default;
}

/* Narrow screens: the tick labels don't fit, so the -/+ buttons carry it. */
@media (max-width: 34rem) {
  .transposer .ticks {
    display: none;
  }
}

@media (min-width: 34.01rem) {
  .transposer .step {
    display: none;
  }
}
