/* iPhone Cam: a broadcast-camera viewfinder. Black field, small OSD readouts,
   and one accent: the red tally that lights only while a PC app is using the
   camera. Depth is hairlines only. */
:root {
  --c-field: oklch(0.17 0.005 265);       /* viewfinder surround */
  --c-plate: oklch(0.17 0.005 265 / 0.62); /* OSD plate over live video */
  --c-plate-solid: oklch(0.23 0.006 265);
  --c-option-on: oklch(0.94 0.004 265);
  --c-hair: oklch(1 0 0 / 0.13);
  --c-text: oklch(0.96 0.004 265);
  --c-text-2: oklch(0.74 0.008 265);
  --c-text-on: oklch(0.2 0.006 265);
  --c-idle: oklch(0.58 0.008 265);
  --c-tally: oklch(0.6 0.22 25);

  --font: "Barlow Semi Condensed", -apple-system, "Segoe UI", sans-serif;
  --fs-small: 13px;
  --fs-base: 16px;
  --fs-readout: 20px;
  --fs-title: 25px;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --r-plate: 10px;
  --r-option: 6px;        /* plate radius - plate padding */
  --r-pill: 999px;
  --tally-width: 3px;
  --hit: 44px;

  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --dur-fast: 150ms;
  --dur-base: 200ms;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--c-field); }
body {
  color: var(--c-text);
  font: 500 var(--fs-base)/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--c-text); }

#app { position: fixed; inset: 0; }

#view {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain;            /* show exactly what the PC receives */
  background: var(--c-field);
}
#view.mirror { transform: scaleX(-1); }

/* Tally: an app on the PC is reading the camera right now. */
.tally {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 var(--tally-width) var(--c-tally);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
#app[data-tally="on"] .tally { opacity: 1; }

.osd {
  position: absolute;
  background: var(--c-plate);
  border: 1px solid var(--c-hair);
  border-radius: var(--r-plate);
}

.status {
  top: calc(var(--safe-t) + var(--sp-3));
  left: calc(var(--safe-l) + var(--sp-3));
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-small);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.dot {
  width: 8px; height: 8px; flex: none; border-radius: var(--r-pill);
  background: var(--c-idle);
}
#app[data-link="ready"] .dot { background: var(--c-text); }
#app[data-tally="on"] .dot { background: var(--c-tally); }

.bar {
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + var(--sp-3));
  display: flex; padding: var(--sp-1);
  gap: var(--sp-1);
}
.readout {
  min-width: var(--hit); height: var(--hit);
  padding: 0 var(--sp-3);
  border-radius: var(--r-option);
  font-size: var(--fs-readout);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-out);
}
.readout:active { transform: scale(0.97); }
.readout[aria-expanded="true"] { background: var(--c-option-on); color: var(--c-text-on); }
.readout.icon { display: grid; place-items: center; padding: 0; }
.readout svg { width: 20px; height: 20px; fill: currentColor; }
.bar .icon { border-left: 1px solid var(--c-hair); border-radius: 0 var(--r-option) var(--r-option) 0; }

.picker {
  left: 50%;
  bottom: calc(var(--safe-b) + var(--sp-3) + var(--hit) + 2 * var(--sp-1) + var(--sp-2) + 2px);
  transform: translateX(-50%);
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--sp-1); padding: var(--sp-1);
  max-width: calc(100vw - 2 * var(--sp-3));
  background: var(--c-plate-solid);
  animation: rise var(--dur-base) var(--ease-out);
}
.picker[hidden] { display: none; }
.option {
  height: var(--hit); padding: 0 var(--sp-4);
  border-radius: var(--r-option);
  font-size: var(--fs-base); font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.option[aria-selected="true"] { background: var(--c-option-on); color: var(--c-text-on); }
@media (hover: hover) {
  .option:hover:not([aria-selected="true"]), .readout:hover:not([aria-expanded="true"]) { background: var(--c-hair); }
}
@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Screen off: OLED black, still streaming. */
.sleep {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-6);
  background: #000;               /* true black switches OLED pixels off */
  color: var(--c-idle);
  font-size: var(--fs-small);
  text-align: left;
}
.sleep[hidden] { display: none; }
.sleep .dot { background: var(--c-idle); }
#app[data-tally="on"] .sleep .dot { background: var(--c-tally); }

.notice {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(340px, calc(100vw - 2 * var(--sp-5)));
}
.notice[hidden] { display: none; }
.notice h1 { font-size: var(--fs-title); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
.notice p { margin-top: var(--sp-3); color: var(--c-text-2); text-wrap: pretty; }
.action {
  margin-top: var(--sp-5); height: var(--hit); padding: 0 var(--sp-5);
  border-radius: var(--r-option);
  background: var(--c-option-on); color: var(--c-text-on);
  font-weight: 600;
}
.action[hidden] { display: none; }
#app.has-notice .bar, #app.has-notice #view, #app.has-notice .status { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .picker { animation: none; }
  .tally, .readout { transition: none; }
}
