/* The course title page.
 *
 * Colours come from static/design-system/tokens.css (--color-*). Bootstrap's --bs-*
 * custom properties are NOT this app's palette: a rule written as
 * var(--bs-primary, #0d6efd) does not fail loudly, it silently falls back, and the
 * component comes up Bootstrap blue inside a forest-green app.
 *
 * Spec: docs/specs/white-label-and-course-landing-page.md §4
 *
 * Design QA r3: this file read --color-text, --color-text-muted and --color-primary-dark,
 * none of which tokens.css defines — so every one fell back to its literal, and those
 * literals were the RETIRED forest palette (#14210f, #5c6b57, #2f5d3a). That is where the
 * green-black title and the sage chapter labels came from. Real tokens only now.
 */

.course-landing {
  --hero-min-h: 78vh;
  --landing-max-w: 1180px;
  color: var(--color-fg);
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */

.course-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: var(--hero-min-h);
  padding: clamp(2rem, 6vw, 5rem) clamp(1rem, 5vw, 4rem) clamp(2rem, 5vw, 4rem);
  overflow: hidden;
  /* Painted by the SECTION, so a blocked or broken hero image degrades to a designed
   * surface rather than a hole. img-src is 'self' data: blob:, so a creator-supplied
   * external image URL is refused by CSP in the browser — this is what they see. */
  background:
    radial-gradient(120% 100% at 15% 100%,
      var(--color-surface-sunken) 0%,
      var(--color-surface) 70%);
  color: var(--color-fg);
}

/* No art at all. This was a 700px mauve-to-pink wash with the title pinned bottom-left
 * and the top and right halves empty — it read as an image that failed to load. Now it
 * is the dark band the art hero's scrim produces anyway (so the two states are one
 * design), sized to its content, with a typeset cover on the right at >=992px. */
.course-hero--noart {
  --hero-min-h: 0;
  align-items: center;
  padding-block: clamp(3rem, 7vw, 6rem);
  background:
    radial-gradient(70% 90% at 85% 10%, color-mix(in srgb, var(--color-primary) 55%, transparent) 0%, transparent 70%),
    radial-gradient(60% 70% at 0% 100%, rgba(217, 119, 6, .07) 0%, transparent 65%),
    var(--color-bg-hero);
  color: #fff;
}
.course-hero--noart .course-hero__inner,
.course-hero--noart .course-hero__inner a { color: #fff; }

.course-hero__cover { display: none; }
@media (min-width: 992px) {
  .course-hero--noart .course-hero__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18rem;
    gap: clamp(2rem, 5vw, 5rem);
    align-items: center;
  }
  .course-hero__cover {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    aspect-ratio: 3 / 4;
    padding: 1.75rem;
    border-radius: 1rem;
    background:
      linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    color: #fff;
  }
  .course-hero__cover-org {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    opacity: .85;
  }
  /* r12b: the cover is the creator's MARK, not a second copy of the H1 beside it. */
  .course-hero__cover-mark {
    align-self: center;
    font-size: 6rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.04em;
    opacity: .9;
  }
}

.course-hero__art {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Contrast is guaranteed by the scrim, never by the picture. An AI-generated hero
 * can be any brightness; without this the title is unreadable on roughly half. */
.course-hero__scrim {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to top, rgba(0, 0, 0, .88) 0%, rgba(0, 0, 0, .55) 45%, rgba(0, 0, 0, .12) 100%),
    linear-gradient(to right, rgba(0, 0, 0, .72) 0%, rgba(0, 0, 0, .18) 55%, transparent 100%);
}

/* Any hero carrying art is on a dark scrim, so its own text is light regardless of
 * the app theme. Scoped to :has() with a fallback below for engines without it. */
.course-hero:not(.course-hero--noart) .course-hero__inner,
.course-hero:not(.course-hero--noart) .course-hero__inner a {
  color: #fff;
}

.course-hero__inner {
  position: relative;
  width: 100%;
  max-width: var(--landing-max-w);
  margin-inline: auto;
}

.course-hero__eyebrow {
  margin: 0 0 .5rem;
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Full white at 600: on the old gradient this was mauve-grey on mauve, under 4.5:1. */
.course-hero__eyebrow a { text-decoration: none; opacity: .9; }
.course-hero__eyebrow a:hover { text-decoration: underline; }

.course-hero__title {
  margin: 0 0 .75rem;
  max-width: 18ch;
  font-size: clamp(2.25rem, 6vw, 4.25rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -.02em;
  text-wrap: balance;
}

.course-hero__tagline {
  margin: 0 0 1rem;
  max-width: 46ch;
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
  line-height: 1.4;
  opacity: .95;
}

.course-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  font-size: .9375rem;
  opacity: .9;
}

.course-hero__meta li + li::before {
  content: "·";
  margin-inline-end: 1.25rem;
  opacity: .6;
}

.course-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

/* What the price buys, under the buttons (inherits the hero's ink). */
.course-hero__terms {
  margin: -.5rem 0 1.25rem;
  font-size: .875rem;
  opacity: .88;
}

/* The buyer's coupon field. Closed it is one quiet link under the price; open it is a
 * light card, so the form's own ink, the error note and the focus ring read on a dark
 * or photographic hero alike. */
.course-coupon { margin: -.5rem 0 1.25rem; }
.course-coupon__toggle,
.course-coupon__remove {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: .9375rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.course-coupon__toggle:focus-visible,
.course-coupon__remove:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}
.course-coupon__form {
  max-width: 26rem;
  padding: 1rem;
  border-radius: 12px;
  background: var(--color-surface);
  color: var(--color-fg);
}
.course-hero .course-coupon__form .form-label { color: var(--color-fg); font-weight: 500; }
.course-coupon__row { display: flex; gap: .5rem; }
.course-coupon__row .form-control { min-height: 44px; flex: 1 1 auto; min-width: 0; text-transform: uppercase; }
.course-coupon__row .btn { min-height: 44px; flex: 0 0 auto; font-weight: 600; }
.course-coupon__applied {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .75rem;
  margin: 0;
  font-weight: 600;
}

.course-hero__synopsis {
  max-width: 56ch;
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  opacity: .88;
  /* Three lines on the hero; the rest of the story is the page below it. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Calls to action ──────────────────────────────────────────────────────── */

.course-cta {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .8125rem 1.75rem;
  border: 2px solid transparent;
  border-radius: 999px;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, background-color .12s ease, opacity .12s ease;
}

.course-cta:hover { transform: translateY(-1px); }
.course-cta:active { transform: translateY(0); }

/* Every control on this page is keyboard-reachable and must SHOW that it is —
 * the hero sits on a photograph, where the UA default ring often disappears. */
.course-cta:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

.course-cta--primary {
  background: var(--color-primary);
  color: #fff;
}
/* On a dark band (the hero, the closing row) the buying button is the LIGHT fill with an
 * ink label. Brand brown on --color-bg-hero was 2.46:1 at its edge — under the 3:1 UI
 * floor — so the white-outlined ghost beside it read as the stronger control. */
.course-hero .course-cta--primary,
.course-closing .course-cta--primary {
  background: var(--color-surface);
  color: var(--color-fg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
}
.course-hero .course-cta--primary:hover,
.course-closing .course-cta--primary:hover { background: var(--color-surface-raised); }

/* Bootstrap's muted utility is !important grey — on a dark hero it is unreadable. */
.course-hero .text-body-secondary { color: rgba(255, 255, 255, .82) !important; }

.course-cta--primary:hover { background: var(--color-primary-hover); }

/* A disabled CTA is an in-flight request, never a permanent state — the page has no
 * CTA that ships disabled, because a control that never works is one people keep
 * pressing. */
.course-cta[disabled] { opacity: .6; cursor: progress; transform: none; }

.course-cta--ghost {
  background: rgba(255, 255, 255, .14);
  border-color: currentColor;
  color: inherit;
  backdrop-filter: blur(6px);
}

.course-cta--ghost:hover { background: rgba(255, 255, 255, .26); }

/* ── Sections ─────────────────────────────────────────────────────────────── */

/* ONE left edge for hero and body. The section used max-width INCLUDING its padding
 * while the hero inner used it EXCLUDING the hero's padding, so the body started 64px
 * right of the title at 1440 and stopped short on the right. */
.course-section {
  width: min(var(--landing-max-w), calc(100% - 2 * clamp(1rem, 5vw, 4rem)));
  margin-inline: auto;
  padding: clamp(2rem, 4vw, 3.25rem) 0;
}

.course-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem 1rem;
  margin-bottom: 1.25rem;
}
.course-section__head .course-section__heading { margin: 0; }
.course-section__sub { margin: 0; color: var(--color-muted-fg); font-weight: 600; }

/* r12b: the hero's editorial voice carried into the body (was 20px/700 under a 64px/800 title,
 * so the page read as a flat list after the first screen). */
.course-section__heading {
  margin: 0 0 1.25rem;
  font-size: var(--font-size-2xl, 1.5rem);
  font-weight: 800;
  letter-spacing: var(--tracking-tight, -.02em);
}
.course-section__note { margin: -.5rem 0 1.25rem; color: var(--color-muted-fg); }

.course-empty {
  margin: 0;
  padding: 1.5rem;
  border: 1px dashed var(--color-border);
  border-radius: .75rem;
  color: var(--color-muted-fg);
  text-align: center;
}

.course-outcomes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: .625rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.course-outcomes li { display: flex; gap: .625rem; align-items: flex-start; }
.course-outcomes i { color: var(--color-success); flex: none; margin-top: .15rem; }

/* ── Curriculum rails ─────────────────────────────────────────────────────── */

.course-rail + .course-rail { margin-top: 2rem; }

.course-rail__title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem .625rem;
  margin: 0 0 .75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-fg);
}
/* r12b: title and count wrap TOGETHER, indented past the number, so a long chapter title
 * pushes its count under the title rather than under the number. */
.course-rail__title { flex-wrap: nowrap; }
.course-rail__label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem .625rem;
  min-width: 0;
}
.course-rail__num {
  flex: none;
  min-width: 1.5rem;
  color: var(--color-muted-fg);
  font-variant-numeric: tabular-nums;
}
/* The count sits BESIDE its chapter title, not pinned to the container's far edge, where
 * it floated ~300px from the last card of a 3-lesson chapter at 1440. */
.course-rail__count {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--color-muted-fg);
  white-space: nowrap;
}

/* The lesson cards WRAP. A sideways rail hid a third (768) to two thirds (390) of each
 * chapter with no cue; a curriculum is evidence and all of it belongs on the page. */
/* Columns are FIXED per width so a chapter's cards always span the container: auto-fill
 * left an empty fourth track at 1440 (the grid stopped at x~1010 of 1310) and 2-up at 768
 * orphaned the third card of every 3-lesson chapter. */
.course-rail__track {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 36rem) {
  .course-rail__track { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 48rem) {
  .course-rail__track { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Testimonials keep a sideways rail — but with a visible peek of the next card. */
.course-rail__track--quotes {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  padding-bottom: .75rem;
}
.course-rail__track--quotes > * { scroll-snap-align: start; }

.lesson-card {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: .875rem;
  background: var(--color-surface);
}

.lesson-card__icon { font-size: 1.25rem; line-height: 1; color: var(--color-muted-fg); }

/* Every title in full ink — locked lessons' titles are the best sales copy on the page. */
.lesson-card__title {
  margin: 0;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-fg);
}

.lesson-card__badge { margin-top: auto; align-self: flex-start; }
.lesson-card__type {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--color-muted-fg);
}

.lesson-card__badge--locked {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--color-muted-fg);
}

/* Below 576px a card is a compact row: glyph, title, status — so a 12-lesson course is
 * a scannable list rather than twelve full-width tiles. */
@media (max-width: 35.98rem) {
  .lesson-card {
    display: grid;
    grid-template-columns: 1.5rem minmax(0, 1fr);
    gap: .25rem .75rem;
    padding: .875rem 1rem;
  }
  .lesson-card__icon { grid-row: span 2; margin-top: .125rem; }
  /* A grid item stretches along the row axis by default: the Free Preview pill became a
   * full-width green bar. Pills size to their label. */
  .lesson-card__badge { justify-self: start; }
}

/* ── Quotes ───────────────────────────────────────────────────────────────── */

.quote-card {
  flex: 0 0 20rem;
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: .875rem;
  background: var(--color-surface);
}

.quote-card__stars { margin: 0 0 .5rem; color: var(--color-accent); }
.quote-card__quote { margin: 0 0 .75rem; font-style: italic; }
.quote-card__author { margin: 0; font-weight: 600; font-size: .9375rem; }

/* ── Creator ──────────────────────────────────────────────────────────────── */

.course-instructor { display: flex; gap: 1.25rem; align-items: flex-start; }
.course-instructor__avatar { border-radius: 50%; object-fit: cover; flex: none; }
.course-instructor__name { margin: 0; font-weight: 700; font-size: 1.0625rem; }
.course-instructor__headline { margin: 0 0 .5rem; color: var(--color-muted-fg); }
/* Inline, not inline-flex: as a flex row the wrapped text was one item and the arrow sat
 * stranded at the right edge at 390. The &nbsp; in the template keeps the arrow on the
 * last word; padding keeps the 44px target. */
.course-instructor__more {
  display: inline-block;
  padding-block: .625rem;
  font-weight: 600;
  color: var(--color-primary-hover);
}

/* ── Closing row ──────────────────────────────────────────────────────────── */

.course-closing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-block: 1rem clamp(2rem, 5vw, 4rem);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-radius: 1rem;
  background: var(--color-bg-hero);
  color: #fff;
}
.course-closing__title { margin: 0 0 .25rem; font-size: 1.375rem; font-weight: 800; letter-spacing: -.01em; }
.course-closing__meta { margin: 0; opacity: .82; }
@media (max-width: 36rem) {
  .course-closing .course-cta { width: 100%; justify-content: center; }
}

/* ── Guarantee ────────────────────────────────────────────────────────────── */

.course-guarantee {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  max-width: var(--landing-max-w);
}

.course-guarantee > i { font-size: 1.75rem; color: var(--color-accent); flex: none; }
.course-guarantee__title { margin: 0 0 .25rem; font-weight: 700; }
.course-guarantee__text { margin: 0; color: var(--color-muted-fg); }

/* ── Sticky bar ───────────────────────────────────────────────────────────── */

.course-sticky {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 1030;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: .75rem clamp(1rem, 5vw, 4rem);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .12);
}

/* `hidden` must actually hide it: the flex display above would otherwise win, which
 * is the single most common way a [hidden] element stays on screen. */
.course-sticky[hidden] { display: none; }

.course-sticky__title {
  margin: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 36rem) {
  .course-sticky__title { display: none; }
  .course-sticky .course-cta { width: 100%; justify-content: center; }
  .course-hero__actions .course-cta { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .course-cta { transition: none; }
  .course-cta:hover { transform: none; }
}
