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

/* ChicagoFLF: public-domain clone of Chicago, the original iPod's screen font (ChicagoFLF-LICENSE.txt). */
@font-face { font-family: ChicagoFLF; src: url(ChicagoFLF.woff) format("woff"); font-display: block; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #d8d8d8;
}

[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } /* author display rules never beat the hidden attribute */
body {
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: Arial, "Liberation Sans", sans-serif;
}

/* Body finish. Settings > Color swaps it (menu.js sets data-color on <html>). White is the 5G; Black and Silver the classic. */
.ipod {
  --face: linear-gradient(#f6f6f4, #e8e8e6); --edge: #bbb;
  --wheel: radial-gradient(#cfcfcf, #bdbdbd); --wheel-edge: #b0b0b0; --label: #f2f2f2;
  --center: linear-gradient(#fafafa, #ececec); --center-edge: #b8b8b8; --center-down: #e2e2e2;
}
[data-color="Black"] .ipod {
  --face: linear-gradient(#1e1e1e, #0a0a0a); --edge: #000;
  --wheel: radial-gradient(#141414, #050505); --wheel-edge: #2a2a2a; --label: #e8e8e8;
  --center: radial-gradient(#141414, #050505); --center-edge: #2a2a2a; --center-down: #222;
}
[data-color="Silver"] .ipod {
  --face: linear-gradient(#d2d3d5, #b4b5b7); --edge: #9a9b9d;
  --wheel: radial-gradient(#f7f7f7, #e6e6e6); --wheel-edge: #c4c4c4; --label: #8e8e8e;
  --center: linear-gradient(#cfd0d2, #b9babc); --center-edge: #a8a9ab; --center-down: #b0b1b3;
}

/* Fills a phone; capped on desktop. Proportions follow the 4th-gen device. */
.ipod {
  width: min(100vw, 100dvh * 0.6, 420px);
  aspect-ratio: 0.6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  background: var(--face);
  border-radius: 6%/3.6%;
  box-shadow: 0 0 0 1px var(--edge), 0 10px 30px rgb(0 0 0 / 0.25);
}

/* Phone: the device fills the screen. */
@media (max-width: 500px) {
  .ipod { width: 100vw; height: 100dvh; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
}

/* Screen colors. Settings > Contrast swaps them (menu.js sets data-contrast on <html>). */
.screen { --ink: #2a2a2a; --lcd: #c6c6c6; --hi: #dadada; }
[data-contrast="High"] .screen { --ink: #0c0c0c; --lcd: #d2d2d2; --hi: #ececec; }
[data-contrast="Low"] .screen { --ink: #5c5c5c; --lcd: #bababa; --hi: #cecece; }

/* Color emoji (playlist names) render as one-color silhouettes: transparent fill plus a solid shadow in the text color.
   No `filter`: iOS Safari sizes a filtered layer to its first visible frame, so a scrolling marquee paints blank. */
#title, #list .lab > span, #now p > span, #s-hits p { -webkit-text-fill-color: transparent; text-shadow: 0 0 0 currentColor; }

.screen {
  width: 84%;
  aspect-ratio: 4 / 3;
  container-type: size;
  display: flex;
  flex-direction: column;
  background: var(--lcd);
  color: var(--ink);
  border: 2px solid #6e6e6e;
  border-radius: 6px;
  overflow: hidden;
  font-family: ChicagoFLF, Arial, sans-serif;
  font-synthesis: none; /* Chicago is already heavy; no faux bold */
}

.titlebar {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  background: linear-gradient(#dedede, #b6b6b6);
  border-bottom: 0.6cqh solid #5a5a5a;
  font-size: 7cqh; /* matches the list */
}

/* One line, clear of the status and battery. `contain` clips Zalgo marks to their own row. */
#title { max-width: 72cqw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; contain: paint; }

/* Play/pause status, left of the title. */
.status { position: absolute; left: 3cqw; font-size: 6cqh; }
.status[data-s]::before { content: ""; display: block; }
.status[data-s="play"]::before { border-left: 0.75em solid; border-block: 0.45em solid transparent; }
.status[data-s="pause"]::before { width: 0.16em; height: 0.85em; border-inline: 0.26em solid; } /* width is the gap: `*` box-sizing skips ::before */

.battery {
  position: absolute;
  right: 3cqw;
  width: 7cqw;
  height: 5cqh;
  border: 0.6cqh solid var(--ink);
  background: linear-gradient(90deg, var(--ink) 70%, transparent 70%);
}
.battery::after {
  content: "";
  position: absolute;
  right: -1.6cqh;
  top: 25%;
  width: 1cqh;
  height: 50%;
  background: var(--ink);
}

.body { flex: 6; display: flex; min-height: 0; position: relative; }

#list {
  flex: 1;
  min-width: 0;
  list-style: none;
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  font-size: 7cqh;
}

#list li {
  contain: paint;
  display: flex;
  align-items: center;
  padding: 0 3cqw;
  white-space: nowrap;
  overflow: hidden;
}
#list li.sub::after { content: "\203A"; margin-left: auto; padding-left: 2cqw; font-size: 1.3em; }
#list li.hl { background: var(--ink); color: var(--hi); }
#list .lab { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Marquee (app.js sets --shift, --dur, --delay): hold, scroll to the end, hold, snap back. */
#list .lab.marquee, #now p.marquee { text-overflow: clip; }
.marquee > span { display: inline-block; animation: marquee var(--dur) linear var(--delay, 0s) infinite; will-change: transform; }
@keyframes marquee { 0%, 25% { transform: none; } 85%, 100% { transform: translateX(var(--shift)); } }

/* Text screen (Legal): paragraphs the wheel or a finger scrolls. */
#text { flex: 1; min-width: 0; overflow-y: auto; touch-action: pan-y; padding: 2cqh 4cqw; font-size: 6cqh; line-height: 1.3; }
#text p + p { margin-top: 2cqh; }

/* Search: query, a few live hits, letter strip with the picked letter boxed. */
#search { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 1cqh 3cqw; font-size: 6.2cqh; }
#search p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#s-query { border-bottom: 0.6cqh solid var(--ink); padding-bottom: 1cqh; }
#s-hits { flex: 1; padding-top: 1cqh; }
#s-strip { display: grid; grid-template-columns: repeat(9, 1fr); text-align: center; border-top: 0.6cqh solid var(--ink); padding-top: 1cqh; }
#s-strip .cur { background: var(--ink); color: var(--hi); }
#s-strip .word { font-size: 0.75em; align-self: center; }

/* Classic spinner, centered on the screen body: while a list is empty and loading, or a Spotify call runs (app.js). */
.body.busy::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  margin: auto;
  width: 18cqh;
  height: 18cqh;
  /* 12 spokes fading dark to light, stepping 30° per tick like the wheel. */
  background: conic-gradient(var(--lcd), var(--ink));
  --spokes: repeating-conic-gradient(#000 0 18deg, transparent 0 30deg);
  mask: radial-gradient(transparent 38%, #000 40% 70%, transparent 72%) intersect, var(--spokes);
  animation: spin 1s steps(12) infinite;
}
/* A screen-colored tile under it, so rows behind don't show through the spokes. */
.body.busy::before { content: ""; position: absolute; inset: 0; margin: auto; width: 24cqh; height: 24cqh; background: var(--lcd); border-radius: 3cqh; z-index: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Now Playing: count top-left, three centered lines, progress bar with elapsed and remaining. */
#now {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 30cqh minmax(0, 1fr);
  column-gap: 4cqw;
  align-content: space-evenly;
  align-items: center;
  padding: 0 5cqw;
  font-size: 7.5cqh;
  text-align: center;
}
#now p { contain: paint; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#np-count { text-align: left; font-size: 6.5cqh; }
/* Art sits left of title/artist/album; the rest spans both columns. No art: one column. */
#np-count, #now .progress, #now .times { grid-column: 1 / -1; }
#np-art { grid-row: 2 / span 3; width: 30cqh; image-rendering: pixelated; }
#now:has(#np-art[hidden]) { grid-template-columns: minmax(0, 1fr); }
.progress { height: 6cqh; border: 0.6cqh solid var(--ink); background: var(--hi); }
#np-fill { height: 100%; width: 0; background: var(--ink); }
.times { display: flex; justify-content: space-between; font-size: 6.5cqh; }
#now.vol .times { visibility: hidden; }

#scrollbar {
  position: relative;
  width: 4cqw;
  border-left: 0.6cqh solid var(--ink);
  background: var(--hi);
}
#thumb { position: absolute; left: 0; right: 0; background: var(--ink); }

/* Click wheel */
.wheel {
  position: relative;
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--wheel);
  box-shadow: inset 0 0 0 1px var(--wheel-edge);
  container-type: size;
  touch-action: none;
  cursor: grab;
}

.label {
  position: absolute;
  color: var(--label);
  font-size: 9cqw;
  font-weight: bold;
  line-height: 1;
  transform: translate(-50%, -50%);
}
.menu { left: 50%; top: 11%; font-size: 7.5cqw; letter-spacing: 0.05em; }
.prev { left: 12%; top: 50%; }
.next { left: 88%; top: 50%; }
.play { left: 50%; top: 89%; }

.center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 37%;
  height: 37%;
  transform: translate(-50%, -50%);
  border: none;
  border-radius: 50%;
  background: var(--center);
  box-shadow: 0 0 0 1px var(--center-edge);
  cursor: pointer;
}
.center:active { background: var(--center-down); }

/* 404.html: the whole page is one link home. */
.home { position: fixed; inset: 0; display: grid; place-items: center; color: inherit; text-decoration: none; }
.sad { height: 80%; margin: auto; image-rendering: pixelated; }
