/* LAN Intercom - dark, high-contrast, thumb-friendly. */

:root {
  --bg: #0b0d10;
  --surface: #14181e;
  --surface-2: #1c222a;
  --line: #2a323d;
  --text: #e8edf3;
  --muted: #8b98a8;
  --accent: #33d17a;
  --accent-dim: #1c7a48;
  --warn: #f0a03c;
  --danger: #e2544a;
  --radius: 14px;
  --tap: 56px;
}

* { box-sizing: border-box; }

/* Any explicit `display` would otherwise beat the `hidden` attribute's
   UA `display: none`, which silently leaves hidden panels on screen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overscroll-behavior: none;
}

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

/* ---------------------------------------------------------------- banner */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #3a1f1d;
  border: 1px solid var(--danger);
  color: #ffd9d5;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.45;
}
.banner[data-tone="warn"] { background: #3a2f1a; border-color: var(--warn); color: #ffe6bf; }
.banner[data-tone="info"] { background: #16262f; border-color: #2f6f86; color: #cfe9f5; }
.banner-close {
  margin-left: auto;
  background: none; border: 0; color: inherit;
  font-size: 22px; line-height: 1; cursor: pointer;
  padding: 0 4px;
}

/* ---------------------------------------------------------------- screens */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.brand { text-align: center; margin: 8vh 0 24px; }
.brand h1 { margin: 0; font-size: 30px; letter-spacing: 0.32em; font-weight: 700; }
.brand-sub { margin: 8px 0 0; color: var(--muted); font-size: 13px; letter-spacing: 0.08em; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 12px; letter-spacing: 0.18em; color: var(--muted); }
.field input {
  height: var(--tap);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  /* 16px minimum keeps iOS Safari from zooming when the field is focused. */
  font-size: 17px;
  letter-spacing: 0.08em;
  padding: 0 14px;
  width: 100%;
}
.field input:focus { outline: 2px solid var(--accent-dim); outline-offset: 1px; }

.hint { color: var(--muted); font-size: 12.5px; margin: 0; line-height: 1.5; }
.foot-note { color: var(--muted); font-size: 12px; text-align: center; margin: 18px 0 0; }

/* ------------------------------------------------------------ open rooms */
.open-rooms { margin-top: 22px; }
.open-rooms-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.open-rooms-head h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-weight: 600;
}
.room-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.room-btn {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.room-btn:disabled { cursor: not-allowed; opacity: 0.55; }
.room-btn .room-id { font-size: 15px; letter-spacing: 0.12em; font-weight: 700; flex: none; }
.room-btn .room-who {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-btn .room-count {
  margin-left: auto;
  flex: none;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.room-btn:disabled .room-count { color: var(--danger); }

/* ---------------------------------------------------------------- buttons */
.btn {
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.16em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--accent); color: #06210f; }
.btn-primary:disabled { background: var(--accent-dim); color: #9fc9b1; cursor: progress; }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-ghost[aria-pressed="true"] { background: var(--warn); color: #2a1a05; border-color: var(--warn); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }

.chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 7px 12px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--accent-dim); }

/* ---------------------------------------------------------------- room */
.room-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.room-title { display: flex; align-items: center; gap: 12px; }
.room-title h2 {
  margin: 0; font-size: 22px; letter-spacing: 0.22em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.room-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pill {
  font-size: 11px;
  letter-spacing: 0.12em;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.pill-ok   { color: var(--accent); border-color: var(--accent-dim); }
.pill-wait { color: var(--warn); border-color: #6b4d1d; }
.pill-bad  { color: var(--danger); border-color: #6d2b26; }
.pill-live { color: #06210f; background: var(--accent); border-color: var(--accent); }
.pill-idle { color: var(--muted); }

.peers {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.peer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.peer:last-child { border-bottom: 0; }
.peer .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #3a4552; flex: none;
  transition: background 90ms linear, box-shadow 90ms linear;
}
.peer.is-speaking .dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(51, 209, 122, 0.22); }
.peer .peer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer .tag {
  margin-left: auto;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--muted);
  white-space: nowrap;
}
.peer.is-speaking .tag { color: var(--accent); }
.peer .tag.tag-bad { color: var(--danger); }
.peer .tag.tag-wait { color: var(--warn); }
.peer-empty {
  padding: 13px 14px;
  color: var(--muted);
  font-size: 14px;
}
.peer.is-self .peer-name::after { content: " (you)"; color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- talk */
.talk-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
}
.talk {
  width: min(78vw, 260px);
  height: min(78vw, 260px);
  border-radius: 50%;
  border: 3px solid var(--accent-dim);
  background: radial-gradient(circle at 50% 35%, #1d2a22, #12161b);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 800;
  letter-spacing: 0.16em;
  cursor: pointer;
  /* Stops iOS from scrolling / long-press-selecting while the finger is down. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 70ms ease, background 70ms linear, border-color 70ms linear;
}
.talk-line-1 { font-size: 26px; }
.talk-line-2 { font-size: 13px; letter-spacing: 0.14em; opacity: 0.8; }
.talk.is-live {
  background: radial-gradient(circle at 50% 35%, #33d17a, #1d8f52);
  border-color: #7dffb9;
  color: #06210f;
}
.talk:active { transform: scale(0.97); }
.talk.is-muted {
  background: radial-gradient(circle at 50% 35%, #3a1f1d, #1a1213);
  border-color: var(--danger);
  color: #ffd9d5;
}

.controls { display: grid; grid-template-columns: 1fr; gap: 12px; }

/* ---------------------------------------------------------------- gate */
.gate {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 9, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.gate .btn { width: 100%; max-width: 340px; }

/* Short landscape screens: shrink the talk button so controls stay reachable. */
@media (max-height: 560px) {
  .talk { width: min(46vh, 190px); height: min(46vh, 190px); }
  .talk-line-1 { font-size: 20px; }
  .brand { margin: 4vh 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .talk, .peer .dot { transition: none; }
}
