/* Jukebox — mobile-first, dark by default. One stylesheet for guest and admin. */

:root {
  --bg: #0e0f13;
  --surface: #181a21;
  --surface-2: #21242e;
  --border: #2d313d;
  --text: #f2f3f7;
  --text-dim: #a0a6b8;
  --accent: #1db954;
  --accent-ink: #04180c;
  --danger: #ff6b6b;
  --warn: #ffc860;
  --radius: 12px;
  --gutter: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fa;
    --surface: #ffffff;
    --surface-2: #eef0f5;
    --border: #d8dbe4;
    --text: #14161c;
    --text-dim: #5d6478;
    --accent: #12833c;
    --accent-ink: #ffffff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; letter-spacing: 0.01em; }

a { color: var(--accent); }

/* --- layout --------------------------------------------------------------- */

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: var(--gutter);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header h1 { margin: 0; font-size: 1.1rem; }

.admin-nav { display: flex; align-items: center; gap: 12px; }
.admin-nav a { text-decoration: none; color: var(--text-dim); font-size: 0.9rem; }
.admin-nav a.is-current { color: var(--text); font-weight: 600; }

.admin-main { padding: var(--gutter); max-width: 720px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gutter);
  margin: 0 0 var(--gutter);
}

.card--narrow { max-width: 380px; margin: 12vh auto; }

.page-login { padding: var(--gutter); }

.inline { display: inline; margin: 0; }

/* --- forms ---------------------------------------------------------------- */

.field { margin: 0 0 14px; }
.field:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 0 5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 1rem; /* 16px stops iOS zooming on focus */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field--check label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  margin: 0;
}

.field--check input { width: 20px; height: 20px; accent-color: var(--accent); }

.field--error input { border-color: var(--danger); }

.hint { margin: 5px 0 0; font-size: 0.8rem; color: var(--text-dim); }
.hint--error { color: var(--danger); }

.form-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.btn {
  display: inline-block;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
}

.btn--primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
  padding: 6px 4px;
  min-height: 0;
}

/* --- notices -------------------------------------------------------------- */

.notice {
  margin: 0 0 var(--gutter);
  padding: 11px 13px;
  border-radius: 9px;
  border: 1px solid;
  font-size: 0.9rem;
}

.notice--ok { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.notice--error { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.notice--info { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }

@media (min-width: 640px) {
  .btn--primary { width: auto; min-width: 200px; }
}

/* --- status page ---------------------------------------------------------- */

.checks, .devices { list-style: none; margin: 0; padding: 0; }

.check {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.check:last-child { border-bottom: 0; }

.check__mark { font-size: 0.8rem; line-height: 1.6; }
.check--ok .check__mark { color: var(--accent); }
.check--bad .check__mark { color: var(--danger); }

.check__body { display: flex; flex-direction: column; gap: 2px; }
.check__detail { font-size: 0.85rem; color: var(--text-dim); }

.devices li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.devices li:last-child { border-bottom: 0; }
.devices .hint { display: block; }

.now { display: flex; gap: 12px; align-items: center; }
.now__art { border-radius: 6px; flex: none; }
.now__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

code {
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}

a.btn { text-decoration: none; text-align: center; }

/* --- guest page ----------------------------------------------------------- */

.page-guest { padding-bottom: 40px; }

.guest-header {
  padding: 22px var(--gutter) 14px;
  text-align: center;
}
.guest-header h1 { margin: 0 0 4px; font-size: 1.5rem; letter-spacing: -0.01em; }
.guest-tagline { margin: 0; color: var(--text-dim); font-size: 0.95rem; }

.guest-main { max-width: 620px; margin: 0 auto; padding: 0 var(--gutter); }

.search__box { position: relative; }

#q {
  width: 100%;
  padding: 14px 44px 14px 14px;
  font-size: 1.05rem;
  border-radius: 12px;
}

.search__spinner {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .search__spinner { animation-duration: 2s; }
}

.results { list-style: none; margin: 10px 0 0; padding: 0; }

.result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px;
  margin: 0 0 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 64px;
}

.result:active { background: var(--surface-2); }

.result__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.result__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result__meta { font-size: 0.83rem; color: var(--text-dim); }

.art { border-radius: 6px; flex: none; object-fit: cover; }
.art--empty {
  width: 48px;
  height: 48px;
  background: var(--surface-2);
  border-radius: 6px;
  flex: none;
}

.tag {
  display: inline-block;
  padding: 0 5px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
}
.tag--request {
  margin-top: 3px;
  align-self: flex-start;
  border-color: var(--accent);
  color: var(--accent);
}

/* --- queue ---------------------------------------------------------------- */

.queue { margin-top: 28px; }

/* Emoji carry no letter-spacing of their own, so uppercase tracked headings
   leave them touching the first letter. */
.emoji {
  display: inline-block;
  margin-right: 0.45em;
  letter-spacing: normal;
}

.queue__title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin: 20px 0 8px;
}

.now-row, .up-next__item { display: flex; align-items: center; gap: 12px; }
.now-row__body, .up-next__body { display: flex; flex-direction: column; min-width: 0; }

.now-playing {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px;
}

.up-next { list-style: none; margin: 0; padding: 0; counter-reset: queue; }

.up-next__item {
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  margin-bottom: 6px;
}

.up-next__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- confirmation sheet --------------------------------------------------- */

body.is-locked { overflow: hidden; }

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }

.sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px var(--gutter) max(20px, env(safe-area-inset-bottom));
  animation: rise 0.18s ease-out;
}

@keyframes rise { from { transform: translateY(12%); } }
@media (prefers-reduced-motion: reduce) { .sheet__panel { animation: none; } }

.sheet__panel h2 { margin: 0 0 14px; font-size: 1.15rem; }
.sheet__track { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.sheet__track-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.sheet__facts {
  display: flex;
  gap: 24px;
  margin: 0 0 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.sheet__facts dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.sheet__facts dd { margin: 2px 0 0; font-weight: 600; }

.sheet__error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: 9px;
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  font-size: 0.9rem;
}

.sheet__actions { display: flex; gap: 10px; }
.sheet__actions .btn { flex: 1; }

.sheet__done { color: var(--accent); }

@media (min-width: 640px) {
  .sheet__panel {
    left: 50%;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 440px;
    border-radius: 16px;
    border: 1px solid var(--border);
  }
  @keyframes rise { from { transform: translate(-50%, -46%); } }
}

/* --- payment return page -------------------------------------------------- */

.return { display: flex; align-items: center; min-height: 70vh; }
.return__card { width: 100%; text-align: center; }
.return__card h1 { font-size: 1.35rem; margin-bottom: 8px; }
.return__card p { margin: 0 0 14px; }
.return__card .btn { margin-top: 8px; }
.return__card--ok h1 { color: var(--accent); }
.return__card--error h1 { color: var(--danger); }
.return__card--info h1 { color: var(--warn); }

/* --- guest: framed header photo ------------------------------------------- */

.guest-header--photo {
  padding-top: 18px;
}

/* A photo in a frame, not a bleeding banner: the mount and border read as a
   picture hung on the page, and the title sits below it rather than over it. */
.guest-header__frame {
  display: block;
  width: min(100% - (var(--gutter) * 2), 420px);
  margin: 0 auto 14px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.guest-header__photo {
  display: block;
  width: 100%;
  /* Whatever gets pasted in is cropped to a consistent shape, so the layout
     never jumps between events. */
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-2);
}

.guest-blurb {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* --- guest: record-sleeve tiles ------------------------------------------- */

.results {
  display: grid;
  /* Two sleeves on a phone; the stylesheet widens it, not the markup. */
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.tile-cell {
  display: flex;
  /* Grid items default to min-width:auto, so an album image's intrinsic width
     stops the column shrinking and the grid overflows the screen. */
  min-width: 0;
}

.tile {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tile__sleeve {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease;
}

.tile:active .tile__sleeve { transform: scale(0.97); }

@media (prefers-reduced-motion: reduce) {
  .tile__sleeve { transition: none; }
}

.tile__sleeve .art,
.tile__sleeve .art--empty {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: cover;
}

.tile__duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.tile__explicit {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 0 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}

.tile__name {
  margin-top: 7px;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.25;
  /* Two lines, then ellipsis — titles vary wildly and a ragged grid looks broken. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile__artist {
  font-size: 0.78rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 520px) {
  .results { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 720px) {
  .results { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

/* --- admin: queue --------------------------------------------------------- */

.count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
}

.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.inline-form { display: inline; margin: 0; }

.btn--small { padding: 7px 11px; min-height: 36px; font-size: 0.85rem; }
.btn--danger { border-color: var(--danger); color: var(--danger); }

.admin-queue { list-style: none; margin: 0; padding: 0; counter-reset: q; }

.admin-queue__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.admin-queue__item:last-child { border-bottom: 0; }
.admin-queue__item.is-handed-over { opacity: 0.62; }

.admin-queue__pos {
  flex: none;
  width: 22px;
  text-align: right;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

.admin-queue__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.admin-queue__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-queue__actions { display: flex; gap: 5px; flex: none; }

.hint--muted { opacity: 0.8; font-style: italic; }
.art--small { width: 40px; height: 40px; }

.blocklist-form { margin-bottom: 14px; }
.blocklist-form .field--check { display: flex; gap: 18px; }
.blocklist { list-style: none; margin: 0; padding: 0; }
.blocklist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.blocklist li:last-child { border-bottom: 0; }

/* --- admin: request log --------------------------------------------------- */

.log-scroll { overflow-x: auto; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); }
.log { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.log th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 0 10px 6px 0;
  font-weight: 600;
}
.log td { padding: 7px 10px 7px 0; border-top: 1px solid var(--border); vertical-align: top; }
.log td .hint { display: block; }
.log__when { color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.log__actions { text-align: right; white-space: nowrap; }

.state {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.state--playing { border-color: var(--accent); color: var(--accent); }
.state--queued { color: var(--text); }
.state--played { color: var(--text-dim); }
.state--failed, .state--cancelled { border-color: var(--danger); color: var(--danger); }
.state--refunded { border-color: var(--warn); color: var(--warn); }
.state--pending_payment { border-color: var(--warn); color: var(--warn); }

/* --- admin: colour pickers ------------------------------------------------ */

.colour-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.colour-row { display: flex; gap: 8px; align-items: center; }
.colour-row input[type="color"] {
  flex: none;
  width: 42px;
  height: 42px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}
.colour-row input[type="text"] { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
