/* css/stage.css: the Watch stage: the workspace layout, the view bar's lit buttons and pager, the panes (overlays,
   spinner, lens, no-signal, the pane menu, the zoom's chip and cursors) and the transport. Moved verbatim from style.css
   (UI plan step 20d). The TV shows the panes: top/right/bottom/left, never inset (Chromium 87; the TV may be 85). */

#btnLive.on { background: var(--live-bg); border-color: var(--live-line); color: var(--live-fg); }

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

.layout {
  display: grid;
  /* Wide enough that every tab label sits comfortably with room for a badge. */
  grid-template-columns: minmax(0, 1fr) var(--side-w);
  /* The video and the side pane, then the deck (UI plan step 20e) the full width under both. */
  grid-template-rows: minmax(0, 1fr) auto;
  flex: 1; min-height: 0;   /* whatever the top bar leaves, however tall it wraps */
}
/* The deck: the transport, the timeline's header and the timeline. The video gives way, never the deck. It comes before
   the side pane in the page, so the keyboard reaches it in the order the screen shows. */
.deck { grid-column: 1 / -1; grid-row: 2; display: flex; flex-direction: column; min-width: 0; }
.stage { grid-column: 1; grid-row: 1; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.side {
  grid-column: 2; grid-row: 1; position: relative;
  border-left: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
}

/* The side pane's width (stage/side/size.js): its left edge drags (the grip), and it gets out of the way altogether
   (the button in its tab strip or the \ key; Events at the transport's right end brings it back). */
.side-grip {
  position: absolute; left: -3px; top: 0; bottom: 0; width: 7px; z-index: 5;
  cursor: col-resize; touch-action: none;
}
.side-grip:hover, .side-grip.dragging { background: var(--accent); opacity: .45; }
.side-grip:focus-visible { background: var(--accent); opacity: 1; outline: none; }   /* focused: ← / → resize it */
.tabs .side-collapse { flex: none; width: 32px; padding: 0; font-size: 16px; color: var(--muted); }
.tabs .side-collapse:hover { color: var(--text); }
.transport .side-open { margin-left: auto; }
@media not all and (max-width: 1000px) {   /* wide screens only (mobile.css's exact complement, no fractional-width
                                               gap): a collapse stored there never reaches a phone's layout */
  body.side-collapsed .layout { grid-template-columns: minmax(0, 1fr) 0; }
  body.side-collapsed .side { display: none; }
}

/* ---------- video ------------------------------------------------------ */

.video-area {
  flex: 1; min-height: 0; display: grid; gap: 3px; padding: 3px; background: var(--bg-video);
  /* The layout's shape (stage/layout.js) at the pane size it computed for the room there is: 16:9 panes, as large as
     the shape allows, centred, never cropped. The same cells on every page, so a short last page keeps the pane size.
     Before the first sizing the cells share the room (minmax(0, 1fr): a plain 1fr refuses to shrink below a video's
     own height and pushed the timeline off the page). */
  grid-template-columns: repeat(var(--cols, 1), var(--cell-w, minmax(0, 1fr)));
  grid-template-rows: repeat(var(--rows, 1), var(--cell-h, minmax(0, 1fr)));
  justify-content: center; align-content: center;
}

/* Grid paging controls in the top bar. */
.pager {
  display: flex; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.pager button {
  background: none; border: 0; color: var(--text); padding: 4px 9px; cursor: pointer;
  font-size: 16px; line-height: 1.2;
}
.pager button:hover { background: var(--panel-3); }
.pager button[disabled] { opacity: .35; cursor: default; background: none; }
.pager span { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); padding: 0 2px; }

.pane {
  position: relative; background: var(--black); overflow: hidden; min-height: 0; min-width: 0;
  border-radius: 3px; cursor: pointer;
  /* Double-tap opens the pane menu: no browser double-tap zoom, no long-press selection/callout. */
  touch-action: manipulation; user-select: none; -webkit-touch-callout: none;
}

/* The pane menu (right-click / long-press): which camera shows in this pane. */
.ctxmenu {
  position: fixed; z-index: var(--z-menu); min-width: 190px; padding: 4px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.55); font-size: 13px;
}
.ctxmenu .head { padding: 4px 8px 5px; color: var(--muted); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.ctxmenu .sep { height: 1px; margin: 4px 0; background: var(--line); }
.ctxmenu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; text-align: left;
  background: none; border: 0; border-radius: 4px; color: var(--text); font: inherit; cursor: pointer;
}
.ctxmenu button:hover:not(:disabled) { background: var(--panel); }
.ctxmenu button.current { color: var(--muted); cursor: default; }
.ctxmenu button small { margin-left: auto; color: var(--muted); font-size: 11px; }
/* Anchored to the pane rather than flowing in it, so the video's own aspect
   never dictates the pane's (and the page's) height. The zoomer wrapper takes
   the digital zoom transform, so the video keeps its own rotation transform. */
.pane .zoomer { position: absolute; top: 0; right: 0; bottom: 0; left: 0; transform-origin: 0 0; }
.pane video { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
/* The last decoded frame, held over the video while the next chunk loads. */
.pane .pane-hold { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
/* The SD stream is the HD picture squeezed into another shape (352×240, 640×480): it is stretched back to the camera's
   own shape (data-ar, --pic-w/--pic-h from stage/panes.js picBox), centred, so SD and HD show the same picture. A
   camera turned sideways keeps contain (rare; its box would be the other way round). */
.pane[data-ar]:not([data-rot="90"]):not([data-rot="270"]) video,
.pane[data-ar]:not([data-rot="90"]):not([data-rot="270"]) .pane-hold {
  object-fit: fill; width: var(--pic-w); height: var(--pic-h); left: calc((100% - var(--pic-w)) / 2); top: calc((100% - var(--pic-h)) / 2);
  right: auto; bottom: auto;
}
/* Spinner over the held frame while the next chunk is fetched or the picture waits for data. */
.pane-loading {
  position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; z-index: 2;
  border: 3px solid rgba(255,255,255,.22); border-top-color: var(--white); border-radius: 50%;
  animation: pane-spin .8s linear infinite; pointer-events: none;
}
@keyframes pane-spin { to { transform: rotate(360deg); } }
/* Under a spinner that has run past 5 s: what it is waiting on (paneWaitCheck). */
.pane-wait {
  position: absolute; top: calc(50% + 24px); left: 50%; transform: translateX(-50%); z-index: 2;
  max-width: calc(100% - 16px); padding: 3px 9px; border-radius: 10px; pointer-events: none;
  font: 12px/1.35 system-ui, sans-serif; color: var(--white); text-align: center;
  background: rgba(0, 0, 0, .66); text-wrap: balance;
}
/* An alert link opened paused (stage/clock.js showLinkPlay): Play in the middle, the frame visible around it. */
.pane-play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0; border: 0; background: none; color: var(--white); cursor: pointer;
}
.pane-play-icon {
  display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--scrim); border: 2px solid var(--white);
}
.pane-play-icon .i { width: 28px; height: 28px; margin-left: 4px; }
.pane-play-note { padding: 3px 9px; border-radius: 10px; background: var(--scrim); font: var(--fs-xs) var(--font-ui); }
.pane-play:hover .pane-play-icon, .pane-play:focus-visible .pane-play-icon { background: var(--scrim-strong); }
/* One pane filling the stage: pinch and drag are ours (no page scroll over
   the picture), the cursor says the picture can be dragged once zoomed. */
.video-area.grid-1 .pane { touch-action: none; }
.pane.zoomed { cursor: grab; }
.pane.grabbing { cursor: grabbing; }
.pane-zoom {
  position: absolute; top: 8px; right: 8px; z-index: 3; padding: 3px 9px;
  font: var(--fs-xs) var(--font-ui); color: var(--text); background: var(--scrim);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
/* The active pane: the one the timeline, scrub preview and frame tools work on. */
/* Drawn as a layer of its own over the picture (::after), not as the pane's outline: playing video painted over the
   outline in Firefox, and the active pane looked like no pane at all (Wade, 2026-11-01). */
.pane.focus::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 3; pointer-events: none;
  border: 2px solid var(--accent);
}
.pane.focus .pane-name { color: var(--accent); }
/* Orientation correction for a camera mounted sideways or inverted. The stored
   stream is never re-encoded — the picture is rotated here, on display. object-fit
   keeps the whole frame visible at 90°/270° (letterboxed rather than clipped),
   which is the safe trade for a rare portrait mount. */
.pane[data-rot="90"]  video, .pane[data-rot="90"]  .pane-hold { transform: rotate(90deg); }
.pane[data-rot="180"] video, .pane[data-rot="180"] .pane-hold { transform: rotate(180deg); }
.pane[data-rot="270"] video, .pane[data-rot="270"] .pane-hold { transform: rotate(270deg); }
/* Mirrors the camera's real IR-cut state, so the day/night feature is
   visible in the picture rather than only in a settings panel. */
.pane.bw video, .pane.bw .pane-hold { filter: grayscale(1) contrast(1.08); }

.pane-overlay {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 7px 9px;
  background: linear-gradient(180deg, rgba(0,0,0,.5), transparent 22%, transparent 78%, rgba(0,0,0,.5));
}
.pane-top { display: flex; align-items: center; gap: 7px; }
.pane-name { font-weight: 600; font-size: 13px; text-shadow: 0 1px 3px var(--black); }
.pane-ch { font-size: 11px; color: var(--muted); }
.pane-bottom { display: flex; justify-content: flex-end; }
.pane-time {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  background: rgba(0,0,0,.55); padding: 2px 6px; border-radius: 3px;
}
/* Lens zoom on a motorised camera: hold + or − to move the lens, ⌂ for the home framing. */
.pane-lens {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); z-index: 3;
  display: flex; flex-direction: column; gap: 6px;
}
.pane-lens button {
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(0,0,0,.55); color: var(--text);
  font: 600 17px/1 system-ui, sans-serif; cursor: pointer; opacity: .7; touch-action: none;
}
.pane:hover .pane-lens button, .pane-lens button:focus-visible { opacity: 1; }
.pane-lens button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); opacity: 1; }
/* The footage tools on the outlined pane (js/stage/pane-tools.js): a see-through column on the picture's left, the
   tools' purple, solid while pointed at. .away fades them out while the picture is touched, zoomed or panned; they fade
   back in by themselves. Hidden from the pointer while faded, so a touch meant for the picture is not caught by them. */
.pane-tools {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%); z-index: 3;
  display: flex; flex-direction: column; gap: 6px;
  opacity: .6; transition: opacity .3s ease;
}
.pane-tools:hover, .pane-tools:focus-within { opacity: 1; }
.pane-tools.away { opacity: 0; pointer-events: none; }
.pane-tools .tbtn {
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; touch-action: manipulation;
}
.pane-tools .tbtn:not(.on) { background: var(--nav-tool-bg); border-color: var(--nav-tool-line); color: var(--nav-tool-fg); }
.pane-tools .tbtn:not(.on):hover { filter: brightness(1.3); }
.pane-tools .tbtn svg.i { width: 18px; height: 18px; }
.pane-tools.compact { gap: 4px; }
.pane-tools.compact .tbtn { width: 28px; height: 28px; }
.pane-tools.compact .tbtn svg.i { width: 14px; height: 14px; }
@media (prefers-reduced-motion: reduce) { .pane-tools { transition: none; } }
/* "Returning to Home": a lens on its way back to the saved framing. */
.pane-note {
  position: absolute; top: 34px; left: 50%; transform: translateX(-50%); z-index: 3;
  padding: 3px 11px; border-radius: 10px; white-space: nowrap; pointer-events: none;
  font: 12px system-ui, sans-serif; color: var(--text);
  background: rgba(0,0,0,.7); border: 1px solid var(--line);
}
.pane-nosignal {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: grid; place-content: center; gap: 4px;
  text-align: center; background: repeating-linear-gradient(45deg, var(--err-bg-deeper), var(--err-bg-deeper) 8px, var(--err-bg-deep) 8px, var(--err-bg-deep) 16px);
}
.pane-nosignal span { color: var(--live-fg); font-weight: 700; letter-spacing: .08em; font-size: 13px; }
.pane-nosignal small { color: var(--gap-text); }
/* Before a security responder's hours (js/stage/overlays.js): its own slate, never the red of missing footage. */
.pane-nosignal.denied { background: repeating-linear-gradient(45deg, var(--denied-bg), var(--denied-bg) 8px, var(--denied-bg-2) 8px, var(--denied-bg-2) 16px); }
.pane-nosignal.denied span, .pane-nosignal.denied small { color: var(--denied-fg); }

/* ---------- a security responder's hours (js/stage/access.js) ---------- */
/* The chip: one line that never wraps; its width holds still as its words change (a link opened or ended), and its
   numbers are tabular. The short words on a phone (css/mobile.css). */
.pill.access-chip { flex: none; white-space: nowrap; width: 38ch; overflow: hidden; text-overflow: ellipsis;   /* one width whatever it says: */
  font-variant-numeric: tabular-nums; color: var(--text-2); }   /* a link opening or ending never moves the top bar */
.access-chip .access-short { display: none; }
.access-pop p { margin: 0 0 var(--s2); }
.access-pop .access-grants { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--s2); }
.access-pop .access-grants li { display: flex; align-items: center; gap: var(--s2); justify-content: space-between; }

/* ---------- transport -------------------------------------------------- */

/* Fixed groups, left to right: playback, speed, the readout, the tools; Events (shown while the side pane is collapsed)
   at the right end. A group wraps whole, never apart (phones: closer, the readout last, mobile.css); below 1100 px of
   deck every button drops its words and keeps its icon (.narrow). */
.transport {
  flex: none;   /* the video gives way, never the controls or the timeline */
  display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; min-height: 40px;
  padding: 5px 6px; background: var(--panel); border-top: 1px solid var(--line);
}
.transport .tgroup { display: flex; align-items: center; gap: 3px; flex: none; }
.transport .tbtn { display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 12px; line-height: 16px; padding: 5px 8px; flex: none; }
.transport .tbtn svg.i { width: 16px; height: 16px; }
.transport .tbtn svg.i.caret { width: 12px; height: 12px; margin-left: -2px; opacity: .8; }
.transport .tbtn.play { min-width: 40px; }
/* One colour per kind (Wade, 2026-10-26), so the eye finds a button by its kind: the ±10 s steps, the previous / next
   event, the tools. A tool that is on keeps the "on" look. */
.transport #btnBack, .transport #btnFwd { background: var(--nav-step-bg); border-color: var(--nav-step-line); color: var(--nav-step-fg); }
.transport #btnPrevEvent, .transport #btnNextEvent { background: var(--nav-event-bg); border-color: var(--nav-event-line); color: var(--nav-event-fg); }
.transport #btnBack:hover, .transport #btnFwd:hover, .transport #btnPrevEvent:hover, .transport #btnNextEvent:hover { filter: brightness(1.3); }
#btnEvSplit { display: none; }   /* a landscape phone's only: mobile.css shows it there */

.transport select {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 5px 8px; font-size: 12px; line-height: 16px; flex: none;
}
.playhead-readout {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  display: flex; gap: 6px; align-items: baseline; margin-left: 2px;
  white-space: nowrap; flex: none;
}
.selection-box {
  margin-left: auto; display: flex; align-items: center; gap: 4px;
  background: var(--sel-bg); border: 1px solid var(--sel-line); border-radius: var(--radius);
  padding: 2px 3px 2px 8px; font-size: 12px;
}
.selection-box .sel-btns { display: flex; gap: 4px; flex: none; }
/* A clip whose end is still being found: the box reads as unfinished. */
.selection-box.open { border-style: dashed; border-color: var(--accent); }
#selectionLabel { font-variant-numeric: tabular-nums; }


.pane-pay:empty { display: none; }
