/* app.css — phone UI. Dark, high-contrast, huge touch targets
   (the phone is handled at arm's length before being mounted in the headset). */

:root {
  --bg: #0a0a0f;
  --panel: #16161f;
  --panel-2: #1e1e2a;
  --border: #2c2c3a;
  --text: #f2f2f7;
  --muted: #9a9aa8;
  --accent: #4f8cff;
  --ok: #2ecc71;
  --warn: #f5b83d;
  --bad: #ff4d4d;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  overscroll-behavior: none;
}

.hidden {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  cursor: pointer;
}

/* ---------- status pill ---------- */

.pill {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: rgba(22, 22, 31, 0.85);
  color: var(--muted);
  pointer-events: none;
}

.pill-ok {
  border-color: var(--ok);
  color: var(--ok);
  background: rgba(46, 204, 113, 0.12);
}

.pill-warn {
  border-color: var(--warn);
  color: var(--warn);
  background: rgba(245, 184, 61, 0.12);
}

.pill-bad {
  border-color: var(--bad);
  color: var(--bad);
  background: rgba(255, 77, 77, 0.12);
}

.pill-idle {
  color: var(--muted);
}

/* ---------- generic layout ---------- */

.view {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 64px) 20px 32px;
}

.card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1.logo {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0.24em;
  margin-bottom: 20px;
  color: var(--text);
}

h1.logo span {
  color: var(--accent);
}

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

.btn {
  display: block;
  width: 100%;
  min-height: 64px;
  border: none;
  border-radius: 16px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-ok {
  background: var(--ok);
  color: #04150b;
}

.btn-bad {
  background: var(--bad);
  color: #fff;
}

.btn-google {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--border, #333);
  color: inherit;
}

.btn-ghost {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--muted);
}

.btn-ready {
  min-height: 96px;
  font-size: 34px;
  letter-spacing: 0.18em;
}

/* ---------- auth ---------- */

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  flex: 1;
  min-height: 56px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(79, 140, 255, 0.1);
}

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

input {
  width: 100%;
  min-height: 60px;
  padding: 0 18px;
  font-size: 20px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

.error {
  color: var(--bad);
  font-size: 16px;
  font-weight: 600;
  min-height: 22px;
  text-align: center;
}

.error.ok {
  color: var(--ok);
}

/* small text link (forgot password) */
.link-btn {
  background: none;
  border: none;
  align-self: center;
  padding: 4px 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: underline;
}

/* ---------- user list ---------- */

.list-header {
  width: 100%;
  max-width: 460px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.list-header .me {
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-small {
  width: auto;
  min-height: 48px;
  padding: 0 18px;
  font-size: 16px;
}

.user-list {
  list-style: none;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
}

.dot-ok {
  background: var(--ok);
}

.dot-busy {
  background: var(--warn);
}

.dot-off {
  background: var(--muted);
}

/* offline roster entry: greyed out, "last seen …", no CALL button */
.user-row.offline {
  opacity: 0.55;
}

.user-name {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-status {
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.btn-call {
  width: auto;
  min-height: 56px;
  padding: 0 26px;
  font-size: 18px;
  background: var(--accent);
  color: #fff;
  flex: none;
}

.empty-hint {
  margin-top: 24px;
  color: var(--muted);
  text-align: center;
  font-size: 18px;
}

/* ---------- modals ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.75);
}

.modal .card {
  text-align: center;
  gap: 20px;
}

.modal h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--muted);
}

.modal .who {
  font-size: 32px;
  font-weight: 900;
  word-break: break-word;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn {
  min-height: 80px;
}

.calling-status {
  font-size: 20px;
  font-weight: 700;
  color: var(--warn);
  min-height: 28px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.pulsing {
  animation: pulse 1.4s ease-in-out infinite;
}

/* ---------- call page: device check ---------- */

.call-page {
  background: #000;
}

#devicePanel {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: calc(env(safe-area-inset-top, 0px) + 60px) 20px 32px;
}

#devicePanel .card {
  max-width: 640px;
}

.peer-line {
  font-size: 20px;
  color: var(--muted);
  text-align: center;
}

.peer-line strong {
  color: var(--text);
}

.preview-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.status-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 18px;
}

.status-label {
  color: var(--muted);
}

.status-value {
  font-weight: 800;
  text-align: right;
}

.status-ok {
  color: var(--ok);
}

.status-bad {
  color: var(--bad);
}

/* ---------- call page: stage ---------- */

#stage {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 10;
}

#stage video {
  background: #000;
}

#singleVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* lens-corrected stereo canvas (WebGL): fills the stage, black surround */
#vrCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

#vrCanvas.hidden {
  display: none;
}

/* In VR mode the camera <video> is only a texture source for the canvas. It must keep
   decoding frames, so it stays in the layout (display:none stops frame production on
   some browsers) — just tiny, transparent and behind everything. */
#singleVideo.tex-source {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 2px;
  opacity: 0.01;
  z-index: -1;
  pointer-events: none;
}

/* calibration strip, floats over the stereo view while tuning the headset */
.calib-bar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  transform: translateX(-50%);
  z-index: 70;
  width: min(96vw, 760px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(10, 10, 15, 0.88);
}

.calib-bar.hidden {
  display: none;
}

.calib-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.calib-row label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calib-row input[type="range"] {
  flex: 1;
  min-width: 60px;
  min-height: 32px;
  accent-color: var(--accent);
}

.calib-row span {
  min-width: 34px;
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

#calibProfile {
  flex: 1;
  min-height: 40px;
  padding: 0 10px;
  font-size: 15px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.calib-btn {
  min-height: 40px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.calib-btn.on {
  border-color: var(--accent);
  color: var(--accent);
}

.calib-done {
  background: var(--ok);
  border-color: var(--ok);
  color: #04150b;
}

/* stereo VR split: two half-width videos, thin center divider, black background */
#vrSplit {
  display: flex;
  width: 100%;
  height: 100%;
  background: #000;
}

#vrSplit.hidden {
  display: none;
}

#vrSplit video {
  width: calc(50% - 1px);
  height: 100%;
  object-fit: cover;
}

.vr-divider {
  width: 2px;
  height: 100%;
  background: #15151c;
  flex: none;
}

.end-mini {
  position: fixed;
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  z-index: 40;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.55);
  color: var(--bad);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.wait-hint {
  position: fixed;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  z-index: 30;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 28px;
  text-align: center;
  background: rgba(0, 0, 0, 0.88);
}

.overlay .big {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.overlay .sub {
  font-size: 18px;
  color: var(--muted);
  max-width: 420px;
}

#reconnectOverlay .big {
  color: var(--warn);
}

#rotateOverlay .icon {
  font-size: 64px;
}

/* ---------- iOS add-to-home-screen hint ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  transform: translateX(-50%);
  z-index: 120;
  width: calc(100% - 32px);
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 16px;
}

.toast button {
  flex: none;
  min-width: 48px;
  min-height: 48px;
  border-radius: 12px;
  border: none;
  background: var(--panel);
  color: var(--muted);
  font-size: 20px;
  font-weight: 800;
}

/* ---------- standalone headset test page ---------- */
#introPanel {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 20px 32px;
}

.intro-line {
  color: var(--muted);
  font-size: 16px;
}

.intro-hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.intro-hint strong {
  color: var(--text);
}

/* anchors styled as buttons need the flex centring <button> gets for free */
a.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

