/* =========================================================================
   lpen-course-preview.css — the clip preview inside a course page's Summary.

   EVERY SELECTOR CONTAINS `#lpen-l21-summary`, and build_course_preview.py
   fails the build if one does not. lpen-assets/ is enqueued site wide
   (CLAUDE.md §18j/§18k), so a single unanchored rule here repaints something
   on every page of the site.

   The block is injected by lpen-course-preview.js, only on the 35 course
   pages that have a clip. This sheet ships everywhere; the markup does not.

     1  tokens
     2  the card
     3  the header row
     4  the poster
     5  the play affordance and the duration chip
     6  the caption
     7  the strip, for a course with more than one clip
     8  the player, once the poster has been clicked
     9  focus and motion
   ========================================================================= */

/* -------------------------------------------------------------- 1 tokens */
/* Read off the l21 page tokens where one exists, with a literal fallback so
   the block is never unstyled if this sheet loads somewhere the l21 token
   block does not. §18b-1: an unresolved var() fails silently. */
#lpen-l21-summary .lpen-cp {
  --cp-ink: var(--l21-ink, #111820);
  --cp-muted: var(--l21-muted, #4a5666);
  --cp-subtle: var(--l21-subtle, #6b7684);
  --cp-border: var(--l21-border, #cfd6dd);
  --cp-surface: var(--l21-surface-1, #f6f8fa);
  --cp-navy-900: var(--l21-navy-900, #012032);
  --cp-navy-700: var(--l21-navy-700, #0b4465);
  --cp-action: var(--l21-action, #0f5c96);
  --cp-white: var(--l21-white, #fff);
  --cp-focus: var(--l21-focus, #6a3fd4);
  --cp-elev: var(--l21-elev-2, 0 4px 16px rgba(1, 32, 50, .12),
    0 2px 6px rgba(1, 32, 50, .08));
}

/* ---------------------------------------------------------------- 2 card */
/* A framed card rather than a bare video. On a page whose whole job is to
   sell the course, an unframed player reads as an embed somebody pasted in;
   the frame says it is a feature of the page. Owner, 2026-09-13. */
#lpen-l21-summary .lpen-cp {
  margin: 28px 0 0;
  padding: 16px;
  max-width: 672px;
  border: 1px solid var(--cp-border);
  border-radius: 14px;
  background: var(--cp-surface);
}

/* ---------------------------------------------------------- 3 header row */
#lpen-l21-summary .lpen-cp__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}

/* The rule is a flex child, not a border on the label: a border would sit at
   the text box edge and leave the gap uneven against the card padding. */
#lpen-l21-summary .lpen-cp__head::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--cp-border);
}

#lpen-l21-summary .lpen-cp__eyebrow {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--cp-navy-700);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}

/* A small filled triangle before the label, drawn in CSS. §18a bans fa-, and
   one shape does not justify reaching for the Tabler set from JavaScript. */
#lpen-l21-summary .lpen-cp__eyebrow::before {
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent var(--cp-action);
}

/* -------------------------------------------------------------- 4 poster */
/* The ratio is reserved before the poster image arrives, so the oEmbed
   thumbnail landing late cannot shift the page. CLS is the whole reason the
   image is not simply appended. */
#lpen-l21-summary .lpen-cp__poster {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  background: var(--cp-navy-900);
  box-shadow: var(--cp-elev);
  -webkit-appearance: none;
  appearance: none;
}

/* ⚠️ THIS RULE IS LOAD BEARING, AND ITS ABSENCE WAS A REAL BUG.
   `display: block` above out-specifies the user agent's `[hidden] {display:
   none}`, so `poster.hidden = true` on play left the poster on screen
   underneath the running video: two copies of the same frame, one of them
   playing. Reported by the owner on the live page, 2026-09-13. Every element
   in this component toggled with `hidden` needs its own rule here. */
#lpen-l21-summary .lpen-cp__poster[hidden],
#lpen-l21-summary .lpen-cp__frame[hidden] {
  display: none !important;
}

#lpen-l21-summary .lpen-cp__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .25s ease;
}

#lpen-l21-summary .lpen-cp__img.is-in {
  opacity: 1;
}

/* A scrim under the play mark, so a white disc holds its contrast over
   whatever frame Vimeo picked. */
#lpen-l21-summary .lpen-cp__poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(1, 32, 50, .05) 0%,
    rgba(1, 32, 50, .35) 100%);
  pointer-events: none;
}

/* --------------------------------- 5 the play affordance and the duration */
#lpen-l21-summary .lpen-cp__play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 2px 10px rgba(1, 32, 50, .35);
  transition: transform .18s ease, background-color .18s ease;
}

#lpen-l21-summary .lpen-cp__play::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  margin: -11px 0 0 -7px;
  border-style: solid;
  border-width: 11px 0 11px 18px;
  border-color: transparent transparent transparent var(--cp-navy-900);
}

#lpen-l21-summary .lpen-cp__poster:hover .lpen-cp__play {
  background: var(--cp-white);
  transform: scale(1.06);
}

#lpen-l21-summary .lpen-cp__dur {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 1;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(1, 32, 50, .82);
  color: var(--cp-white);
  font-size: 12px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity .2s ease;
}

#lpen-l21-summary .lpen-cp__dur.is-in {
  opacity: 1;
}

/* -------------------------------------------------------- 6 the caption */
#lpen-l21-summary .lpen-cp__cap {
  margin: 12px 0 0;
  padding: 0;
}

#lpen-l21-summary .lpen-cp__title {
  display: block;
  color: var(--cp-ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

#lpen-l21-summary .lpen-cp__note {
  display: block;
  margin: 5px 0 0;
  color: var(--cp-subtle);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------------------------------------------------------- 7 the strip */
/* Only rendered when the course has more than one clip. One chip would be a
   label with a picture on it, not a choice. */
#lpen-l21-summary .lpen-cp__strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--cp-border);
  list-style: none;
}

#lpen-l21-summary .lpen-cp__stripitem {
  margin: 0;
  padding: 0;
  list-style: none;
}

#lpen-l21-summary .lpen-cp__chip {
  display: block;
  width: 116px;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 7px;
  overflow: hidden;
  background: var(--cp-navy-900);
  cursor: pointer;
  opacity: .72;
  transition: opacity .18s ease;
  -webkit-appearance: none;
  appearance: none;
}

#lpen-l21-summary .lpen-cp__chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#lpen-l21-summary .lpen-cp__chip:hover {
  opacity: 1;
}

#lpen-l21-summary .lpen-cp__chip[aria-current="true"] {
  border-color: var(--cp-action);
  opacity: 1;
}

/* ---------------------------------------------------------- 8 the player */
#lpen-l21-summary .lpen-cp__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 9px;
  overflow: hidden;
  background: var(--cp-navy-900);
  box-shadow: var(--cp-elev);
}

#lpen-l21-summary .lpen-cp__frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ------------------------------------------------- 9 focus and motion */
#lpen-l21-summary .lpen-cp__poster:focus-visible,
#lpen-l21-summary .lpen-cp__chip:focus-visible {
  outline: 3px solid var(--cp-focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  #lpen-l21-summary .lpen-cp__img,
  #lpen-l21-summary .lpen-cp__dur,
  #lpen-l21-summary .lpen-cp__play,
  #lpen-l21-summary .lpen-cp__chip {
    transition: none;
  }

  #lpen-l21-summary .lpen-cp__poster:hover .lpen-cp__play {
    transform: none;
  }
}

@media (max-width: 600px) {
  #lpen-l21-summary .lpen-cp {
    padding: 12px;
    border-radius: 12px;
  }

  #lpen-l21-summary .lpen-cp__play {
    width: 52px;
    height: 52px;
    margin: -26px 0 0 -26px;
  }

  #lpen-l21-summary .lpen-cp__chip {
    width: 96px;
  }
}
