/* LMS exercise — page-level image display layouts.
 *
 * Companion to public/js/lms-exercise-display.js. Selectively ported from the
 * design prototype at design-handoffs/lms-exercises/design_handoff_exercise_image_styles/
 * per HANDOFF.md §2. Drops vignette / matrix / header sections — those belong
 * with the homework-page integration step.
 *
 * Pair with lms-exercise-fallbacks.css (no-image gradient backgrounds).
 */

/* ── Homework-page integration wrapper ───────────────────────────────
 * The student-homework view mounts the renderer onto a dedicated wrapper
 * inserted as the first child of `#exercise-view` (Alpine owns everything
 * else, so we stay out of its way). Banner / faded modes use the wrapper
 * in normal flow; background mode uses --bg to absolute-fill the host
 * container behind the Alpine content.
 */
.exercise-image-treatment--bg {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--compact-static-offset, 48px);
  height: clamp(340px, 56vw, 760px);
  z-index: -1;          /* contained by .exercise-page's `isolation: isolate` */
  pointer-events: none;
}

/* ── Frost / glass design tokens (scoped to the exercise page) ───── */
.exercise-page {
  --frost-blur: 24px;
  --frost-opacity: 0.62;
  --frost-opacity-dark: 0.55;
  --frost-saturate: 180%;
  --passage-frost-blur: 20px;
  --passage-frost-saturate: 180%;
  --passage-frost-light-top: 0.74;
  --passage-frost-light-bottom: 0.64;
  --passage-frost-dark-top: 0.68;
  --passage-frost-dark-bottom: 0.58;

  /* --exercise-title-color is intentionally unset by default: each title rule
   * supplies its own prototype default via var(--exercise-title-color, <fallback>),
   * and the renderer only sets the var when displayStyle.titleColor is provided.
   * This keeps the design-spec defaults intact (dark on white-fade, white on
   * banner overlay, etc.) without forcing a single brand purple on every mode. */
  --exercise-font-family: inherit;
  --exercise-overlay-strength: 0.55;

  /* Layout primitives only — `position: relative` + `isolation: isolate` are
   * required to contain the z-index:-1 background wrapper. Sizing is left to
   * the host: standalone full-bleed pages should add `min-height: 100vh`
   * themselves. (The student-homework view mounts on a 900px card, where
   * imposing 100vh would create a giant empty container.)
   */
  position: relative;
  isolation: isolate;
}
.exercise-page.has-image { background: #fff; }
.exercise-page.theme-black { background: #0a0a0a; color: #f0f0f0; }

/* Homework-page integration: the host `#exercise-view` is normally a centred
 * 900px white card with `overflow: hidden` and rounded corners. None of that
 * fits a full-bleed banner / fade / background-image hero, so for image modes
 * we strip the card constraints. */
.exercise-page.has-image.exercise-container {
  max-width: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  margin: 0;
}

/* Image-mode hero needs to bleed edge-to-edge — `.student-homework`'s 16px
 * padding + light-blue background shows up as a frame around the page on
 * mobile and is wrong for these layouts. When the host contains an image-
 * mode exercise, neutralise the surrounding chrome. (`:has()` is supported
 * in all evergreen browsers since 2023.) */
.student-homework:has(> #exercise-view.has-image),
.student-homework:has(> .container > #exercise-view.has-image) {
  padding: 0;
  background: transparent;
}

/* Image modes replace Alpine's purple `.exercise-header` with the renderer's
 * frosted compact header (`.lms-compact-header`). Hide the Alpine block to
 * avoid two competing chromes stacked on top of each other. (Functional
 * controls — timer, feedback toggle, dots — will return when the
 * homework-header redesign wires Alpine state into the new compact strip.) */
.exercise-page.has-image > .exercise-header { display: none; }

/* Keep the body content readable inside the now-full-bleed host: re-impose a
 * reading-width on Alpine's `.exercise-content` and the hoisted title block. */
.exercise-page.has-image > .exercise-content,
.exercise-page.has-image > .background-title-block {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
.exercise-page.has-image > .exercise-content { padding-left: 24px; padding-right: 24px; }

/* ── Renderer-side compact header ─────────────────────────────────────
 * Visual replica of the prototype's CompactHeader (image-modes.jsx).
 *
 *   .lms-compact-header-group
 *     .lms-compact-header.lms-compact-header-static    ← scrolls away (rows 1 + meta)
 *     .lms-compact-header.lms-compact-header-sticky    ← pins to top (timer / dots / feedback)
 *
 * The static block carries the back-link / breadcrumb / progress / settings
 * row and the Target/Attempt meta row — both scroll out of view as the user
 * reads. The sticky strip below pins to the top of the scroll container with
 * three independent glass-pills (timer · question dots · feedback toggle).
 * The pills sit on top of the banner / fade image while in view; the image
 * shows between them. (Adaptive frost — fading the strip's own backdrop in
 * once the user scrolls past the image area — is already wired up via
 * `attachAdaptiveFrost` and the `.frost-sentinel` placed at the bottom of
 * the image; nothing here adds it.) */
.lms-compact-header-group { display: contents; }

.lms-compact-header {
  position: relative;
  z-index: 100;
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.30));
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-bottom: 1px solid rgba(255,255,255,0.4);
  box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset, 0 8px 24px -8px rgba(0,0,0,0.18);
  color: var(--text-dark, #4a4a4a);
}
.lms-compact-header .compact-row {
  display: flex; align-items: center; gap: 14px;
  height: 48px; padding: 0 20px;
}
.lms-compact-header .compact-row.row-1 {
  height: auto;
  min-height: 48px;
  padding-top: 8px;
  padding-bottom: 8px;
  flex-wrap: wrap;
  row-gap: 8px;
}
.lms-compact-header .meta-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.lms-compact-header .back-link {
  background: none; border: none;
  color: #502f77; font-weight: 500; font-size: 0.9rem;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  margin: 0;
  line-height: 1;
  text-decoration: none;
}
.lms-compact-header .back-link:hover { background: rgba(0,0,0,0.04); }
.lms-compact-header .breadcrumb {
  font-size: 0.85rem; color: #666;
  display: inline-flex; align-items: center; gap: 6px;
}
.lms-compact-header .breadcrumb strong { color: #4a4a4a; font-weight: 600; }
.lms-compact-header .compact-progress {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.82rem; color: #666;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.lms-compact-header .compact-progress .bar {
  width: 96px; height: 4px; background: rgba(0,0,0,0.10); border-radius: 2px; overflow: hidden;
}
.lms-compact-header .compact-progress .bar > div {
  height: 100%; background: #502f77; transition: width 300ms ease;
}
.lms-compact-header .compact-icon-btn {
  width: 32px; height: 32px; border-radius: 10px;
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.5);
  color: #502f77;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
  margin-left: auto;
  flex: 0 0 auto;
}
.lms-compact-header .compact-icon-btn:hover { background: rgba(255,255,255,0.7); }
.lms-compact-header .meta-pill {
  font-size: 0.78rem; color: #666;
  background: rgba(255,255,255,0.4);
  border: 1px solid rgba(255,255,255,0.5);
  padding: 3px 10px; border-radius: 50px;
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.lms-compact-header .meta-pill strong { color: #4a4a4a; font-weight: 600; }

/* Dark theme (fadeToBlackImage applies .theme-black on the host) */
.exercise-page.theme-black .lms-compact-header {
  background: linear-gradient(180deg, rgba(20,20,24,0.55), rgba(10,10,14,0.35));
  border-bottom-color: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.92);
  box-shadow: 0 1px 0 rgba(255,255,255,0.10) inset, 0 8px 24px -8px rgba(0,0,0,0.5);
}
.exercise-page.theme-black .lms-compact-header .back-link { color: #fff; }
.exercise-page.theme-black .lms-compact-header .breadcrumb { color: rgba(255,255,255,0.6); }
.exercise-page.theme-black .lms-compact-header .breadcrumb strong { color: #fff; }
.exercise-page.theme-black .lms-compact-header .compact-progress { color: rgba(255,255,255,0.6); }
.exercise-page.theme-black .lms-compact-header .compact-progress .bar { background: rgba(255,255,255,0.12); }
.exercise-page.theme-black .lms-compact-header .compact-progress .bar > div { background: #fff; }
.exercise-page.theme-black .lms-compact-header .compact-icon-btn,
.exercise-page.theme-black .lms-compact-header .meta-pill {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.9);
  box-shadow: none;
}
.exercise-page.theme-black .lms-compact-header .meta-pill strong { color: #fff; }

/* Sticky strip — pinned, transparent until the IntersectionObserver toggles
 * `.over-content` when the user scrolls past the image. */
.lms-compact-header.lms-compact-header-sticky {
  position: sticky;
  top: 0;
  z-index: 110;
  background: rgba(255, 255, 255, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  border-bottom: 1px solid rgba(255, 255, 255, 0);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  transition:
    background 560ms ease-in-out,
    backdrop-filter 560ms ease-in-out,
    -webkit-backdrop-filter 560ms ease-in-out,
    border-color 560ms ease-in-out,
    box-shadow 560ms ease-in-out;
}
.lms-compact-header.lms-compact-header-sticky.over-content {
  background: transparent;
  backdrop-filter: blur(var(--frost-blur, 24px)) saturate(var(--frost-saturate, 180%));
  -webkit-backdrop-filter: blur(var(--frost-blur, 24px)) saturate(var(--frost-saturate, 180%));
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 6px 14px -10px rgba(0,0,0,0.18);
}
.exercise-page.theme-black .lms-compact-header.lms-compact-header-sticky.over-content {
  background: transparent;
  border-bottom-color: rgba(255,255,255,0.08);
  box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 6px 14px -10px rgba(0,0,0,0.6);
}

.lms-compact-header .compact-row.row-sticky {
  display: grid;
  /* Keep side pills sized to real content, and give dots pill only the true
   * remaining width. This prevents overlap when question count changes. */
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: center;
  height: 52px;
  padding: 0 16px;
  gap: 10px;
}
.lms-compact-header .sticky-cell { display: flex; align-items: center; min-width: 0; }
.lms-compact-header .sticky-cell-left   { justify-content: flex-start; }
.lms-compact-header .sticky-cell-center { justify-content: center; }
.lms-compact-header .sticky-cell-right  { justify-content: flex-end; }
/* When there are no dots yet, hide the empty center slot cleanly. */
.lms-compact-header .sticky-cell-center:empty {
  opacity: 0;
  pointer-events: none;
}
.lms-compact-header .sticky-cell-center .q-progress-pill {
  max-width: 100%;
}

/* When dots exceed two rows, place the whole progress pill on its own row. */
.lms-compact-header .compact-row.row-sticky.progress-breakout {
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "timer toggle"
    "dots  dots";
  height: auto;
}
.lms-compact-header .compact-row.row-sticky.progress-breakout .sticky-cell-left {
  grid-area: timer;
}
.lms-compact-header .compact-row.row-sticky.progress-breakout .sticky-cell-center {
  grid-area: dots;
}
.lms-compact-header .compact-row.row-sticky.progress-breakout .sticky-cell-right {
  grid-area: toggle;
}

/* Glass-pill capsule — each control floats independently. */
.lms-compact-header .glass-pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 50px;
  background: linear-gradient(180deg,
    rgba(255,255,255,calc(var(--frost-opacity, 0.62) - 0.18)),
    rgba(255,255,255,calc(var(--frost-opacity, 0.62) - 0.28)));
  border: 1px solid rgba(255,255,255,0.55);
  backdrop-filter: blur(calc(var(--frost-blur, 24px) * 0.85)) saturate(var(--frost-saturate, 180%));
  -webkit-backdrop-filter: blur(calc(var(--frost-blur, 24px) * 0.85)) saturate(var(--frost-saturate, 180%));
  box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset, 0 4px 12px -4px rgba(0,0,0,0.18);
  color: var(--text-dark, #4a4a4a);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  transition:
    background 560ms ease-in-out,
    backdrop-filter 560ms ease-in-out,
    -webkit-backdrop-filter 560ms ease-in-out,
    border-color 560ms ease-in-out,
    box-shadow 560ms ease-in-out,
    color 560ms ease-in-out;
}
/* Sticky-row pills need stronger legibility because they can sit on image or text. */
.lms-compact-header .compact-row.row-sticky .glass-pill {
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.86),
    rgba(255,255,255,0.78)
  );
  border-color: rgba(255,255,255,0.9);
  backdrop-filter: blur(calc(var(--frost-blur, 24px) * 1.35)) saturate(var(--frost-saturate, 180%));
  -webkit-backdrop-filter: blur(calc(var(--frost-blur, 24px) * 1.35)) saturate(var(--frost-saturate, 180%));
  box-shadow: 0 1px 0 rgba(255,255,255,0.9) inset, 0 8px 20px -10px rgba(0,0,0,0.28);
}
.lms-compact-header .glass-pill svg { color: #666; }
.exercise-page.theme-black .lms-compact-header .glass-pill {
  background: linear-gradient(180deg,
    rgba(20,20,24,calc(var(--frost-opacity-dark, 0.55) - 0.05)),
    rgba(10,10,14,calc(var(--frost-opacity-dark, 0.55) - 0.12)));
  border-color: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.92);
  box-shadow: 0 1px 0 rgba(255,255,255,0.10) inset, 0 4px 12px -4px rgba(0,0,0,0.55);
}
.exercise-page.theme-black .lms-compact-header .compact-row.row-sticky .glass-pill {
  background: linear-gradient(
    180deg,
    rgba(10,10,14,0.82),
    rgba(10,10,14,0.74)
  );
  border-color: rgba(255,255,255,0.34);
  backdrop-filter: blur(calc(var(--frost-blur, 24px) * 1.35)) saturate(var(--frost-saturate, 180%));
  -webkit-backdrop-filter: blur(calc(var(--frost-blur, 24px) * 1.35)) saturate(var(--frost-saturate, 180%));
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 8px 20px -10px rgba(0,0,0,0.72);
}
.exercise-page.theme-black .lms-compact-header .glass-pill svg { color: rgba(255,255,255,0.65); }

/* Once the strip itself is frosted (over body), pills lose their own backdrop. */
.lms-compact-header.over-content .glass-pill {
  backdrop-filter: blur(calc(var(--frost-blur, 24px) * 1.05)) saturate(var(--frost-saturate, 180%));
  -webkit-backdrop-filter: blur(calc(var(--frost-blur, 24px) * 1.05)) saturate(var(--frost-saturate, 180%));
  background: rgba(255,255,255,0.84);
  border-color: rgba(0,0,0,0.2);
  box-shadow: 0 1px 0 rgba(255,255,255,0.82) inset, 0 6px 14px -8px rgba(0,0,0,0.35);
}
.exercise-page.theme-black .lms-compact-header.over-content .glass-pill {
  background: rgba(10,10,14,0.82);
  border-color: rgba(255,255,255,0.34);
  box-shadow: 0 1px 0 rgba(255,255,255,0.14) inset, 0 6px 14px -8px rgba(0,0,0,0.6);
}

/* Question-progress dots inside the sticky pill. */
.lms-compact-header .q-progress-pill { padding: 0 12px; }
.lms-compact-header .q-progress-mini {
  display: flex; gap: 5px; align-items: center;
  flex-wrap: wrap; justify-content: center; row-gap: 4px;
}
.lms-compact-header .q-progress-mini .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(0,0,0,0.18);
  border: 0;
  padding: 0;
  margin: 0;
  display: inline-block;
  flex: 0 0 auto;
}
.lms-compact-header .q-progress-mini button.dot {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  font: inherit;
  line-height: 0;
}
.lms-compact-header .q-progress-mini button.dot:hover {
  transform: scale(1.18);
}
.lms-compact-header .q-progress-mini button.dot:focus-visible {
  outline: 2px solid rgba(80,47,119,0.45);
  outline-offset: 3px;
}
.lms-compact-header .q-progress-mini .dot.correct { background: #4caf50; }
.lms-compact-header .q-progress-mini .dot.incorrect { background: #e53935; }
/* `.current` only paints the dot purple when it hasn't been answered yet — the
 * ring is the actual current-question indicator and is always applied so the
 * answered-and-current dot keeps its green/red while still being marked. */
.lms-compact-header .q-progress-mini .dot.current {
  box-shadow: 0 0 0 3px rgba(80,47,119,0.20);
}
.lms-compact-header .q-progress-mini .dot.current:not(.correct):not(.incorrect) {
  background: #502f77;
}
/* Pending dots only — same source order + specificity as `.dot.correct` /
 * `.dot.incorrect` would otherwise win and paint answered dots back to grey. */
.exercise-page.theme-black .lms-compact-header .q-progress-mini .dot:not(.correct):not(.incorrect) { background: rgba(255,255,255,0.2); }
.exercise-page.theme-black .lms-compact-header .q-progress-mini .dot.current {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25);
}
.exercise-page.theme-black .lms-compact-header .q-progress-mini .dot.current:not(.correct):not(.incorrect) {
  background: #fff;
}

/* Feedback toggle. */
.lms-compact-header .compact-toggle.glass-pill { padding: 0 12px; font-size: 0.8rem; color: #666; }
.lms-compact-header .compact-toggle .pill {
  width: 26px; height: 14px; border-radius: 50px;
  background: rgba(0,0,0,0.18); position: relative;
  transition: background 180ms ease;
}
.lms-compact-header .compact-toggle .pill::after {
  content: ''; position: absolute; left: 1px; top: 1px;
  width: 12px; height: 12px; border-radius: 50%; background: white;
  transition: transform 180ms ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.lms-compact-header .compact-toggle.on .pill { background: #502f77; }
.lms-compact-header .compact-toggle.on .pill::after { transform: translateX(12px); }
.lms-compact-header .compact-toggle.is-locked {
  opacity: 0.72;
  cursor: not-allowed;
}
.lms-compact-header .compact-toggle.is-locked .pill {
  background: #94a3b8;
}
.lms-compact-header .compact-toggle.is-locked .pill::after {
  background: #e5e7eb;
}
.exercise-page.theme-black .lms-compact-header .compact-toggle .pill { background: rgba(255,255,255,0.2); }
.exercise-page.theme-black .lms-compact-header .compact-toggle.on .pill { background: #fff; }
.exercise-page.theme-black .lms-compact-header .compact-toggle.on .pill::after { background: #502f77; }

/* Mobile-friendly toggle label swap. */
.lms-compact-header .toggle-label-short { display: none; }
@media (max-width: 768px) {
  .lms-compact-header .toggle-label-full  { display: none; }
  .lms-compact-header .toggle-label-short { display: inline; }
}

@media (max-width: 760px) {
  .lms-compact-header .compact-row.row-1 {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "back meta settings"
      "crumb crumb crumb";
    align-items: center;
    column-gap: 10px;
    row-gap: 8px;
  }

  .lms-compact-header .back-link {
    grid-area: back;
  }

  .lms-compact-header .breadcrumb {
    grid-area: crumb;
    min-width: 0;
  }

  .lms-compact-header .meta-inline {
    grid-area: meta;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .lms-compact-header .compact-icon-btn {
    grid-area: settings;
    justify-self: end;
    margin-left: 0;
  }
}

/* ── Narrow-viewport tweaks (≤ 480px) ────────────────────────────────
 * Phones from iPhone SE 1 (320) up through iPhone 14 Plus (414). */
@media (max-width: 480px) {
  .lms-compact-header .compact-row { padding: 0 12px; gap: 10px; }
  .lms-compact-header .compact-row.row-1 { padding-top: 6px; padding-bottom: 6px; gap: 8px; }
  .lms-compact-header .back-link { padding: 4px 6px; }
  .lms-compact-header .breadcrumb {
    font-size: 0.8rem;
    min-width: 0; flex: 0 1 auto;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  /* Keep one adaptive row on mobile as long as space allows. The center pill
   * wraps its dots only when it truly runs out of room. */
  .lms-compact-header .compact-row.row-sticky {
    grid-template-columns: max-content minmax(0, 1fr) max-content;
    height: auto;
    padding: 8px 12px;
    row-gap: 6px;
    column-gap: 8px;
  }
  .lms-compact-header .sticky-cell-left   { justify-content: flex-start; }
  .lms-compact-header .sticky-cell-right  { justify-content: flex-end; }
  .lms-compact-header .sticky-cell-center { justify-content: center; }
  .lms-compact-header .glass-pill { min-height: 30px; padding: 0 11px; font-size: 0.78rem; }
  /* Dots row: full width, allow multi-line wrap (up to 54 questions). */
  .lms-compact-header .sticky-cell-center .glass-pill {
    max-width: 100%;
  }
  .lms-compact-header .q-progress-pill { padding: 0 11px; }
  .lms-compact-header .q-progress-mini { flex-wrap: wrap; row-gap: 5px; }
}

/* Even tighter on very narrow screens (≤ 360px — iPhone SE 1). */
@media (max-width: 360px) {
  .lms-compact-header .compact-row { padding: 0 10px; gap: 8px; height: 44px; }
  .lms-compact-header .compact-row.row-1 { min-height: 44px; padding-top: 6px; padding-bottom: 6px; }
  .lms-compact-header .compact-icon-btn { width: 28px; height: 28px; }
  .lms-compact-header .meta-pill { font-size: 0.74rem; padding: 3px 8px; }
  .lms-compact-header .compact-row.row-sticky { padding: 6px 10px; column-gap: 6px; }
  .lms-compact-header .glass-pill { min-height: 28px; padding: 0 10px; font-size: 0.74rem; gap: 6px; }
  .lms-compact-header .q-progress-mini .dot { width: 6px; height: 6px; }
  .lms-compact-header .compact-toggle.glass-pill { padding: 0 10px; font-size: 0.74rem; }
  .lms-compact-header .compact-toggle .pill { width: 22px; height: 12px; }
  .lms-compact-header .compact-toggle .pill::after { width: 10px; height: 10px; }
  .lms-compact-header .compact-toggle.on .pill::after { transform: translateX(10px); }
}

/* IntersectionObserver target — invisible 1px sentinel at the bottom of the
 * image area. Sticky bar gets `.over-content` once this scrolls off the top. */
.frost-sentinel {
  height: 1px;
  width: 100%;
  pointer-events: none;
  visibility: hidden;
}

/* ── Banner mode ──────────────────────────────────────────────────── */
.banner-image-container {
  width: 100%;
  height: 45vw;
  max-height: 520px;
  min-height: 240px;
  overflow: hidden;
  position: relative;
}
.banner-image-container .parallax-wrap {
  position: absolute;
  inset: 0;
  height: 160%;       /* oversized so upward translation never reveals bg */
  top: -30%;
  will-change: transform;
}
.banner-image-container .parallax-wrap img,
.banner-image-container > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
@media (max-width: 768px) {
  .banner-image-container { height: 75vw; max-height: 78vh; }
}

.banner-image-container .title-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 48px 24px 24px;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, var(--exercise-overlay-strength)),
    transparent
  );
  color: white;
  pointer-events: none;
  font-family: var(--exercise-font-family);
}
.banner-image-container .title-overlay h1 {
  font-size: 2.4rem;
  margin: 0 auto 6px;
  max-width: 720px;
  letter-spacing: -0.01em;
  color: inherit;            /* defeat .student-homework h1 { color: purple } */
  font-weight: 600;
  text-align: left;          /* defeat .student-homework h1 { text-align: center } */
}
.banner-image-container .title-overlay .lede {
  font-size: 1rem;
  opacity: 0.9;
  max-width: 720px;
  margin: 0 auto;
}
@media (max-width: 768px) {
  .banner-image-container .title-overlay { padding: 32px 20px 16px; }
  .banner-image-container .title-overlay h1 { font-size: 1.6rem; }
}

/* ── Background mode ──────────────────────────────────────────────── */
.exercise-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.exercise-background .parallax-wrap {
  position: absolute;
  inset: 0;
  height: 180%;
  top: -40%;
  will-change: transform;
}
.exercise-background .parallax-wrap img,
.exercise-background > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  will-change: transform;
}
.exercise-background::after {
  /* Subtle vignette so frosted cards always have legible contrast. */
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0.25) 100%);
  pointer-events: none;
}

/* Ken Burns drift on the <img> itself (composes with parallax on .parallax-wrap). */
.exercise-background.kb .parallax-wrap img,
.exercise-background.kb > img {
  animation: lmsKenBurnsBg 36s ease-in-out infinite alternate;
}
@keyframes lmsKenBurnsBg {
  0%   { transform: scale(1.05) translate(0, 0); }
  100% { transform: scale(1.15) translate(-2%, -1%); }
}

.exercise-content-layer {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 52px);
}

.background-title-block {
  text-align: left;
  margin: 16px auto 16px;
  max-width: 720px;
  padding: 0 24px;
  color: #1a1a1a;
  font-family: var(--exercise-font-family);
}
.background-title-block h1 {
  font-size: 2rem;
  line-height: 1.12;
  margin: 0;
  letter-spacing: -0.01em;
  color: inherit;
  text-align: left;
}
.background-title-block .lede {
  margin: 8px 0 0;
  max-width: 48ch;
  color: rgba(26, 26, 26, 0.72);
  font-size: 0.95rem;
}

/* ── Faded mode (fadeToBlackImage / fadeToWhiteImage) ────────────── */
.faded-image-container {
  position: relative;
  width: 100%;
  height: 60vh;
  min-height: 360px;
  max-height: 600px;
  overflow: hidden;
}
.exercise-image-treatment--bg .faded-image-container {
  position: absolute;
  inset: 0;
  height: 100%;
  min-height: 0;
  max-height: none;
}
.faded-image-container .parallax-wrap {
  position: absolute;
  inset: 0;
  height: 170%;
  top: -35%;
  will-change: transform;
}
.faded-image-container .parallax-wrap img,
.faded-image-container > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.faded-image-container.theme-white::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 30%,
    rgba(255, 255, 255, 0.6) 55%,
    rgba(255, 255, 255, 1) 100%
  );
}
.faded-image-container.theme-black::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 30%,
    rgba(0, 0, 0, 0.6) 55%,
    rgba(0, 0, 0, 1) 100%
  );
}
.background-title-block.faded-title-block {
  margin: 20px auto 16px;
  text-align: left;
  color: var(--exercise-title-color, #1a1a1a);
}
.background-title-block.faded-title-block h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  text-align: left;
}
.background-title-block.faded-title-block .lede {
  margin-top: 6px;
  font-size: 0.95rem;
  color: rgba(26, 26, 26, 0.72);
}
.exercise-page.theme-black .background-title-block.faded-title-block {
  color: var(--exercise-title-color, #fff);
}
.exercise-page.theme-black .background-title-block.faded-title-block .lede {
  color: rgba(255, 255, 255, 0.75);
}

@media (max-width: 768px) {
  .faded-image-container { height: 50vh; min-height: 280px; }
  .background-title-block.faded-title-block h1 { font-size: 1.5rem; }
}

/* Keep faded-mode content in normal flow when image is mounted as a background layer. */
.faded-content { margin-top: 0; position: relative; z-index: 2; }

/* Exercise-content frosting for background + faded modes (the --bg wrapper is
 * only used by those three image treatments). This gives *all* exercise types
 * (multiple choice, gap fill, passage, etc.) the same frosted readability layer
 * without needing type-specific container selectors. */
.exercise-page.has-image:has(> .exercise-image-treatment--bg) > .exercise-content {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, var(--passage-frost-light-top, 0.74)),
    rgba(255, 255, 255, var(--passage-frost-light-bottom, 0.64))
  );
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 16px;
  box-shadow: 0 16px 40px -24px rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(var(--passage-frost-blur, 20px)) saturate(var(--passage-frost-saturate, 180%));
  -webkit-backdrop-filter: blur(var(--passage-frost-blur, 20px)) saturate(var(--passage-frost-saturate, 180%));
  overflow: hidden; /* clip frosted background to rounded corners */
}

/* Fade-to-black previously overrode the content slab with a dark frosted
 * gradient. The slab is now image-mode-agnostic and stays light by default; the
 * dark frosted treatment is reserved for user-toggled Dark Mode (see
 * `.student-homework.dark-mode` rules in student-homework.css). */

/* ── Generic content slot (banner / fallback) ─────────────────────── */
.lms-exercise-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 4rem;
  font-family: var(--exercise-font-family);
}
.lms-exercise-content.fallback-content { padding-top: 0; }

.exercise-page .fallback-title-block h1 {
  font-size: 2rem;
  line-height: 1.15;
  margin: 0 0 8px;
  color: var(--exercise-title-color, #502f77);
  letter-spacing: -0.01em;
  text-align: left;
}
.fallback-title-block .lede {
  margin: 0 0 24px;
  font-size: 1rem;
  color: #666;
}
@media (max-width: 768px) {
  .fallback-title-block h1 { font-size: 1.5rem; }
}
