/* Crowdspeaker: a dark house, one pool of tungsten light.
   The screen stays dim on purpose: a hundred bright phones would light up the audience. */

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

:root {
  --house: #160c11;        /* house lights down */
  --velvet: #2b1119;       /* curtain, for surfaces */
  --velvet-edge: #55273a;
  --tungsten: #ffc061;     /* the spotlight */
  --tungsten-hot: #ffe6b8;
  --bone: #f3eadb;         /* text */
  --dust: #ad989f;         /* secondary text */
  --onair: #ff5a45;        /* talker is live */
  --level: 0;              /* 0..1, how loud the stage is right now */
  --font: "Bricolage Grotesque", "Avenir Next Condensed", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--house);
  color: var(--bone);
  font: 400 1.0625rem/1.5 var(--font);
}

main {
  max-width: 26rem;
  margin: 0 auto;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom));
}

.wordmark {
  margin: 0;
  font-weight: 700;
  font-stretch: 75%;
  font-size: 1.125rem;
  letter-spacing: 0.01em;
  color: var(--dust);
}

h1 {
  margin: 2rem 0 1.5rem;
  font-weight: 800;
  font-stretch: 75%;
  font-size: 2.5rem;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 0.5rem;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--dust);
}

p { margin: 0 0 1rem; }

button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--bone); outline-offset: 3px; }

/* ---------- listener: the pool of light ---------- */

.pool {
  display: grid;
  place-items: center;
  width: min(64vw, 17rem);
  aspect-ratio: 1;
  margin: 2.75rem auto 2.25rem;
  padding: 0;
  border: 2px solid var(--tungsten);
  border-radius: 50%;
  background: transparent;
  color: var(--bone);
  font-weight: 800;
  font-stretch: 75%;
  font-size: 2.75rem;
  line-height: 1;
  letter-spacing: -0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.25s ease-out, box-shadow 0.25s ease-out, background-color 0.4s, border-color 0.4s, color 0.4s;
}

body[data-state="connecting"] .pool,
body[data-state="reconnecting"] .pool {
  border-style: dashed;
  color: var(--dust);
  font-size: 1.75rem;
  cursor: default;
  animation: breathe 1.6s ease-in-out infinite;
}

body[data-state="waiting"] .pool {
  border-color: var(--velvet-edge);
  background: var(--velvet);
  color: var(--dust);
  font-size: 2rem;
  cursor: default;
}

body[data-state="live"] .pool {
  border-color: transparent;
  background: radial-gradient(circle at 50% 40%, var(--tungsten-hot) 0%, var(--tungsten) 42%, #c47f2a 100%);
  color: var(--house);
  font-size: 2rem;
  cursor: default;
  transform: scale(calc(1 + var(--level) * 0.07));
  box-shadow:
    0 0 calc(2rem + var(--level) * 5rem) calc(var(--level) * 1.5rem)
    rgb(255 192 97 / calc(0.22 + var(--level) * 0.5));
}

body[data-state="blocked"] .pool {
  border-color: var(--onair);
  font-size: 1.75rem;
}

@keyframes breathe {
  50% { opacity: 0.45; }
}

.status { min-height: 3em; }

.talkers {
  margin: 0 0 1.75rem;
  padding: 0;
  list-style: none;
}

.talkers li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--velvet-edge);
  font-weight: 600;
  font-size: 1.25rem;
  transition: color 0.2s;
}
.talkers li:last-child { border-bottom: 1px solid var(--velvet-edge); }
.talkers li small { font-weight: 400; font-size: 0.9375rem; color: var(--dust); }
.talkers li.speaking { color: var(--tungsten); }
.talkers li.speaking small { color: var(--tungsten); }
.talkers li.muted { color: var(--dust); }

.delay { margin: 0 0 1.75rem; }
.delay .total {
  margin: 0 0 0.25rem;
  font-weight: 800;
  font-stretch: 75%;
  font-size: 1.75rem;
  line-height: 1.1;
}
.delay dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.125rem 1rem;
  margin: 0;
  font-size: 0.9375rem;
  color: var(--dust);
}
.delay dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.delay .warn { margin: 0.75rem 0 0; color: var(--tungsten); }

.hint { color: var(--dust); font-size: 0.9375rem; }

/* ---------- buttons and fields ---------- */

.quiet {
  padding: 0.5rem 0;
  border: 0;
  background: none;
  color: var(--dust);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.solid {
  display: block;
  width: 100%;
  padding: 0.9rem 1rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--bone);
  color: var(--house);
  font-weight: 700;
  font-size: 1.1875rem;
  cursor: pointer;
}
.solid.onair { background: var(--onair); }
.solid:disabled { opacity: 0.5; cursor: default; }

.field { display: block; margin: 0 0 1rem; color: var(--dust); font-size: 0.9375rem; }
.field input, .field select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--velvet-edge);
  border-radius: 0.5rem;
  background: var(--velvet);
  color: var(--bone);
  font-size: 1.125rem;
}

.check { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.6rem; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--tungsten); }
.checks { margin: 1.25rem 0 1.5rem; }

.error { min-height: 1.5em; margin-top: 1rem; color: var(--onair); }

/* ---------- talker: live panel ---------- */

.onair-title {
  margin: 2.5rem 0 1.25rem;
  font-weight: 800;
  font-stretch: 75%;
  font-size: 3.5rem;
  line-height: 0.95;
  letter-spacing: -0.015em;
  color: var(--onair);
}
body[data-state="muted"] .onair-title,
body[data-state="reconnecting"] .onair-title { color: var(--dust); }

.meter {
  height: 0.875rem;
  margin: 0 0 1.5rem;
  border-radius: 0.4375rem;
  background: var(--velvet);
  overflow: hidden;
}
.meter div {
  height: 100%;
  width: 100%;
  background: var(--tungsten);
  transform-origin: left;
  transform: scaleX(var(--level));
}
body[data-state="muted"] .meter div { background: var(--velvet-edge); }

.audience { font-weight: 600; font-size: 1.25rem; }
.live-actions { display: grid; gap: 0.75rem; margin-top: 1.5rem; }

@media (prefers-reduced-motion: reduce) {
  .pool { transition: none; animation: none !important; }
  body[data-state="live"] .pool { transform: none; }
}

/* ---------- rooms: header, home page ---------- */

.wordmark { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.wordmark a { color: inherit; text-decoration: none; }
.room { font-weight: 400; font-stretch: 100%; font-size: 0.9375rem; }
.code { font-weight: 800; letter-spacing: 0.12em; color: var(--tungsten); white-space: nowrap; }

form { margin-top: 1.75rem; }

.roles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 2rem 0 1rem;
}
.role {
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid var(--tungsten);
  border-radius: 50%;
  background: transparent;
  color: var(--bone);
  font-weight: 800;
  font-stretch: 75%;
  font-size: 2.25rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.role.speak { border-color: var(--onair); }
.role:active { background: var(--velvet); }
.role:disabled { opacity: 0.5; cursor: default; }

.field .code-input {
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.25em;
}

.resume a { color: var(--tungsten); font-weight: 800; letter-spacing: 0.12em; }
.explain { margin-top: 2rem; color: var(--dust); font-size: 0.9375rem; }

.page-actions { display: grid; justify-items: start; gap: 0.25rem; margin-top: 0.5rem; }
a.quiet { display: inline-block; }

/* ---------- invitations: QR codes ---------- */

/* The first screen is at least one viewport tall, so the speaker invitation always sits below the fold. */
.first-screen { min-height: 100dvh; padding-bottom: 2.5rem; }

.invite-block { margin-top: 2.5rem; }
.invite-title {
  margin: 0 0 0.75rem;
  font-weight: 800;
  font-stretch: 75%;
  font-size: 1.75rem;
  line-height: 1.1;
  color: var(--bone);
}
.qr {
  max-width: 17rem;
  margin: 0 auto 1rem;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #f3eadb;
}
.qr svg { display: block; width: 100%; height: auto; }
.invite-how { margin-top: 1rem; color: var(--dust); }
.invite-how strong { color: var(--bone); }

.invite-block.speakers {
  margin-top: 0;
  padding-top: 2rem;
  border-top: 1px solid var(--velvet-edge);
}
.invite-block.speakers .invite-title { color: var(--onair); }
.invite-block.speakers .qr { border: 5px solid var(--onair); }

dialog.share {
  width: min(100vw - 2rem, 24rem);
  max-height: calc(100dvh - 2rem);
  padding: 1.5rem 1.25rem 1rem;
  border: 1px solid var(--velvet-edge);
  border-radius: 1rem;
  background: var(--house);
  color: var(--bone);
}
dialog.share::backdrop { background: rgb(10 5 8 / 0.85); }
dialog.share h2 {
  margin: 0 0 1rem;
  font-weight: 800;
  font-stretch: 75%;
  font-size: 1.75rem;
  line-height: 1.1;
  color: var(--bone);
}
