/*
 * ai-playground-s4-bedside-r2.css
 * §4 Bedside Manner — video carousel with listening loop
 * bedside-v19 — fix disclaimer/source race via pendingSegment.
 *
 * Layout: two-column. Skinny left for copy, wider right for player + 4+3 grid.
 * Player: listening loop persistent, active video fades in on top.
 * Grid: 4 across top row, 3 across bottom row (centered).
 * Requires: design-system.css v2 loaded first.
 */


/* ═══════════════════════════════════════════════════════════════════════
   SECTION SHELL
   ═══════════════════════════════════════════════════════════════════════ */

.bedside {
  width: 100%;
  padding: 120px 7vw;
  background: var(--steel);
}

.bedside__inner {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 60px;
  align-items: start;
}


/* ═══════════════════════════════════════════════════════════════════════
   LEFT COLUMN — COPY
   ═══════════════════════════════════════════════════════════════════════ */

.bedside__copy {
  position: sticky;
  top: calc(var(--nav-height) + 40px);
  max-width: 340px;
}

.bedside__eyebrow {
  display: block;
  margin-bottom: 20px;
}

.bedside__headline {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: clamp(26px, 2.3vw, 36px);
  font-weight: 300;
  color: var(--white);
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin-bottom: 24px;
  text-wrap: balance;
}

/* ─── BULLET NOTES — chunked copy, no markers, generous spacing ─── */
.bedside__notes {
  list-style: none;
  padding: 0;
  margin: 0 0 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bedside__notes li {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 300;
  color: var(--silver-bright);
  line-height: 1.55;
  /* Subtle leading hairline gives the chunks structure without bullets */
  padding-left: 14px;
  position: relative;
}

.bedside__notes li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 6px;
  height: 1px;
  background: var(--chart);
}

.bedside__instruction {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 400;
  color: var(--silver);
  line-height: 1.55;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0;
}

.bedside__dev-note {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 400;
  color: var(--chart);
  line-height: 1.55;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 20px;
}


/* ═══════════════════════════════════════════════════════════════════════
   RIGHT COLUMN — PLAYER + GRID
   ═══════════════════════════════════════════════════════════════════════ */

.bedside__stage {
  display: flex;
  flex-direction: column;
  gap: 28px;
}


/* ─── HERO PLAYER ────────────────────────────────────────────── */

.bedside__player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.bedside__loop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  z-index: 1;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease, visibility 0s;
}

/* When a clip is actively playing, HARD-hide the loop — visibility:hidden plus
   opacity:0. visibility removes it from rendering entirely (not just transparent),
   so even if the active layer's computed height is a pixel short of the player
   box, there is no loop content to peek through anywhere. The "Avatar Video"
   chrome and any edge bleed become impossible. During the bridge the .is-playing
   class is off, so the loop returns for the "Dr. Cliff is thinking" beat.
   visibility is delayed via transition so the opacity fade still reads smoothly. */
.bedside__player.is-playing .bedside__loop {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}

/* Active layer — padding-ratio wrapper. The 16:9 box is defined in pure CSS
   (the parent .bedside__player already has aspect-ratio:16/9, and this layer
   fills it via inset:0). The pre-existing iframe inside pins to fill this box.
   Because the iframe is correctly sized in the DOM before Vimeo measures it,
   the player never locks the wrong dimensions. */
.bedside__active {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.bedside__active.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* The pre-existing iframe fills the wrapper completely. These are plain rules
   (no !important needed) because we own this iframe — Vimeo attaches to it
   rather than injecting its own. */
.bedside__active iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Bridge overlay — appears ONLY between parent question and Dr. Cliff response.
   Full-player dark veil with a single line of rotating copy. Never visible during
   actual video playback. */
.bedside__bridge {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 40, 47, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.bedside__bridge.is-visible {
  opacity: 1;
}

.bedside__bridge-line {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: clamp(17px, 1.6vw, 22px);
  font-weight: 400;
  font-style: italic;
  color: var(--white);
  letter-spacing: -0.005em;
  text-align: center;
  max-width: 70%;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
  /* Subtle rise as the line appears */
  transform: translateY(6px);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.05s;
}

.bedside__bridge.is-visible .bedside__bridge-line {
  transform: translateY(0);
}


/* ═══════════════════════════════════════════════════════════════════════
   THUMBNAIL GRID — 4 + 3 ASYMMETRIC
   ═══════════════════════════════════════════════════════════════════════ */

.bedside__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

/* Row 2: tiles 5–7 wrap into a 4-col grid. To center 3 tiles in 4 columns,
   shift each by half a column width. */
.bedside__grid .bs-tile:nth-child(5) { grid-column: 1 / span 1; transform: translateX(50%); }
.bedside__grid .bs-tile:nth-child(6) { grid-column: 2 / span 1; transform: translateX(50%); }
.bedside__grid .bs-tile:nth-child(7) { grid-column: 3 / span 1; transform: translateX(50%); }


/* ─── TILE ───────────────────────────────────────────────────── */

.bs-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: opacity 0.25s ease;
}

.bs-tile:hover { opacity: 1; }
.bs-tile:focus-visible {
  outline: 1px solid var(--chart);
  outline-offset: 6px;
}

.bs-tile__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--mid);
}

.bs-tile__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(0.2) brightness(0.92);
  transition: filter 0.35s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.bs-tile:hover .bs-tile__thumb img,
.bs-tile:focus-visible .bs-tile__thumb img {
  filter: grayscale(0) brightness(1);
  transform: scale(1.03);
}

/* Active tile state — chartreuse hairline + persistent caption color */
.bs-tile.is-active .bs-tile__thumb {
  box-shadow: 0 0 0 2px var(--chart);
}

.bs-tile.is-active .bs-tile__name {
  color: var(--chart);
}

/* ─── TILE META ──────────────────────────────────────────────── */

.bs-tile__meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bs-tile__name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--white);
  line-height: 1.15;
  letter-spacing: -0.005em;
  transition: color 0.25s ease;
}

.bs-tile__topic {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 400;
  color: var(--silver);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  line-height: 1.4;
}


/* ═══════════════════════════════════════════════════════════════════════
   DISCLAIMER BAR — inside player, pinned bottom edge, doctor segments only
   ═══════════════════════════════════════════════════════════════════════ */

.bedside__disclaimer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  padding: 0 12px;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.bedside__disclaimer.is-visible {
  opacity: 1;
}

.bedside__disclaimer-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 400;
  color: var(--silver);
  letter-spacing: 0.07em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ═══════════════════════════════════════════════════════════════════════
   SOURCE CARD — inside player, lower-left, above disclaimer bar
   ═══════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════
   SOURCE CARD — inside player, lower-left, above disclaimer bar
   Treatment B: dark pill backing, all elements 11px IBM Plex Mono 500
   ═══════════════════════════════════════════════════════════════════════ */

.bedside__source {
  position: absolute;
  bottom: 40px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0, 0, 0, 0.62);
  border-radius: 3px;
  padding: 5px 10px 5px 8px;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.bedside__source.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.bedside__source-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--silver);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  white-space: nowrap;
}

.bedside__source-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--white);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.bedside__source-arrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--chart);
  white-space: nowrap;
}

/* Jeff routing variant */
.bedside__source.is-route .bedside__source-label {
  display: none;
}

.bedside__source.is-route .bedside__source-title {
  color: var(--white);
}


/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */

/* Tablet — copy stacks above stage, grid stays 4+3 if room, else 3+3+1 */
@media (max-width: 1100px) {
  .bedside {
    padding: 100px 7vw;
  }
  .bedside__inner {
    grid-template-columns: 1fr;
    gap: 48px;
  }
  .bedside__copy {
    position: static;
    max-width: 640px;
  }
}

/* Smaller tablet — grid becomes 3 + 3 + 1, drop the row-2 centering offset */
@media (max-width: 900px) {
  .bedside__grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .bedside__grid .bs-tile:nth-child(5),
  .bedside__grid .bs-tile:nth-child(6),
  .bedside__grid .bs-tile:nth-child(7) {
    grid-column: auto;
    transform: none;
  }
}

/* Mobile — single column, 2-up grid */
@media (max-width: 600px) {
  .bedside {
    padding: 72px 6vw;
  }
  .bedside__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .bedside__grid .bs-tile:nth-child(5),
  .bedside__grid .bs-tile:nth-child(6),
  .bedside__grid .bs-tile:nth-child(7) {
    grid-column: auto;
    transform: none;
  }
  .bs-tile__name { font-size: 14px; }
  .bs-tile__topic { font-size: 9px; }
}


/* ═══════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .bedside__loop,
  .bedside__active,
  .bedside__bridge,
  .bedside__bridge-line,
  .bedside__disclaimer,
  .bedside__source,
  .bs-tile__thumb img {
    transition: none;
  }
}
