/*
 * The video call.
 *
 * Loaded by both the console and the portal, because a call looks the same from either side and
 * two copies of this would drift the moment one of them got a fix. It assumes the tokens in
 * site.css and nothing else.
 *
 * The stage is deliberately dark regardless of theme. Video is the content here, and a light
 * surround around a dark frame makes the picture look washed out and the room look badly lit —
 * which the client reads as a problem with their camera.
 */

.video-stage {
  display: grid;
  gap: 0.5rem;
  background: #0a1119;
  border-radius: var(--radius);
  overflow: hidden;
  padding: 0.5rem;
  min-height: 18rem;
  align-content: start;
}

/* One participant fills the frame; two or more share it. */
.video-stage[data-count="0"],
.video-stage[data-count="1"] { grid-template-columns: 1fr; }

.video-stage[data-count="2"],
.video-stage[data-count="3"],
.video-stage[data-count="4"] { grid-template-columns: repeat(2, 1fr); }

.video-tile {
  position: relative;
  background: #101c27;
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-tile .video-media,
.video-tile .video-stream {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/*
 * A participant with no video still gets a tile. An empty grid cell would read as a bug, whereas a
 * labelled dark tile reads as "their camera is off", which is what is actually true.
 */
.video-tile[data-has-video="false"]::after {
  content: "Camera off";
  color: #6f8496;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.video-tile[data-has-video="true"]::after { content: none; }

/* Audio elements are real and must play, but there is nothing to look at. */
.video-audio { display: none; }

.video-label {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgb(6 12 18 / 72%);
  color: #e8eef3;
  font-size: 0.74rem;
  max-width: calc(100% - 1rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The estimator's own tile, small and in the corner: they are looking at the client, not at
   themselves. Suppressed on narrow screens, where it would cover a third of the client's picture. */
.video-stage[data-count="2"] .video-tile[data-local="true"] {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  width: 8.5rem;
  aspect-ratio: 4 / 3;
  z-index: 2;
  border: 1px solid rgb(255 255 255 / 18%);
  box-shadow: 0 6px 18px rgb(0 0 0 / 40%);
}

.video-stage[data-count="2"] {
  position: relative;
  grid-template-columns: 1fr;
}

@media (max-width: 40rem) {
  .video-stage[data-count="2"] .video-tile[data-local="true"] {
    width: 6rem;
    right: 0.5rem;
    bottom: 0.5rem;
  }
}

.call-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

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

.call-layout {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1.6fr) minmax(19rem, 1fr);
  align-items: start;
}

@media (max-width: 62rem) {
  .call-layout { grid-template-columns: 1fr; }
}

.call-lines { display: grid; gap: 0.35rem; }

.call-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.88rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--hairline);
}

.call-line span:last-child {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Description wide, quantity and price narrow, button sized to its text: the estimator types
   into the first field almost every time, so it gets the room. */
.call-line-form {
  display: grid;
  gap: 0.4rem;
  grid-template-columns: minmax(0, 1fr) 4.5rem 6rem auto;
  align-items: center;
}

@media (max-width: 30rem) {
  .call-line-form { grid-template-columns: 1fr 1fr; }
}

/* ---------- Captured stills ---------- */

.capture-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.capture {
  flex: 0 0 8rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.capture img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.capture figcaption {
  padding: 0.3rem 0.4rem;
  font-size: 0.72rem;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Recording ---------- */

/*
 * The recording indicator is loud on purpose. Everyone on the call is entitled to know they are
 * being recorded without having to look for it, and a subtle badge is how someone ends up recorded
 * without realising.
 */
.recording-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  background: var(--bad-bg);
  color: var(--bad);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.recording-banner .dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

@media (prefers-reduced-motion: no-preference) {
  .recording-banner .dot { animation: recording-pulse 1.6s ease-in-out infinite; }

  @keyframes recording-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
  }
}

/* ---------- Consent ---------- */

.consent-prompt {
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
  margin-bottom: 1rem;
}

.consent-prompt h2 {
  font-size: 1rem;
  font-family: var(--font-display);
  margin: 0 0 0.5rem;
}

.consent-prompt p { font-size: 0.88rem; margin: 0 0 0.75rem; }

.consent-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- Device picker ---------- */

/*
 * Below the call controls rather than beside them: muting is a reflex done mid-sentence and needs
 * to be a fixed target, while choosing a camera happens once. Putting them on one row would move
 * the mute button every time a device is plugged in.
 */
.device-picker {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.device-choice {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.device-choice select {
  width: auto;
  max-width: 13rem;
}
