/* Themes tab — home-style guided tour of the Next-steps classification.

   Reuses the landing kit (the fk-band / lp-step / lp-hero / lp-hero-dark
   recipes shared with styles/tabs/home.css — all global selectors), like
   styles/tabs/rise.css. This file adds:
     - the #tab-themes full-bleed padding hook (home scopes its own),
     - the story-page atoms (headline figures, chart heads, capped chart
       column, the dark-band CTA links), and
     - the lens filter bar + toolkit chart styles carried over from the
       pre-rebuild tab (the chips and per-area chart scaffolding are
       unchanged).
   Themes joins FULL_BLEED_TABS (js/index.js), so body.home-fullbleed
   already zeroes the .main-inner gutters + hides the filter chrome.
   Tokens only — see CLAUDE.md "Tokens, not literals". */

/* Full-bleed: the gutter/width rules are global on body.home-fullbleed;
   only the tab-content padding is home-scoped, so mirror it here. */
#tab-themes.tab-content { padding: 0; }

.themes-tab { display: flex; flex-direction: column; }

/* ── Page filter cog bar (under the hero) ─────────────────────────────
   A single page-level cog (chart-customise recipe, components.css) that
   narrows every band to a cohort — phase / region / school / lowest grade
   (see js/tabs/themes.js). Full-bleed strip; the inner wrapper aligns to
   the same 1400px centered content column as .fk-band > .lp-step, and its
   inline padding mirrors .fk-band (56px, shrinking to --space-6 on narrow).
   .lp-cohort / .lp-cog-clear are the home.css cohort-summary atoms (global
   selectors, loaded site-wide). Tokens only. */
.th-cog-bar { padding-inline: 56px; }
.th-cog-bar-inner {
  max-width: 1400px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--rule);
}
.th-cog-bar-spacer { flex: 1 1 auto; }
@media (max-width: 1199px) {
  .th-cog-bar { padding-inline: var(--space-6); }
}

/* ── Headline figures (band 01) — the rise-figs recipe ───────────── */
.th-figs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-7);
  margin-bottom: var(--space-5);
}
.th-fig { display: flex; flex-direction: column; gap: var(--space-1); }
.th-fig-n {
  font-family: "Charter", "Iowan Old Style", "Cambria", Georgia, serif;
  font-weight: 600;
  font-size: var(--text-xl);
  line-height: var(--lh-tight);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.th-fig-l {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--track-eyebrow);
  color: var(--ink-3);
  font-weight: 600;
}

/* ── Chart column + per-chart head ────────────────────────────────
   Charts sit directly on the band background (no card chrome). The
   column caps at the Plot spec width so the responsive SVG doesn't
   stretch across the whole 1000px+ content track at wide viewports. */
.th-chart { max-width: 780px; }
.th-chart-head { margin: var(--space-5) 0 var(--space-2); }
.th-chart-head:first-child,
.th-figs + .th-chart-head { margin-top: 0; }
.th-chart-head .eyebrow { margin-bottom: var(--space-1); }
.th-chart-sub {
  font-size: var(--text-sm);
  line-height: var(--lh-base);
  color: var(--ink-3);
  margin: 0;
  max-width: 70ch;
}
/* Grade legend under the toolkit-by-grade chart (band 05). */
.themes-tab .lp-step-content > .legend { margin-top: var(--space-3); }

/* Live count above the lens bar (band 07). */
.th-lens-count {
  font-size: var(--text-sm);
  color: var(--ink-2);
  margin: 0 0 var(--space-3);
}
.th-lens-count strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ── Closing dark band — CTA links on navy ────────────────────────
   The home chip-link recipe re-inked for the --surface-strong band
   (--accent is invisible on its own navy). */
.th-cta-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-6);
  padding-top: var(--space-4);
}
.th-dark-link {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--surface-strong-ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--surface-strong-ink) 45%, transparent);
  padding-bottom: 1px;
}
.th-dark-link:hover { border-bottom-color: var(--surface-strong-ink); }
.th-dark-link:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
  border-radius: 3px;
}

/* ── Lens filter bar — carried over from the pre-rebuild tab ──────

   Hierarchy:
   - .lens-bar — the bordered container card with the title and
     Reset button at the top, then one <details> per lens below.
   - .lens-section — a single lens's collapsible group, with a
     rotating ▸ caret and an explainer block (.lens-explain) that
     describes what the lens is filtering on.
   - .lens-group / .lens-group-title — sub-groupings of chips
     within a single lens (e.g. polarity, severity).
   - .lens-chip — the individual filter chip. Hard-coded
     border-radius:999px and padding:4px 10px; both want to migrate
     to var(--r-full) + var(--space-1/2) when the component
     primitive lands.

   Migration follow-ups (per the audit):
   - .lens-chip hardcodes hex-free colour but its on-state mixes
     surface-strong-ink across themes — keep an eye on dark-mode
     contrast.

   Audit A20 (.lens-info should be a <button>) — resolved: the
   element is now a `<button type="button">` (see tabs/themes.js). */

/* Next-steps insights: lens filter bar + chips */
.lens-bar {
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--r-md); padding: 18px 22px; margin-bottom: var(--space-6);
  box-shadow: var(--shadow);
}
.lens-bar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-3);
}
.lens-bar-title {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--track-eyebrow);
  color: var(--ink-3); font-weight: 600; margin: 0;
}
.lens-section {
  border-top: 1px dashed var(--rule); padding: 12px 0;
}
.lens-section[open] { padding-bottom: 14px; }
/* Disclosure chrome (summary list-style suppression, caret ▸,
   [open] rotate, caret hover-darken) is provided by the
   `.disclosure` primitive in components.css — JS composes
   `class="disclosure lens-section"`. The 10px gap below is
   intentional UI spacing wider than the primitive's default 6px
   (the lens row sits more open than e.g. a chart-notes summary),
   so it stays as a tab-specific override. */
.lens-section > summary {
  gap: 10px;
  padding: 4px 0;
}
.lens-section > summary:hover { color: var(--ink); }
.lens-name {
  font-size: 13px; font-weight: 600; color: var(--ink);
}
/* @applies-to button */
.lens-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--rule-2); color: var(--ink-2);
  font: inherit;
  font-size: var(--text-xs); font-weight: 600;
  border: 0; padding: 0;
  cursor: pointer;
  user-select: none;
}
.lens-info:hover { background: var(--ink-3); color: #fff; }
.lens-selected {
  font-size: 11px; color: var(--ink-3); margin-left: auto;
}
.lens-explain {
  font-size: 13px; color: var(--ink-2); line-height: 1.5;
  margin: 8px 0 12px; padding: 10px 12px;
  background: var(--paper-2); border-radius: var(--r-sm);
  border-left: 3px solid var(--accent);
}

.lens-group { margin-top: 10px; }
/* lens-group-title visual now provided by the .eyebrow primitive
   in base.css. */
.lens-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: var(--space-2);
}
/* @applies-to button */
.lens-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--rule); background: var(--card);
  color: var(--ink-2); border-radius: var(--r-full);
  padding: 4px 10px; font-size: 12px; cursor: pointer;
  font-family: inherit;
  transition: background .1s, color .1s, border-color .1s;
}
.lens-chip:hover:not(.dim) {
  border-color: var(--ink-3); color: var(--ink);
}
.lens-chip.on {
  background: var(--surface-strong); color: var(--surface-strong-ink); border-color: var(--surface-strong);
}
.lens-chip.dim { opacity: 0.4; cursor: default; }
.lens-chip-count {
  font-variant-numeric: tabular-nums; font-size: 11px;
  color: var(--ink-3);
}
.lens-chip.on .lens-chip-count { color: rgba(255,255,255,.7); }

/* ────────────────────────────────────────────────────────────
   Toolkit-by-area chart styles. The .toolkit-area-* selectors
   group bars by inspection area (each area has a dot picking up
   its palette colour).
   ──────────────────────────────────────────────────────────── */

/* Toolkit-by-area chart on the Themes tab. Each of the nine
   inspection areas gets a labelled group of horizontal bars;
   the area dot picks up the area's palette colour so the bars
   within an area read as a visual cluster. */
.toolkit-area-group,
.toolkit-grade-section {
  margin: 12px 0 18px;
}
.toolkit-area-group:first-child,
.toolkit-grade-section:first-child {
  margin-top: 0;
}
/* Eyebrow recipe (uppercase / weight / size / track / colour)
   comes from .eyebrow in base.css; this rule carries the area-row
   specifics: the flex layout for the dot + label + count, the
   slightly tighter bottom margin, and the underline that separates
   each area's bar group. Colour overridden to --ink-2 so the area
   title reads a touch darker than the canonical eyebrow. */
.toolkit-area-title {
  color: var(--ink-2);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule-2);
}
/* Per-area legend dot — colour driven by a hyphenated CSS custom
   property pass-through (`--th-dot`) set inline by the renderer.
   The fallback to `currentColor` covers the unusual case where a
   caller forgets to set it; falls back to readable contrast on the
   neutral grey eyebrow. Same recipe as `.legend .dot` / `--dot-bg`
   in components.css. */
.toolkit-area-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--th-dot, currentColor);
}
.toolkit-area-count {
  color: var(--ink-3);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  margin-left: auto;
  cursor: help;
}
/* Optional second clause inside the per-area count — only rendered
   when the distinct-bullet count diverges from the factor-occurrence
   sum (multi-class bullets in that area). Mutes the suffix so the
   primary "N factor occurrences" reads first. */
.toolkit-area-count-distinct {
  color: var(--ink-3);
  opacity: 0.85;
}

/* Observable Plot mount points for the migrated toolkit charts.
   .tba-plot = one per area in renderToolkitByArea.
   .tbg-plot = one per area in renderToolkitByGrade.
   Both contain SVGs rendered by renderPlot(); they need no style of
   their own — the SVG sizes itself via the Plot spec width/height and
   the .ofsted-chart className on the SVG element carries the shared
   ink/rule palette from components.css. */
.tba-plot,
.tbg-plot {
  display: block;
  overflow: visible;
}
/* Column header above the toolkit-by-grade sections: left label
   column (blank — the area title above it acts as the heading) +
   right "% Attention−" label aligned with the Plot text marks. */
.tbg-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 10px;
}
.tbg-header-pct {
  font-size: var(--text-xs);
  color: var(--ink-3);
  font-weight: 500;
  white-space: nowrap;
  cursor: help;
  text-align: right;
  min-width: 55px;
}
