/* ============================================================
   iPod · Spotify — pantalla completa
   ============================================================ */

:root {
  --shell-1: #fdfdfd;
  --shell-2: #dcdde1;
  --shell-edge: rgba(0,0,0,.18);
  --lcd-1: #cfe0e8;
  --lcd-2: #a9c3d0;
  --lcd-ink: #16202a;
  --accent: #1db954;
  --out: cubic-bezier(.2,.7,.2,1);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: #08090b;
  color: #e9eaee;
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* ─── fons: portada difuminada ─── */

.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; background: #08090b; }
.bg__img {
  position: absolute; inset: -12%;
  background: center / cover no-repeat;
  filter: blur(70px) saturate(1.5) brightness(.55);
  transform: scale(1.15);
  opacity: 0;
  transition: opacity .8s ease, background-image .1s;
}
.bg__img.is-on { opacity: .85; }
.bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, rgba(0,0,0,.15), rgba(0,0,0,.78) 78%);
}

/* ─── escenari ─── */

.stage {
  position: relative; z-index: 1;
  height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
}

/* ═══════════════════════ iPod ═══════════════════════ */

.ipod {
  --w: min(440px, 90vw, 62dvh);
  width: var(--w);
  font-size: calc(var(--w) * .04);
  padding: 1.417em 1.417em 1.75em;   /* % es mesuraria sobre el pare, no sobre l'iPod */
  border-radius: 8.7%/5.7%;
  background: linear-gradient(150deg, var(--shell-1) 0%, var(--shell-2) 58%, var(--shell-1) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.85),
    inset 0 0 0 1px var(--shell-edge),
    0 2px 3px rgba(0,0,0,.2),
    0 40px 80px -30px rgba(0,0,0,.9);
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  flex: none;
}
.ipod:focus, .ipod:focus-visible { outline: none; }
.ipod *:focus, .ipod *:focus-visible { outline: none; }
.wheel__btn, .wheel__center { -webkit-tap-highlight-color: transparent; }

.ipod__screen {
  border-radius: 1.7%;
  padding: .85em;
  background: linear-gradient(180deg, #14161a, #26292f);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.75), 0 1px 0 rgba(255,255,255,.6);
}

.screen {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 2px;
  overflow: hidden;
  background: linear-gradient(175deg, var(--lcd-1), var(--lcd-2));
  color: var(--lcd-ink);
  line-height: 1.25;
  display: flex; flex-direction: column;
  box-shadow: inset 0 0 22px rgba(20,40,60,.22);
}
.screen::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: linear-gradient(197deg, rgba(255,255,255,.5) 0%, rgba(255,255,255,0) 42%);
  mix-blend-mode: soft-light;
}

/* ─── barra superior ─── */

.screen__bar {
  flex: none; display: flex; align-items: center; gap: .5em;
  padding: .25em .5em;
  background: linear-gradient(180deg, #f4f7f8, #c3ced4);
  border-bottom: 1px solid #8c9aa2;
  font-size: .875em; font-weight: 600;
}
.screen__title {
  flex: 1; min-width: 0; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: -.01em;
}
.screen__play {
  flex: none; width: 1em; height: 1em;
  background: currentColor; opacity: 0;
  clip-path: polygon(15% 5%, 15% 95%, 92% 50%);
  transition: opacity .2s;
}
.screen__play.is-play { opacity: .75; }
.screen__play.is-pause {
  opacity: .75;
  clip-path: polygon(14% 5%, 40% 5%, 40% 95%, 14% 95%, 14% 5%, 60% 5%, 86% 5%, 86% 95%, 60% 95%, 60% 5%);
}
.screen__flags {
  flex: none; font-size: .85em; letter-spacing: .1em; opacity: .7;
  font-variant-numeric: tabular-nums;
}
.screen__flags:empty { display: none; }

.screen__battery {
  flex: none; width: 1.25em; height: .68em; border: 1px solid #4a545a; border-radius: 1.5px;
  position: relative; padding: 1px;
}
.screen__battery i {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(180deg, #7de07d, #3aa93a);
}
.screen__battery.is-low i { background: linear-gradient(180deg, #f0a24a, #d2661f); }
.screen__battery::after {
  content: ""; position: absolute; right: -3px; top: 50%; translate: 0 -50%;
  width: 2px; height: 45%; background: #4a545a; border-radius: 0 1px 1px 0;
}

/* ─── panells ─── */

.pane { flex: 1; min-height: 0; animation: paneIn .18s var(--out) both; }
.pane[hidden], .hud[hidden] { display: none !important; }
.pane--list { display: flex; }
@keyframes paneIn { from { opacity: 0; transform: translateX(6%); } to { opacity: 1; transform: none; } }

/* llistes */

.list {
  flex: 1; min-width: 0; margin: 0; padding: 0; list-style: none;
  overflow: hidden; position: relative;
}
.list__inner {
  position: absolute; inset: 0 0 auto;
  transition: transform .16s var(--out);
  will-change: transform;
}
.list li {
  display: flex; align-items: center; gap: .5em;
  padding: 0 .5em;
  height: 1.834em;             /* = ROW_H a ipod.js */
  cursor: pointer;
  border-bottom: 1px solid rgba(120,140,155,.28);
  overflow: hidden; white-space: nowrap;
}
.list li .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list li .arw { flex: none; opacity: .45; font-size: .92em; }
.list li .num { flex: none; min-width: 1.1em; text-align: right; opacity: .45; font-variant-numeric: tabular-nums; }
.list li .thumb {
  flex: none; width: 1.25em; height: 1.25em; border-radius: 1.5px; object-fit: cover;
  background: rgba(0,0,0,.12);
  box-shadow: 0 0 0 .5px rgba(0,0,0,.3);
}
.list li.is-sel {
  background: linear-gradient(180deg, #6ea8f0 0%, #2f6fd0 48%, #1c56b4 52%, #3b7fdc 100%);
  color: #fff; border-bottom-color: transparent;
}
.list li.is-sel .arw, .list li.is-sel .num { opacity: .85; }
.list li:active:not(.is-sel) { background: rgba(110,168,240,.3); }
@media (hover: hover) and (pointer: fine) {
  .list li:hover:not(.is-sel) { background: rgba(110,168,240,.18); }
}
.list li.is-cur .lbl::after { content: " ♪"; opacity: .7; }
.list li.is-off { opacity: .45; }

/* previsualització lateral */

.preview {
  flex: none; width: 42%;
  border-left: 1px solid rgba(120,140,155,.35);
  padding: .7em;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: .6em; text-align: center;
  background: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0));
}
.preview.is-on { display: flex; }
.preview__art { width: 100%; aspect-ratio: 1; background: rgba(0,0,0,.1); border-radius: 2px; }
.preview img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 2px;
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
  transition: opacity .18s var(--out);
}
.preview p { margin: 0; font-size: .8em; opacity: .72; line-height: 1.3; white-space: pre-line; }

/* ─── ara sonant ─── */

.pane--now { display: flex; gap: .8em; padding: .8em; align-items: center; }
.now__art { flex: none; width: 40%; aspect-ratio: 1; background: rgba(0,0,0,.12); border-radius: 2px; }
.now__art img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 2px;
  box-shadow: 0 4px 10px rgba(0,0,0,.4);
  transition: opacity .2s var(--out);
}
.now__info { flex: 1; min-width: 0; }
.now__count { margin: 0 0 .4em; font-size: .8em; opacity: .6; font-variant-numeric: tabular-nums; }
.now__count:empty { display: none; }
.now__title {
  margin: 0; font-weight: 700; font-size: 1.05em; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.now__sub {
  margin: .1em 0 0; font-size: .88em; opacity: .72;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.now__sub--dim { opacity: .5; font-size: .8em; margin-bottom: .6em; }
.now__bar {
  height: .58em; border-radius: 4px; overflow: hidden;
  background: rgba(255,255,255,.55);
  box-shadow: inset 0 0 0 1px rgba(60,80,95,.5);
}
.now__bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(180deg, #6ea8f0, #2059ba);
}
.now__times {
  margin: .25em 0 0; display: flex; justify-content: space-between;
  font-size: .75em; opacity: .6; font-variant-numeric: tabular-nums;
}
.now__note { margin: .5em 0 0; font-size: .72em; opacity: .55; min-height: 1em; }

/* ─── missatge ─── */

.pane--msg { display: flex; align-items: center; justify-content: center; padding: 1em 1.2em; }
.msg { text-align: center; font-size: .92em; line-height: 1.5; }
.msg h3 { margin: 0 0 .4em; font-size: 1.05em; }
.msg p { margin: 0 0 .5em; opacity: .78; text-wrap: balance; }
.msg p:last-child { margin-bottom: 0; }
.msg .k { opacity: .55; font-size: .85em; }
.msg .spin {
  display: inline-block; width: 1.1em; height: 1.1em; margin-bottom: .5em;
  border: 2px solid rgba(22,32,42,.25); border-top-color: rgba(22,32,42,.8);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }

/* ─── cerca ─── */

.pane--search { display: flex; flex-direction: column; justify-content: center; padding: 1em; text-align: center; position: relative; }
.search__label { margin: 0 0 .6em; font-size: .8em; text-transform: uppercase; letter-spacing: .1em; opacity: .55; }
.search__q {
  margin: 0; font-size: 1.15em; font-weight: 600; min-height: 1.4em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: center;
}
.search__q span { direction: ltr; unicode-bidi: embed; }
.caret {
  display: inline-block; width: .09em; height: 1em; background: currentColor;
  vertical-align: -.12em; animation: blink 1.05s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.search__hint { margin: .9em 0 0; font-size: .72em; opacity: .55; line-height: 1.5; }
.search__hint kbd { font-family: var(--mono); }
.search__input {
  position: absolute; inset: 0; opacity: 0; border: 0; background: none;
  width: 100%; height: 100%; font-size: 16px; color: transparent; cursor: default;
}

/* ─── HUD volum / posició ─── */

.hud {
  position: absolute; left: 8%; right: 8%; bottom: 8%; z-index: 4;
  padding: .55em .7em; border-radius: 4px;
  background: rgba(238,245,248,.93);
  box-shadow: 0 3px 12px rgba(0,0,0,.3), inset 0 0 0 1px rgba(60,80,95,.35);
  animation: fade .15s var(--out) both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.hud__label { margin: 0 0 .35em; font-size: .75em; text-transform: uppercase; letter-spacing: .08em; opacity: .6; }
.hud__bar { height: .55em; border-radius: 4px; overflow: hidden; background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 1px rgba(60,80,95,.45); }
.hud__bar span { display: block; height: 100%; background: linear-gradient(180deg, #6ea8f0, #2059ba); }

/* ═══════════════════════ click wheel ═══════════════════════ */

.wheel {
  position: relative;
  width: 64%; aspect-ratio: 1;
  margin: 8% auto 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #ffffff 0%, #f0f0f1 40%, #dcdde0 78%, #cbccd0 100%);
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,.95),
    inset 0 -1px 3px rgba(0,0,0,.12),
    0 0 0 1px var(--shell-edge),
    0 3px 8px -3px rgba(0,0,0,.35);
  cursor: grab;
  touch-action: none;
}
.wheel:active { cursor: grabbing; }

.wheel__btn {
  position: absolute;
  background: none; border: 0; padding: 0;
  color: #6f7178; font: inherit;
  font-size: .84em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer;
  display: grid; place-items: center;
  width: 24%; height: 18%;
  transition: color .15s ease, transform .1s var(--out);
}
.wheel__btn.is-hit { color: var(--accent); transform: scale(.88); }
.wheel__btn svg { width: 1.45em; height: 1.45em; fill: currentColor; }
@media (hover: hover) and (pointer: fine) { .wheel__btn:hover { color: #2c2e34; } }

.wheel__btn--menu { top: 2.5%;  left: 50%; translate: -50% 0; }
.wheel__btn--play { bottom: 2.5%; left: 50%; translate: -50% 0; }
.wheel__btn--prev { left: 2%;  top: 50%; translate: 0 -50%; }
.wheel__btn--next { right: 2%; top: 50%; translate: 0 -50%; }

.wheel__center {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: 38.5%; aspect-ratio: 1; border-radius: 50%;
  border: 0; padding: 0; cursor: pointer;
  background: radial-gradient(circle at 50% 30%, #fdfdfd, #e6e7ea 70%, #d2d3d7 100%);
  box-shadow:
    0 0 0 1px rgba(0,0,0,.12),
    inset 0 1px 1px rgba(255,255,255,.9),
    0 2px 5px -1px rgba(0,0,0,.28);
  transition: transform .1s var(--out);
}
.wheel__center:active, .wheel__center.is-hit { transform: scale(.93); }

/* ═══════════════════════ configuració ═══════════════════════ */

.setup {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center; padding: 20px;
  background: rgba(6,7,9,.86); backdrop-filter: blur(14px);
  overflow: auto;
}
.setup[hidden] { display: none; }
.setup__box {
  width: min(520px, 100%);
  background: #121418; border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px; padding: 26px 26px 22px;
  box-shadow: 0 30px 70px -20px rgba(0,0,0,.9);
}
.setup h1 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.02em; }
.setup p { margin: 0 0 14px; font-size: 13.5px; line-height: 1.6; color: rgba(255,255,255,.62); }
.setup ol { margin: 0 0 18px; padding-left: 20px; font-size: 13.5px; line-height: 1.75; color: rgba(255,255,255,.72); }
.setup li { margin-bottom: 8px; }
.setup a { color: var(--accent); }
.setup code {
  display: inline-block; margin: 4px 6px 4px 0; padding: 3px 8px;
  font-family: var(--mono); font-size: 12px; word-break: break-all;
  background: rgba(255,255,255,.07); border-radius: 6px; color: #fff;
}
.copy {
  font: inherit; font-size: 11.5px; padding: 3px 9px; cursor: pointer;
  background: rgba(255,255,255,.1); color: #fff;
  border: 1px solid rgba(255,255,255,.14); border-radius: 6px;
}
.copy:hover { background: rgba(255,255,255,.16); }
.setup label { display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.5); margin-bottom: 6px; }
.setup input {
  width: 100%; font: inherit; font-family: var(--mono); font-size: 14px;
  padding: 11px 13px; border-radius: 9px; color: #fff;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14);
}
.setup input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.setup__go {
  width: 100%; margin-top: 14px; font: inherit; font-weight: 600; font-size: 15px;
  padding: 12px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: #05230f;
}
.setup__go:hover { filter: brightness(1.07); }
.setup__note { margin: 14px 0 0; font-size: 12px; color: rgba(255,255,255,.45); }
.setup__err { margin: 12px 0 0 !important; color: #ff8b7a; font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
