/*  WAVERS — WAVEROULETTE™ Field Terminal
 *  Palette and type lifted from wavers.club so the app reads as the same Office.
 */

:root {
  --paper: #f4efe4;
  --paper-warm: #ede6d7;
  --white: #fffdf8;
  --navy: #1b2a4a;
  --navy-soft: #3c4a68;
  --orange: #ff6a13;
  --rule: #d9d2c3;
  --nickel: #b8bec6;

  --night: #0a0a0c;
  --bezel: #15171b;
  --screen: #050607;
  --grid: #2e9e5b;
  --alert: #c8102e;
  --screen-text: #f4f4f4;
  --screen-muted: #9aa0a8;

  --font-display: "Helvetica Neue Condensed", "HelveticaNeue-CondensedBold",
    "Arial Narrow", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, monospace;

  --pad: clamp(18px, 4vw, 56px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--navy);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { overflow: hidden; }

button { font: inherit; color: inherit; cursor: pointer; }

.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
}

/* ── The ticker, as on the site ─────────────────────────────────────────── */

.ticker {
  position: fixed; inset-inline: 0; top: 0; z-index: 60;
  background: var(--navy); color: var(--paper);
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  padding: 7px 0; white-space: nowrap; overflow: hidden;
  border-bottom: 1px solid #0d1526;
}
body.in-call .ticker { display: none; }
.ticker span { display: inline-block; padding-inline: 2rem; animation: drift 44s linear infinite; }
.ticker span b { color: var(--orange); font-weight: 600; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ── Gate: choose a Member ──────────────────────────────────────────────── */

.gate {
  position: fixed; inset: 0; z-index: 40;
  background: var(--paper);
  overflow-y: auto;
  padding: calc(34px + var(--pad)) var(--pad) var(--pad);
  display: flex; flex-direction: column; gap: clamp(20px, 3vh, 40px);
}
.gate[hidden] { display: none; }

.back-to-wavers {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 0 0 26px; padding: 7px 13px;
  border: 1px solid var(--navy); border-radius: 2px;
  background: transparent; color: var(--navy-soft); text-decoration: none;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
}
.back-to-wavers:hover { background: var(--navy); color: var(--paper); }
.gate-head { max-width: 62ch; }
.eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--navy-soft); margin: 0 0 14px;
}
.gate h1 {
  font-family: var(--font-display);
  font-size: clamp(38px, 8.5vw, 92px);
  line-height: .92; letter-spacing: -.02em; text-transform: uppercase;
  margin: 0 0 16px; font-weight: 700; font-stretch: condensed;
}
.gate h1 em { font-style: normal; color: var(--orange); }
.gate-head p { margin: 0; max-width: 54ch; line-height: 1.5; color: var(--navy-soft); font-size: 15px; }

.cast {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.member {
  appearance: none; text-align: left; padding: 0;
  background: var(--white); border: 1px solid var(--rule);
  border-radius: 2px; overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.member:hover, .member:focus-visible {
  transform: translateY(-3px);
  border-color: var(--navy);
  box-shadow: 0 10px 0 -4px rgba(27, 42, 74, .12);
  outline: none;
}
.member-shot { position: relative; aspect-ratio: 4 / 5; background: var(--paper-warm); overflow: hidden; }
.member-shot img { width: 100%; height: 100%; object-fit: cover; object-position: center 22%; display: block; }
.member-flag {
  position: absolute; left: 0; bottom: 0;
  background: var(--navy); color: var(--paper);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; padding: 5px 9px;
}
.member-flag.unsworn { background: var(--alert); }
.member-body { padding: 14px 15px 16px; display: grid; gap: 6px; }
.member-body h2 {
  font-family: var(--font-display); font-size: 27px; letter-spacing: .01em;
  text-transform: uppercase; margin: 0; font-weight: 700; font-stretch: condensed;
}
.member-id { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; color: var(--orange); text-transform: uppercase; }
.member-note { font-size: 13.5px; line-height: 1.45; color: var(--navy-soft); margin: 0; }
.member-go {
  margin-top: 6px; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--navy);
  display: flex; align-items: center; gap: 7px;
}
.member-go::after { content: "→"; transition: transform .18s ease; }
.member:hover .member-go::after { transform: translateX(4px); }

.gate-foot {
  border-top: 1px solid var(--rule); padding-top: 18px;
  display: flex; flex-wrap: wrap; gap: 12px 26px; align-items: center;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--navy-soft);
}
.gate-foot p { margin: 0; max-width: 46ch; letter-spacing: .06em; text-transform: none;
  font-family: var(--font-body); font-size: 12.5px; line-height: 1.5; }

.toggle {
  display: inline-flex; border: 1px solid var(--navy); border-radius: 2px; overflow: hidden;
}
.toggle button {
  background: transparent; border: 0; padding: 7px 13px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
}
.toggle button[aria-pressed="true"] { background: var(--navy); color: var(--paper); }

/* ── Call: the stage ────────────────────────────────────────────────────── */

.call { position: fixed; inset: 0; background: var(--night); overflow: hidden; }
.call[hidden] { display: none; }

.backdrop {
  position: absolute; inset: -8%;
  background-size: cover; background-position: center;
  filter: blur(46px) saturate(.6) brightness(.32);
  transform: scale(1.1);
}

.frame {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 0;
}

.screen {
  position: relative;
  height: 100%; aspect-ratio: 9 / 16;
  max-width: 100%;
  background: #000; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 40px 120px rgba(0,0,0,.7);
}
/* Portrait viewports: let it bleed to the edges. */
@media (max-aspect-ratio: 3/4) {
  .screen { width: 100%; height: 100%; aspect-ratio: auto; box-shadow: none; }
}

.stage { position: absolute; inset: 0; z-index: 0; }
.stage-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  will-change: opacity;
}

/* ── HUD ────────────────────────────────────────────────────────────────── */

.hud { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.hud > * { pointer-events: auto; }

.hud::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.55) 0%, transparent 22%),
    linear-gradient(to top, rgba(0,0,0,.62) 0%, transparent 28%);
  opacity: 1; transition: opacity .3s ease;
}

.hud-top {
  position: absolute; inset-inline: 0; top: 0;
  padding: 16px 16px 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}

.callee { color: var(--screen-text); }
.callee h2 {
  font-family: var(--font-display); font-size: 25px; text-transform: uppercase;
  margin: 0; letter-spacing: .01em; font-weight: 700; font-stretch: condensed;
  text-shadow: 0 1px 12px rgba(0,0,0,.6);
}
.callee .mono { color: var(--orange); display: block; margin-top: 2px; }
.callee .place { color: var(--screen-muted); font-size: 11.5px; margin-top: 3px; }

.link {
  display: flex; align-items: center; gap: 7px;
  background: rgba(8,10,14,.72); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.1);
  padding: 6px 10px; border-radius: 2px;
  color: var(--screen-text);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
}
.bars { display: flex; align-items: flex-end; gap: 2px; height: 11px; }
.bars i { width: 3px; background: var(--grid); display: block; }
.bars i:nth-child(1) { height: 4px; }
.bars i:nth-child(2) { height: 7px; }
.bars i:nth-child(3) { height: 11px; }

/* Detection strip — the watch face, flattened */
.detect {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 108px; width: min(420px, calc(100% - 32px));
  background: rgba(5,6,7,.86); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 3px; overflow: hidden;
  transition: border-color .2s ease, background .2s ease;
}
.detect-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px;
  color: var(--screen-text);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .13em; text-transform: uppercase;
}
.lamp {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--grid); box-shadow: 0 0 10px var(--grid);
}
.detect-msg { flex: 1; min-width: 0; }
.clock { color: var(--screen-muted); font-variant-numeric: tabular-nums; }

.detect-meter { height: 2px; background: rgba(255,255,255,.12); }
.detect-meter i { display: block; height: 100%; width: 0%; background: var(--grid); transition: width .1s linear, background .2s ease; }

.call[data-phase="asking"] .detect { border-color: var(--alert); background: rgba(40,4,10,.9); }
.call[data-phase="asking"] .lamp { background: var(--orange); box-shadow: 0 0 10px var(--orange); }
.call[data-phase="asking"] .detect-meter i { background: var(--alert); }
.call[data-phase="returned"] .detect { border-color: var(--grid); }
.call[data-phase="breach"] .detect { border-color: var(--alert); background: rgba(40,4,10,.9); }
.call[data-phase="breach"] .lamp { background: var(--alert); box-shadow: 0 0 14px var(--alert); }


.hud-bottom {
  position: absolute; inset-inline: 0; bottom: 0;
  padding: 0 16px 18px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.callee { transition: opacity .3s ease; }

.key {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(14,16,20,.8); backdrop-filter: blur(8px);
  color: var(--screen-text);
  display: grid; place-items: center;
  transition: background .16s ease, transform .16s ease, border-color .16s ease;
}
.key:hover { background: rgba(30,34,42,.92); transform: translateY(-2px); }
.key[aria-pressed="true"] { background: var(--paper); color: var(--navy); border-color: var(--paper); }
.key.rude:hover { background: rgba(200,16,46,.85); border-color: var(--alert); }
.key.hang { background: var(--alert); border-color: var(--alert); width: 58px; border-radius: 24px; }
.key.hang:hover { background: #e01535; }
.key svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Self view */
.self {
  position: absolute; right: 14px; bottom: 108px;
  width: clamp(76px, 20vw, 104px); aspect-ratio: 3 / 4;
  border-radius: 3px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  background: #0d0f13;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  transition: opacity .25s ease, border-color .2s ease;
}
.self video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.self[data-hand="true"] { border-color: var(--orange); }
.self-tag {
  position: absolute; inset-inline: 0; bottom: 0; text-align: center;
  background: rgba(5,6,7,.8); color: var(--screen-text);
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .1em;
  text-transform: uppercase; padding: 3px 2px;
}

/* Tally */
.tally {
  position: absolute; right: 16px; top: 62px; text-align: right;
  color: var(--screen-muted);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  line-height: 1.7; pointer-events: none;
}
.tally b { color: var(--screen-text); font-weight: 500; }
.tally { text-shadow: 0 1px 6px rgba(0,0,0,.9), 0 0 16px rgba(0,0,0,.6); }
@media (max-height: 560px), (max-width: 460px) { .tally { display: none; } }

/* Restitution note */
.restitution {
  position: absolute; left: 50%; transform: translateX(-50%) translateY(6px);
  bottom: 168px; width: min(420px, calc(100% - 32px));
  background: var(--paper); color: var(--navy);
  border-left: 3px solid var(--alert);
  padding: 10px 13px; font-size: 12.5px; line-height: 1.45;
  opacity: 0; transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
.restitution[data-show="true"] { opacity: 1; transform: translateX(-50%) translateY(0); }
.restitution b { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; display: block; margin-bottom: 3px; color: var(--alert); }

/* Loading */
.loading {
  position: absolute; inset: 0; z-index: 6;
  background: var(--night); color: var(--screen-muted);
  display: grid; place-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  transition: opacity .4s ease;
}
.loading[hidden] { display: none; }
.loading div { text-align: center; }
.loading .bar { width: 160px; height: 2px; background: rgba(255,255,255,.14); margin: 12px auto 0; overflow: hidden; }
.loading .bar i { display: block; height: 100%; width: 34%; background: var(--orange); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

@media (prefers-reduced-motion: reduce) {
  .ticker span, .lamp, .loading .bar i { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* ── Swap: you big, the Member in the corner ────────────────────────────── */

.self { cursor: pointer; }
.self-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.call[data-swap="true"] .self {
  inset: 0; right: auto; bottom: auto;
  width: 100%; height: 100%;
  aspect-ratio: auto; border: 0; border-radius: 0; box-shadow: none;
  z-index: 1;
}
.call[data-swap="true"] .self .self-tag { display: none; }

.call[data-swap="true"] .stage {
  inset: auto 14px 112px auto;
  width: clamp(88px, 22vw, 124px);
  height: auto; aspect-ratio: 9 / 16;
  border-radius: 3px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  z-index: 3;
}
.call[data-swap="true"] .stage::after {
  content: attr(data-who);
  position: absolute; inset-inline: 0; bottom: 0; text-align: center;
  background: rgba(5,6,7,.8); color: var(--screen-text);
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .1em;
  text-transform: uppercase; padding: 3px 2px;
}

/* ── Service panel ──────────────────────────────────────────────────────── */

.dbg {
  position: absolute; left: 14px; top: 62px; z-index: 5;
  width: min(268px, calc(100% - 28px));
  background: #07080a;   /* opaque: a blur over live video recomposites every frame */
  border: 1px solid rgba(255,255,255,.14); border-radius: 3px;
  color: var(--screen-text);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em;
  overflow: hidden;
}
.dbg[hidden] { display: none; }
.dbg-title {
  background: rgba(255,255,255,.07); padding: 5px 9px;
  font-size: 9px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--screen-muted);
}
.dbg-body { padding: 6px 9px 8px; }
.dbg-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 2px 0; line-height: 1.5;
}
.dbg-row span { flex: 0 0 52px; color: var(--screen-muted); text-transform: uppercase; }
.dbg-row i { flex: 1; font-style: normal; color: var(--screen-text); font-variant-numeric: tabular-nums; }
.dbg-row b { font-weight: 500; color: var(--screen-muted); }
.dbg-row b.out { color: var(--grid); }
.dbg-row b.in { color: var(--alert); }
.dbg-head {
  padding: 7px 9px 4px; font-size: 9px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--screen-muted);
}
.dbg-head b { color: var(--orange); font-weight: 600; }
.dbg-sep { height: 1px; background: rgba(255,255,255,.1); margin: 6px 0; }
.dbg-trace { display: block; width: 100%; height: 46px; }
.dbg-note {
  padding: 5px 9px 8px; color: var(--screen-muted); line-height: 1.5;
  border-top: 1px solid rgba(255,255,255,.08);
}
.dbg-note b { color: var(--alert); font-weight: 500; }

@media (max-width: 460px) {
  .dbg { width: calc(100% - 28px); font-size: 9.5px; }
}

.dbg-tune { padding: 6px 9px 8px; display: grid; gap: 5px; }
.dbg-tune label {
  display: grid; grid-template-columns: 44px 1fr 40px; align-items: center; gap: 7px;
  color: var(--screen-muted); text-transform: uppercase; font-size: 9px; letter-spacing: .1em;
}
.dbg-tune input[type="range"] { width: 100%; accent-color: var(--orange); height: 14px; }
.dbg-tune i { font-style: normal; color: var(--screen-text); text-align: right;
  font-variant-numeric: tabular-nums; font-size: 10px; }
.dbg-tune button {
  justify-self: start; margin-top: 2px; background: transparent; color: var(--screen-muted);
  border: 1px solid rgba(255,255,255,.2); border-radius: 2px; padding: 3px 8px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
}
.dbg-tune button:hover { color: var(--screen-text); border-color: var(--screen-text); }

.dbg-back {
  display: block; width: 100%; margin: 12px 0 2px; cursor: pointer;
  background: transparent; color: var(--screen-text);
  border: 1px solid rgba(255,255,255,.28); border-radius: 2px; padding: 6px 8px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
}
.dbg-back:hover { background: rgba(255,255,255,.08); border-color: var(--screen-text); }


/* The service panel should not sit on your face. Beside the video on a wide
   screen; a movable card when there is no room. */
@media (min-aspect-ratio: 1/1) {
  .call[data-debug="true"] .frame { padding-left: min(300px, 32vw); }
  .dbg { left: 16px; top: 50%; transform: translateY(-50%); }
}
.dbg[data-dock="right"] { left: auto; right: 16px; }
.dbg-move {
  position: absolute; top: 3px; right: 5px;
  background: transparent; border: 0; color: var(--screen-muted);
  font-family: var(--font-mono); font-size: 11px; line-height: 1; padding: 3px 5px;
}
.dbg-move:hover { color: var(--screen-text); }
