/* Autocinema — paleta "cinema a la fresca de nit": cel nocturn + bombetes del rètol. */
@font-face { font-family: "Big Shoulders Display"; font-weight: 800; font-display: swap;
  src: url("fonts/big-shoulders-display-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap;
  src: url("fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap;
  src: url("fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap;
  src: url("fonts/barlow-latin-600-normal.woff2") format("woff2"); }

:root {
  --night: #0e1629;   /* fons */
  --dusk: #19243d;    /* superfícies */
  --line: #2a3658;    /* vores */
  --haze: #8e9ab8;    /* text secundari */
  --screen: #eaeef6;  /* text principal */
  --bulb: #ffb547;    /* bombeta del rètol: l'únic accent */
  --brake: #ff6b5b;   /* errors */
  --sans: "Barlow", "Helvetica Neue", Arial, sans-serif;
  --sign: "Big Shoulders Display", "Barlow", Impact, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night); color: var(--screen);
  font: 500 20px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
p { margin: 0; }
button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
button:focus-visible, .seek:focus-visible { outline: 3px solid var(--bulb); outline-offset: 3px; }
svg { width: 1em; height: 1em; flex: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Rètol: el nom amb una filera de bombetes a sota. */
.marquee {
  margin: 0; padding-bottom: 16px;
  font: 800 46px/0.9 var(--sign); letter-spacing: 0.03em; text-transform: uppercase;
  background:
    radial-gradient(circle, var(--bulb) 2.4px, transparent 3px) 1px 100% / 14px 8px repeat-x,
    radial-gradient(circle, rgba(255, 181, 71, 0.28) 0, transparent 6px) 1px 100% / 14px 14px repeat-x;
}
.marquee--big {
  font-size: 92px; padding-bottom: 26px;
  background:
    radial-gradient(circle, var(--bulb) 3.4px, transparent 4.2px) 1px 100% / 21px 12px repeat-x,
    radial-gradient(circle, rgba(255, 181, 71, 0.3) 0, transparent 9px) 1px 100% / 21px 20px repeat-x;
}

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 54px; padding: 0 22px; border-radius: 27px;
  border: 1.5px solid var(--line); font-size: 18px; font-weight: 600;
}
.btn-ghost svg { width: 22px; height: 22px; margin-right: 10px; }
.btn-ghost:active { background: var(--dusk); }
.btn-ghost.is-busy svg { animation: turn 1s linear infinite; }
.btn-small { min-height: 46px; padding: 0 18px; font-size: 17px; }
.btn-bulb {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 60px; padding: 0 28px; border-radius: 30px;
  background: var(--bulb); color: var(--night); font-size: 20px; font-weight: 600;
}
.btn-bulb svg { width: 26px; height: 26px; margin-right: 12px; }
.btn-bulb:active, .btn-play:active { filter: brightness(0.9); }

/* PIN */
.pin {
  min-height: 100%; padding: 32px 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.pin-help { margin: 36px 0 16px; color: var(--haze); font-size: 22px; }
.pin-dots { display: flex; justify-content: center; align-items: center; min-height: 24px; }
.pin-dots i {
  width: 16px; height: 16px; margin: 0 7px; border-radius: 50%;
  background: var(--bulb); box-shadow: 0 0 14px rgba(255, 181, 71, 0.6);
}
.pin-msg { min-height: 28px; margin: 12px 0 20px; color: var(--brake); font-size: 18px; }
.keypad { display: grid; grid-template-columns: repeat(3, 92px); grid-auto-rows: 92px; gap: 16px; }
.keypad button {
  display: flex; align-items: center; justify-content: center;
  border-radius: 24px; background: var(--dusk); font: 800 44px/1 var(--sign);
}
.keypad button:active { background: #24314f; transform: scale(0.96); }
.keypad svg { width: 34px; height: 34px; }
.keypad .key-ok { background: var(--bulb); color: var(--night); }

/* Biblioteca */
.library { max-width: 1760px; margin: 0 auto; padding: 32px 40px 56px; }
.lib-head { display: flex; align-items: flex-end; justify-content: space-between; }
.lib-status { min-height: 26px; margin: 14px 0 18px; color: var(--haze); font-size: 18px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 34px 26px; align-items: start;
}
.tile { display: block; width: 100%; text-align: left; }
.tile-art {
  position: relative; padding-top: 56.25%; overflow: hidden;
  border-radius: 12px; background: var(--dusk); transition: transform 0.12s;
}
.tile:active .tile-art { transform: scale(0.98); }
.tile-art img, .tile-ph { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.tile-art img { object-fit: cover; }
.tile-ph {
  display: flex; align-items: center; justify-content: center;
  color: var(--line); font: 800 84px/1 var(--sign);
}
.tile.is-waiting .tile-art img { opacity: 0.4; }
.tile-flag {
  position: absolute; top: 10px; left: 10px; padding: 3px 11px; border-radius: 8px;
  background: rgba(14, 22, 41, 0.88); font-size: 16px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tile-flag.is-prep { color: var(--bulb); }
.tile-flag.is-error { color: var(--brake); }
.tile-bar { position: absolute; left: 0; bottom: 0; height: 5px; width: 0; background: var(--bulb); }
.tile-bar.is-prep { background: rgba(234, 238, 246, 0.55); }
.tile-title {
  margin-top: 12px; font-size: 21px; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-meta { margin-top: 3px; color: var(--haze); font-size: 17px; font-variant-numeric: tabular-nums; }
.tile-meta.is-error { color: var(--brake); }
.empty { max-width: 32em; margin-top: 10vh; color: var(--haze); }
.empty-title { margin-bottom: 8px; color: var(--screen); font-size: 28px; font-weight: 600; }

/* Reproductor */
.player { position: fixed; top: 0; right: 0; bottom: 0; left: 0; overflow: hidden; background: #000; }
.stage { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
.stage canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; }

/* Bombetes que s'encenen en roda mentre carrega */
.bulbs { position: absolute; top: 50%; left: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px; }
.bulbs i {
  position: absolute; top: 50%; left: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: var(--bulb); box-shadow: 0 0 10px rgba(255, 181, 71, 0.7);
  opacity: 0.15; animation: bulb 1.2s linear infinite;
}
.bulbs i:nth-child(1)  { transform: rotate(0deg)   translateY(-32px); animation-delay: -1.1s; }
.bulbs i:nth-child(2)  { transform: rotate(30deg)  translateY(-32px); animation-delay: -1.0s; }
.bulbs i:nth-child(3)  { transform: rotate(60deg)  translateY(-32px); animation-delay: -0.9s; }
.bulbs i:nth-child(4)  { transform: rotate(90deg)  translateY(-32px); animation-delay: -0.8s; }
.bulbs i:nth-child(5)  { transform: rotate(120deg) translateY(-32px); animation-delay: -0.7s; }
.bulbs i:nth-child(6)  { transform: rotate(150deg) translateY(-32px); animation-delay: -0.6s; }
.bulbs i:nth-child(7)  { transform: rotate(180deg) translateY(-32px); animation-delay: -0.5s; }
.bulbs i:nth-child(8)  { transform: rotate(210deg) translateY(-32px); animation-delay: -0.4s; }
.bulbs i:nth-child(9)  { transform: rotate(240deg) translateY(-32px); animation-delay: -0.3s; }
.bulbs i:nth-child(10) { transform: rotate(270deg) translateY(-32px); animation-delay: -0.2s; }
.bulbs i:nth-child(11) { transform: rotate(300deg) translateY(-32px); animation-delay: -0.1s; }
.bulbs i:nth-child(12) { transform: rotate(330deg) translateY(-32px); animation-delay: 0s; }
@keyframes bulb { 0% { opacity: 1; } 70%, 100% { opacity: 0.15; } }
@keyframes turn { to { transform: rotate(360deg); } }
.stage-msg {
  position: absolute; top: 50%; left: 0; right: 0; margin-top: 62px;
  color: var(--haze); font-size: 19px; text-align: center;
}

.gate {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; background: rgba(0, 0, 0, 0.62); text-align: center;
}
.end-title { max-width: 26em; margin-bottom: 26px; font-size: 26px; font-weight: 600; }
.end-actions .btn-ghost { margin-left: 14px; border-color: rgba(234, 238, 246, 0.5); }

.hud {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 4;
  display: flex; flex-direction: column; justify-content: space-between;
  pointer-events: none; transition: opacity 0.25s;
}
.hud > * { pointer-events: auto; }
.hud.is-hidden { opacity: 0; }
.hud.is-hidden > * { pointer-events: none; }
.hud-top {
  display: flex; align-items: center; padding: 18px 22px 44px;
  background: linear-gradient(rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
}
.now-title {
  flex: 1; min-width: 0; margin: 0 18px; font-size: 21px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud-top .btn-small { margin-right: 14px; border-color: rgba(234, 238, 246, 0.35); }
.hud-bottom {
  padding: 44px 30px 24px;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));
}
.btn-round {
  display: inline-flex; align-items: center; justify-content: center;
  width: 62px; height: 62px; border-radius: 50%; background: rgba(234, 238, 246, 0.12);
}
.btn-round:active { background: rgba(234, 238, 246, 0.24); }
.btn-round svg { width: 32px; height: 32px; }
.btn-skip { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.btn-play {
  display: inline-flex; align-items: center; justify-content: center;
  width: 86px; height: 86px; margin: 0 28px; border-radius: 50%;
  background: var(--bulb); color: var(--night);
}
.btn-play svg { width: 42px; height: 42px; }

.seek { position: relative; height: 46px; cursor: pointer; touch-action: none; }
.seek-track {
  position: absolute; top: 20px; left: 0; right: 0; height: 6px; overflow: hidden;
  border-radius: 3px; background: rgba(234, 238, 246, 0.16);
}
.seek-avail, .seek-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; }
.seek-avail { background: rgba(234, 238, 246, 0.26); }
.seek-fill { background: var(--bulb); }
.seek-knob {
  position: absolute; top: 12px; left: 0; width: 22px; height: 22px; margin-left: -11px;
  border-radius: 50%; background: var(--bulb); box-shadow: 0 0 0 6px rgba(255, 181, 71, 0.22);
}
.seek-tip {
  position: absolute; bottom: 48px; left: 0; padding: 5px 11px; border-radius: 8px;
  transform: translateX(-50%); background: rgba(14, 22, 41, 0.94);
  font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.transport { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.transport-buttons { display: flex; align-items: center; }
.time { width: 7.5em; font-size: 19px; font-variant-numeric: tabular-nums; }
.time--total { color: var(--haze); text-align: right; }

.toast {
  position: fixed; left: 50%; bottom: 34px; z-index: 20; max-width: 90vw;
  padding: 13px 22px; border-radius: 12px; transform: translateX(-50%);
  background: var(--dusk); border: 1px solid var(--line); font-size: 18px;
}

@media (max-width: 640px) {
  .library { padding: 22px 18px 40px; }
  .marquee { font-size: 38px; }
  .marquee--big { font-size: 64px; }
  .keypad { grid-template-columns: repeat(3, 80px); grid-auto-rows: 80px; gap: 12px; }
  .btn-ghost span { display: none; }
  .btn-ghost svg { margin-right: 0; }
  .btn-play { margin: 0 14px; }
  .time { width: 5em; font-size: 16px; }
}
@media (max-height: 820px) {
  .marquee--big { font-size: 68px; padding-bottom: 22px; }
  .pin-help { margin-top: 22px; }
  .pin-msg { margin: 8px 0 12px; }
  .keypad { grid-template-columns: repeat(3, 80px); grid-auto-rows: 80px; gap: 12px; }
  .keypad button { font-size: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .bulbs i { opacity: 0.8; }
}
