/* Accestomyphone — viewer styles. Dark by default: the phone screen is the
   only thing that should be bright on this page. */
:root {
  --bg: #0b0d10;
  --surface: #14181d;
  --surface-2: #1c2128;
  --border: #272d36;
  --text: #e6e9ee;
  --muted: #98a2b3;
  --accent: #4f9cf9;
  --accent-ink: #04121f;
  --danger: #f2545b;
  --ok: #3ecf8e;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.center-page {
  /* Flex, not grid: an auto-sized grid track takes its width from the content
     (here the six code boxes), so the card kept its 420px on a 320px phone and
     the page scrolled sideways. In a flex column the card's width: 100%
     resolves against the container instead. */
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.brand-name { font-weight: 650; letter-spacing: -0.01em; }

h1 { font-size: 1.25rem; margin: 0 0 6px; letter-spacing: -0.02em; }
p.lead { color: var(--muted); font-size: 0.9rem; line-height: 1.5; margin: 0 0 20px; }

label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; }

/* The code input: one box per digit, big enough to read out loud from. */
.code-input {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.code-input input {
  flex: 1;
  min-width: 0;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  caret-color: var(--accent);
}
.code-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(79 156 249 / 0.18);
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn-primary {
  width: 100%;
  height: 46px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 620;
}
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary:not(:disabled):hover { background: #6cabfa; }

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
  padding: 8px 14px;
}
.btn-ghost:hover { background: #242b34; }
.btn-danger { background: var(--danger); color: #fff; padding: 8px 14px; }

.status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.45;
  display: none;
}
.status.show { display: block; }
.status.info { background: rgb(79 156 249 / 0.12); color: #bcd9ff; }
.status.error { background: rgb(242 84 91 / 0.12); color: #ffb7ba; }
.status.ok { background: rgb(62 207 142 / 0.12); color: #a5ecc9; }

.hint { font-size: 0.78rem; color: var(--muted); margin-top: 18px; line-height: 1.5; }

/* ------------------------------------------------------------- session view */

.session {
  display: grid;
  /* minmax(0, 1fr): without the 0 minimum the stage row grows to fit the
     video instead of the video fitting the row. */
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.device-name { font-weight: 600; font-size: 0.9rem; }
.badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.live { color: var(--ok); border-color: rgb(62 207 142 / 0.4); }
.badge.view-only { color: #ffd479; border-color: rgb(255 212 121 / 0.35); }

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  background: #000;
  overflow: hidden;
  padding: 12px;
}

/* The video is the control surface: no native gestures should fight ours. */
#screen {
  /* Fill the stage and letterbox: the decoded resolution changes as WebRTC
     ramps the encoder, the displayed size must not jump around with it.
     object-fit: contain is also what the pointer mapping in control.js
     assumes when it converts a click into frame coordinates. */
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: crosshair;
}
#screen.view-only { cursor: default; }

.nav-keys {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: rgb(20 24 29 / 0.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px;
  backdrop-filter: blur(8px);
}
.nav-keys[hidden] { display: none; }
.nav-keys button {
  background: transparent;
  color: var(--text);
  width: 44px;
  height: 36px;
  font-size: 1rem;
}
.nav-keys button:hover { background: var(--surface-2); }
.nav-keys button:disabled { opacity: 0.3; cursor: not-allowed; }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(11 13 16 / 0.92);
  text-align: center;
  padding: 24px;
}
.overlay[hidden] { display: none; }
.overlay .spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stats {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: rgb(20 24 29 / 0.88);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  line-height: 1.6;
  pointer-events: none;
}
.stats[hidden] { display: none; }
.stats b { color: var(--text); font-weight: 600; }

.text-input-row { display: flex; gap: 8px; width: 100%; margin-top: 8px; }
.text-input-row[hidden] { display: none; }
.text-input-row input {
  flex: 1;
  height: 36px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.text-input-row input:focus { outline: none; border-color: var(--accent); }

@media (max-width: 560px) {
  /* One scrollable row instead of three stacked ones: on a phone the video is
     what matters, and a 128px toolbar was eating a sixth of the screen. */
  .toolbar {
    gap: 6px;
    padding: 6px 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar > * { flex: 0 0 auto; }
  .toolbar .spacer { flex: 1 0 auto; }
  .device-name {
    font-size: 0.8rem;
    max-width: 8em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .btn-ghost, .btn-danger { padding: 6px 10px; font-size: 0.82rem; }
  #text-form { flex: 0 0 150px !important; }
  #text-form input { height: 32px; font-size: 0.82rem; }
  .badge { font-size: 0.62rem; padding: 2px 6px; }
  .nav-keys button { width: 40px; height: 34px; }
}
