/* Mobile-first base — design for small screens first, scale up. See structure.md §3d */

:root {
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --border: #dde3ec;
  --text: #14213d;
  --text-dim: #5b6577;
  --brand: #2f6fdd;
  --brand-dark: #1a56b8;
  --navy: #16305c;
  --navy-dark: #0e2043;
  --good: #2e9e6b;
  --bad: #d64545;
  --warn: #c98a1f;
  --radius: 14px;
  --maxw: 640px;
  --maxw-wide: 1120px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout shell ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.brand span { color: var(--brand); }

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 16px 48px;
  min-height: 70vh;
}
/* Pages that opt into a wider desktop layout (landing, course detail,
   lesson player) — other pages (quiz, certificate, etc.) stay narrow. */
@media (min-width: 900px) {
  .app.wide { max-width: var(--maxw-wide); }
}

.footer {
  max-width: var(--maxw); margin: 0 auto;
  padding: 20px 16px 40px;
  color: var(--text-dim); font-size: 0.8rem;
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ---- Buttons: large tap targets, mobile-first (§3d) ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--navy);
  color: #ffffff;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-sm { min-height: 40px; padding: 8px 16px; font-size: 0.9rem; width: auto; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { width: auto; flex: 1 1 auto; }

/* ---- Cards / sections ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.hero {
  padding: 28px 4px 8px;
}
.hero h1 { font-size: 1.6rem; margin: 0 0 8px; }
.hero p { color: var(--text-dim); margin: 0 0 18px; }

.pill {
  display: inline-block;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  margin-right: 6px;
  margin-bottom: 6px;
}

/* ---- Badge pill (light-blue tag with icon, catalogue/detail meta rows) ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.78rem; font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  color: var(--navy);
}
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Course catalogue card ---- */
.eyebrow {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 6px;
}
/* Full-bleed band — breaks out of #app's own max-width/padding to span the
   whole viewport, like a real top-of-page hero, while its inner content
   still lines up with the rest of the page. Navy, matching the topbar/cert
   banner elsewhere — so text needs light colors, not the page defaults. */
.catalogue-hero {
  background: var(--navy);
  width: 100vw;
  position: relative;
  left: 50%;
  margin-left: -50vw;
  margin-top: -16px;
  margin-bottom: 24px;
  padding: 32px 16px 40px;
}
.catalogue-hero-inner { max-width: var(--maxw-wide); margin: 0 auto; }
.catalogue-hero .eyebrow { color: #9cc0ff; }
.catalogue-hero h1 { font-size: 1.55rem; margin: 0 0 10px; color: #fff; }
.catalogue-hero p { color: rgba(255,255,255,0.82); margin: 0; max-width: 620px; }

@media (min-width: 900px) {
  .catalogue-hero { padding: 48px 24px 56px; }
  .catalogue-hero h1 { font-size: 2.4rem; }
  .catalogue-hero p { font-size: 1.05rem; }
}

.catalogue-grid { display: block; }
@media (min-width: 900px) {
  .catalogue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    /* stretch (not start): every card in a row matches the tallest card's
       height, so cards with less content (e.g. a "coming soon" card with
       no badges/footer) don't end up visibly shorter than the others. */
    align-items: stretch;
  }
  .catalogue-grid .course-card { margin-bottom: 0; }
}

.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}
.course-card-img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.course-card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.course-card-body h3 { margin: 10px 0 6px; font-size: 1.15rem; }
.course-card-body p { margin: 0 0 12px; color: var(--text-dim); font-size: 0.92rem; }
.course-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 12px; margin-top: auto;
  font-size: 0.88rem;
}
.course-card-footer .meta { color: var(--text-dim); }
.course-card-footer .view-link { color: var(--navy); font-weight: 700; }

.faq-section { margin-top: 32px; max-width: 760px; }
.faq-section h2, .faq-section h3 { font-size: 1.3rem; margin: 0 0 14px; }
.faq-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px 18px; margin-bottom: 10px;
}
.faq-item summary {
  cursor: pointer; font-weight: 600; padding: 14px 0;
  list-style: none; font-size: 0.88rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; float: right; color: var(--text-dim); font-weight: 400; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { color: var(--text-dim); margin: 0 0 14px; font-size: 0.85rem; }

/* ---- Course detail page ---- */
.detail-hero {
  background: var(--navy);
  color: #ffffff;
  border-radius: var(--radius);
  padding: 20px 18px 22px;
  margin-bottom: 16px;
}
.detail-hero .back-link {
  color: rgba(255,255,255,0.75); font-size: 0.85rem;
  display: inline-block; margin-bottom: 14px;
}
.detail-hero h1 { margin: 0 0 10px; font-size: 1.5rem; }
.detail-hero p { color: rgba(255,255,255,0.82); margin: 0 0 16px; }
.detail-meta-row { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.82rem; color: rgba(255,255,255,0.85); }

.detail-grid { display: block; }
@media (min-width: 900px) {
  .detail-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; align-items: start; }
}
.detail-meta-row span { display: inline-flex; align-items: center; gap: 5px; }

.price-card { padding: 0; overflow: hidden; }
.price-card .hero-img { margin-bottom: 0; border-radius: 0; }
.price-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 6px;
}
.price-row .price-big { font-size: 1.3rem; font-weight: 700; }
.price-row .price-sub { display: block; font-size: 0.78rem; color: var(--text-dim); font-weight: 400; }
.price-card .fine-print { padding: 0 18px 16px; margin: 0; font-size: 0.8rem; color: var(--text-dim); }
.price-card .btn { width: auto; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 0; font-size: 0.92rem;
}
.checklist .ok-icon { color: var(--good); flex-shrink: 0; }

.loose-heading { font-size: 1.05rem; margin: 20px 4px 10px; }
.outcome-list { display: flex; flex-direction: column; gap: 8px; }
.outcome-card {
  display: flex; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 0.88rem; line-height: 1.35;
}
.outcome-card .ok-icon { color: var(--navy); flex-shrink: 0; }

.module-card { border-top: 1px solid var(--border); padding: 16px 0; }
.module-card:first-of-type { border-top: none; padding-top: 4px; }
/* No number-circle badge — it left an empty gutter under itself since the
   rows below were indented to align with the title, not the badge. Flush
   left label + rows instead, matching the reference's alignment. */
.module-head { margin-bottom: 10px; }
.module-eyebrow {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 2px;
}
.module-head h4 { margin: 0 0 4px; font-size: 1rem; }
.module-head p { margin: 0; font-size: 0.85rem; color: var(--text-dim); }
.module-rows { display: flex; flex-direction: column; gap: 8px; padding-left: 0; }
.module-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface-2); border-radius: 8px;
  padding: 10px 12px; font-size: 0.86rem;
}
.module-row .row-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.module-row .row-meta { color: var(--text-dim); font-size: 0.8rem; flex-shrink: 0; }

.built-card { background: var(--surface-2); border: none; }

.hr-divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ---- Lesson-player shell ---- */
.lesson-topbar {
  background: var(--navy); color: #fff;
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  font-size: 0.85rem;
}
.lesson-topbar .lt-title { font-weight: 700; flex: 1; margin: 0 10px; text-align: center; }
.lesson-topbar a { color: rgba(255,255,255,0.85); }

/* Compact, subtle-but-visible progress indicator inline in the top-right —
   not a big attention-grabbing full-width strip. */
.lt-progress-group { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lt-progress-track {
  width: 64px; height: 5px; border-radius: 999px;
  background: rgba(255,255,255,0.25); overflow: hidden;
  display: inline-block;
}
.lt-progress-fill { display: block; height: 100%; background: #fff; transition: width .3s ease; }
.lt-pct { color: rgba(255,255,255,0.85); white-space: nowrap; }

/* Outer pad unifying both columns — a new wrapper, left column's own
   internal styling untouched. Only visible as a card at desktop; on mobile
   the two pieces just stack with no extra nesting. */
.lesson-outer-card { }
@media (min-width: 900px) {
  .lesson-outer-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
  }
}

.lesson-grid { display: block; }
@media (min-width: 900px) {
  /* minmax(0, Nfr), not just Nfr — otherwise each track still respects its
     content's min-content width and the grid blows out past the container
     (the slide deck's flex children have a wide natural size).
     7:3 instead of 8:2 — the narrower ratio made the sidebar text cramped. */
  .lesson-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 3fr); gap: 20px; align-items: start; }
}

/* Right column: full card look on mobile (stacks below, needs its own
   frame); on desktop it's nested in .lesson-outer-card, so simplify to a
   divider line instead of a second nested box. */
.lesson-right {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-top: 18px;
}
.lesson-right h3 { margin-top: 0; }
@media (min-width: 900px) {
  .lesson-right {
    background: transparent; border: none; border-left: 1px solid var(--border);
    border-radius: 0; padding: 0 0 0 24px; margin-top: 0;
  }
}

/* JS caps this to the left column's height on desktop (setupSidebarHeightMatch) */
#courseContentCard.height-matched {
  display: flex; flex-direction: column; overflow: hidden;
}
#courseContentCard.height-matched > h3 { flex-shrink: 0; }
#courseContentCard.height-matched #courseContentSidebar {
  overflow-y: auto; flex: 1; min-height: 0;
}

.sidebar-module .module-row { cursor: pointer; }
.sidebar-module .module-row.current { background: color-mix(in srgb, var(--navy) 12%, var(--surface-2)); border: 1px solid var(--navy); }
.sidebar-module .module-row.done .row-label::before { content: "✓ "; color: var(--good); }

.module-row.locked { color: var(--text-dim); opacity: 0.6; cursor: not-allowed; }
.locked-hint {
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border: 1px solid var(--warn);
  border-radius: 10px; padding: 10px 14px;
  font-size: 0.85rem; margin-top: 10px;
}

/* Certificate — standalone navy card below the Course Content/Outline list,
   not counted as a section. Width-matched to that column, not full-page. */
.cert-teaser {
  position: relative;
  background: var(--navy); color: #fff;
  border-radius: var(--radius);
  padding: 18px; margin-top: 16px;
}
.cert-teaser-icon { font-size: 1.3rem; margin-bottom: 4px; }
.cert-teaser h4 { margin: 6px 0 6px; font-size: 1.05rem; }
.cert-teaser p { margin: 0; color: rgba(255,255,255,0.82); font-size: 0.88rem; }
.cert-teaser a.btn { margin-top: 12px; background: #ffffff; color: var(--navy); }

/* Lock badge — sits like a tab extending off the card's top-right corner
   while the certificate isn't unlocked yet. */
.cert-teaser-lock-badge {
  position: absolute; top: -12px; right: 16px;
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--surface); border: 2px solid var(--navy);
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
}

/* ---- Province confirm modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 33, 61, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: modalFadeIn 0.15s ease-out;
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: var(--maxw);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
}
.modal-card .btn-row .btn { flex: 1 1 0; }
.modal-card .btn-secondary { background: var(--surface-2); }

@media (min-width: 700px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: var(--radius); max-width: 420px; }
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
td, th { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }

/* ---- What you'll get grid ---- */
.get-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.get-item { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.get-item b { display: block; font-size: 0.85rem; color: var(--brand); margin-bottom: 2px; }
.get-item span { font-size: 0.9rem; color: var(--text-dim); }

/* ---- Progress ---- */
.progress-bar {
  height: 8px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; margin: 10px 0 18px;
}
.progress-fill { height: 100%; background: var(--brand); transition: width .3s ease; }

/* ---- Slideshow deck (HTML5-slideshow-style lesson viewer, §3d mobile-first) ---- */
.slide-deck-wrap { position: relative; }
.expand-toggle-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 36px; height: 36px; border-radius: 999px;
  background: rgba(0,0,0,0.45); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.expand-toggle-btn.active { background: var(--brand); }

/* Slide focus mode: the expand button turns the deck into a true
   fullscreen viewer — site header/footer, the lesson topbar, the
   resource card, ads, and the sidebar all disappear so only the slide
   content remains. The nav row (prev/dots/next) moves inside the deck
   wrap and floats as a low-profile pill over the bottom of the slide,
   since the normal below-deck row has nowhere to sit once everything
   else is gone. */
body.slide-focus-mode { overflow: hidden; }
body.slide-focus-mode .topbar,
body.slide-focus-mode .footer,
body.slide-focus-mode .lesson-topbar,
body.slide-focus-mode .lesson-right,
body.slide-focus-mode .resource-card,
body.slide-focus-mode .ad-slot {
  display: none !important;
}
body.slide-focus-mode .lesson-outer-card { padding: 0; border: none; background: none; }
body.slide-focus-mode .slide-deck-wrap {
  position: fixed; inset: 0; z-index: 500;
  background: var(--surface);
}
body.slide-focus-mode .slide-deck {
  height: 100%; margin-bottom: 0; border-radius: 0; border: none;
}
body.slide-focus-mode .slide-nav-row {
  position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 4px 12px;
  z-index: 2;
}
body.slide-focus-mode .slide-nav-btn {
  width: 34px; height: 34px; font-size: 1.05rem;
  background: transparent; border: none; color: #fff;
}
body.slide-focus-mode .slide-nav-btn.waiting { color: rgba(255,255,255,0.75); }
body.slide-focus-mode .slide-nav-btn.quiz-btn { background: var(--brand); border-radius: 999px; }
body.slide-focus-mode .dot { background: rgba(255,255,255,0.35); }
body.slide-focus-mode .dot.active { background: #fff; }

.slide-deck {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.slide-deck::-webkit-scrollbar { display: none; }

.slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  min-height: 320px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* Lets descendants (e.g. .content-bullets-columns) size themselves off
     this slide's actual rendered width instead of the page viewport —
     the slide can be much narrower than the viewport (two-column desktop
     layout, focus mode, mobile) so a viewport media query picks the wrong
     column count and text overflows its wrapping. */
  container-type: inline-size;
}
.slide h1 { font-size: 1.4rem; margin: 4px 0 10px; }
.slide h3 { font-size: 1.1rem; margin: 4px 0 10px; }
.slide p { color: var(--text); font-size: 0.98rem; margin: 0; }

.slide-title { text-align: center; align-items: center; background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%); }
.slide-title p { color: var(--text-dim); }

.slide-pictogram { align-items: center; text-align: center; }
.pictogram-photo { width: 110px; height: 110px; object-fit: contain; margin-bottom: 8px; }
.slide-pictogram h3 { font-size: 1.2rem; }
.slide-example { margin-top: 10px !important; font-size: 0.85rem !important; color: var(--brand) !important; }

.slide-callout { background: rgba(245,181,68,0.07); }
.slide-callout .callout-tag { color: var(--warn); }
.slide-example-card { background: rgba(79,179,255,0.05); }
.slide-example-card .callout-tag { color: var(--brand); }
.callout-tag { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; color: var(--text-dim); }

.slide-recap ul { padding-left: 20px; margin: 4px 0 0; }
.slide-recap li { margin-bottom: 8px; font-size: 0.95rem; }

/* Fully designed-elsewhere slide (admin-tool upload) — no padding so the
   image can fill the row edge to edge; contain (not cover) so nothing
   baked into the image gets cropped. */
.slide-image { padding: 0; }
.slide-full-img { width: 100%; height: 100%; object-fit: contain; }

/* Content slides with a bullet list (plain enumeration or labeled groups).
   Capped height + internal scroll for the same reason as .slide-flipgrid —
   a long list would otherwise stretch every sibling slide in the section. */
.slide-content-bulleted { justify-content: flex-start; max-height: 620px; overflow-y: auto; }
.content-bullets { padding-left: 20px; margin: 10px 0 0; }
.content-bullets li { margin-bottom: 8px; font-size: 0.95rem; }
/* Plain enumeration lists (e.g. the 19 physical / 12 health hazard classes)
   flow into columns instead of one long vertical run. Breakpoints are
   container queries keyed to the slide's own width, not the page viewport —
   see the container-type note on .slide above. */
.content-bullets-columns {
  columns: 1; column-gap: 24px; margin-top: 10px;
}
.content-bullets-columns li { break-inside: avoid; font-size: 0.9rem; margin-bottom: 6px; }
@container (min-width: 280px) {
  .content-bullets-columns { columns: 2; }
}
@container (min-width: 560px) {
  .content-bullets-columns { columns: 3; }
}

.triad { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.triad-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 0.88rem;
}

/* Flip-card review grid — gates the deck's Next button on "every card
   flipped once" instead of the dwell timer (see setupFlipGrids() in
   learn.js). Classic 3D-flip: two faces back-to-back, rotated on click. */
/* Capped height, not just min-height: the deck is a flex row, and flex
   items stretch to match the tallest sibling by default — without a cap
   here, this slide's 10-card grid would drag every OTHER slide in the
   section up to match its height too. Scrolls internally instead. */
.slide-flipgrid { justify-content: flex-start; max-height: 460px; overflow-y: auto; }
.flipgrid-instructions { color: var(--text-dim); font-size: 0.9rem; margin: 0 0 14px; }
.flip-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
@media (min-width: 480px) {
  .flip-grid { grid-template-columns: repeat(3, 1fr); }
}
.flip-card {
  aspect-ratio: 1 / 1;
  perspective: 800px;
  cursor: pointer;
}
.flip-card-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-card-front, .flip-card-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: 10px; border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px; text-align: center;
}
.flip-card-front { background: var(--surface-2); }
.flip-card-front img { width: 56%; height: 56%; object-fit: contain; margin-bottom: 6px; }
.flip-card-label { font-size: 0.72rem; font-weight: 700; }
.flip-card-back {
  background: var(--navy); color: #fff;
  transform: rotateY(180deg);
}
.flip-card-back p { margin: 0; font-size: 0.72rem; line-height: 1.35; color: #fff; }
.flipgrid-progress {
  text-align: center; margin: 14px 0 0;
  font-size: 0.82rem; color: var(--text-dim);
}

.hero-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 12px;
  background: var(--surface-2);
}
/* Inside the slide deck specifically: cap height so a wide container (e.g.
   focus mode) doesn't balloon the image to match 16:9 at full width. */
.slide .hero-img { max-height: 280px; }

/* Side-image layout: a smaller supporting image next to the text instead
   of a full-width banner above it. Deliberately no forced aspect-ratio —
   images may be landscape, portrait, or square; each keeps its own shape
   and just gets capped to fit the media column. Stacks on mobile, sits
   side by side once there's enough width to make that worthwhile. */
.slide.slide-side {
  flex-direction: column; align-items: stretch;
  gap: 14px; justify-content: flex-start;
}
/* A side-image slide with a long bullet list can get much taller than its
   siblings — cap it and scroll internally instead of stretching every
   other slide in the deck to match (flex row default align-items: stretch). */
.slide-side-bulleted { max-height: 700px; overflow-y: auto; }
.slide-side-media {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.slide-side-media .side-img {
  max-width: 100%; max-height: 220px;
  width: auto; height: auto;
  object-fit: contain;
  border-radius: 10px;
}
.slide-side-text { flex: 1; min-width: 0; }
.slide-side-text h3 { margin-top: 0; }
@media (min-width: 600px) {
  .slide.slide-side { flex-direction: row; align-items: center; gap: 24px; }
  .slide-side-media { max-width: 40%; }
  .slide-side-media .side-img { max-height: 240px; }
  /* Image on the right instead of the left — text keeps reading order,
     only the visual position flips (mobile stays stacked either way). */
  .slide.slide-side.slide-side-right { flex-direction: row-reverse; }
}

/* Wide banner image (e.g. 16:3) below the text, full width — for supporting
   images too wide/short to sit naturally beside a text column. */
.slide-bottom-image {
  flex-direction: column; align-items: stretch;
  gap: 10px; justify-content: flex-start;
}
.bottom-img-wrap {
  width: 100%; aspect-ratio: 16 / 3;
  background: var(--surface-2); border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  margin-top: 4px;
}
.bottom-img-wrap img { width: 100%; height: 100%; object-fit: contain; }

/* Dual side-image layout: two stacked image+paragraph rows in one slide.
   Capped height + internal scroll for the same reason as .slide-flipgrid —
   otherwise this taller slide would stretch every sibling slide in the
   section to match it (flex row default align-items: stretch). */
.slide-dualside { justify-content: flex-start; max-height: 480px; overflow-y: auto; }
.dualside-blocks { display: flex; flex-direction: column; gap: 18px; }
.dualside-block { display: flex; flex-direction: column; gap: 10px; }
.dualside-block .slide-side-media .side-img { max-height: 130px; }
@media (min-width: 600px) {
  .dualside-block { flex-direction: row; align-items: center; gap: 18px; }
  .dualside-block .slide-side-media { max-width: 38%; flex-shrink: 0; }
}

.slide-nav-row {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 16px;
}

.resource-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
}
.resource-card h4 { margin: 2px 0 8px; font-size: 1.05rem; }
.resource-highlight { color: var(--text-dim); font-size: 0.9rem; margin: 0 0 14px; }
.resource-card .btn-row .btn { width: auto; flex: 1 1 auto; }
.slide-nav-btn {
  width: 44px; height: 44px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-size: 1.3rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.slide-dots { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; max-width: 180px; }
.dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--border); cursor: pointer; flex-shrink: 0;
}
.dot.active { background: var(--brand); width: 20px; border-radius: 999px; }
.dot.ahead-locked { cursor: not-allowed; opacity: 0.5; }

.slide-nav-btn.waiting {
  font-size: 0.85rem; font-weight: 700;
  color: var(--text-dim); cursor: not-allowed;
  background: var(--surface);
}
.slide-nav-btn:disabled { cursor: not-allowed; }
.slide-nav-btn.quiz-btn { background: var(--brand); border-color: var(--brand); color: #fff; }

.section-list { list-style: none; padding: 0; margin: 0; }
.section-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.section-list li:last-child { border-bottom: none; }
.chip-done { color: var(--good); font-weight: 700; }
.chip-pending { color: var(--text-dim); }

/* ---- Lesson screen ---- */
.lesson-title { font-size: 1.15rem; margin: 4px 0 10px; }
.lesson-body { color: var(--text); font-size: 1rem; }
.listen-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 44px;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 14px;
}
.listen-btn.speaking { color: var(--brand); border-color: var(--brand); }

/* ---- Tap-to-flip cards (mobile: tap, not hover — §3d) ---- */
.flip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.flip-card {
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}
.flip-card.flipped { background: var(--navy); color: #ffffff; border-color: var(--navy); }

/* ---- Quiz ---- */
.quiz-progress { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 6px; }
.quiz-q { font-size: 1.05rem; margin: 6px 0 14px; }
.choice {
  display: block; width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 10px;
  min-height: 48px;
  font-size: 0.98rem;
  cursor: pointer;
}
.choice.correct { background: rgba(62,207,142,0.18); border-color: var(--good); }
.choice.incorrect { background: rgba(255,107,107,0.18); border-color: var(--bad); }
.choice.disabled { pointer-events: none; opacity: 0.9; }

.result-score { font-size: 2rem; font-weight: 700; text-align: center; margin: 10px 0; }
.result-pass { color: var(--good); }
.result-fail { color: var(--bad); }

/* ---- Ad slot placeholders ---- */
.ad-slot {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 22px 14px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 16px 0;
  background: var(--surface);
}
.ad-slot b { display: block; color: var(--warn); margin-bottom: 4px; }

/* ---- Certificate ---- */
.cert {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--brand-dark);
  border-radius: var(--radius);
  padding: 22px 18px;
}
.cert h2 { margin: 0 0 2px; font-size: 1.3rem; }
.cert .cert-name { font-size: 1.5rem; font-weight: 700; margin: 10px 0; color: var(--brand); }
.cert-meta { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 14px; }
.check-list { list-style: none; padding: 0; margin: 12px 0; }
.check-list li {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.check-list li:last-child { border-bottom: none; }
.check-ok { color: var(--good); flex-shrink: 0; }
.notice-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 16px;
}
.notice-card .notice-head {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 0.95rem; color: var(--text);
  margin-bottom: 6px;
}
.notice-card .notice-head svg { color: var(--navy); }
.notice-card p { font-size: 0.85rem; color: var(--text-dim); margin: 0; }
.notice-card a { font-size: 0.85rem; }

/* Large certificate icon accent — an actual illustrated graphic, not the
   thin-outline icon system (that read as too plain at this size). */
.cert-icon-large img { width: 64px; height: 64px; object-fit: contain; flex-shrink: 0; }

/* Course detail page: tabbed panel (Scope & Who It's For / Certification /
   What You'll Be Able To Do / FAQ) instead of everything stacked and
   scrolled through. .tab-panels is the ONE shared white container every
   tab's content sits inside — individual tabs shouldn't nest their own
   card-within-a-card. */
.tabs-nav {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border); margin-top: 20px;
}
.tabs-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 12px 14px; font-size: 0.88rem; font-weight: 600; color: var(--text-dim);
  white-space: nowrap; border-radius: 0; cursor: pointer;
}
.tab-btn:hover { background: var(--surface-2); color: var(--text); }
.tab-btn.active { color: var(--navy); border-bottom-color: var(--navy); }
.tab-panels {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-top: 18px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-section + .tab-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.tab-section h3 { margin-top: 0; }

/* One consistent text scale for everything inside the tab panels — every
   tab was previously using its own one-off font-size, which read as
   inconsistent switching between them. Scoped specifically to the Scope
   tab's sections and the Certification tab's statement column — NOT the
   wallet-card demo, which must keep its own compact, print-accurate
   typography exactly matching the real certificate page (a blanket
   ".tab-panels p" rule was bleeding into it and inflating its text). */
.tab-section p, .cert-tab-text p, .cert-tab-text li { font-size: 0.88rem; line-height: 1.45; }

.wallet-demo-badge {
  display: inline-block; background: var(--surface-2); color: var(--text-dim);
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 4px 10px; border-radius: 999px; margin-bottom: 8px;
}

/* Certification tab: statement on top, wallet-card demo below it — a
   simple stack, not a side-by-side column. The card keeps its real,
   print-accurate size/aspect-ratio (same as the actual certificate page),
   just centered under the text instead of squeezed into a side column. */
.cert-tab-text ul { margin: 12px 0; padding-left: 20px; }
.cert-tab-text li { margin-bottom: 8px; }
.cert-tab-closing { font-weight: 600; margin-top: 16px; }
.cert-tab-demo { margin-top: 20px; }
.cert-tab-demo .wallet-card-joined { margin-left: auto; margin-right: auto; }

/* FAQ tab restyled to match the outcome-list's row style (same border/
   radius/padding/font-size) instead of its own separate accordion-box
   look — still expands on click, just visually consistent with the other
   list-style tab. */
.tab-panels .faq-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 8px;
}
.tab-panels .faq-item summary { padding: 0; font-size: 0.88rem; }
.tab-panels .faq-item p { margin: 10px 0 0; }

/* Course Outline card (right column): on desktop, JS caps this to match
   the tab panel's height and scrolls the module list internally instead
   of stretching the row — same technique as the lesson page's sidebar
   (setupSidebarHeightMatch in learn.js). */
#courseOutlineCard.height-matched { display: flex; flex-direction: column; overflow: hidden; }
#courseOutlineCard.height-matched > h3,
#courseOutlineCard.height-matched > p { flex-shrink: 0; }
#courseOutlineCard.height-matched .outline-scroll { overflow-y: auto; flex: 1; min-height: 0; }

@media (max-width: 899px) {
  .detail-right { margin-top: 28px; }
}
@media (min-width: 900px) {
  .detail-grid { gap: 32px; }
}

/* ---- Province picker ---- */
.province-select {
  width: 100%; min-height: 48px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 1rem;
}
.province-info { margin-top: 10px; font-size: 0.88rem; color: var(--text-dim); }
.modal-field-row { display: flex; gap: 8px; }
.modal-field-row .province-select { min-width: 0; }

/* ---- Scale up past mobile (still simple; mobile stays primary) ---- */
@media (min-width: 700px) {
  .flip-grid { grid-template-columns: repeat(3, 1fr); }
  .get-grid { grid-template-columns: 1fr 1fr; }
}

/* Site is intentionally always light — no dark-mode override.
   This is a deliberate brand choice (matches the reference platform),
   not a fallback based on the visitor's OS/browser preference. */

/* ---- Lesson resources PDF export (window.print(), no library) ---- */
#printExportArea { display: none; }
@media print {
  body.printing-lesson > *:not(#printExportArea) { display: none !important; }
  body.printing-lesson #printExportArea { display: block !important; color: #000; }
}

/* ---- Certificate page: scope note + printable wallet card ---- */
.scope-note-card { margin-top: 20px; }
.scope-tips-grid {
  display: grid; grid-template-columns: 1fr; gap: 14px;
  margin-top: 16px;
}
.scope-tip b { display: block; font-size: 0.9rem; margin: 6px 0 3px; }
.scope-tip p { margin: 0; font-size: 0.82rem; color: var(--text-dim); }
.scope-tip-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-2); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
}
@media (min-width: 700px) {
  .scope-tips-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Printable wallet card — front and back, each sized to true ID-1
   credit/bank-card proportions (3.375in x 2.125in, ratio ~1.588:1),
   joined into one sheet: a dashed line runs around the OUTER edge only
   (cut here), while the seam between front and back is a solid line
   (fold here) — cut the outside, fold the middle, get a two-sided card. */
.wallet-card-joined {
  display: flex; flex-direction: column;
  max-width: 340px; margin: 14px 0 8px;
  border: 1.5px dashed var(--text-dim);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.wallet-card-single {
  position: relative;
  aspect-ratio: 3.375 / 2.125;
  display: flex; flex-direction: column;
}
.wallet-fold-joint {
  position: relative;
  border-top: 1.5px solid var(--text-dim);
  flex-shrink: 0;
}
.wallet-fold-joint span {
  position: absolute; left: 50%; top: -6px; transform: translateX(-50%);
  background: var(--surface); padding: 0 6px;
  font-size: 0.52rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
}
/* Navy brand strip + a thin accent bookend — front face only; the back
   stays plain, like the reverse of a real ID card. */
.wallet-card-topstrip {
  background: var(--navy); color: #fff;
  padding: 6px 12px;
  flex-shrink: 0;
}
.wallet-topstrip-brand { font-size: 0.68rem; font-weight: 700; }
.wallet-topstrip-brand span { color: #9dc0ff; }
.wallet-card-bottomstrip { height: 5px; background: var(--brand); flex-shrink: 0; }
.wallet-face-body {
  position: relative;
  flex: 1; min-height: 0;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 3px;
  font-size: 0.62rem;
}
.wallet-front-title { font-size: 0.8rem; font-weight: 700; color: var(--navy); margin: 0 0 4px; }
.wallet-field { display: flex; flex-direction: column; margin-bottom: 3px; min-width: 0; }
.wallet-field-label { font-size: 0.54rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-dim); }
.wallet-field-value { font-size: 0.68rem; font-weight: 600; color: var(--text); overflow-wrap: break-word; }
.wallet-field-blank { display: block; border-bottom: 1px solid var(--border); min-height: 14px; }
.wallet-field-row { display: flex; gap: 10px; padding-right: 46px; }
.wallet-field-row .wallet-field { flex: 1 1 0; }
.wallet-back-meta { font-size: 0.6rem; color: var(--text-dim); overflow-wrap: break-word; }
.wallet-back-intro { font-size: 0.6rem; margin: 3px 0 2px; }
.wallet-topics {
  margin: 0; padding-left: 14px; font-size: 0.56rem; color: var(--text-dim);
}
.wallet-topics li { margin-bottom: 1px; }
.wallet-qr-corner {
  position: absolute; right: 8px; bottom: 8px;
  width: 38px; height: 38px;
}

/* On screen, let each card grow to fit its content naturally (more
   readable in a preview); only lock to true card proportions when
   actually printed, since that's what needs to be physically accurate
   for cutting. */
@media print {
  .topbar, .footer, .ad-slot, .btn-row { display: none !important; }
  .wallet-card-joined { max-width: none; width: 3.375in; break-inside: avoid; }
  .wallet-card-single { width: 3.375in; aspect-ratio: 3.375 / 2.125; }

  /* Browsers drop background colors/images by default when printing
     (to save ink) unless told otherwise — without this, the printed
     PDF loses the navy strip, accent bar, and card backgrounds that
     show fine on screen. */
  html {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }

  /* Keep the main cert card and the scope note together on page 1
     (never split mid-card); start the wallet card section fresh on
     its own page rather than letting it spill across a page break. */
  #certCard, .scope-note-card { break-inside: avoid; }
  .wallet-card-section { break-before: page; }

  /* The page heading is redundant on paper (the cert card already
     shows "Certificate of Completion" + the course title), so drop it
     to reclaim a little vertical room. */
  #app > h2:first-child { display: none; }

  /* Tighten spacing (not font sizes) on the cert card and scope note
     so both fit on page 1 together instead of the note spilling onto
     page 2 — measured to bring their combined height from ~1080px to
     ~844px, comfortably under a standard printable page. */
  #certCard { padding: 10px 14px; }
  #certCard .pill { margin-bottom: 2px; }
  #certCard h2 { margin: 2px 0; }
  #certCard .cert-name { margin: 4px 0; }
  #certCard .cert-meta { margin-bottom: 6px; }
  #certCard .check-list { margin: 6px 0; }
  #certCard .check-list li { padding: 3px 0; }
  #certCard p { margin: 3px 0; }
  .scope-note-card { padding: 12px 14px; }
  .scope-note-card > p { margin: 5px 0; }
  .scope-tips-grid { margin-top: 8px; gap: 8px; }
  .scope-tip b { margin: 3px 0 1px; }
  .scope-tip-icon { width: 24px; height: 24px; }
}
