/* The candidate's page.
 *
 * Written for someone about to be interviewed, which is the whole brief. They
 * are nervous, they are on a machine we know nothing about, and they have one
 * question: am I ready. Everything here answers it or gets out of the way.
 *
 * Deliberately dark, and not for fashion: the video is the brightest thing on
 * screen and everything around it should recede. There is no light theme
 * because there is no choice to honour — this page is one screen with one job.
 *
 * Tokens, the reset, the top bar and the form controls are in base.css, which
 * this page links first. Only what belongs to the interview screen is here.
 *
 * CSP is style-src 'self', so there are no inline styles anywhere and no <style>
 * block in the page.
 *
 * THINGS THE JAVASCRIPT DEPENDS ON — changing any of these breaks the page
 * silently, which is the worst way for this page to break:
 *
 *   #zoomRoot needs position:relative and a real size. The SDK renders
 *   absolutely-positioned content inside it, and a container with no
 *   positioning context collapses the meeting into a corner.
 *
 *   #controls is display:none here and set to 'flex' by controls.js, so it is
 *   styled as a flex row.
 *
 *   #camBtn and #camState must NOT have a display set. controls.js toggles them
 *   with '' and 'none', and '' means "fall back to the stylesheet" — a
 *   display:none here would make '' resolve to none and the element would never
 *   appear. That was a real bug: on Zoom, supports.camera is false, so the
 *   camera indicator was permanently invisible.
 *
 *   .sub is queried with querySelector, so the FIRST .sub in document order is
 *   the status line under the heading. #captureStatus also carries .sub and
 *   must stay after it.
 */

/* The page is a column: top bar, then the layout taking whatever is left.
   base.css leaves body unstyled for flow, because the other pages centre their
   content instead. */
body { display: flex; flex-direction: column; }

/* ── Layout ────────────────────────────────────────────────────────────────
   Video-dominant. The panel is a narrow column beside it, never on top of it.

   The stage is NOT hidden before joining, tempting though that is. The SDK
   reads the container's size when it initialises, and a display:none ancestor
   at that moment gives it a zero box to render into. The placeholder below is
   the honest alternative: it says what will happen there. */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 20px;
  padding: 20px 22px 24px;
  min-height: 0;
}

/* The stage takes the full height of the row; the panel keeps its natural
   height at the top. Letting both stop at their content left the video ending
   two thirds down a dark screen, which reads as something failing to load. */
.col-right { min-width: 0; display: flex; flex-direction: column; }
.col-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  align-self: start;
}

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  /* The form first on a narrow screen: nothing renders in the stage until it
     has been used. */
  .col-left { order: -1; }
}

/* ── The meeting ───────────────────────────────────────────────────────────
   min-height tracks the 2:1 box the SDK is initialised with (see joinZoom); a
   taller one would leave dead space under the video. */
#zoomRoot {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
@media (max-width: 1080px) { #zoomRoot { min-height: 340px; } }

#zoomRoot:empty {
  /* A dashed edge reads as "nothing here yet" rather than "something failed". */
  border-style: dashed;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(63, 208, 201, .05), transparent 60%),
    var(--surface);
}
#zoomRoot:empty::after {
  content: "Your interview opens here";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  font-size: 13.5px;
  letter-spacing: .01em;
}

/* ── Panel ─────────────────────────────────────────────────────────────────*/
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}


/* The status line. join.js rewrites its text on every state change — waiting,
   ready, and every failure the candidate is allowed to see — so it carries more
   meaning than its size suggests. Pulled up under the heading; the rest of .sub
   is in base.css. */
.sub { margin: -8px 0 0; }

.warn {
  background: var(--danger-bg);
  border: 1px solid #5c2a22;
  color: #ffb9a8;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ── Form ──────────────────────────────────────────────────────────────────
   Inputs, labels and buttons come from base.css. The inputs stay inside their
   labels here because join.js hides a field with
   $('meeting').closest('label') — the label is the unit that disappears. */
form { display: grid; gap: 13px; margin: 0; }


/* The one thing on the page the candidate is meant to press. */
#joinBtn {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 16px;
  font-size: 14.5px;
  margin-top: 2px;
}
#joinBtn:hover:not(:disabled) { background: var(--accent-hi); }

/* ── In-meeting controls ───────────────────────────────────────────────────
   display:none here, set to 'flex' by controls.js.

   No display on #camBtn or #camState — see the header. */
#controls {
  display: none;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
}
#controls button { padding: 8px 13px; font-size: 13px; }

#camState {
  font-size: 12.5px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  line-height: 1.3;
}

#leaveBtn {
  margin-left: auto;
  background: transparent;
  border-color: #4a2721;
  color: #f0917f;
}
#leaveBtn:hover:not(:disabled) { background: var(--danger-bg); border-color: #5c2a22; }

/* ── Capture ───────────────────────────────────────────────────────────────
   Separate from joining on purpose: the SDK opens the camera for its own
   self-view and this opens it again, so keeping the buttons apart means a
   failure is attributable to one side or the other. */
.capture {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
#captureBtn { align-self: flex-start; padding: 8px 13px; font-size: 13px; }
#captureStatus { margin: 0; font-size: 12px; color: var(--ink-faint); }

/* ── Diagnostics ───────────────────────────────────────────────────────────
   The log is load-bearing — every module writes to it through dom.js — but a
   candidate should not be reading a console. Collapsed, and phrased as
   something to be asked for rather than something going wrong. */
.diag {
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  margin-top: auto;
}
.diag > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-faint);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
  user-select: none;
}
.diag > summary::-webkit-details-marker { display: none; }
.diag > summary::before {
  content: "▸";
  font-size: 10px;
  transition: transform .12s ease;
}
.diag[open] > summary::before { transform: rotate(90deg); }
.diag > summary:hover { color: var(--ink-soft); }
.diag > summary:focus-visible { outline: none; color: var(--accent); }

#log {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px;
  margin-top: 10px;
  max-height: 240px;
  overflow-y: auto;
  color: var(--ink-soft);
}
.err { color: #ff8f7d; }
.ok  { color: var(--ok); }
