/* Storify: warm paper, ink text and one teal accent for recorded listening. */

:root {
  color-scheme: light dark;
  --paper: #f6f3ec;
  --surface: #fffdf8;
  --ink: #1f1d1a;
  --muted: #5d5850;
  --line: #d9d3c7;
  --accent: #0d6b63;
  --accent-ink: #ffffff;
  --accent-soft: #dcefeb;
  --partial: #8a5100;
  --focus: #b54708;
  --radius: 12px;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171614;
    --surface: #221f1c;
    --ink: #f1ede4;
    --muted: #bdb5a8;
    --line: #3d3934;
    --accent: #5cc2b6;
    --accent-ink: #10201e;
    --accent-soft: #1f3a36;
    --partial: #e7a84a;
    --focus: #f59e0b;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0 auto;
  max-width: 72rem;
  padding: 0 1rem 2rem;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
  overflow-wrap: anywhere;
}

h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); }
ol, ul { margin: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip { position: absolute; left: -100vw; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: 0.5rem 1rem; z-index: 1; }

.muted, .sources { color: var(--muted); font-size: 0.95rem; }
.empty { color: var(--muted); font-style: italic; }

/* Masthead and import */

.masthead {
  display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; align-items: end; justify-content: space-between;
  padding: 1rem 0; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem;
}
.brand { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.logo { font: 700 1.6rem/1 var(--serif); margin: 0; letter-spacing: 0.02em; }
.tagline { margin: 0; color: var(--muted); font-style: italic; }

.field { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field.grow { flex: 1 1 16rem; }
select, input[type="search"] {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 0.45rem 0.6rem;
  max-width: 100%; min-height: 2.5rem;
}
#timezone { width: 18rem; }

.import {
  display: grid; gap: 1rem 2rem; grid-template-columns: minmax(0, 1fr);
  margin-bottom: 1.5rem;
}
@media (min-width: 52rem) {
  .import { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}
.lede { font-size: 1.1rem; max-width: 42rem; }
.picker { position: relative; display: inline-block; margin-bottom: 0.5rem; }
.picker input { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; }
.picker:focus-within label { outline: 3px solid var(--focus); outline-offset: 2px; }
.progress-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.status:empty, .error:empty { display: none; }
.error {
  color: var(--ink); background: var(--surface); border-left: 4px solid var(--focus);
  padding: 0.6rem 0.8rem; border-radius: 4px;
}
.export-help {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem;
}
.export-help summary { font: 600 1.15rem var(--serif); cursor: pointer; }
.export-help ol { padding-left: 1.25rem; margin: 0.75rem 0; }
.export-help li { margin-bottom: 0.5rem; }

.has-results .import { grid-template-columns: minmax(0, 1fr); margin-bottom: 1rem; }
.has-results .import h1 { font-size: 1.1rem; font-family: var(--sans); }
.has-results .lede, .has-results .sample { display: none; }
.has-results .import-main { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }
.has-results .import-main > * { margin: 0; }

/* Buttons and Spotify links */

.button {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.45rem 0.95rem;
  min-height: 2.5rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.button.quiet { background: transparent; }
.button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.button[aria-expanded="true"] { border-color: var(--accent); }
.button:disabled { opacity: 0.45; cursor: default; }

.spotify {
  display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0.25rem 0.7rem;
  border: 1px solid var(--line); border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  text-decoration: none; white-space: nowrap; background: var(--surface);
}
.spotify:hover { border-color: var(--accent); }

.segmented { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.modes { margin-bottom: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin-bottom: 0.75rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }

/* Views and panels */

.view-head { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.view-head h2 { margin: 0; flex: 1 1 12rem; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: 1rem; min-width: 0;
}
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem; align-items: end; margin-bottom: 0.75rem; }
.panel-head h3 { margin: 0; }
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.cards .panel { margin: 0; display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.cards .panel > div, .cards .panel > ol, .cards .panel > section { align-self: stretch; }
.columns { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.import-summary { margin-bottom: 1rem; }
.import-summary summary { cursor: pointer; font-weight: 600; }
.dates, .coverage { font-weight: 600; }
.comparison { color: var(--muted); }

.tag {
  display: inline-block; font: 600 0.75rem/1.4 var(--sans); padding: 0 0.45rem;
  border-radius: 999px; border: 1px solid currentColor; white-space: nowrap;
}
.tag.partial { color: var(--partial); }

/* Measures */

.measures { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); margin: 0.75rem 0 1rem; }
.measures.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); }
.measures .measure {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem;
}
.measure-value { font: 700 1.5rem/1.2 var(--serif); font-variant-numeric: tabular-nums; }
.measure-label { color: var(--muted); font-size: 0.9rem; }
.measure.unavailable .measure-value { color: var(--muted); font-size: 1.1rem; overflow-wrap: normal; }
.row-measures { display: flex; gap: 1rem; }
.row-measures .measure { display: flex; gap: 0.3rem; align-items: baseline; }
.row-measures .measure-value { font: 600 1rem var(--sans); }

/* Trend: one labelled bar per period, which is also the text equivalent. */

.chart { list-style: none; padding: 0; max-height: 30rem; overflow-y: auto; }
.bar-row {
  display: grid; grid-template-columns: 3.5rem minmax(0, 1fr) auto auto; gap: 0.6rem; align-items: center;
  width: 100%; min-height: 2.25rem; padding: 0.2rem 0.4rem; border-radius: 8px;
  font: inherit; color: inherit; text-align: left; background: none; border: 1px solid transparent;
}
button.bar-row { cursor: pointer; }
button.bar-row:hover { background: var(--accent-soft); }
.bar-label { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { height: 1rem; }
.bar { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.bar.is-partial, .key.is-partial::before {
  background: repeating-linear-gradient(135deg, var(--accent) 0 4px, var(--accent-soft) 4px 7px);
}
.bar-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-note { grid-column: 2 / 4; color: var(--muted); font-size: 0.9rem; font-style: italic; }
.bar-row.outside { color: var(--muted); }
.bar-row.outside .bar-note { border-top: 1px dashed var(--line); padding-top: 0.15rem; }

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0 0; }
.key { display: inline-flex; align-items: center; gap: 0.4rem; }
.key::before { content: ""; width: 1.2rem; height: 0.7rem; border-radius: 2px; }
.key.recorded::before { background: var(--accent); }
.key.empty::before { border: 1px solid var(--muted); }
.key.outside::before { border: 1px dashed var(--muted); opacity: 0.6; }

/* Result rows */

.results { list-style: none; padding: 0; margin: 0; }
.result {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1rem;
  padding: 0.65rem 0; border-top: 1px solid var(--line);
}
.results > li:first-child > .result, .results > .result:first-child { border-top: 0; }
.result-text { flex: 1 1 14rem; min-width: 0; display: flex; flex-direction: column; }
.result-title { font-weight: 600; }
.result-sub, .result-facts { color: var(--muted); font-size: 0.9rem; }
.result-facts { flex: 1 1 12rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.nested + .nested > .result { border-top: 1px solid var(--line); }
.subpanel {
  border-left: 3px solid var(--accent); padding: 0.5rem 0 0.5rem 0.9rem; margin: 0 0 0.75rem 0.25rem;
}
.pager { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-top: 0.75rem; }

/* Year Recap */

.chapter {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; margin: 0.75rem 0;
}
.figure { font: 700 1.6rem/1.25 var(--serif); margin-bottom: 0.5rem; }
.story { font-size: 1.15rem; }
.recap-nav .button.primary { min-width: 6rem; }

/* Royalties */

.answer { font: 600 1.1rem var(--serif); }
.royalty-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); margin-bottom: 1rem; }
.royalty-block { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.royalty-block.personal { border-style: dashed; }
.royalty-block.citation { border-left: 4px solid var(--accent); }

.footer { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: 1rem; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 30rem) {
  body { padding: 0 0.75rem 1.5rem; }
  .panel, .chapter { padding: 0.9rem; }
  .bar-row { grid-template-columns: 3rem minmax(0, 1fr) auto; }
  .bar-row .tag { grid-column: 2 / -1; justify-self: start; }
  #timezone { width: 100%; }
  .masthead .field { flex: 1 1 100%; }
}
