/* ==========================================================
   LearnWater — lesson pages (lessons/*.html)
   Layered on css/style.css + css/adult.css. Each page sets its
   chapter colors on <body>: --theme, --theme-dark, --theme-tint.
   ========================================================== */

body.lesson-page { background: var(--mist); --theme: var(--ocean); }

/* Reading progress */
.read-progress { position: fixed; left: 0; right: 0; top: var(--nav-h); height: 3px; z-index: 190; pointer-events: none; }
.read-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--theme), var(--aqua)); box-shadow: 0 0 10px rgba(39,193,212,.6); }

/* ---------- Hero ---------- */
.lesson-hero {
  position: relative; overflow: hidden; isolation: isolate; color: var(--white);
  padding: 3rem 0 6.75rem;
  background: var(--grad-deep);
  background:
    radial-gradient(760px 420px at 88% 16%, color-mix(in srgb, var(--theme) 60%, transparent), transparent 72%),
    radial-gradient(520px 300px at 6% 115%, rgba(39,193,212,.28), transparent 70%),
    var(--grad-deep);
}
.lesson-hero::before {
  content: ''; position: absolute; z-index: -1; width: 820px; height: 820px; right: -300px; top: -320px;
  background: url(../img/contours.svg) center / contain no-repeat; opacity: .7; pointer-events: none;
}
.lesson-hero .motif { position: absolute; z-index: -1; right: 7%; top: 44%; transform: translateY(-50%); width: 280px; height: 280px; opacity: .13; pointer-events: none; }
.lesson-hero .motif svg { width: 100%; height: 100%; }
.lesson-hero-inner { position: relative; z-index: 1; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .86rem; color: rgba(232,246,250,.7); margin-bottom: 1.3rem; }
.crumbs a { color: var(--spray); font-weight: 600; }
.chapter-kicker {
  display: inline-flex; align-items: center; gap: .6rem; margin-bottom: .9rem;
  font-family: var(--font-mono); font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--spray);
}
.chapter-kicker::before { content: ''; width: 22px; height: 2px; background: currentColor; border-radius: 2px; }
.lesson-hero h1 { color: var(--white); font-size: clamp(1.9rem, 4.6vw, 3rem); display: flex; align-items: center; gap: .9rem; margin-bottom: .85rem; }
.hero-icon {
  flex-shrink: 0; width: 64px; height: 64px; display: grid; place-items: center; font-size: 2rem; border-radius: 18px;
  background: color-mix(in srgb, var(--theme) 45%, rgba(255,255,255,.08)); border: 1px solid rgba(255,255,255,.25);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 14px 30px -14px rgba(0,0,0,.6);
}
.lesson-hero .dek { font-size: 1.12rem; color: rgba(232,246,250,.88); max-width: 680px; margin: 0 0 1.2rem; }
.hero-meta { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1.5rem; min-height: 1.9rem; }
.hero-meta span, .hero-meta a {
  font-size: .8rem; font-weight: 600; padding: .3rem .75rem; border-radius: 999px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(143,227,238,.25); color: rgba(255,255,255,.92);
}
/* Hero chips are jump links to their part of the page */
.hero-meta a {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; padding: .4rem .85rem;
  text-decoration: none; cursor: pointer; transition: background .2s, border-color .2s, transform .2s;
}
.hero-meta a::after { content: '↓'; font-weight: 800; color: #8fe3ee; transition: transform .2s; }
.hero-meta a:hover { background: rgba(255,255,255,.18); border-color: rgba(143,227,238,.65); color: #fff; text-decoration: none; }
.hero-meta a:hover::after { transform: translateY(2px); }
.hero-meta a:active { transform: scale(.97); }
.hero-meta a:focus-visible { outline: 3px solid #8fe3ee; outline-offset: 2px; }
.hero-meta .status.done { background: rgba(17,133,95,.45); border-color: rgba(143,238,190,.5); }
.hero-cta { display: flex; gap: .6rem; flex-wrap: wrap; }

/* ---------- Layout ---------- */
.lesson-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 2.75rem; align-items: start; padding-top: 1.5rem; padding-bottom: 4.5rem; }
.lesson-toc { position: sticky; top: calc(var(--nav-h) + 1.75rem); }
.toc-title { display: block; font-family: var(--font-mono); font-size: .68rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: .6rem; }
.lesson-toc ol { list-style: none; border-left: 2px solid var(--line); }
.lesson-toc a { display: block; margin-left: -2px; padding: .36rem .85rem; border-left: 2px solid transparent; color: var(--ink-2); font-size: .87rem; line-height: 1.35; transition: color .15s, border-color .15s; }
.lesson-toc a:hover { color: var(--theme); text-decoration: none; }
.lesson-toc a.active { color: var(--theme-dark); border-left-color: var(--theme); font-weight: 700; }
.lesson-toc .toc-sep { margin-top: .45rem; padding-top: .45rem; border-top: 1px dashed var(--line); }
.toc-done {
  margin-top: 1.1rem; width: 100%; cursor: pointer; font-weight: 700; font-size: .85rem;
  border: 1.5px solid var(--line); background: var(--white); color: var(--ink-2); border-radius: 999px; padding: .55rem .9rem;
}
.toc-done:hover { border-color: var(--theme); color: var(--theme-dark); }
.toc-done[aria-pressed="true"] { background: var(--success-bg); border-color: rgba(17,133,95,.35); color: var(--success); }

.lesson-main { min-width: 0; max-width: 800px; }
.lesson-main > section, .lesson-main > aside, .complete-bar { scroll-margin-top: calc(var(--nav-h) + 18px); }

/* Greg's take */
.greg-take {
  position: relative; display: flex; gap: 1.1rem; align-items: flex-start;
  background: var(--white); border: 1px solid var(--line-2); border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem; margin-bottom: 1.4rem; box-shadow: var(--shadow-sm); overflow: hidden;
}
.greg-take::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--theme); }
.greg-take .greg-avatar { width: 58px; height: 58px; box-shadow: 0 0 0 3px var(--theme-tint), var(--shadow-sm); }
.greg-take h2 { font-size: 1.05rem; margin: .1rem 0 .35rem; }
.greg-take p { margin: 0; color: var(--ink-2); }

/* Sections */
.lesson-section, .lesson-block {
  background: var(--white); border: 1px solid var(--line-2); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 1.8rem 1.95rem; margin-bottom: 1.25rem;
}
.lesson-section h2 { display: flex; align-items: center; gap: .75rem; font-size: clamp(1.2rem, 2.5vw, 1.45rem); margin-bottom: .95rem; }
.lesson-section h2 .num {
  flex-shrink: 0; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px;
  background: var(--theme); color: var(--white); font-family: var(--font-mono); font-size: .92rem; font-weight: 700;
  box-shadow: 0 8px 16px -8px var(--theme);
}
.lesson-section p { font-size: 1.03rem; line-height: 1.78; color: var(--ink); margin-bottom: 1rem; }
.lesson-section p:last-child { margin-bottom: 0; }
.lesson-section ul, .lesson-section ol { margin: 0 0 1rem 1.3rem; }
.lesson-section li { font-size: 1.01rem; line-height: 1.7; margin-bottom: .5rem; padding-left: .2rem; }
.lesson-section li::marker { color: var(--theme); font-weight: 700; }
.lesson-section strong { color: var(--abyss); }
.lesson-section table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 1rem 0; font-size: .94rem; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.lesson-section th { background: var(--theme-tint); color: var(--theme-dark); text-align: left; font-weight: 700; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
.lesson-section td { padding: .6rem .8rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.lesson-section tr:last-child td { border-bottom: 0; }
.lesson-section tr:nth-child(even) td { background: var(--mist); }

/* Current-rule notes */
.rule-note {
  display: flex; gap: .9rem; align-items: flex-start;
  background: #fffaf0; border: 1px solid #f0d9a8; border-left: 4px solid #d98a00; border-radius: 14px;
  padding: 1rem 1.2rem; margin: -.35rem 0 1.25rem;
}
.rule-note .rn-icon { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #b45309; color: #fff; font-family: var(--font-display); font-weight: 800; font-style: italic; }
.rule-note strong { display: block; color: #7a4a00; margin-bottom: .25rem; font-size: .95rem; }
.rule-note p { margin: 0; font-size: .95rem; line-height: 1.6; color: var(--ink-2); }
.rule-note p strong { display: inline; color: var(--abyss); margin: 0; }

/* Exam watch: common traps */
.exam-watch {
  display: flex; gap: .9rem; align-items: flex-start;
  background: var(--theme-tint); border: 1px solid var(--line); border-left: 4px solid var(--theme); border-radius: 14px;
  padding: 1rem 1.2rem; margin: -.35rem 0 1.25rem;
}
.exam-watch .ew-icon {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--theme); color: #fff; font-family: var(--font-display); font-weight: 800;
}
.exam-watch strong { display: block; color: var(--theme-dark); margin-bottom: .25rem; font-size: .95rem; }
.exam-watch p { margin: 0; font-size: .95rem; line-height: 1.6; color: var(--ink-2); }
.exam-watch p strong { display: inline; color: var(--abyss); margin: 0; }

/* Numbers to memorize */
.key-numbers {
  position: relative; overflow: hidden; color: var(--white);
  background: linear-gradient(145deg, var(--theme-dark), var(--abyss) 85%);
  border-radius: var(--radius-lg); padding: 1.8rem 1.95rem; margin: 1.6rem 0 1.25rem; box-shadow: var(--shadow);
}
.key-numbers::after { content: ''; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px; background: url(../img/contours.svg) center / contain no-repeat; opacity: .5; pointer-events: none; }
.key-numbers h2 { position: relative; z-index: 1; color: var(--white); font-size: 1.25rem; margin-bottom: 1rem; }
.key-numbers ul { position: relative; z-index: 1; list-style: none; margin: 0; display: grid; gap: .55rem; }
.key-numbers li { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.13); border-radius: 12px; padding: .7rem .95rem; font-size: .97rem; line-height: 1.5; color: rgba(255,255,255,.88); }
.key-numbers strong { color: var(--spray); font-family: var(--font-display); font-weight: 800; }

/* Key terms */
.kt-list { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem .8rem; }
.kt-item { background: var(--mist); border: 1px solid var(--line-2); border-left: 3px solid var(--theme); border-radius: 12px; padding: .7rem .9rem; }
.kt-item dt { font-family: var(--font-display); font-weight: 800; font-size: .98rem; line-height: 1.3; color: var(--abyss); margin-bottom: .2rem; }
.kt-item dd { margin: 0; font-size: .88rem; line-height: 1.5; color: var(--ink-2); }
.kt.collapsed .kt-item:nth-child(n+11) { display: none; }
.kt-more { margin-top: .9rem; }

/* Blocks: check yourself, cards, Greg, videos */
.block-head h2 { font-size: clamp(1.2rem, 2.5vw, 1.45rem); margin: .4rem 0 .35rem; }
.block-head p { color: var(--muted); margin: 0 0 1.1rem; font-size: .95rem; }
.block-foot { margin: 1rem 0 0; font-weight: 700; font-size: .92rem; }
.lesson-block .q-text { font-size: 1.15rem; margin: 1rem 0; }
.lesson-block .q-choices .choice { padding: .75rem .9rem; font-size: .97rem; }
.check-done { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.cd-score { width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; text-align: center; background: var(--theme-tint); border: 6px solid var(--theme); flex-shrink: 0; }
.cd-score b { display: block; font-family: var(--font-display); font-size: 1.7rem; color: var(--abyss); line-height: 1; }
.cd-score span { font-size: .74rem; color: var(--muted); }
.check-done p { margin: 0 0 .8rem; color: var(--ink-2); }

.lc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; }
.lc-card { position: relative; height: 150px; border: 0; padding: 0; background: none; cursor: pointer; perspective: 900px; text-align: center; }
.lc-inner { position: absolute; inset: 0; transition: transform .5s cubic-bezier(.3,.7,.2,1); transform-style: preserve-3d; }
.lc-card.flipped .lc-inner { transform: rotateY(180deg); }
.lc-face { position: absolute; inset: 0; display: grid; place-items: center; padding: .9rem 1rem; border-radius: 14px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: auto; }
.lc-front { background: linear-gradient(150deg, var(--theme), var(--theme-dark)); color: var(--white); font-family: var(--font-display); font-weight: 800; font-size: 1.02rem; line-height: 1.3; box-shadow: var(--shadow-sm); }
.lc-back { background: var(--theme-tint); color: var(--ink); border: 1px solid var(--line); font-size: .86rem; line-height: 1.45; transform: rotateY(180deg); }

.lesson-chat .gchat-log { max-height: 380px; min-height: 120px; padding: .25rem; }

/* Completion + pager */
.complete-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(120deg, var(--white), var(--theme-tint)); border: 1px solid var(--line-2);
  border-radius: var(--radius-lg); padding: 1.3rem 1.5rem; margin: 1.75rem 0 1.25rem; box-shadow: var(--shadow-sm);
}
.complete-bar strong { display: block; font-family: var(--font-display); font-size: 1.12rem; color: var(--abyss); }
.complete-bar span { color: var(--muted); font-size: .92rem; }
.complete-bar .btn[aria-pressed="true"] { background: var(--success); box-shadow: none; }
.chapter-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.chapter-pager a {
  display: flex; flex-direction: column; gap: .3rem; background: var(--white); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow-sm); color: var(--ink);
  border-top: 3px solid var(--c, var(--tide)); transition: transform .2s, box-shadow .2s;
}
.chapter-pager a:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; }
.chapter-pager .pg-next { text-align: right; grid-column: 2; }
.pg-dir { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.pg-title { font-family: var(--font-display); font-weight: 800; color: var(--abyss); line-height: 1.3; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .lesson-layout { grid-template-columns: 1fr; gap: 0; }
  .lesson-toc { display: none; }
  .lesson-hero .motif { display: none; }
}
@media (max-width: 640px) {
  .lesson-hero { padding: 2.25rem 0 5.5rem; }
  .lesson-hero h1 { align-items: flex-start; flex-direction: column; gap: .7rem; }
  .hero-icon { width: 54px; height: 54px; font-size: 1.7rem; }
  .lesson-section, .lesson-block, .key-numbers { padding: 1.3rem 1.2rem; }
  .greg-take { flex-direction: column; }
  .chapter-pager { grid-template-columns: 1fr; }
  .chapter-pager .pg-next { grid-column: auto; }
  .kt-list { grid-template-columns: 1fr; }
  .lesson-section table { font-size: .84rem; table-layout: fixed; }
  .lesson-section th, .lesson-section td { padding: .5rem .5rem; overflow-wrap: anywhere; hyphens: auto; }
}

/* Link from a lesson to its deep-dive page */
.deep-link {
  display: flex; align-items: center; gap: .9rem; margin: 1.75rem 0;
  padding: 1rem 1.15rem; background: var(--theme-tint); border: 1px solid var(--line-2);
  border-left: 5px solid var(--theme); border-radius: var(--radius-lg);
  color: inherit; text-decoration: none; transition: transform .2s, box-shadow .2s;
}
.deep-link:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.deep-link:focus-visible { outline: 3px solid var(--theme); outline-offset: 2px; }
.dl-icon { width: 46px; height: 46px; flex-shrink: 0; display: grid; place-items: center; font-size: 1.45rem; border-radius: 12px; background: var(--white); }
.dl-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.dl-text strong { font-family: var(--font-display); color: var(--theme-dark); font-size: 1.04rem; }
.dl-text span { color: var(--ink-2); font-size: .92rem; line-height: 1.5; }
.dl-arrow { font-weight: 700; color: var(--theme); transition: transform .2s; }
.deep-link:hover .dl-arrow { transform: translateX(4px); }

@media print {
  .deep-link { display: none; }
  .site-nav, .read-progress, .lesson-hero .motif, .hero-waves, .hero-cta, .lesson-toc, #check, #cards, #ask, #videos, .complete-bar, .chapter-pager, .site-footer, .skip-link { display: none !important; }
  .lesson-hero { background: none !important; color: #000; padding: 0 0 1rem; }
  .lesson-hero h1, .lesson-hero .dek, .chapter-kicker, .crumbs, .hero-meta span, .hero-meta a { color: #000 !important; background: none !important; border-color: #999 !important; }
  .hero-meta a::after { content: none; }
  .lesson-layout { display: block; padding: 0; }
  .lesson-section, .greg-take, .rule-note { box-shadow: none; break-inside: avoid; }
  .key-numbers { background: #fff !important; color: #000; border: 2px solid #000; }
  .key-numbers h2, .key-numbers li, .key-numbers strong { color: #000 !important; }
  .key-numbers li { background: none; border-color: #999; }
  .exam-watch, .kt-item { break-inside: avoid; }
  .kt.collapsed .kt-item:nth-child(n+11) { display: block !important; }
  .kt-more, #terms .block-foot { display: none !important; }
}
