/* Huddle on the web, under the house design law
 * (docs/design-docs/brand-canon.md).
 *
 * §3  The page ground is the platform's, light and dark; brand owns no page
 *     colour. Ink and the secondary ink are the canon's solved values.
 * §2.2 No shadow chrome, no gradient chrome, no box around a section. Space
 *     and type separate things. A hairline appears only inside a dense list.
 * §3  Colour is data: a hue states which person, or that a mic is live, or
 *     that a path is relayed. Chrome is ink.
 * §5  Nothing a person reads sits under 13px, and every ink is measured on
 *     its real ground in both schemes.
 * §3  Numbers are mono, everywhere.
 */

:root {
  color-scheme: light dark;

  --page: #ffffff;
  --ink: #181826;          /* 16.5:1 on white */
  --secondary: #66635c;    /* 5.7:1 on white — solved, not .secondary */
  --hairline: #e4e3e0;
  --quiet-ground: #f3f3f1;
  --alert: #9a1d14;        /* 7.0:1 on white */
  --affirm: #207a36;       /* 4.6:1 on white */
  --live: #b2260d;         /* the mic-is-open hue, 5.6:1 on white */

  --radius-s: 4px;
  --radius-m: 8px;
  --radius-l: 12px;
  --radius-xl: 16px;

  --text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #1c1c1e;
    --ink: #f2f1ef;
    --secondary: #a7a29a;  /* 6.4:1 on #1c1c1e */
    --hairline: #333336;
    --quiet-ground: #27272a;
    --alert: #ff6b5e;
    --affirm: #30d158;
    --live: #ff6b4a;
  }
}

:root[data-theme="dark"] {
  --page: #1c1c1e;
  --ink: #f2f1ef;
  --secondary: #a7a29a;
  --hairline: #333336;
  --quiet-ground: #27272a;
  --alert: #ff6b5e;
  --affirm: #30d158;
  --live: #ff6b4a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 var(--text);
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 44rem;        /* §7: the measure, not the window */
  margin: 0 auto;
  padding: 0 16px 48px;    /* §7: a 16px gutter at phone width */
  display: flex;
  flex-direction: column;
}

/* §8: the reason the page was opened comes first. Once there is a room, the
   room is the page and the join form is the thing below it. With no room the
   form is the only section, so its order never shows. */
#live { order: 1; }
#rooms-section { order: 2; }
#door { order: 3; }

h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 20px; font-weight: 600; margin: 32px 0 4px; letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 600; margin: 32px 0 8px; color: var(--secondary); }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 44rem;
  margin: 0 auto;
  padding: 16px;
}

.lede { margin: 0 0 24px; color: var(--secondary); max-width: 38rem; }
/* An invite link is one long unbreakable word; §7 allows no horizontal page
   scroll, so it breaks rather than widening the room. */
.whisper { font-size: 13px; color: var(--secondary); margin: 8px 0 0; overflow-wrap: anywhere; }
.problem { color: var(--alert); font-size: 14px; margin: 8px 0 0; }

.banner {
  position: sticky;
  bottom: 0;
  margin: 0;
  padding: 12px 16px;
  background: var(--page);
  border-top: 1px solid var(--hairline);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 16px; top: 16px;
  z-index: 2;
  background: var(--page);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: var(--radius-m);
}

/* ── fields ──────────────────────────────────────────────────────────── */

.form { display: flex; flex-direction: column; gap: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend {
  font-size: 13px;
  color: var(--secondary);
  padding: 0;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.field small { font-size: 13px; color: var(--secondary); font-weight: 400; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline > span { white-space: nowrap; }

input[type="text"], input[type="url"] {
  font: 15px var(--mono);
  color: var(--ink);
  background: var(--quiet-ground);
  border: 0;
  border-radius: var(--radius-m);
  padding: 10px 12px;
  min-width: 0;
  width: 100%;
}
input[type="text"]:focus-visible, input[type="url"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.choice { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.choice input { margin-top: 4px; flex: none; width: 18px; height: 18px; accent-color: var(--ink); }
.choice span { display: flex; flex-direction: column; }
.choice strong { font-weight: 500; font-size: 15px; }
.choice small { font-size: 13px; color: var(--secondary); }

/* ── actions: one door, the rest quiet (§2.4) ────────────────────────── */

.actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }

button { font: inherit; cursor: pointer; }

.door {
  background: var(--ink);
  color: var(--page);
  border: 0;
  border-radius: var(--radius-l);
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 500;
}
.door:disabled { opacity: 0.4; cursor: default; }
.door.big { font-size: 18px; padding: 16px 32px; }
.actions.start { margin: 8px 0 16px; }
details#advanced { margin-top: 24px; }
details#advanced > summary { cursor: pointer; color: var(--secondary); font-size: 15px; padding: 8px 0; }
details#advanced[open] > summary { margin-bottom: 12px; }
.share { margin: 8px 0 16px; }
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--secondary); border-radius: var(--radius-l); background: var(--page); color: var(--ink); }

.quiet {
  background: none;
  border: 0;
  color: var(--ink);
  padding: 11px 4px;
  font-size: 15px;
}
.quiet:disabled { color: var(--secondary); cursor: default; }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ── the hero fact, then the signature object (§8) ───────────────────── */

.hero { margin: 24px 0 16px; }
.hero-state {
  margin: 0;
  font: 500 40px/1.1 var(--text);
  letter-spacing: -0.02em;
}
.hero-state[data-live="true"] { color: var(--live); }
.hero-room { margin: 4px 0 0; color: var(--secondary); font: 14px var(--mono); }

.talk {
  display: block;
  width: 100%;
  min-height: 112px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-xl);
  background: none;
  color: var(--ink);
  font-size: 20px;
  font-weight: 500;
  touch-action: none;             /* a held finger must not scroll the page */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.talk[aria-pressed="true"] { background: var(--live); border-color: var(--live); color: #ffffff; }
.talk:disabled { border-color: var(--hairline); color: var(--secondary); cursor: default; }

.modes { margin-top: 24px; }

.strip { margin-top: 20px; }
.strip p { margin: 0; }
#floor-holder { font-size: 15px; }

/* ── rooms and peers: dense lists, so a hairline is allowed (§2.2) ───── */

.rooms, .peers { list-style: none; margin: 0; padding: 0; }
.rooms li, .peers li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
}
.rooms li:last-child, .peers li:last-child { border-bottom: 0; }

.rooms .name, .peers .name { flex: 1 1 auto; min-width: 0; }
.rooms .name strong, .peers .name strong { display: block; font-weight: 500; font-size: 15px; }
.rooms .name small, .peers .name small { display: block; font-size: 13px; color: var(--secondary); }
.peers .name small { font-family: var(--mono); }

/* The identity dot: the house 12-hue wheel, keyed by name. The hue says
   WHICH person and nothing else; it is never the only carrier of a fact. */
.dot {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--hue, var(--secondary));
  display: grid;
  place-items: center;
  color: #ffffff;
  font: 600 12px var(--text);
}

/* The level meter is decoration for a fact the row also states in words. */
.meter {
  flex: none;
  width: 56px; height: 6px;
  border-radius: var(--radius-s);
  background: var(--quiet-ground);
  overflow: hidden;
}
.meter i { display: block; height: 100%; width: 0; background: var(--ink); }
.meter[data-talking="true"] i { background: var(--live); }

.mute {
  flex: none;
  background: none;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-m);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 13px;
  min-height: 32px;
}
.mute[aria-pressed="true"] { border-color: var(--ink); background: var(--quiet-ground); }

.pill {
  flex: none;
  font: 12px var(--mono);
  color: var(--secondary);
  white-space: nowrap;
}
.pill[data-path="relayed"] { color: var(--ink); }
.pill[data-path="failed"] { color: var(--alert); }

.rooms .talking { color: var(--live); font-size: 13px; }
.rooms input[type="radio"] { flex: none; width: 18px; height: 18px; accent-color: var(--ink); }

@media (min-width: 44rem) {
  .talk { min-height: 128px; }
}
