/* Guest page. Colors, type and shapes from DESIGN.md §3.
   Sizes follow BUILD_SPEC §9 where the mockups are smaller:
   main text 18px, secondary 16px or more, tap targets 48px or more. */

:root {
  --bg: #110F0D;
  --surface: #1C1915;
  --surface-2: #28231D;
  --line: #40392F;
  --track: #352F27;
  --text: #F7F1E4;
  --text-muted: #ADA597;
  --text-soft: #E2D9C8;
  --accent: #FFB224;
  --on-accent: #1A1203;
  --mine-row: #1F1C17;
  --display: 'Bricolage Grotesque', 'Arial Black', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --key: inset 0 -5px 0 rgba(26, 18, 3, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 18px/1.4 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

/* Layout */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 14px; }
.grow { flex: 1; }
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.center { text-align: center; }

/* Type */
.brand { font: 800 20px var(--display); letter-spacing: 0.06em; }
.headline { font: 800 44px/1 var(--display); letter-spacing: -0.02em; margin-top: 8px; }
.headline-xl { font: 800 52px/0.98 var(--display); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.label { font-size: 16px; font-weight: 700; letter-spacing: 0.08em; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.label.accent { color: var(--accent); }
.strong { font-weight: 700; }
.sub { font-size: 16px; color: var(--text-muted); }
.soft { font-size: 16px; color: var(--text-soft); }
.fine { font-size: 16px; color: var(--text-muted); }
.lede { font-size: 19px; line-height: 1.45; color: var(--text-muted); }
.lede b { color: var(--text); }

.top { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.hello { font-size: 16px; color: var(--text-muted); }
.hello b { color: var(--text); }
.code-chip { padding: 6px 12px; border-radius: 14px; background: var(--surface); font-size: 16px; font-weight: 700; letter-spacing: 0.1em; color: var(--text-muted); }

/* Buttons */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; height: 64px; padding: 0 20px; border: 0; border-radius: 32px;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--key);
  font: 800 22px var(--display);
}
.btn-primary:active { transform: translateY(1px); box-shadow: inset 0 -2px 0 rgba(26, 18, 3, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
.btn-left { justify-content: flex-start; }
.btn-outline {
  width: 100%; min-height: 52px; border-radius: 26px; border: 1px solid var(--line);
  background: transparent; font-weight: 700; font-size: 16px;
}
.icon-btn {
  width: 48px; height: 48px; flex: none; border: 0; border-radius: 24px;
  background: var(--surface); display: flex; align-items: center; justify-content: center;
}

/* Album tiles: placeholder colors with initials in a thin ring, like a record label */
.tile {
  position: relative; flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; color: #FFFFFF;
  background: var(--surface-2);
}
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile .ring { display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.3); }
.tile-48 { width: 48px; height: 48px; border-radius: 10px; font-size: 14px; }
.tile-48 .ring { width: 34px; height: 34px; }
.tile-56 { width: 56px; height: 56px; border-radius: 12px; font-size: 15px; }
.tile-56 .ring { width: 40px; height: 40px; }
.tile-72 { width: 72px; height: 72px; border-radius: 14px; font-size: 22px; }
.tile-72 .ring { width: 52px; height: 52px; }
.tile-40 { width: 40px; height: 40px; border-radius: 8px; font-size: 12px; }
.tile-40 .ring { width: 28px; height: 28px; }

/* Now playing */
.np-card { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 20px; background: var(--surface); margin-top: 8px; }
.np { display: flex; align-items: center; gap: 14px; }
.np-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.np-title { font: 800 24px/1.1 var(--display); overflow-wrap: anywhere; }
.np-title-sm { font-size: 18px; font-weight: 700; }

@keyframes eq { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i { display: block; width: 3px; height: 12px; border-radius: 1px; background: currentColor; transform-origin: bottom; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1.1s linear infinite; flex: none; margin-top: 2px; color: var(--accent); }

/* Reactions under Now playing, and the emoji floating up the screen */
.reactions { display: flex; justify-content: space-between; gap: 8px; }
.react-btn {
  flex: 1; min-width: 48px; height: 52px; border: 0; border-radius: 26px;
  background: var(--surface); font-size: 26px; line-height: 1;
}
.react-btn:active { background: var(--surface-2); transform: scale(0.94); }
.floats { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
@keyframes float-up {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  12% { opacity: 1; transform: translate(0, -6vh) scale(1.1); }
  100% { transform: translate(var(--drift, 0), -70vh) scale(1); opacity: 0; }
}
@keyframes float-fade { 0%, 100% { opacity: 0; } 20%, 70% { opacity: 1; } }
.float { position: absolute; bottom: 8vh; font-size: 36px; animation: float-up 2.8s ease-out forwards; }

/* Crowd skip */
.skip-vote {
  width: 100%; min-height: 48px; border-radius: 24px; border: 1px solid var(--line);
  background: transparent; font-weight: 700; font-size: 16px; color: var(--text-muted);
}
.skip-vote.voted { border-color: var(--accent); color: var(--accent); }
.skip-note { font-size: 16px; color: var(--text-soft); }

/* Up next: taking back your own song */
.icon-btn-quiet { background: transparent; color: var(--text-muted); }
.take-back {
  flex: none; min-height: 48px; padding: 0 16px; border: 0; border-radius: 24px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 16px;
}

@media (prefers-reduced-motion: reduce) {
  .eq i, .spin { animation: none; }
  .float { animation: float-fade 1.6s ease-out forwards; }
  .btn-primary:active { transform: none; }
}

/* Banner: host reconnecting, or this phone lost its connection */
.banner { display: flex; gap: 14px; padding: 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }

/* Fields */
.field { display: flex; flex-direction: column; gap: 10px; }
.field-label { font-weight: 700; }
.text-input {
  height: 60px; padding: 0 18px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--surface); font-size: 19px; font-weight: 500;
}
.text-input::placeholder, #q::placeholder { color: #958C7E; }
.text-input[aria-invalid="true"] { border-color: var(--accent); }

/* Join code */
.code-box { position: relative; }
.code-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.code-tile {
  height: 84px; border-radius: 18px; background: var(--surface); border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font: 800 46px var(--display);
}
.code-tile.current { border-color: var(--text-muted); }
.code-tile.bad { border-color: var(--accent); color: var(--accent); }
/* The real input sits over the tiles so a tap anywhere on them opens the keyboard.
   16px keeps iOS from zooming in on focus. */
.code-input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0;
  font-size: 16px; border: 0; background: transparent; caret-color: transparent;
}
.code-box:focus-within .code-tile.current { border-color: var(--accent); }
.code-msg { display: flex; gap: 10px; align-items: flex-start; font-size: 16px; color: var(--text-soft); }
.code-msg svg { flex: none; margin-top: 2px; color: var(--accent); }
.code-msg b { color: var(--text); }

/* Your song card */
.mine-card { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 20px; background: rgba(255, 178, 36, 0.12); border: 1px solid rgba(255, 178, 36, 0.35); }
.pos-badge {
  width: 56px; height: 56px; flex: none; border-radius: 28px;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font: 800 24px var(--display);
}

/* Queue */
.queue-list { display: flex; flex-direction: column; gap: 2px; }
.queue-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 14px; }
.queue-row.mine { background: var(--mine-row); }
.queue-row .pos { width: 24px; flex: none; font-size: 16px; font-weight: 700; color: var(--text-muted); text-align: center; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 16px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub.accent { color: var(--accent); white-space: normal; }
.by { flex: none; font-size: 16px; font-weight: 700; color: var(--text-muted); max-width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine .by { color: var(--accent); }

/* Search */
.search-bar { display: flex; align-items: center; gap: 10px; }
.search-field { flex: 1; position: relative; display: flex; align-items: center; }
.search-field svg { position: absolute; left: 16px; color: var(--text-muted); pointer-events: none; }
#q {
  width: 100%; height: 52px; padding: 0 16px 0 46px; border-radius: 26px;
  border: 1px solid var(--line); background: var(--surface); font-size: 19px; font-weight: 500;
  -webkit-appearance: none; appearance: none;
}
#q:focus { border-color: var(--accent); outline: none; }

.results { display: flex; flex-direction: column; gap: 4px; }
#results-msg { padding-bottom: 120px; } /* room for the toast */
.result { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.result.blocked .tile, .result.blocked .row-text { opacity: 0.5; }
.title-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.badge-e { flex: none; padding: 1px 6px; border-radius: 4px; background: var(--line); font-size: 13px; font-weight: 700; color: var(--text-soft); }
.add-btn {
  width: 52px; height: 52px; flex: none; border-radius: 26px;
  border: 2px solid var(--accent); background: transparent; color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.add-btn.added { background: var(--accent); color: var(--on-accent); cursor: default; }
.add-btn.wait { border: 2px dashed var(--line); color: var(--text-muted); cursor: default; }
.add-btn:disabled:not(.added):not(.wait) { opacity: 0.6; }

.limit-card { display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 20px; background: var(--surface); border: 1.5px solid var(--accent); }
.limit-title { font: 800 22px var(--display); }
.dots { display: flex; gap: 5px; flex: none; }
.dots span { width: 10px; height: 10px; border-radius: 5px; background: var(--accent); }
.limit-card b { color: var(--text); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: max(24px, env(safe-area-inset-bottom));
  max-width: 448px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 22px;
  background: var(--text); color: #141216; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.toast-pos {
  width: 48px; height: 48px; flex: none; border-radius: 24px;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font: 800 19px var(--display);
}
.toast-sub { font-size: 16px; color: #4A4752; }
.toast { flex-wrap: wrap; row-gap: 4px; }
.toast-actions { flex-basis: 100%; display: flex; justify-content: flex-end; gap: 16px; margin-bottom: -8px; }
.toast-link { flex: none; min-height: 48px; padding: 0 4px; border: 0; background: none; color: #141216; font-weight: 700; font-size: 16px; text-decoration: underline; }

/* Session over */
.ended-hero { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.ended-icon { width: 88px; height: 88px; border-radius: 44px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; }
.ended-songs { display: flex; flex-direction: column; gap: 6px; }
.ended-songs li { display: flex; align-items: center; gap: 12px; font-size: 16px; }
.ended-songs .by-artist { color: var(--text-muted); }

/* The guest's own song playing: the payoff moment (DESIGN.md §8) */
.np.mine-playing { padding: 14px; border-radius: 20px; background: rgba(255, 178, 36, 0.14); border: 1px solid rgba(255, 178, 36, 0.45); }
.np.mine-playing .np-sub-you { color: var(--accent); font-weight: 700; }

.welcome { font: 800 28px/1.05 var(--display); letter-spacing: -0.01em; }
.nudge { font-size: 16px; font-weight: 700; color: var(--accent); }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet {
  width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 16px;
  padding: 24px 20px max(24px, env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0; background: var(--surface);
}
.sheet-title { font: 800 26px var(--display); }
.sheet .text-input { background: var(--bg); }
