/* Scrobbler. Cool paper, ink, and an oxblood record-label accent. */

:root {
  --paper: #eef1f4;
  --paper-raised: #f8f9fb;
  --ink: #18222f;
  --ink-soft: #4e5b6b;
  --ink-faint: #7c8796;
  --rule: #d3dae2;
  --label: #8c2f39;        /* accent: the record label */
  --label-soft: #e8cfd2;
  --vinyl: #1d1f24;
  --vinyl-groove: #2c2f36;
  --bar: #8c2f39;

  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --text: "Instrument Sans", "Helvetica Neue", system-ui, sans-serif;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.625rem;
  --step-3: clamp(2rem, 5vw + 0.5rem, 3.5rem);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15181d;
    --paper-raised: #1c2027;
    --ink: #e9e6e1;
    --ink-soft: #b4b0aa;
    --ink-faint: #8a8781;
    --rule: #2d323b;
    --label: #e0848d;
    --label-soft: #4a2a2f;
    --vinyl: #08090c;
    --vinyl-groove: #3a3f48;
    --bar: #d97a84;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.5 var(--text);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

main, .masthead {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
}
@media (min-width: 48rem) { main, .masthead { padding: 0 2rem; } }

a { color: inherit; text-underline-offset: 0.2em; }
a:hover { color: var(--label); }
:focus-visible { outline: 2px solid var(--label); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0; }
h2 { font-size: var(--step-1); margin-bottom: 1rem; }
h3 { font-size: var(--step-0); margin: 1.5rem 0 0.5rem; }
small { display: block; color: var(--ink-soft); font-size: var(--step--1); }
.quiet { color: var(--ink-faint); }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.875em; }

.link-button {
  background: none; border: 0; padding: 0; font: inherit; color: inherit;
  text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer;
}
.link-button:hover { color: var(--label); }
.danger { color: var(--ink-faint); font-size: var(--step--1); }

/* --- masthead --- */
.masthead {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-top: 1.25rem; padding-bottom: 1.25rem;
}
.wordmark { font-family: var(--display); font-weight: 700; font-size: var(--step-1); text-decoration: none; }
.account { font-size: var(--step--1); color: var(--ink-soft); }

/* --- turntable: the one loud thing on the page --- */
.turntable {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem;
  align-items: end;
  padding: 1.5rem 0 3rem;
}
@media (min-width: 48rem) {
  .turntable { grid-template-columns: 22rem minmax(0, 1fr); gap: 4.5rem; padding: 2.5rem 0 4rem; }
}

.sleeve {
  position: relative;
  width: min(72vw, 18rem);
  aspect-ratio: 1;
}
@media (min-width: 48rem) { .sleeve { width: 18rem; } }

.sleeve img, .sleeve-blank {
  position: relative; z-index: 2;
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 18px 40px -18px rgba(10, 20, 35, .55);
}
.sleeve-blank {
  display: grid; place-items: center;
  background: var(--label); color: var(--paper);
  font: 700 7rem/1 var(--display);
}

.record {
  position: absolute; z-index: 1;
  top: 4%; left: 22%;
  width: 92%; aspect-ratio: 1; border-radius: 50%;
  background:
    radial-gradient(circle, var(--paper) 0 3%, var(--label) 3.4% 17%, transparent 17.4%),
    repeating-radial-gradient(circle, var(--vinyl) 0 2px, var(--vinyl-groove) 2px 3px);
  transition: left 600ms cubic-bezier(.2,.8,.2,1);
}
.is-playing .record { left: 38%; animation: spin 1.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .record { transition: none; }
  .is-playing .record { animation: none; }
}

.spin-text { min-width: 0; }
.spin-state { margin: 0 0 0.75rem; color: var(--label); font-weight: 600; font-size: var(--step--1); }
.is-playing .spin-state::before {
  content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; margin-right: 0.5rem;
  border-radius: 50%; background: currentColor; vertical-align: 0.05em;
}
.spin-track {
  font-size: var(--step-3);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.spin-artist { margin: 0.75rem 0 0; font-size: var(--step-1); color: var(--ink-soft); }
.spin-album { display: block; font-size: var(--step-0); color: var(--ink-faint); margin-top: 0.25rem; }

.empty { padding: 3rem 0; max-width: 40rem; }
.empty h1 { font-size: var(--step-2); margin-bottom: 0.75rem; }
.webhook {
  display: inline-block; padding: 0.5rem 0.75rem; border-radius: 4px;
  background: var(--paper-raised); border: 1px solid var(--rule);
  overflow-wrap: anywhere;
}

/* --- period + totals --- */
.period {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end;
  gap: 1.5rem; padding: 1.25rem 0; border-top: 1px solid var(--rule);
}
.ranges { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.ranges a {
  padding: 0.375rem 0.75rem; border-radius: 999px; text-decoration: none;
  font-size: var(--step--1); color: var(--ink-soft);
}
.ranges a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.totals { display: flex; gap: 2rem; margin: 0; }
.totals div { display: flex; flex-direction: column-reverse; }
.totals dt { font-size: var(--step--1); color: var(--ink-faint); }
.totals dd { margin: 0; font: 700 var(--step-2)/1 var(--display); }

/* --- daily chart --- */
.chart-block { padding: 2rem 0; border-top: 1px solid var(--rule); }
.chart-block h2 { font-size: var(--step-0); font-family: var(--text); font-weight: 600; color: var(--ink-soft); }
.daily { display: block; width: 100%; height: 9rem; overflow: visible; }
.daily .hit { fill: transparent; }
.daily .mark { fill: var(--bar); }
.daily .bar:hover .mark { fill: var(--ink); }
.daily .baseline { stroke: var(--rule); stroke-width: 1; }
.chart-axis {
  display: flex; justify-content: space-between;
  font-size: var(--step--1); color: var(--ink-faint); margin-top: 0.375rem;
}
.chart-table { margin-top: 0.75rem; font-size: var(--step--1); color: var(--ink-soft); }
.chart-table summary { cursor: pointer; }
.chart-table table { margin-top: 0.5rem; border-collapse: collapse; }
.chart-table td, .chart-table th { padding: 0.125rem 1.5rem 0.125rem 0; text-align: left; }

/* --- streaks (in the daily chart header) --- */
.chart-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline;
  gap: 0.5rem 2rem; margin-bottom: 1rem;
}
.chart-head h2 { margin: 0; }
.streaks { display: flex; gap: 1.5rem; margin: 0; }
.streaks div { display: flex; align-items: baseline; gap: 0.5rem; }
.streaks dt { font-size: var(--step--1); color: var(--ink-faint); }
.streaks dd { margin: 0; font-weight: 600; }
.streak-note { margin: -0.5rem 0 1rem; font-size: var(--step--1); color: var(--label); }

/* --- when you listen: 7 days x 24 hours --- */
.clock-summary { margin: -0.25rem 0 1rem; color: var(--ink-soft); }
.clock-summary strong { color: var(--ink); font-weight: 600; }
.clock {
  display: grid;
  grid-template-columns: 2.25rem repeat(24, minmax(0, 1fr));
  gap: 2px;
  max-width: 48rem;
}
.clock-day { font-size: var(--step--1); color: var(--ink-faint); line-height: 1; align-self: center; }
.clock .cell {
  aspect-ratio: 1; border-radius: 2px;
  background: color-mix(in srgb, var(--bar) calc(var(--v, 0) * 100%), var(--paper-raised));
}
.clock .cell:hover { outline: 1.5px solid var(--ink); outline-offset: -1px; }
.clock-hour { font-size: var(--step--1); color: var(--ink-faint); padding-top: 0.25rem; }

/* --- discoveries --- */
.discoveries { padding: 2rem 0; border-top: 1px solid var(--rule); }
.discovery-counts { margin: -0.25rem 0 1rem; color: var(--ink-soft); }
.discovery-counts strong { color: var(--ink); font-weight: 600; }
.found {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 0.75rem 2rem;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
}
.found .name { font-weight: 500; overflow-wrap: anywhere; }

/* --- charts --- */
.charts {
  display: grid; gap: 2.5rem 3rem;
  grid-template-columns: minmax(0, 1fr);
  padding: 2rem 0; border-top: 1px solid var(--rule);
}
@media (min-width: 48rem) {
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .albums-block { grid-column: 1 / -1; }
}

.ranked { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.ranked li {
  counter-increment: rank;
  position: relative;
  display: grid; grid-template-columns: 1.75rem minmax(0, 1fr) auto; gap: 0.5rem;
  align-items: baseline;
  padding: 0.5rem 0 0.625rem;
}
.ranked li::before { content: counter(rank); color: var(--ink-faint); font-size: var(--step--1); }
.ranked li::after {
  content: ""; position: absolute; left: 2.25rem; bottom: 0.25rem;
  height: 3px; border-radius: 2px;
  width: calc((100% - 2.25rem) * var(--share, 0));
  background: var(--bar); opacity: 0.85;
}
.ranked .name { min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.ranked .plays { color: var(--ink-soft); font-size: var(--step--1); }

.crate {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1.5rem 1rem;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
}
.crate img, .cover-blank {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block; border-radius: 3px;
}
.cover-blank, .thumb-blank {
  display: grid; place-items: center;
  background: var(--label-soft); color: var(--label);
  font: 700 2.5rem/1 var(--display);
}
.album-title { margin: 0.5rem 0 0; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.album-meta, .album-plays { margin: 0.125rem 0 0; font-size: var(--step--1); color: var(--ink-soft); }
.album-plays { color: var(--ink-faint); }

/* --- history --- */
.history { padding: 2rem 0; border-top: 1px solid var(--rule); }
.log { list-style: none; margin: 0; padding: 0; }
.log li {
  display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto; gap: 0.875rem;
  align-items: center; padding: 0.5rem 0;
}
.log li:has(form) { grid-template-columns: 2.5rem minmax(0, 1fr) auto auto; }
.log img, .thumb-blank { width: 2.5rem; height: 2.5rem; border-radius: 2px; object-fit: cover; }
.log-track { min-width: 0; overflow-wrap: anywhere; }
.log time { font-size: var(--step--1); color: var(--ink-faint); white-space: nowrap; }
@media (max-width: 30rem) {
  .log li, .log li:has(form) { grid-template-columns: 2.5rem minmax(0, 1fr); }
  .log time, .log form { grid-column: 2; }
}
.pager { display: flex; gap: 1.5rem; margin-top: 1rem; }

/* --- admin + login --- */
.admin { padding: 2rem 0 4rem; border-top: 1px solid var(--rule); }
.ignored { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.ignored th, .ignored td { text-align: left; padding: 0.375rem 1rem 0.375rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ignored th { color: var(--ink-faint); font-weight: 500; }
@media (max-width: 40rem) { .admin { overflow-x: auto; } }

.login { max-width: 24rem; padding: 4rem 0; }
.login h1 { font-size: var(--step-2); margin-bottom: 0.75rem; }
.login p { color: var(--ink-soft); }
.login form { display: grid; gap: 0.5rem; margin-top: 1.5rem; }
.login input {
  font: inherit; padding: 0.625rem 0.75rem; border-radius: 4px;
  border: 1px solid var(--rule); background: var(--paper-raised); color: var(--ink);
}
.login button {
  margin-top: 0.75rem; font: 600 var(--step-0) var(--text); padding: 0.625rem 1rem;
  border: 0; border-radius: 4px; background: var(--ink); color: var(--paper); cursor: pointer;
}
.login button:hover { background: var(--label); }
.error { color: var(--label) !important; font-weight: 500; }
