/* ==========================================================================
   Odell revision: unit.css
   Single source of truth for the curriculum unit components. Loads after
   brand.css (a verbatim copy of the IAIS site stylesheet) and uses its tokens.
   Colour rules (see reference/iais_site_design.md, section 8):
   - Yellow #ffd800 only on dark green.
   - Burnt orange only on white, or as a fill with white text.
   - Every left border is a darker shade of its own background.
   ========================================================================== */

:root {
  --unit-yellow: #ffd800;
  --ai-bg: #E8ECF0;          /* tint-cool */
  --ai-border: #3d5468;      /* darker shade of the cool tint */
  --incl-bg: #F5F0E8;        /* tint-warm */
  --incl-border: #8a5609;    /* darker shade of the warm tint */
  --note-bg: #E8F0EC;        /* tint-green-light */
  --line-no: #636B73;
}

/* ---------- Unit bar (below the IAIS header, not sticky) ---------- */
.unit-bar { background: var(--primary); color: var(--bg-white); }
.unit-bar__inner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm) var(--space-xl);
  padding-block: var(--space-md); }
.unit-bar__title { color: var(--bg-white); font-weight: 700; text-decoration: none; }
.unit-bar__title:hover { color: var(--tint-green); text-decoration: underline; }
.unit-bar__title span { color: var(--unit-yellow); }
.unit-bar ul { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-md); list-style: none; margin: 0; padding: 0; }
.unit-bar a { color: var(--bg-white); }
.unit-bar ul a { display: inline-block; padding: var(--space-xs) var(--space-sm); border-radius: var(--border-radius-sm);
  text-decoration: none; min-height: 24px; }
.unit-bar ul a:hover { background: rgba(255,255,255,0.12); text-decoration: underline; }
.unit-bar ul a[aria-current="page"] { background: var(--unit-yellow); color: var(--primary); font-weight: 700; }
.unit-bar { --ring: var(--bg-white); }

/* ---------- Page hero ---------- */
.page-hero { background: var(--bg-grad); border-bottom: var(--border-subtle); padding-block: var(--space-3xl) var(--space-2xl); }
.page-hero h1 { font-size: clamp(1.8rem, 3vw + 1rem, 2.5rem); margin: 0 0 var(--space-md); }
.page-hero .intro { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-sm); list-style: none; padding: 0; margin: var(--space-lg) 0 0; }
.chips li { background: var(--bg-white); border: 1px solid var(--secondary); border-radius: var(--border-radius-pill);
  padding: var(--space-xs) var(--space-md); font-size: var(--text-sm); color: var(--text-primary); }
.chips li strong { color: var(--primary); }

/* ---------- Layout for long pages: content + in-page contents ---------- */
.unit-main { padding-block: var(--space-3xl); }
.with-toc { display: grid; gap: var(--space-3xl); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) {
  .with-toc { grid-template-columns: 220px minmax(0, 1fr); }
  .toc { position: sticky; top: 88px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; }
}
.toc { font-size: var(--text-sm); }
.toc h2 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-secondary); margin: 0 0 var(--space-sm); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--tint-green); }
.toc li a { display: block; padding: var(--space-xs) var(--space-md); text-decoration: none; color: var(--text-body); }
.toc li a:hover { color: var(--primary); text-decoration: underline; }
.prose > * + * { margin-top: var(--space-lg); }
.prose h2 { margin-top: var(--space-3xl); font-size: var(--text-2xl); }
.prose h3 { margin-top: var(--space-2xl); font-size: var(--text-xl); }
.prose ul, .prose ol { padding-left: 1.4em; max-width: var(--reading-max); }
.prose li + li { margin-top: var(--space-xs); }
.prose table { max-width: 100%; }

/* ---------- Activities ---------- */
.activity { background: var(--bg-white); border: var(--border-subtle); border-radius: var(--border-radius);
  padding: var(--space-2xl); margin-top: var(--space-2xl); scroll-margin-top: 88px; }
.activity > h2 { display: flex; align-items: baseline; gap: var(--space-md); margin: 0 0 var(--space-md); font-size: var(--text-xl); }
.activity__num { flex: none; display: inline-grid; place-items: center; min-width: 2.2em; height: 2.2em; border-radius: 50%;
  background: var(--primary); color: var(--bg-white); font-size: var(--text-sm); }
.activity > * + * { margin-top: var(--space-lg); }
.activity ul, .activity ol { padding-left: 1.4em; }
.materials { display: flex; flex-wrap: wrap; gap: var(--space-sm); list-style: none; padding: 0 !important; }
.materials a { display: inline-block; background: var(--tint-green); color: var(--primary); font-weight: 700;
  font-size: var(--text-sm); padding: var(--space-xs) var(--space-md); border-radius: var(--border-radius-pill); text-decoration: none; }
.materials a:hover { text-decoration: underline; }
.questions li { margin-top: var(--space-sm); }

/* ---------- Notes and flags ---------- */
details.teacher-note { background: var(--note-bg); border-left: 4px solid var(--primary); border-radius: var(--border-radius); }
details.teacher-note > summary { cursor: pointer; padding: var(--space-md) var(--space-lg); font-weight: 700; color: var(--primary);
  list-style-position: inside; min-height: 44px; display: flex; align-items: center; }
details.teacher-note > summary::-webkit-details-marker { margin-right: var(--space-sm); }
details.teacher-note > summary::before { content: "\25B8"; margin-right: var(--space-sm); transition: transform var(--transition-fast); }
details.teacher-note[open] > summary::before { transform: rotate(90deg); }
details.teacher-note > summary { list-style: none; }
details.teacher-note > div { padding: 0 var(--space-lg) var(--space-lg); }
details.teacher-note > div > * + * { margin-top: var(--space-md); }

.flag { border-radius: var(--border-radius); padding: var(--space-lg) var(--space-xl); border-left: 4px solid; }
.flag > * + * { margin-top: var(--space-sm); }
.flag__label { display: block; font-size: var(--text-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.flag--ai { background: var(--ai-bg); border-color: var(--ai-border); }
.flag--ai .flag__label { color: var(--ai-border); }
.flag--inclusion { background: var(--incl-bg); border-color: var(--incl-border); }
.flag--inclusion .flag__label { color: var(--incl-border); }
.flag--support { background: var(--tint-green); border-color: var(--primary); }
.flag--support .flag__label { color: var(--primary); }
/* support boxes on the supported tools: clear of the buttons above and the fields below */
.tool-actions + .flag, .tool fieldset > .flag { margin-block: var(--space-lg); }

.revised { font-size: var(--text-sm); color: var(--text-muted); }
.revised a { color: var(--text-muted); }

/* ---------- Cards on the unit home ---------- */
.part-list { list-style: none; padding: 0; margin: var(--space-2xl) 0 0; display: grid; gap: var(--space-lg); }
.part-card { display: grid; grid-template-columns: auto minmax(0,1fr); gap: var(--space-lg); background: var(--bg-white);
  border: var(--border-subtle); border-radius: var(--border-radius); padding: var(--space-xl); }
.part-card:hover { box-shadow: var(--shadow-md); }
.part-card__num { width: 3rem; height: 3rem; border-radius: 50%; background: var(--primary); color: var(--unit-yellow);
  display: grid; place-items: center; font-weight: 700; font-size: var(--text-lg); }
.part-card h3 { margin: 0; font-size: var(--text-xl); }
.part-card h3 a { text-decoration: none; }
.part-card h3 a:hover { text-decoration: underline; }
.part-card p { margin: var(--space-xs) 0 0; }
.part-card .meta { font-size: var(--text-sm); color: var(--text-muted); }
.resource-grid { display: grid; gap: var(--space-xl); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: var(--space-xl); }
.resource-grid ul { padding-left: 1.2em; }

/* ---------- Speech texts ---------- */
.speech-meta { color: var(--text-secondary); }
.speech { max-width: 78ch; }
.speech .para { position: relative; margin: var(--space-xl) 0 0; padding-top: var(--space-sm); border-top: 1px solid rgba(46,78,66,0.10); scroll-margin-top: 88px; }
.para__label { display: inline-block; font-size: var(--text-sm); font-weight: 700; color: var(--primary);
  background: var(--tint-green); border-radius: var(--border-radius-pill); padding: 0 var(--space-sm); margin-bottom: var(--space-xs); }
.speech .line { display: block; padding-left: 3.2em; text-indent: -3.2em; line-height: 1.75; scroll-margin-top: 100px; }
.speech .ln { display: inline-block; width: 2.6em; margin-right: 0.6em; text-indent: 0; text-align: right;
  font-size: 0.8em; color: var(--line-no); font-variant-numeric: tabular-nums; user-select: none; }
.speech .ln--5 { font-weight: 700; color: var(--text-secondary); }
.speech .line:target { background: #fff6bf; outline: 2px solid var(--primary); outline-offset: 2px; }
.speech .gl { font-weight: 700; text-decoration: underline dotted; text-underline-offset: 0.2em; }
.gloss { margin: var(--space-sm) 0 0 3.2em; font-size: var(--text-sm); background: var(--bg-light); border-left: 3px solid var(--primary-light);
  border-left-color: #9fbfb3; padding: var(--space-sm) var(--space-md); border-radius: var(--border-radius-sm); }
.gloss dl { margin: 0; }
.gloss dt { display: inline; font-weight: 700; }
.gloss dd { display: inline; margin: 0; }
.gloss dd::after { content: ""; display: block; }
.line-toggle { margin-top: var(--space-lg); }
.hide-minor .ln:not(.ln--5) { visibility: hidden; }

/* ---------- Tools (fillable) ---------- */
.tool-actions { display: flex; flex-wrap: wrap; gap: var(--space-md); align-items: center; margin-top: var(--space-lg); }
.tool-actions .save-status { font-size: var(--text-sm); color: var(--text-muted); }
button.btn { cursor: pointer; font-family: inherit; }
.tool { margin-top: var(--space-2xl); }
.tool fieldset { border: 1px solid var(--secondary); border-radius: var(--border-radius); padding: var(--space-xl); margin: var(--space-xl) 0 0; background: var(--bg-white); }
.tool legend { font-weight: 700; font-size: var(--text-lg); color: var(--primary); padding: 0 var(--space-sm); }
.tool .step-hint { margin: 0 0 var(--space-md); color: var(--text-secondary); max-width: var(--reading-max); }
.tool .form-field textarea { width: 100%; min-height: 5.5em; resize: vertical; font: inherit; line-height: 1.5; }
.tool .form-field input[type="text"] { width: 100%; font: inherit; }
.field-row { display: grid; gap: var(--space-lg); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.evidence { display: grid; gap: var(--space-md); grid-template-columns: minmax(0,1fr) 9rem; align-items: start;
  border-top: 1px solid rgba(46,78,66,0.12); padding-top: var(--space-md); margin-top: var(--space-md); }
.evidence .form-field { margin-bottom: 0; }
@media (max-width: 560px) { .evidence { grid-template-columns: minmax(0,1fr); } }
.step-arrow { text-align: center; color: var(--primary); font-weight: 700; margin: var(--space-md) 0 0; }
.name-row { display: grid; gap: var(--space-lg); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- Models (completed tools, read-only) ---------- */
.model { background: var(--bg-white); border: 1px solid var(--secondary); border-radius: var(--border-radius); padding: var(--space-xl); margin-top: var(--space-xl); }
.model h2, .model h3 { margin-top: 0; }
.model table { width: 100%; }
.model-entry { font-style: italic; }

/* ---------- Tables: checklists, rubric, errata ---------- */
.data-table { width: 100%; border-collapse: collapse; background: var(--bg-white); font-size: var(--text-base); }
.data-table caption { text-align: left; font-weight: 700; padding: var(--space-sm) 0; caption-side: top; }
.data-table th, .data-table td { border: 1px solid #9aa4ad; padding: var(--space-md); text-align: left; vertical-align: top; }
.data-table thead th { background: var(--primary); color: var(--bg-white); }
.data-table tbody th { background: var(--note-bg); color: var(--text-primary); }
.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline: 2px solid var(--ring); }
.check-cell { width: 5rem; text-align: center !important; }
.check-cell input { width: 24px; height: 24px; }
.data-table textarea { width: 100%; min-height: 3em; font: inherit; border: 1px solid var(--secondary); border-radius: var(--border-radius-sm); padding: var(--space-sm); }

/* Linear rubric: one section per criterion */
.criterion { margin-top: var(--space-2xl); }
.levels { display: grid; gap: var(--space-md); grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); list-style: none; padding: 0; }
.levels li { background: var(--bg-white); border: 1px solid #9aa4ad; border-top: 4px solid var(--primary); border-radius: var(--border-radius-sm); padding: var(--space-md); }
.levels li h4 { font-size: var(--text-base); margin: 0 0 var(--space-xs); }

/* ---------- Errata ---------- */
.errata-filter { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-lg); }
.errata-filter button[aria-pressed="true"] { background: var(--primary); color: var(--bg-white); }
.cat { display: inline-block; font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px var(--space-sm); border-radius: var(--border-radius-pill); background: var(--tint-green); color: var(--primary); white-space: nowrap; }
.cat--ai-era { background: var(--ai-bg); color: var(--ai-border); }
.cat--inclusion { background: var(--incl-bg); color: var(--incl-border); }
.cat--correction { background: #ffebee; color: #a61b1b; }
del.orig { text-decoration: line-through; color: #6b3a3a; }
ins.rev { text-decoration: none; background: #e3f1e6; }

/* ---------- Attribution ---------- */
.attribution { border-top: var(--border-subtle); margin-top: var(--space-4xl); padding-top: var(--space-xl); font-size: var(--text-sm); color: var(--text-secondary); }
.attribution p { max-width: none; }
.attribution img { vertical-align: middle; margin-right: var(--space-sm); }
.site-footer { margin-top: var(--space-2xl); }

/* ---------- /literacy-units/ case study and sign-up ---------- */
.page-hero .btn { margin-top: var(--space-lg); }
.before-after dt { font-weight: 700; }
.before-after dd { margin: 0 0 var(--space-md); }
.before-after dd:last-child { margin-bottom: 0; }
.signup { background: var(--bg-white); border: 1px solid var(--secondary); border-radius: var(--border-radius); padding: var(--space-2xl); }
.signup__form { max-width: 34rem; }
.form-check { display: flex; gap: var(--space-sm); align-items: flex-start; margin-bottom: var(--space-lg); }
.form-check input { width: 24px; height: 24px; flex: none; margin-top: 2px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.signup__status { margin-top: var(--space-lg); }
.signup__status:empty { display: none; }
.signup__status--ok { background: var(--tint-green); border-left: 4px solid var(--primary); padding: var(--space-md) var(--space-lg); }
.signup__status--error { background: #ffebee; border-left: 4px solid #a61b1b; padding: var(--space-md) var(--space-lg); }

/* ---------- Print ---------- */
.print-value { display: none; }
@media print {
  .skip-link, .site-header, .unit-bar, .site-footer, .toc, .tool-actions, .line-toggle, .no-print { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .page-hero { background: none; border: 0; padding: 0 0 12pt; }
  .activity, .tool fieldset, .model { break-inside: avoid; border-color: #666; }
  .with-toc { display: block; }
  details.teacher-note > div { display: block !important; }
  .tool textarea, .tool input[type="text"], .data-table textarea { display: none; }
  .print-value { display: block; white-space: pre-wrap; min-height: 4em; border-bottom: 1px dotted #666; }
  .data-table .print-value { min-height: 2em; }
  a { color: #000; text-decoration: none; }
  /* Speeches print for annotation: every line number, one printed line per unit line (so references
     match), and room between lines to write. The Google Doc copy adds a notes column. */
  .speech { max-width: none; font-size: 10.5pt; }
  .speech .line { line-height: 2.1; white-space: nowrap; padding-left: 2.6em; text-indent: -2.6em; }
  .speech .ln { width: 2.2em; margin-right: 0.4em; }
  .hide-minor .ln:not(.ln--5) { visibility: visible; }
  .speech .para { break-inside: auto; border-top-color: #bbb; }
  .para__label { break-after: avoid; }
  .gloss { break-inside: avoid; background: none; border-left-color: #666; }
}
@media (prefers-reduced-motion: reduce) {
  details.teacher-note > summary::before { transition: none; }
}

/* ---------- Spacing fixes (after gold-standard review) ---------- */
.prose section > * + * { margin-top: var(--space-lg); }
.prose .materials li + li { margin-top: 0; }
.prose section > h3 { margin-top: var(--space-2xl); }
.resource-grid > div { background: var(--bg-white); border: var(--border-subtle); border-radius: var(--border-radius); padding: var(--space-xl); }
.resource-grid h3 { font-size: var(--text-lg); margin: 0 0 var(--space-sm); color: var(--primary); }
.resource-grid li + li { margin-top: var(--space-xs); }
.prose .levels li + li, .levels li + li { margin-top: 0; }
.tool h2 { font-size: var(--text-xl); margin-top: var(--space-2xl); }
.tool h3, .tool fieldset h3 { font-size: var(--text-lg); margin: var(--space-lg) 0 var(--space-sm); }
