/* Guess The Audio family — shared engine styles.
   Theming: body[data-theme="metal"] / body[data-theme="rap"] swap the
   palette; layout and components are identical across genres. */

:root {
  --display: 'Luckiest Guy', cursive;
  --body: 'Patrick Hand', 'Comic Sans MS', cursive, sans-serif;
}

/* Late-night violet with gold — boombox era */
body[data-theme='rap'] {
  --bg: oklch(0.24 0.05 295);
  --bg-deep: oklch(0.19 0.045 295);
  --panel: oklch(0.3 0.055 295);
  --panel-2: oklch(0.36 0.06 295);
  --ink: oklch(0.16 0.035 300);
  --text: oklch(0.95 0.02 90);
  --muted: oklch(0.74 0.04 300);
  --accent: oklch(0.82 0.14 90);
  --accent-deep: oklch(0.7 0.14 85);
  --on-accent: oklch(0.25 0.06 85);
  --good: oklch(0.75 0.15 150);
  --bad: oklch(0.68 0.17 20);
}

/* Molten fire on scorched charcoal */
body[data-theme='metal'] {
  --bg: oklch(0.17 0.012 40);
  --bg-deep: oklch(0.13 0.01 40);
  --panel: oklch(0.23 0.016 40);
  --panel-2: oklch(0.29 0.02 40);
  --ink: oklch(0.11 0.008 40);
  --text: oklch(0.93 0.015 75);
  --muted: oklch(0.66 0.025 60);
  --accent: oklch(0.63 0.19 35);
  --accent-deep: oklch(0.52 0.17 33);
  --on-accent: oklch(0.97 0.01 75);
  --good: oklch(0.72 0.15 148);
  --bad: oklch(0.6 0.19 25);
}

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

html { height: 100%; }

body {
  min-height: 100%;
  background:
    radial-gradient(1100px 500px at 50% -160px, var(--panel), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 19px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 16px calc(28px + env(safe-area-inset-bottom, 0px));
}

button { touch-action: manipulation; }

main {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- Header ---------- */

header {
  width: 100%;
  max-width: 500px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.home-link { flex: none; line-height: 0; }

.home-link img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  transform: rotate(-6deg);
  transition: transform 0.5s ease;
  animation: bob 2.2s ease-in-out infinite;
}

.home-link:hover img { transform: rotate(354deg); }

@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}

.masthead { flex: 1; min-width: 0; }

h1 {
  font-family: var(--display);
  font-size: clamp(26px, 7vw, 34px);
  letter-spacing: 1.5px;
  line-height: 1;
  padding-top: 5px; /* Luckiest Guy sits high */
  color: var(--accent);
  text-shadow: 2.5px 2.5px 0 var(--ink);
}

.masthead small {
  display: block;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.2;
}

.streaks {
  flex: none;
  text-align: right;
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 1px;
  line-height: 1.55;
  color: var(--text);
}

.streaks .best { color: var(--muted); }

.streaks .num { color: var(--accent); font-size: 18px; }

/* streak flame pops when it grows */
.streaks .flame.pop { display: inline-block; animation: pop 0.5s ease-out; }

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.7) rotate(-8deg); }
  100% { transform: scale(1); }
}

/* ---------- Player ---------- */

.player {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 5px 0 var(--ink);
}

.play-btn {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.play-btn:disabled { opacity: 0.45; cursor: default; }

/* nudge the triangle optically center */
.play-btn .tri { translate: 2px 0; }

.bar-wrap { flex: 1; min-width: 0; }

.bar {
  position: relative;
  height: 26px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--bg-deep);
  overflow: hidden;
}

.bar .unlocked {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--panel-2);
  transition: width 0.35s ease;
}

.bar .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--accent);
  opacity: 0.9;
}

.bar .tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--ink);
  opacity: 0.6;
}

.bar-times {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  color: var(--muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Guess rows ---------- */

.guesses { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.guess-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border: 2.5px dashed color-mix(in oklab, var(--muted) 45%, transparent);
  border-radius: 12px;
  color: var(--muted);
  font-size: 17px;
}

.guess-row .icon { flex: none; width: 22px; text-align: center; }

.guess-row .what {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guess-row.current {
  border-style: solid;
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 9%, transparent);
}

.guess-row.wrong,
.guess-row.skipped {
  border-style: solid;
  border-color: var(--ink);
  background: var(--panel);
  color: var(--text);
}

.guess-row.skipped .what { color: var(--muted); letter-spacing: 1px; }

.guess-row.won {
  border-style: solid;
  border-color: var(--good);
  background: color-mix(in oklab, var(--good) 16%, transparent);
  color: var(--text);
}

/* ---------- Search + actions ---------- */

.guess-ui { display: flex; flex-direction: column; gap: 10px; }

.search-wrap { position: relative; }

#search {
  width: 100%;
  font-family: var(--body);
  font-size: 19px;
  padding: 12px 14px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--text);
  color: var(--ink);
  outline: none;
  box-shadow: 0 4px 0 var(--ink);
}

#search:focus { border-color: var(--accent); }

#search { scroll-margin-top: 16px; }

#search::placeholder { color: color-mix(in oklab, var(--ink) 55%, var(--text)); }

.suggestions {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  list-style: none;
  background: var(--text);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 8px 0 var(--ink);
  overflow: hidden;
  max-height: 264px;
  overflow-y: auto;
}

/* keyboard open, no room below: open upward instead */
.suggestions.up {
  top: auto;
  bottom: calc(100% + 6px);
  box-shadow: 0 -8px 0 var(--ink);
}

.suggestions li {
  touch-action: manipulation;
  padding: 10px 14px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.25;
  cursor: pointer;
  border-bottom: 1.5px solid color-mix(in oklab, var(--ink) 14%, transparent);
}

.suggestions li:last-child { border-bottom: 0; }

.suggestions li .s-artist { opacity: 0.65; }

.suggestions li.active,
.suggestions li:hover { background: var(--accent); color: var(--on-accent); }

.suggestions li.note { cursor: default; opacity: 0.6; font-size: 15px; }

.suggestions li.note:hover { background: inherit; color: var(--ink); }

.action-row { display: flex; gap: 10px; }

.btn {
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 1.5px;
  padding: 12px 16px 9px; /* Luckiest Guy sits high: rebalance */
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.btn:disabled { opacity: 0.45; cursor: default; }

.btn:disabled:active { transform: none; box-shadow: 0 4px 0 var(--ink); }

.btn:focus-visible, .play-btn:focus-visible, #search:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn-skip { flex: 1; }

.btn-submit { flex: 2; background: var(--accent); color: var(--on-accent); }

/* ---------- Reveal ---------- */

.reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 20px 16px 18px;
  box-shadow: 0 5px 0 var(--ink);
  animation: reveal-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes reveal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.reveal .verdict {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 2px;
  line-height: 1;
  padding-top: 4px;
}

.reveal.win .verdict { color: var(--good); text-shadow: 2px 2px 0 var(--ink); }

.reveal.loss .verdict { color: var(--bad); text-shadow: 2px 2px 0 var(--ink); }

.reveal img {
  width: 132px;
  height: 132px;
  border-radius: 12px;
  border: 3px solid var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  background: var(--bg-deep);
}

.reveal .r-title { font-size: 23px; line-height: 1.15; }

.reveal .r-artist { font-size: 19px; color: var(--muted); margin-top: -6px; }

.reveal .r-meta { font-size: 16px; color: var(--muted); }

.reveal .btn-next { margin-top: 6px; min-width: 200px; background: var(--accent); color: var(--on-accent); }

/* ---------- Status / footer ---------- */

.status {
  min-height: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 17px;
}

footer {
  margin-top: auto;
  padding-top: 34px;
  font-size: 16px;
  color: var(--muted);
}

footer a { color: var(--muted); }

.hidden { display: none !important; }

/* ---------- Small screens ---------- */

@media (max-width: 400px) {
  body { padding-top: 14px; font-size: 18px; }
  header { margin-bottom: 12px; }
  .home-link img { width: 38px; height: 38px; }
  .player { padding: 11px; gap: 11px; }
  .play-btn { width: 56px; height: 56px; }
  .guess-row { min-height: 40px; font-size: 16px; }
  .btn { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .home-link img, .streaks .flame.pop { animation: none; }
  .reveal { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
