/* Aux Swap
   One family (Bricolage Grotesque, self-hosted), one motif (the cord),
   two accents with fixed jobs: cord blue = connection, spark yellow = a match. */

@font-face {
  font-family: "Bricolage";
  src: url("/static/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  --paper: #f3f3ef;
  --ink: #121417;
  --cord: #2743e6;
  --cord-ink: #ffffff;
  --spark: #ffd23f;
  --ash: #6f757f;
  --line: #d6d8d2;
  --tile: #e6e7e2;
  --mine: var(--cord);
  --theirs: #e6e7e2;
  --online: #2fa36b;
  --danger: #c0392b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15171b;
    --ink: #eceef1;
    --cord: #7b88ff;
    --cord-ink: #0f1230;
    --ash: #9aa0aa;
    --line: #2b2f36;
    --tile: #23262c;
    --theirs: #23262c;
    --danger: #ff7b6b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Bricolage", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.wrap { max-width: 600px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

a { color: inherit; }
:focus-visible { outline: 3px solid var(--cord); outline-offset: 2px; border-radius: 4px; }

/* --- type --------------------------------------------------------------- */

h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2.2rem, 7vw, 3.1rem);
  font-weight: 800;
  font-stretch: 82%;
  line-height: 0.98;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
h2 { margin: 0; font-size: 1.5rem; font-weight: 700; font-stretch: 88%; line-height: 1.1; letter-spacing: -0.01em; }
p { margin: 0 0 0.75rem; }
.lead { font-size: 1.05rem; }
.small { font-size: 0.9rem; }
.ash { color: var(--ash); }
.context { margin: 0 0 0.75rem; color: var(--ash); }
.error { margin: 0.75rem 0 0; color: var(--danger); font-weight: 600; }
code { font-size: 0.9em; }

/* --- header ------------------------------------------------------------- */

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 3rem;
  font-size: 0.95rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-weight: 800; font-stretch: 85%; font-size: 1.15rem; letter-spacing: -0.01em;
  text-decoration: none;
}
.masthead nav { display: flex; align-items: center; gap: 1rem; }
.masthead nav a { color: var(--ash); text-decoration: none; }
.masthead nav a:hover { color: var(--ink); }
.stats { display: inline-flex; gap: 0.9rem; color: var(--ash); }
.stats .streak-on { color: var(--ink); font-weight: 600; }
.unread {
  display: inline-block;
  padding: 0 0.5rem;
  font-size: 0.8rem; font-weight: 700; line-height: 1.5rem;
  color: #121417; background: var(--spark);
  border-radius: 999px; text-decoration: none;
}
.dev { font-size: 0.8rem; color: var(--ash); border: 1px solid var(--line); border-radius: 4px; padding: 0 0.4rem; }

/* --- the plug ------------------------------------------------------------ */
/* A 3.5mm plug drawn in CSS: a body and a tip. Used at cord ends. */

.plug {
  position: relative;
  display: inline-block;
  width: 22px; height: 10px;
  background: var(--cord);
  border-radius: 3px;
  vertical-align: middle;
}
.plug::after {
  content: "";
  position: absolute;
  left: 100%; top: 3px;
  width: 12px; height: 4px;
  background: var(--cord);
  border-radius: 0 2px 2px 0;
}
.plug.flip { transform: scaleX(-1); }
.brand .plug { width: 16px; height: 8px; }
.brand .plug::after { top: 2px; width: 9px; }

/* --- buttons ------------------------------------------------------------ */

button {
  font: inherit;
  font-weight: 600;
  padding: 0.7rem 1.1rem;
  border-radius: 6px;
  border: 1.5px solid transparent;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
}
button:active { transform: translateY(1px); }
.primary { color: var(--cord-ink); background: var(--cord); border-color: var(--cord); }
.primary:hover { filter: brightness(1.06); }
.primary:disabled { opacity: 0.4; cursor: default; transform: none; }
.ghost { border-color: var(--ink); }
.ghost:hover { background: var(--tile); }
.quiet { color: var(--ash); padding: 0.4rem 0.6rem; }
.quiet:hover { color: var(--ink); }
.big { padding: 0.95rem 1.5rem; font-size: 1.1rem; }
.danger-text { color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin-top: 1.75rem; }

.spinner {
  display: none;
  width: 0.8em; height: 0.8em;
  margin-left: 0.4em;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: currentColor;
  border-radius: 50%;
  vertical-align: middle;
  animation: spin 0.7s linear infinite;
}
.htmx-request .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- lobby -------------------------------------------------------------- */

.prompt { margin-bottom: 2.25rem; }
.prompt h1 { margin-bottom: 0.75rem; }

.lobby .lead { max-width: 34ch; margin-bottom: 0.5rem; }

/* --- pick --------------------------------------------------------------- */

.pick label { display: block; font-weight: 600; margin-bottom: 0.4rem; }
.pick input[type="url"] {
  width: 100%;
  padding: 0.85rem 0.9rem;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
}
.pick input[type="url"]::placeholder { color: var(--ash); }
.hint { margin: 0.4rem 0 0; font-size: 0.85rem; color: var(--ash); }

/* --- queue: a cord hangs from the top and sways until someone plugs in -- */

.queue { padding-top: 0.5rem; }
.hang {
  position: relative;
  width: 3px;
  height: 150px;
  margin: 0 0 2.5rem 3rem;
  background: var(--cord);
  transform-origin: top center;
  animation: sway 3.2s ease-in-out infinite alternate;
}
/* The plug on the end: body, then the tip below it. */
.hang::before {
  content: "";
  position: absolute; left: 50%; top: 100%;
  width: 12px; height: 24px;
  transform: translateX(-50%);
  background: var(--cord);
  border-radius: 3px;
}
.hang::after {
  content: "";
  position: absolute; left: 50%; top: calc(100% + 24px);
  width: 5px; height: 12px;
  transform: translateX(-50%);
  background: var(--cord);
  border-radius: 0 0 2px 2px;
}
.hang.short { height: 90px; }
@keyframes sway { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
.timer { font-size: 2.6rem; font-weight: 800; font-stretch: 85%; letter-spacing: -0.02em; margin: 0.25rem 0 1rem; }
.timer.inline { font-size: inherit; font-weight: 600; font-stretch: 100%; letter-spacing: 0; margin: 0; }

/* --- reveal: two tiles joined by the cord ------------------------------- */

.pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 0.5rem;
  margin: 1.5rem 0 0.5rem;
}
.side { min-width: 0; }
.cord {
  align-self: center;
  display: flex; align-items: center;
  width: 84px;
  margin-top: -3.5rem; /* sit level with the tiles, not the captions */
}
.cord .line { flex: 1; height: 3px; background: var(--cord); }
@media (max-width: 430px) {
  .pair { grid-template-columns: 1fr; }
  .cord { width: 3px; height: 56px; margin: 0 auto; flex-direction: column; }
  .cord .line { width: 3px; height: auto; }
  .cord .plug { transform: rotate(90deg); }
  .cord .plug.flip { transform: rotate(-90deg); }
}

.card { perspective: 900px; aspect-ratio: 1; }
.card-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0;
  border-radius: 8px;
  overflow: hidden;
  backface-visibility: hidden;
  background: var(--tile);
}
.card-front { display: grid; place-items: center; background: var(--ink); }
.card-front .plug { width: 44px; height: 20px; background: var(--paper); }
.card-front .plug::after { top: 6px; width: 22px; height: 8px; background: var(--paper); }
.card-back { transform: rotateY(180deg); }
.card-back img, .no-art { display: block; width: 100%; height: 100%; object-fit: cover; }
.no-art { background: var(--tile); }
.caption { margin-top: 0.6rem; }
.caption .who { display: block; font-size: 0.85rem; color: var(--ash); }
.caption .title { display: block; font-weight: 700; line-height: 1.2; }
.caption .artist { display: block; color: var(--ash); }

/* --- listen ------------------------------------------------------------- */

.player { display: block; width: 100%; margin: 1rem 0 0.75rem; border: 0; border-radius: 8px; }

/* --- react -------------------------------------------------------------- */

.choices { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }

/* --- outcome: two plugs meet ------------------------------------------- */

.connect {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  height: 60px;
  margin: 0.5rem 0 1.5rem;
}
.connect .end { display: flex; align-items: center; width: 50%; }
.connect .end .line { flex: 1; height: 3px; background: var(--cord); }
.connect .end.left { justify-content: flex-end; animation: meet-left 0.9s cubic-bezier(0.3, 0, 0.2, 1) both; }
.connect .end.right { animation: meet-right 0.9s cubic-bezier(0.3, 0, 0.2, 1) both; }
.connect .spark {
  position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  background: var(--spark);
  border-radius: 50%;
  animation: spark 0.6s ease-out 0.8s both;
}
@keyframes meet-left  { from { transform: translateX(-40px); } to { transform: none; } }
@keyframes meet-right { from { transform: translateX(40px); }  to { transform: none; } }
@keyframes spark { from { transform: scale(0); opacity: 1; } 60% { transform: scale(3); opacity: 0.9; } to { transform: scale(4.5); opacity: 0; } }
.outcome-matched h1 { color: var(--cord); }

/* --- chat --------------------------------------------------------------- */

.chat-head { padding-bottom: 0.75rem; border-bottom: 1.5px solid var(--line); }
.chat-head p { margin: 0 0 0.2rem; }
.presence { display: flex; align-items: center; gap: 0.4rem; color: var(--ash); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--online); }

.messages {
  display: flex; flex-direction: column; gap: 0.35rem;
  height: 50vh; min-height: 280px;
  padding: 1rem 0;
  overflow-y: auto;
}
.msg { display: flex; flex-direction: column; max-width: 80%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.bubble {
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  background: var(--theirs);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.mine .bubble { background: var(--mine); color: var(--cord-ink); border-bottom-right-radius: 3px; }
.msg.theirs .bubble { border-bottom-left-radius: 3px; }
.msg time { font-size: 0.72rem; color: var(--ash); margin: 0.15rem 0.3rem 0; }
.system { align-self: center; margin: 0.5rem 0; font-size: 0.85rem; color: var(--ash); text-align: center; }

.chat-form { display: flex; gap: 0.5rem; padding-top: 0.75rem; border-top: 1.5px solid var(--line); }
.chat-form input {
  flex: 1; min-width: 0;
  padding: 0.7rem 0.8rem;
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--ink); border-radius: 6px;
}
.chat-actions { justify-content: space-between; margin-top: 1rem; }

/* --- crate -------------------------------------------------------------- */

.crate-list { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.crate-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.85rem 0;
  border-top: 1.5px solid var(--line);
}
.crate-item img, .crate-item .no-art { width: 56px; height: 56px; border-radius: 6px; }
.crate-text { display: flex; flex-direction: column; min-width: 0; }
.crate-text .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crate-text .prompt-line { font-size: 0.85rem; color: var(--ash); }
.crate-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; font-size: 0.85rem; }
.crate-meta a { color: var(--ash); }
.tag { font-size: 0.8rem; color: var(--ash); }
.tag.match { color: #121417; background: var(--spark); padding: 0 0.5rem; border-radius: 999px; font-weight: 700; }

/* --- motion off --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
