/* =========================================================================
   Grade 6 lesson design system.
   Extends the portfolio tokens in /styles.css. Loaded by every week-K.html.
   Dark/light aware, print-friendly, WCAG 2.1 AA. No external dependencies.
   ========================================================================= */

:root {
  --l-maxw: 1180px;
  --l-chrome-h: 52px;
  /* Tier colors route through the theme tokens (dark values are identical to
     the previous hexes) so a future theme.js on week pages inherits the
     AA-tuned light palette. --l-ext has no token equivalent; dark-only hex. */
  --l-tier1: var(--accent);    /* universal / core   */
  --l-tier2: var(--accent2);   /* targeted scaffold  */
  --l-tier3: var(--accent3);   /* intensive re-teach */
  --l-ext:   #b98aff;          /* extension          */
  --l-sel:   var(--accent4);   /* SEL / PBIS         */
  --l-soft:  rgba(94,170,255,.08);
}

.lesson { max-width: var(--l-maxw); margin: 0 auto; padding: var(--l-chrome-h) clamp(16px, 3vw, 36px) 80px; }
.lesson :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---- skip + utility ---- */
.l-skip { position: absolute; left: -9999px; top: auto; }
.l-skip:focus { left: 12px; top: 12px; z-index: 1000; background: var(--accent);
  color: #fff; padding: 8px 14px; border-radius: 6px; }
.l-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- persistent lesson progress + table of contents ---- */
.l-progress-shell { position: fixed; inset: 0 0 auto; z-index: 100; background: var(--surface2);
  background: color-mix(in srgb, var(--surface2) 94%, transparent);
  border-bottom: 1px solid var(--border); box-shadow: 0 4px 18px rgba(0,0,0,.12); backdrop-filter: blur(12px); }
.l-progress-track { position: absolute; inset: auto 0 0; height: 3px; background: var(--border); }
.l-progress-bar { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .15s ease-out; }
.l-progress-inner { max-width: var(--l-maxw); min-height: 48px; margin: auto; padding: 7px clamp(16px, 3vw, 36px);
  display: flex; align-items: center; gap: 14px; }
.l-progress-label { flex: 0 0 auto; font-size: .78rem; font-weight: 750; color: var(--text2); }
.l-progress-label strong { color: var(--text); font-variant-numeric: tabular-nums; }
.l-toc { min-width: 0; flex: 1; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; overscroll-behavior-inline: contain; }
.l-toc a { flex: 0 0 auto; min-height: 44px; padding: 5px 9px; border-radius: 7px; color: var(--muted); font-size: .75rem;
  display: inline-flex; align-items: center; font-weight: 650; text-decoration: none; white-space: nowrap; }
.l-toc a:hover, .l-toc a[aria-current="location"] { color: var(--accent-hover); background: var(--l-soft); }
.l-toc a:focus-visible { outline-offset: -2px; }

/* ---- lesson header ---- */
.l-head { background: linear-gradient(135deg, var(--flagship-grad-start), var(--flagship-grad-end));
  color: #eaf2ff; border-radius: var(--radius-lg); padding: 26px 24px; margin: 18px 0 24px;
  border: 1px solid var(--border-hl); }
.l-eyebrow { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; opacity: .85; margin: 0 0 6px; }
.l-head h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 0 0 10px; color: #fff; line-height: 1.2; }
.l-question { font-size: 1.05rem; font-weight: 600; margin: 0 0 16px; color: #cfe4ff; }
.l-3d { display: flex; flex-wrap: wrap; gap: 8px; }
.l-3d .l-tag { font-size: .72rem; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); color: #eaf2ff; }
.l-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; font-size: .85rem; opacity: .9; }

/* ---- global controls bar ---- */
.l-controls { position: sticky; top: calc(var(--l-chrome-h) + 4px); z-index: 50; display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 20px; }
.l-controls .l-ctl-label { font-size: .8rem; color: var(--muted); margin-right: 2px; }
.l-privacy-note { font-size: .72rem; color: var(--muted); line-height: 1.25; }
.l-data-toggle { margin-left: auto; }
.l-btn { font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; padding: 6px 12px;
  border-radius: 8px; border: 1px solid var(--border-hl); background: var(--surface); color: var(--text); }
.l-btn:hover { border-color: var(--accent); color: var(--accent-hover); }
.l-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #08111e); }
.l-btn:disabled { cursor: not-allowed; opacity: .55; }

/* ---- sections ---- */
.l-sec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px 22px; margin: 0 0 18px; }
.l-sec[id], .l-head[id] { scroll-margin-top: calc(var(--l-chrome-h) + 60px); }
.l-sec > h2 { font-size: 1.2rem; margin: 0 0 4px; display: flex; align-items: center; gap: 9px; }
.l-sec > .l-sec-sub { color: var(--text2); font-size: .9rem; margin: 0 0 14px; }
.l-step { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; font-size: .82rem;
  letter-spacing: .04em; text-transform: uppercase; }
.l-sec p, .l-sec li { line-height: 1.65; color: var(--text); }
.l-prose { font-size: 1rem; }

/* ---- SEL / PBIS callouts ---- */
.l-sel { border-left: 4px solid var(--l-sel); background: var(--tag-red-bg); border-radius: 10px;
  padding: 14px 16px; margin: 14px 0; }
.l-sel h3 { margin: 0 0 6px; font-size: .98rem; color: var(--l-sel); }
.l-expect { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.l-expect li { font-size: .82rem; padding: 4px 10px; border-radius: 999px; background: var(--pill-bg);
  border: 1px solid var(--border); }

/* ---- phenomenon ---- */
.l-phenom { border: 1px solid var(--border-hl); border-radius: 12px; overflow: hidden; }
.l-phenom figure { margin: 0; background: var(--surface2); }
.l-phenom figure img, .l-phenom figure svg { width: 100%; height: auto; display: block; }
.l-phenom figcaption { font-size: .85rem; color: var(--text2); padding: 8px 14px; }
.l-wonder { padding: 14px 16px; }

/* ---- worked example (fading support) ---- */
.l-worked { border: 1px dashed var(--border-hl); border-radius: 12px; padding: 16px; background: var(--l-soft); margin: 14px 0; }
.l-worked .l-worked-label { font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }

/* ---- response choice ---- */
.l-choice { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.l-choice .l-chip { font-size: .82rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--pill-bg); color: var(--text2); }

/* ---- support tiers (details/summary) ---- */
.l-support { border-radius: 10px; border: 1px solid var(--border); margin: 10px 0; overflow: hidden; }
.l-support > summary { cursor: pointer; list-style: none; padding: 10px 14px; font-weight: 600; font-size: .9rem;
  display: flex; align-items: center; gap: 9px; background: var(--surface2); }
.l-support > summary::-webkit-details-marker { display: none; }
.l-support > summary::before { content: "+"; font-weight: 700; width: 1em; }
.l-support[open] > summary::before { content: "\2212"; }
.l-support .l-support-body { padding: 12px 16px; }
.l-support.t2 { border-left: 4px solid var(--l-tier2); }
.l-support.t3 { border-left: 4px solid var(--l-tier3); }
.l-support.ext { border-left: 4px solid var(--l-ext); }
.l-support .l-pill { font-size: .68rem; padding: 2px 8px; border-radius: 999px; font-weight: 700; margin-left: auto; }
.l-support.t2 .l-pill { background: var(--tag-green-bg); color: var(--l-tier2); }
.l-support.t3 .l-pill { background: var(--tag-amber-bg); color: var(--l-tier3); }
.l-support.ext .l-pill { background: rgba(185,138,255,.16); color: var(--l-ext); }

/* sentence frames / organizers */
.l-frame { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; margin: 8px 0; font-style: italic; color: var(--text2); }

/* ---- self-check (branching) ---- */
.l-check { border: 1px solid var(--border-hl); border-radius: 12px; padding: 16px; }
.l-success { background: var(--l-soft); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.l-success ul { margin: 6px 0 0; padding-left: 1.2em; }
.l-q { margin: 14px 0; }
.l-opt { display: block; width: 100%; text-align: left; margin: 6px 0; padding: 10px 14px; cursor: pointer;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font: inherit; }
.l-opt:hover { border-color: var(--accent); }
.l-feedback { margin-top: 10px; padding: 12px 14px; border-radius: 8px; display: none; }
.l-feedback.show { display: block; }
.l-feedback.good { background: var(--tag-green-bg); border: 1px solid rgba(76,199,100,.3); }
.l-feedback.notyet { background: var(--tag-amber-bg); border: 1px solid rgba(224,168,50,.3); }

/* ---- brain break ---- */
.l-break { text-align: center; background: var(--tag-red-bg); border: 1px dashed var(--l-sel);
  border-radius: 12px; padding: 16px; margin: 18px 0; }
.l-break h3 { margin: 0 0 6px; color: var(--l-sel); font-size: 1rem; }

/* ---- exit ticket ---- */
.l-exit ol { padding-left: 1.3em; }
.l-exit li { margin: 8px 0; }
.l-exit .l-spiral { font-size: .72rem; color: var(--l-tier2); font-weight: 700; }
.l-exit .l-transfer { font-size: .72rem; color: var(--l-ext); font-weight: 700; }

/* ---- educator panel ---- */
.l-educator { margin-top: 26px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.l-educator > summary { cursor: pointer; padding: 14px 18px; font-weight: 700; background: var(--surface2);
  display: flex; align-items: center; gap: 9px; }
.l-educator > summary::-webkit-details-marker { display: none; }
.l-educator .l-educator-body { padding: 18px; }
.l-iep { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 10px 0; }
.l-iep h3, .l-iep h4 { margin: 0 0 8px; font-size: .95rem; }
.l-iep table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.l-iep th, .l-iep td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.l-iep th { color: var(--muted); font-weight: 600; }
.l-educator-body, .l-support-body { min-width: 0; }
.l-iep { overflow-x: auto; }
.l-table-scroll { max-width: 100%; overflow-x: auto; border-radius: 8px; scrollbar-gutter: stable; }
.l-table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---- simplified-text swap ---- */
[data-simplified] { display: none; }
.lesson.simplified [data-standard] { display: none; }
.lesson.simplified [data-simplified] { display: revert; }

/* ---- nav back to unit/site (reuses the curriculum breadcrumb idea) ---- */
.l-crumb { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: .85rem;
  padding: 9px 0; color: var(--muted); }
.l-crumb a { color: var(--accent); text-decoration: none; }
.l-crumb a:hover { text-decoration: underline; }
.l-crumb .sep { color: var(--muted); }

@media (max-width: 640px) {
  .l-progress-inner { align-items: flex-start; flex-direction: column; gap: 2px; padding-block: 6px; }
  .l-toc { width: 100%; }
  .l-controls { position: static; }
  .l-head { padding: 20px 18px; }
  .l-sec { padding: 18px 16px; }
  .l-btn { min-height: 42px; }
  .l-data-toggle { margin-left: 0; }
  .l-privacy-note { flex-basis: 100%; }
  .l-support > summary, .l-educator > summary { min-height: 44px; }
  .l-iep { margin-inline: -4px; padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---- print: clean worksheet, supports expanded, controls hidden ---- */
@media print {
  .l-controls, .l-progress-shell, .l-skip, .l-btn, .l-break { display: none !important; }
  .l-support[open] .l-support-body, .l-support .l-support-body { display: block !important; }
  .lesson { max-width: none; color: #000; }
  .l-sec, .l-head { break-inside: avoid; border: 1px solid #bbb; background: #fff; color: #000; }
  .l-head { background: #fff; color: #000; }
}
