/*
 * Presenter cockpit.
 *
 * Dense and glanceable, not pretty. The speaker is standing in front of a room
 * and needs to read this in a glance: current slide, what is next, their notes,
 * how long they have been talking, and whether the room can see them.
 *
 * Keyboard-first, because a speaker with a clicker or arrow keys should never
 * need the mouse.
 */

.cockpit {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
}

/* ------------------------------------------------------------------- header */

.cockpit-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: var(--z-controls);
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-value-lg {
  font-size: 20px;
}

/* --------------------------------------------------------------------- body */

.cockpit-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  padding: var(--space-4);
  align-items: start;
}

/* On a wide screen: current slide, then next slide, then notes. */
@media (min-width: 1024px) {
  .cockpit-body {
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-areas:
      "current next"
      "current notes";
    grid-template-rows: auto 1fr;
  }

  .area-current {
    grid-area: current;
  }

  .area-next {
    grid-area: next;
  }

  .area-notes {
    grid-area: notes;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.panel-body {
  padding: var(--space-3);
}

/* The current slide is the one thing that must be unmissable. */
.current-frame {
  aspect-ratio: 16 / 9;
  background: #000;
  display: grid;
  place-items: center;
  width: 100%;
}

.current-frame img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.next-frame {
  aspect-ratio: 16 / 9;
  background: #000;
  display: grid;
  place-items: center;
  width: 100%;
}

.next-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.notes {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 340px;
  overflow-y: auto;
  min-height: 120px;
}

.notes:empty::before {
  content: "No notes for this slide.";
  color: var(--text-faint);
  font-size: 13px;
}

/* ------------------------------------------------------------------ toolbar */

.cockpit-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-wrap: wrap;
}

.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  color: var(--text-faint);
  background: var(--surface);
}

/* ------------------------------------------------------------------ warnings */

.note-warn {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-muted);
}

/* -------------------------------------------------------------------- thumbs */

.rail {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-2);
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.rail-item {
  flex: none;
  scroll-snap-align: center;
  width: 112px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background: #000;
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: border-color var(--dur-fast) var(--ease);
}

.rail-item img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  display: block;
}

.rail-item[aria-current="true"] {
  border-color: var(--accent);
  outline: 2px solid var(--accent-dim);
}

.rail-item:hover {
  border-color: var(--border-strong);
}

/* ------------------------------------------------------------------ fallback */

.list-plain {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ------------------------------------------------------------ join overlay */

/*
 * The join code, reachable at any time from the cockpit.
 *
 * A speaker often needs this after the room has already sat down, so it must not
 * require leaving the session or opening a second window. The QR sits on a light
 * panel because a QR code needs a light quiet zone to scan, which is the same
 * reason the projector screen does it.
 */
.join-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: grid;
  place-items: center;
  padding: var(--space-4);
}

.join-overlay[hidden] {
  display: none;
}

.join-overlay-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  background: rgba(6, 6, 7, 0.82);
  cursor: pointer;
}

.join-overlay-panel {
  position: relative;
  width: min(880px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  animation: join-rise var(--dur-base) var(--ease) both;
}

@keyframes join-rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .join-overlay-panel {
    animation: none;
  }
}

.join-overlay-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.join-overlay-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  padding: var(--space-5);
  align-items: center;
}

@media (min-width: 720px) {
  .join-overlay-body {
    grid-template-columns: 320px minmax(0, 1fr);
    gap: var(--space-8);
  }
}

/* Light panel: a QR code needs a light quiet zone to scan reliably. */
.join-qr-wrap {
  background: #ffffff;
  border-radius: var(--r-md);
  padding: var(--space-3);
  display: grid;
  place-items: center;
}

.join-qr {
  display: block;
  width: 100%;
  height: auto;
  max-width: 320px;
  aspect-ratio: 1;
}

.join-overlay-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.join-url {
  font-size: clamp(18px, 2.4vw, 26px);
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
  word-break: break-all;
}

.join-code-big {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
  color: var(--accent);
  margin-bottom: var(--space-2);
}
