/* ============================================================
   DFM LESSON INTERFACE — seven-tab lesson player
   Loads after academy.css and reuses its tokens.
   ============================================================ */

/* ---------- Lesson header ---------- */
.lesson-head {
  background: linear-gradient(160deg, #0f172a 0%, #16233f 55%, #0b1220 100%);
  color: #fff; padding: 40px 0 0; position: relative; overflow: hidden;
}
.lesson-head::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 26px 26px; mask-image: linear-gradient(180deg, #000, transparent 80%);
}
.lesson-head .wrap { position: relative; z-index: 1; }

.crumb { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: #94a3b8; margin-bottom: 18px; flex-wrap: wrap; }
.crumb a { color: #cbd5e1; }
.crumb a:hover { color: #fff; }
.crumb .sep { opacity: 0.45; }

.lesson-title-row { display: flex; align-items: flex-start; gap: 26px; flex-wrap: wrap; margin-bottom: 22px; }
.lesson-badge {
  font-family: "Montserrat", sans-serif; font-weight: 800; font-size: 12px; letter-spacing: 0.9px;
  background: rgba(16,185,129,0.16); border: 1px solid rgba(16,185,129,0.4); color: #6ee7b7;
  padding: 8px 14px; border-radius: 9px; flex: none; margin-top: 6px;
}
.lesson-head h1 { color: #fff; font-size: clamp(26px, 4vw, 40px); letter-spacing: -0.9px; margin-bottom: 8px; }
.lesson-head .sub { color: #a9b6cc; font-size: 16px; }
.lesson-facts { display: flex; flex-wrap: wrap; gap: 10px 22px; font-size: 13.5px; color: #94a3b8; margin-bottom: 26px; }
.lesson-facts span { display: inline-flex; align-items: center; gap: 7px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: 0; cursor: pointer; white-space: nowrap;
  font-family: "Poppins", sans-serif; font-size: 14.5px; font-weight: 500;
  color: #94a3b8; padding: 15px 18px; border-bottom: 3px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
  display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: #e2e8f0; }
.tab[aria-selected="true"] { color: #fff; font-weight: 600; border-bottom-color: #34d399; }
.tab .tnum {
  font-size: 11px; font-weight: 700; width: 20px; height: 20px; border-radius: 6px;
  background: rgba(255,255,255,0.1); display: grid; place-items: center; flex: none;
}
.tab[aria-selected="true"] .tnum { background: #34d399; color: #06281c; }
.tab.done .tnum::after { content: "✓"; }
.tab.done .tnum { font-size: 12px; color: #6ee7b7; }
.tab.done .tnum span { display: none; }

/* ---------- Panels ---------- */
.panel { display: none; padding: 48px 0 72px; }
.panel.active { display: block; animation: fade 0.28s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .panel.active { animation: none; } }

.panel h2 {
  font-size: clamp(23px, 3vw, 30px); letter-spacing: -0.6px; margin-bottom: 14px;
}
.panel .lede { font-size: 17px; color: var(--muted); margin-bottom: 34px; max-width: 760px; }

.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 30px; margin-bottom: 22px;
}
.card h3 { font-size: 18.5px; margin-bottom: 12px; }
.card p { margin-bottom: 12px; }
.card p:last-child { margin-bottom: 0; }

.hook {
  border-left: 4px solid var(--green); background: linear-gradient(90deg, #ecfdf5, #fff 60%);
  padding: 24px 28px; border-radius: 12px; margin-bottom: 26px; font-size: 16.5px; color: var(--ink-2);
}
.bigidea {
  background: linear-gradient(135deg, rgba(37,99,235,0.07), rgba(124,58,237,0.07));
  border: 1px solid rgba(37,99,235,0.2); border-radius: 13px; padding: 24px 28px; margin-bottom: 30px;
}
.bigidea .k {
  font-size: 11.5px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--primary); margin-bottom: 8px;
}
.bigidea p { font-size: 16.5px; color: var(--ink-2); margin: 0; }

ul.ticks, ul.checks { list-style: none; }
ul.ticks li, ul.checks li {
  position: relative; padding-left: 30px; margin-bottom: 11px; font-size: 15.2px;
}
ul.ticks li::before {
  content: "✓"; position: absolute; left: 0; top: -1px; color: var(--green); font-weight: 700;
}
ul.checks li::before {
  content: ""; position: absolute; left: 2px; top: 7px; width: 12px; height: 12px;
  border: 2px solid var(--primary); border-radius: 4px;
}
ol.steps { list-style: none; counter-reset: s; }
ol.steps li {
  counter-increment: s; position: relative; padding-left: 44px; margin-bottom: 16px; font-size: 15.2px;
}
ol.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -2px;
  width: 28px; height: 28px; border-radius: 9px; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-family: "Montserrat", sans-serif; font-size: 13px; font-weight: 800;
}

/* summary points */
.points { display: grid; gap: 14px; margin-bottom: 34px; }
.point {
  background: var(--white); border: 1px solid var(--line); border-radius: 13px; padding: 20px 24px;
  border-left: 4px solid var(--green);
}
.point h4 { font-size: 16px; margin-bottom: 6px; }
.point p { font-size: 14.8px; color: var(--muted); margin: 0; }

/* vocabulary */
.vocab { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.vword {
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 15px 18px;
}
.vword b { display: block; color: var(--ink); font-size: 14.8px; margin-bottom: 4px; }
.vword span { font-size: 13.8px; color: var(--muted); }

/* speaker */
.speaker-hero {
  display: flex; gap: 28px; align-items: flex-start; padding: 32px;
  border-radius: var(--radius-lg); color: #fff; margin-bottom: 26px;
  background: linear-gradient(135deg, var(--sp) 0%, var(--ink) 130%);
}
.speaker-face {
  width: 84px; height: 84px; border-radius: 22px; flex: none; display: grid; place-items: center;
  font-size: 40px; background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.28);
}
/* ---- Written response block (Activity + Exam tabs) ---- */
.writeblock {
  background: var(--white); border: 2px solid var(--line); border-radius: var(--radius-lg);
  padding: 28px 30px; margin-top: 30px;
}
.writeblock h3 { font-size: 18px; margin-bottom: 10px; }
.wb-prompt {
  font-size: 16px; color: var(--ink-2); margin-bottom: 18px; line-height: 1.65;
  border-left: 3px solid var(--primary); padding-left: 16px;
}
.wb-text {
  width: 100%; padding: 16px 18px; border: 1.5px solid var(--line); border-radius: 12px;
  font-family: inherit; font-size: 15.5px; line-height: 1.7; color: var(--ink);
  resize: vertical; min-height: 190px; background: var(--bg);
}
.wb-text:focus {
  outline: none; border-color: var(--primary); background: var(--white);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
.wb-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px;
}
.wb-count { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wb-count .n { font-weight: 700; color: var(--ink); }
.wb-short .wb-count .min { color: var(--amber-dark); font-weight: 600; }
.wb-ok .wb-count .n { color: var(--green-dark); }
.wb-saved { font-size: 13px; color: var(--muted); margin-left: auto; }
.wb-saved.warn { color: var(--amber-dark); font-weight: 600; }
.wb-send:disabled { opacity: 0.45; cursor: not-allowed; }
.wb-status { margin-top: 14px; font-size: 14.5px; border-radius: 10px; padding: 0; }
.wb-status:not(:empty) { padding: 13px 16px; }
.wb-status.ok   { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.wb-status.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.wb-status.err  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ---- Lesson artwork (Overview tab) ----
   Source images are 1024x1024 squares, so they are cropped to a wide band
   with object-fit rather than letterboxed. If the file is missing the
   <img> onerror removes the whole figure, so no broken icon appears. */
.lesson-art {
  margin: 0 0 30px; border-radius: var(--radius-lg); overflow: hidden;
  background: var(--bg); box-shadow: var(--shadow-md); line-height: 0;
}
.lesson-art img {
  /* height:auto is load-bearing: the height="1024" markup attribute is
     a presentational hint that otherwise wins (no author height rule)
     and disables aspect-ratio — the "16:9" hero was actually rendering
     1024px tall until this was caught on 1 Sep 2026. */
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 9;
  object-fit: cover; object-position: center;
}

/* ---- Deep Dive lesson art ----
   The lesson illustration embedded in the first "Going deeper" section,
   floated right so the prose wraps around it — the same treatment as
   the speaker portrait below, and for the same reasons: flow-root
   contains the float without overflow:hidden clipping the shadow, and
   below 700px the column is too narrow to wrap readably so it goes back
   to its own row. Cropped 4:3 here (the Overview shows the same square
   master as 16:9), so the two tabs read differently. */
.card.dd { display: flow-root; }
.dd-art {
  float: right;
  width: min(320px, 42%);
  margin: 2px 0 16px 24px;
  border-radius: 14px; overflow: hidden;
  background: var(--bg); box-shadow: var(--shadow-md);
  line-height: 0;
}
.dd-art img {
  /* height:auto is load-bearing: the height="1024" attribute is a
     presentational hint, and without an author height it wins and
     disables aspect-ratio entirely (a 1024px-tall float). */
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 3;
  object-fit: cover; object-position: center;
}
@media (max-width: 700px) {
  .dd-art {
    float: none; width: 100%; max-width: 360px;
    margin: 0 auto 20px;
  }
}

/* ---- Guest speaker portrait (Speaker tab) ----
   Shown large enough to read the framed artwork rather than crushed into
   the small avatar. Square source, so displayed square. */
/* The portrait sits INSIDE "Their story" and the bio wraps around it.
   It used to be a full-width block on its own row, which left a tall
   empty column beside a 340px square and pushed the reading down the
   page. Bios run 500-950 characters, so there is always enough text to
   wrap. flow-root on the card contains the float without the side
   effects of overflow:hidden (which would clip the box-shadow). */
.speaker-story { display: flow-root; }
.speaker-portrait {
  float: right;
  width: min(300px, 40%);
  margin: 2px 0 16px 24px;
  border-radius: 14px; overflow: hidden;
  background: var(--bg); box-shadow: var(--shadow-md);
}
/* Below this the remaining column is too narrow to read comfortably, so
   the portrait goes back to its own row rather than squeezing the bio
   into a four-word ribbon. */
@media (max-width: 700px) {
  .speaker-portrait {
    float: none; width: 100%; max-width: 340px;
    margin: 0 auto 20px;
  }
}
.speaker-portrait img {
  /* height:auto is load-bearing — see .lesson-art img. Without it the
     height="1024" attribute wins and this "square" rendered 1024px
     tall, stretching the story card. */
  display: block; width: 100%; height: auto; aspect-ratio: 1 / 1;
  object-fit: cover; object-position: center;
}
.speaker-portrait figcaption {
  padding: 11px 14px; font-size: 13px; color: var(--muted);
  background: var(--white); border-top: 1px solid var(--line);
}

.speaker-hero h2 { color: #fff; margin-bottom: 4px; font-size: 27px; }
.speaker-hero .role { color: rgba(255,255,255,0.9); font-size: 15.5px; font-weight: 500; }
.speaker-hero .era { color: rgba(255,255,255,0.65); font-size: 13.5px; margin-top: 3px; }
.pullquote {
  border-left: 4px solid var(--green); padding: 20px 26px; margin-bottom: 24px;
  font-family: "Montserrat", sans-serif; font-size: 19px; font-style: italic; color: var(--ink);
  background: var(--white); border-radius: 0 12px 12px 0;
}
.also {
  background: var(--bg); border: 1px dashed var(--line); border-radius: 13px; padding: 22px 26px;
}
.also h4 { font-size: 15px; margin-bottom: 10px; }
.also .who { font-weight: 600; color: var(--ink); }

/* deep dive */
.dd { margin-bottom: 26px; }
.dd h3 {
  font-size: 19px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 2px solid var(--line);
}
.dd p { font-size: 15.4px; margin-bottom: 13px; }

/* activity */
.act-banner {
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%); color: #fff;
  border-radius: var(--radius); padding: 28px 32px; margin-bottom: 24px;
}
.act-banner h2 { color: #fff; margin-bottom: 6px; }
.act-banner .type { font-size: 13.5px; color: rgba(255,255,255,0.8); letter-spacing: 0.5px; }
.notice {
  background: #fffbeb; border: 1px solid #fcd34d; border-radius: 12px; padding: 18px 22px;
  margin-bottom: 24px; font-size: 14.6px; color: #78350f;
}
.notice b { color: #92400e; }
.bookbox {
  background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 12px; padding: 20px 24px;
  font-size: 14.8px; color: #065f46; margin-top: 22px;
}
.bookbox b { color: #047857; }

/* exam */
.exam-intro {
  display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 26px; margin-bottom: 24px;
}
.exam-intro .meta { font-size: 14.5px; color: var(--muted); }
.q {
  background: var(--white); border: 1px solid var(--line); border-radius: 13px;
  padding: 22px 26px; margin-bottom: 14px;
}
.q .qn { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.8px; margin-bottom: 8px; }
.q .qt { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 16px; }
.opts { display: grid; gap: 9px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 10px; font-size: 15px;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.opt:hover { border-color: var(--primary); background: #f8fafc; }
.opt input { margin-top: 3px; flex: none; accent-color: var(--primary); }
.q.marked .opt { cursor: default; }
.q.marked .opt:hover { border-color: var(--line); background: none; }
.q.marked .opt.correct { border-color: var(--green); background: #ecfdf5; }
.q.marked .opt.wrong { border-color: #f87171; background: #fef2f2; }
.why {
  display: none; margin-top: 14px; padding: 14px 18px; border-radius: 10px;
  background: var(--bg); border-left: 3px solid var(--primary); font-size: 14.4px; color: var(--text);
}
.q.marked .why { display: block; }
.why b { color: var(--ink); }

.score {
  display: none; text-align: center; padding: 34px; border-radius: var(--radius);
  margin-bottom: 24px; color: #fff;
}
.score.show { display: block; }
.score.pass { background: linear-gradient(135deg, #059669, #10b981); }
.score.fail { background: linear-gradient(135deg, #b45309, #f59e0b); }
.score .n { font-family: "Montserrat", sans-serif; font-size: 46px; font-weight: 800; line-height: 1; }
.score .l { font-size: 15.5px; margin-top: 10px; color: rgba(255,255,255,0.92); }

/* resources */
.res { display: grid; gap: 13px; }
.res-item {
  display: flex; gap: 18px; align-items: flex-start; background: var(--white);
  border: 1px solid var(--line); border-radius: 13px; padding: 20px 24px;
}
.res-ic {
  width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center;
  font-size: 21px; background: var(--bg); border: 1px solid var(--line);
}
.res-item h4 { font-size: 15.8px; margin-bottom: 4px; }
.res-item p { font-size: 14.4px; color: var(--muted); margin: 0; }
.res-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase;
  color: var(--primary); margin-bottom: 5px;
}

/* footer nav */
.lesson-nav {
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 26px; margin-top: 10px;
}

@media (max-width: 720px) {
  .panel { padding: 34px 0 56px; }
  .card, .hook, .bigidea, .act-banner, .q { padding-left: 20px; padding-right: 20px; }
  .speaker-hero { flex-direction: column; gap: 18px; padding: 24px; }
  .lesson-title-row { gap: 14px; }
  .res-item { flex-direction: column; gap: 12px; }
}
