/* Storify look: warm paper, dark ink and one teal accent. System fonts only, so the page
   never fetches a third-party resource. */

:root {
  --paper: #f7f4ee;
  --card: #ffffff;
  --ink: #1f1c24;
  --muted: #5c5766;
  --line: #ddd6ca;
  --accent: #0b6b6b;
  --accent-soft: #d8ecea;
  --empty: #8a8394;
  --error: #a3261b;
  --focus: #1d4ed8;
  --radius: 10px;
  color-scheme: light;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--accent);
}

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

[hidden] {
  display: none !important;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--card);
  color: var(--accent);
  padding: 0.4rem 0.9rem;
  min-height: 2.5rem;
}

button:hover {
  background: var(--accent-soft);
}

button[aria-pressed='true'],
button[aria-expanded='true'] {
  background: var(--accent);
  color: #fff;
}

button:disabled {
  cursor: not-allowed;
  border-color: var(--line);
  color: var(--empty);
  background: transparent;
}

select,
input[type='search'] {
  border: 1px solid var(--muted);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  padding: 0.4rem 0.5rem;
  min-height: 2.5rem;
  max-width: 100%;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
}

/* Masthead: import and time zone stay available in every view. */
.masthead {
  background: var(--ink);
  color: #fff;
  padding: 0.75rem 1rem;
}

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem 1.5rem;
  max-width: 68rem;
  margin: 0 auto;
}

.brand {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0 auto 0 0;
}

.import {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  min-width: 0;
}

.import label {
  flex-basis: 100%;
}

.import input {
  max-width: 100%;
}

.masthead button {
  border-color: #fff;
  color: #fff;
  background: transparent;
}

.masthead .status,
.masthead .error {
  max-width: 68rem;
  margin: 0.5rem auto 0;
}

.status:empty,
.error:empty {
  display: none;
}

.masthead .error {
  background: #fff;
  color: var(--error);
  border-left: 4px solid var(--error);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
}

main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.welcome {
  margin-bottom: 1rem;
}

.guide {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.guide summary {
  cursor: pointer;
}

.guide summary h2 {
  display: inline;
  font-size: 1.1rem;
}

.guide ol {
  padding-left: 1.25rem;
}

.sources {
  font-size: 0.9rem;
  color: var(--muted);
}

.footer {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Views */
.view {
  display: grid;
  gap: 1.25rem;
}

.view-head .back {
  margin-bottom: 0.75rem;
}

.view-head h1:focus {
  outline: none;
}

.coverage,
.hint,
.legend {
  color: var(--muted);
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  min-width: 0;
}

.columns {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
}

.actions,
.toolbar,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: end;
}

.toolbar {
  margin-bottom: 1rem;
}

.search {
  flex: 1 1 14rem;
  align-items: stretch;
}

.measures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  gap: 0.75rem;
  margin: 0;
}

.measure {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.measure dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.measure dd {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.measures.compact .measure {
  padding: 0.5rem 0.75rem;
}

/* Trend bars: each entry is a labelled button, so the chart is also its own text equivalent. */
.bars {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  max-height: 32rem;
  overflow-y: auto;
}

.bar {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) minmax(6.5rem, auto);
  align-items: center;
  gap: 0.25rem 0.75rem;
  width: 100%;
  text-align: left;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 0.3rem 0.5rem;
  min-height: 2.5rem;
}

button.bar:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.bar-label {
  font-weight: 600;
}

.bar-track {
  height: 0.9rem;
  border-radius: 4px;
  background: var(--paper);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  width: calc(var(--share) * 100%);
  background: var(--accent);
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bar-note {
  grid-column: 2 / -1;
  font-size: 0.85rem;
  color: var(--muted);
}

.bar-empty .bar-track {
  background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px);
}

.bar-empty .bar-value,
.bar-outside {
  color: var(--empty);
}

.bar-outside .bar-track {
  background: repeating-linear-gradient(135deg, var(--line) 0 4px, transparent 4px 8px);
}

/* Result rows */
.rows {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
}

.rows > li {
  border-top: 1px solid var(--line);
}

.rows > li:first-child {
  border-top: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.5rem 0;
}

.row .what {
  flex: 1 1 14rem;
  min-width: 0;
}

.row .name {
  font-weight: 600;
}

.spotify::after {
  content: ' \2197';
  font-weight: 400;
}

.byline,
.album {
  display: inline;
  color: var(--muted);
}

.byline::before {
  content: ' ';
}

.album::before {
  content: ' \00b7\0020';
}

.when {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.9rem;
}

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  font-variant-numeric: tabular-nums;
}

.rank {
  min-width: 1.75rem;
  color: var(--muted);
}

.artist-tracks,
.track-plays {
  margin: 0 0 0.75rem 1rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--accent-soft);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.filter {
  background: var(--accent-soft);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
}

.summary summary {
  cursor: pointer;
  font-weight: 600;
}

/* Royalties: three blocks kept visibly apart. */
.royalty-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  margin: 1rem 0;
}

.royalty-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.royalty-block.citation {
  border-style: dashed;
  background: var(--paper);
}

.headline {
  font-size: 1.35rem;
  font-weight: 700;
}

.royalties h2:focus {
  outline: none;
}

/* Recap */
.progress {
  color: var(--muted);
  margin: 0;
}

.chapter {
  min-height: 14rem;
}

@media (prefers-reduced-motion: no-preference) {
  .chapter {
    animation: rise 160ms ease-out;
  }
}

@keyframes rise {
  from {
    opacity: 0.4;
    transform: translateY(4px);
  }
}
