:root {
  --bg: #0d1211;
  --cream: #efe8dc;
  --moss: #6a994e;
  --moss-soft: #8fbb74;
  --line: rgba(239, 232, 220, 0.18);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--cream);
  font-family: Poppins, ui-sans-serif, system-ui, sans-serif;
  font-weight: 500;
  overflow: hidden;
  overscroll-behavior: none;
}

button, input, textarea { font: inherit; color: inherit; }

/* ---- root ---------------------------------------------------------------- */
.root {
  position: relative;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  overflow: clip; /* can't be scrolled sideways by focus or scrollIntoView */
  container-type: inline-size;
  background: #2a1a0c;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  --pad: clamp(16px, 3.6cqw, 44px);
}
.root:focus-visible { box-shadow: inset 0 0 0 2px var(--moss); }
.root[data-dragging], .root[data-dragging] .slide { cursor: grabbing; }

/* ---- sizes + background ----------------------------------------------------
   --s is the record size. The photo is placed so the floating woman (62–74% down the photo,
   centred) lies just under the record: her top edge sits 10px below it. --bg-h is the photo's
   height, never less than what keeps her above that line and the screen covered. */
.root {
  --s: clamp(150px, min(40vmin, 28vw), 360px);
  --woman: calc(44svh + var(--s) * 0.6 + 10px);
  --bg-h: max(100svh, calc(var(--woman) / 0.62));
}
@media (max-width: 720px) {
  .root {
    --s: clamp(120px, min(52vw, 25svh), 280px);
    --woman: calc(186px + var(--s) * 1.22);
    --bg-h: max(100svh, calc((100svh - var(--woman)) / 0.38));
  }
}
@media (max-width: 720px) and (min-width: 480px) {
  .root { --s: clamp(160px, min(38vw, 28svh), 300px); }
}
@media (max-width: 720px) and (max-height: 740px) {
  .root { --s: clamp(110px, min(44vw, 18svh), 260px); }
}

.bg, .bg span { position: absolute; inset: 0; pointer-events: none; }
.bg { z-index: 0; overflow: hidden; }
/* a blurred copy fills the sides on wide screens */
.bg-blur { inset: -80px; background: url("background-floating.webp") center / cover; filter: blur(48px) brightness(0.85); }
.bg-photo {
  background: url("background-floating.webp") 50% calc(var(--woman) - 0.62 * var(--bg-h)) / auto var(--bg-h) no-repeat;
  -webkit-mask: linear-gradient(to right, transparent calc(50% - 0.4 * var(--bg-h)), #000 calc(50% - 0.4 * var(--bg-h) + 90px),
    #000 calc(50% + 0.4 * var(--bg-h) - 90px), transparent calc(50% + 0.4 * var(--bg-h)));
  mask: linear-gradient(to right, transparent calc(50% - 0.4 * var(--bg-h)), #000 calc(50% - 0.4 * var(--bg-h) + 90px),
    #000 calc(50% + 0.4 * var(--bg-h) - 90px), transparent calc(50% + 0.4 * var(--bg-h)));
}
/* dark top and edges keep the text readable */
.bg-shade {
  background:
    linear-gradient(to bottom, rgba(8, 11, 10, 0.55), transparent 24%, transparent 70%, rgba(8, 11, 10, 0.45)),
    radial-gradient(120% 90% at 50% 45%, transparent 45%, rgba(8, 11, 10, 0.5) 100%);
}

/* ---- brand --------------------------------------------------------------- */
.brand {
  position: absolute;
  top: calc(var(--pad) * 0.8);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}
.mark { font-size: 22px; letter-spacing: 0.32em; margin-right: -0.32em; }
.sub { font-size: 10px; letter-spacing: 0.3em; margin-right: -0.3em; text-transform: uppercase; opacity: 0.55; }

/* ---- the credits block ------------------------------------------------------ */
.head {
  position: absolute;
  top: calc(var(--pad) * 1.1);
  left: var(--pad);
  z-index: 4;
  width: clamp(190px, 24cqw, 320px);
}
.title {
  margin: 0 0 14px;
  font-weight: 500;
  font-size: clamp(22px, 2.7cqw, 38px);
  line-height: 1.04;
  letter-spacing: -0.01em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.rows { margin: 0; }
.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 7px;
  border-top: 1px solid var(--line);
}
.row dt { font-size: 9px; line-height: 15px; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.6; }
.row dd { margin: 0; font-size: 12px; line-height: 15px; text-align: right; text-wrap: balance; }
.listen {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--moss);
  color: #0d1211;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}
.listen:hover { background: var(--moss-soft); }
.listen:active { transform: scale(0.96); }
.listen:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
.empty-note { margin: 0; font-size: 12px; opacity: 0.6; }
.meta { display: none; margin: 0; font-size: 12px; opacity: 0.7; }

/* ---- lyric quote ------------------------------------------------------------ */
.quote {
  position: absolute;
  left: 50%;
  bottom: calc(var(--pad) * 1.1 + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 4;
  width: min(520px, 40cqw);
  margin: 0;
  text-align: center;
  pointer-events: none;
}
.quote, .head, .brand { text-shadow: 0 1px 14px rgba(8, 11, 10, 0.75), 0 0 2px rgba(8, 11, 10, 0.5); }
.quote blockquote {
  margin: 0;
  font-weight: 400;
  font-size: clamp(16px, 1.6cqw, 22px);
  line-height: 1.35;
  white-space: pre-line;
  text-wrap: balance;
}
.quote blockquote::before { content: "\201C"; color: var(--moss-soft); }
.quote blockquote::after { content: "\201D"; color: var(--moss-soft); }
/* Capped so the lyric never covers the woman in the photo. */
.quote blockquote { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (min-width: 721px) and (max-height: 860px) {
  .quote blockquote { -webkit-line-clamp: 2; }
}
.quote figcaption { margin-top: 10px; font-size: 9px; letter-spacing: 0.24em; text-transform: uppercase; opacity: 0.55; }

/* ---- Spotify player ------------------------------------------------------------ */
.player {
  position: absolute;
  left: var(--pad);
  bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  width: clamp(240px, 24cqw, 320px);
}
.player:empty { display: none; }
.player iframe { display: block; width: 100%; height: 80px; border: 0; border-radius: 12px; background: #121212; }

.in { animation: in 0.8s cubic-bezier(0.2, 0.7, 0.1, 1) both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes in { from { opacity: 0; transform: translateY(12px); filter: blur(5px); } }

/* ---- stage + slides ------------------------------------------------------------ */
.stage {
  position: absolute;
  left: 50%;
  top: 44%;
  width: var(--s);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  perspective: calc(var(--s) * 3.2);
}
.slide {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  will-change: transform;
  transform-style: preserve-3d;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.tilt {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.slide[data-active] .tilt {
  transform: translateZ(var(--lift, 0px)) rotateX(calc(var(--py, 0) * -10deg)) rotateY(calc(var(--px, 0) * 10deg));
}
.slide[data-active]:hover { --lift: calc(var(--s) * 0.04); }

.shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform: translate3d(14%, 10%, -40px) scale(1.05, 0.9);
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.25) 60%, transparent);
}

/* the record: black grooves, the cover as the centre label, slides out of the sleeve */
.vinyl {
  position: absolute;
  inset: 2.5%;
  border-radius: 50%;
  transform: translate3d(calc(var(--out, 0) * 54%), 0, -2px);
  box-shadow: 0 14px 30px -8px rgba(0, 0, 0, 0.7);
}
.roll, .spin, .light { position: absolute; inset: 0; border-radius: 50%; }
.roll { transform: rotate(var(--roll, 0deg)); }
.spin {
  background:
    radial-gradient(circle closest-side, transparent 0 34.5%, rgba(255, 255, 255, 0.08) 35%, transparent 36.5%,
      transparent 52%, #050505 52.5%, #050505 53.2%, transparent 53.7%,
      transparent 68%, #050505 68.5%, #050505 69.1%, transparent 69.6%,
      transparent 83%, #050505 83.5%, #050505 84.1%, transparent 84.6%,
      transparent 96.5%, rgba(255, 255, 255, 0.06) 97.5%, transparent 99%),
    repeating-radial-gradient(circle closest-side, #121212 0 0.9px, #1b1b1b 1.3px 1.9px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.root[data-spin] .slide .spin { animation: spin 1.8s linear infinite; animation-play-state: paused; }
.root[data-spin] .slide[data-active] .spin { animation-play-state: running; }
.root[data-dragging] .slide .spin { animation-play-state: paused; }
@keyframes spin { to { transform: rotate(1turn); } }
.label {
  position: absolute;
  inset: 33%;
  width: 34%;
  height: 34%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.spin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3.2%;
  height: 3.2%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #0b0f0e;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}
/* fixed light on the grooves, grey only: two soft highlights that don't turn with the record */
.light {
  pointer-events: none;
  mix-blend-mode: screen;
  background: conic-gradient(from calc(var(--glint, 0deg) + var(--px, 0) * 50deg),
    transparent 0deg, rgba(255, 255, 255, 0.13) 22deg, transparent 50deg, transparent 180deg,
    rgba(255, 255, 255, 0.1) 202deg, transparent 230deg, transparent 360deg);
  -webkit-mask: radial-gradient(circle closest-side, transparent 34.5%, #000 35.5%);
  mask: radial-gradient(circle closest-side, transparent 34.5%, #000 35.5%);
}

/* the sleeve: the cover art, a bit of paper sheen and ring wear */
.sleeve {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  overflow: hidden;
  background: #1d2422;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 6px 0 14px -6px rgba(0, 0, 0, 0.6);
}
.sleeve img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.sleeve::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  mix-blend-mode: screen;
  background: radial-gradient(circle closest-side, transparent 88%, rgba(255, 255, 255, 0.07) 90%, transparent 93%);
}
.sleeve::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(to left, rgba(0, 0, 0, 0.35), transparent 3%),
    linear-gradient(118deg, rgba(255, 255, 255, 0.16), transparent 34%, transparent 70%, rgba(0, 0, 0, 0.22));
}
.slide:focus-visible .sleeve { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--moss); }

/* the empty crate */
.slide.placeholder { cursor: default; }
.placeholder .sleeve { display: grid; place-items: center; background: linear-gradient(140deg, #1e2826, #121918); }
.placeholder .sleeve span { position: relative; z-index: 2; font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase; opacity: 0.5; }
.placeholder .label-blank {
  position: absolute; inset: 33%; border-radius: 50%; background: var(--moss);
  display: grid; place-items: center; font-size: calc(var(--s) * 0.045); letter-spacing: 0.2em; color: #0d1211;
}

/* ---- controls -------------------------------------------------------------- */
.ctl {
  position: absolute;
  right: var(--pad);
  bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(239, 232, 220, 0.25);
  background: none;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s, transform 0.2s;
}
.btn:hover:not(:disabled) { background: rgba(239, 232, 220, 0.08); }
.btn:active:not(:disabled) { transform: scale(0.9); }
.btn:disabled { opacity: 0.28; cursor: default; }
.btn:focus-visible, .text-btn:focus-visible, .pill:focus-visible { outline: 2px solid var(--moss); outline-offset: 3px; }
.count { font-size: 11px; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; min-width: 58px; text-align: center; }
.count b { font-weight: 500; color: var(--moss-soft); }
.hint {
  position: absolute;
  left: var(--pad);
  bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  z-index: 4;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.45;
  line-height: 38px;
  pointer-events: none;
}
.root:has(.player iframe) .hint { bottom: calc(var(--pad) + 88px + env(safe-area-inset-bottom, 0px)); }

/* ---- admin box (only for Arthur) ---------------------------------------------------- */
.admin {
  position: absolute;
  left: 50%;
  bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 6;
  width: min(460px, calc(100% - 2 * var(--pad)));
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(13, 18, 17, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  user-select: text;
  -webkit-user-select: text;
}
.admin[hidden] { display: none; }
.admin-lock, .admin-link, .admin-save { display: flex; gap: 8px; align-items: center; }
.admin-add { display: flex; flex-direction: column; gap: 8px; }
.admin-save .text-btn { margin-left: 6px; }
.admin:not([data-mode="lock"]) .admin-lock,
.admin[data-mode="lock"] .admin-add,
.admin:not([data-mode="add"]) .admin-link,
.admin:not([data-mode="edit"]) .admin-save,
.admin:not([data-mode="add"]) .edit,
.admin:not([data-mode="add"]) .remove,
.admin:not([data-mode="add"]) .lock { display: none; }
.admin textarea {
  resize: none;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(239, 232, 220, 0.05);
  font-size: 16px;
  line-height: 1.35;
  outline: none;
}
.admin textarea:focus { border-color: var(--moss); }
.admin textarea::placeholder { color: rgba(239, 232, 220, 0.45); }
.admin input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(239, 232, 220, 0.05);
  font-size: 16px; /* 16px stops iOS from zooming in */
  outline: none;
}
.admin input:focus { border-color: var(--moss); }
.admin input::placeholder { color: rgba(239, 232, 220, 0.45); }
.pill {
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--moss);
  color: #0d1211;
  font-size: 13px;
  cursor: pointer;
}
.pill:disabled { opacity: 0.5; cursor: progress; }
.admin-foot { display: flex; align-items: center; gap: 14px; padding: 8px 6px 0; font-size: 11px; }
.status { flex: 1; opacity: 0.7; min-height: 1em; }
.status[data-tone="ok"] { color: var(--moss-soft); opacity: 1; }
.status[data-tone="err"] { color: #e6a08a; opacity: 1; }
.text-btn { padding: 0; border: 0; background: none; font-size: 11px; opacity: 0.6; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.text-btn:hover { opacity: 1; }

/* With the admin box open, lift the controls above it. */
.root[data-admin] .ctl,
.root[data-admin] .quote { bottom: calc(var(--pad) + 190px + env(safe-area-inset-bottom, 0px)); }
.root[data-admin] .hint { display: none; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- phone + tablet ---------------------------------------------------------- */
@container (max-width: 1100px) and (min-width: 721px) {
  .player { width: 260px; }
  .quote { width: min(420px, 36cqw); }
}

/* Phones: brand, title + one meta line, record, lyric, player, buttons, top to bottom. */
@container (max-width: 720px) {
  .hint, .rows, .listen { display: none; }
  .meta { display: block; }
  .head { top: 76px; width: calc(100% - 2 * var(--pad)); }
  .title { font-size: clamp(21px, 6.4cqw, 28px); margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .stage { top: calc(178px + var(--s) * 0.62); }
  .quote {
    top: calc(var(--woman) + 0.12 * var(--bg-h) + 8px);
    bottom: auto;
    width: calc(100% - 2 * var(--pad));
  }
  .quote blockquote { font-size: clamp(15px, 4.4cqw, 18px); }
  .player { left: var(--pad); right: var(--pad); width: auto; bottom: calc(var(--pad) + 52px + env(safe-area-inset-bottom, 0px)); }
  .ctl { left: 50%; right: auto; transform: translateX(-50%); }
  .root[data-admin] .player,
  .root[data-admin] .ctl { display: none; }
  .root[data-admin] .quote { bottom: auto; }
}
/* Short phones (iPhone SE and similar): a long lyric stops at two lines. */
@media (max-height: 740px) {
  @container (max-width: 720px) {
    .quote blockquote { font-size: 14.5px; -webkit-line-clamp: 2; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .root .spin { animation: none; }
  .in { animation: none; }
  .tilt, .btn { transition: none; }
}
