/* Cognition Blueprint — Cinematic Design Module
 * Scoped to LMS pages via the `cb-lms` body class so it never bleeds into the
 * rest of the site or fights the active theme. Dark by default; `cb-light` for
 * parchment mode. Accent colour is injected as --cb-accent by the plugin.
 *
 * :not(.am-focus, .am-focus *) on the three token-setting rules below —
 * TWO-SWITCHES RECONCILIATION (card, 31 Jul 2026). This module's own
 * `.cb-lms` is meant for the surfaces its header comment names (course
 * landing, cart, account, dashboard) via a STATIC body class, same as the
 * theme's bridge (style.css). But some focus-mode components carry
 * `cb-lms` on themselves too (e.g. `class-am-quiz-render.php`'s
 * `<div class="am-quiz cb-lms">`, nested inside `body.am-focus`), so this
 * module's dark-default directly matched them regardless of either scheme
 * switch — caught by the pixel-conservation screenshot-diff proof after
 * the style.css bridge fix stopped masking it (data-theme used to win on
 * these elements by higher specificity; once it no longer matched, THIS
 * module's unconditional default won instead, painting them dark even in
 * matched-light). Excluding `.am-focus` and its descendants here lets
 * `body.am-focus.cb-light`/`.cb-dark` (focus.css) reach them by ordinary
 * inheritance instead. See DESIGN-STANDARD §6a-bis.
 */

.cb-lms:not(.am-focus, .am-focus *) {
	--cb-accent: #d4af37;
	--cb-ink: #0f0e0c;
	--cb-surface: #17150f;
	--cb-surface-2: #1f1c15;
	--cb-line: rgba(212, 175, 55, 0.18);
	--cb-text: #ece7da;
	--cb-prose: #ece7da;
	--cb-muted: #a39c8a;
	/* THE TYPE SYSTEM — MIRROR of modules/design/assets/type.css. Byte-identical
	 * values, asserted by test-type-system.mjs. Do not edit one without the
	 * other. As of 0.45.49 --cb-display and --cb-body are THE SAME FACE — IBM
	 * Plex Serif — which reverses 0.45.36's pairing; --cb-sans is IBM Plex Sans
	 * and carries the chrome, so the three tokens still name three jobs. The
	 * `font-optical-sizing: none` line that used to sit here is GONE: it pinned
	 * Inter's opsz axis and no IBM Plex family has one. */
	--cb-display: "IBM Plex Serif", Georgia, "Times New Roman", serif;
	--cb-body: "IBM Plex Serif", Georgia, "Times New Roman", serif;
	--cb-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--cb-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.cb-lms.cb-light:not(.am-focus, .am-focus *) {
	--cb-ink: #f4f1ea;
	--cb-surface: #ffffff;
	--cb-surface-2: #faf7ef;
	--cb-line: rgba(26, 26, 26, 0.12);
	--cb-text: #1c1a16;
	/* 🔴 --cb-prose — BODY PROSE INK, Kevin's ruling of 7 Aug 2026: #3A3A3A.
	 * SEPARATE FROM --cb-text on purpose. The reference card Kevin endorsed
	 * runs #1A1A1A for titles against #4A4A4A for body, and softening the
	 * running text while headings stay full-strength is half of what he liked
	 * about it. Repointing --cb-text would have softened the headings too,
	 * which is the opposite. Dark mode keeps --cb-text: the ruling was made on
	 * a light page and inventing a dark value would be a design decision this
	 * card was not given. */
	--cb-prose: #3A3A3A;
	--cb-muted: #6b6457;
}

/* ---- Page canvas ---- */
.cb-lms.cb-dark:not(.am-focus, .am-focus *),
.cb-lms.cb-dark:not(.am-focus, .am-focus *) .am-page {
	background: radial-gradient(120% 120% at 50% 0%, #1b1810 0%, var(--cb-ink) 60%);
	color: var(--cb-text);
}

.cb-lms .am-page,
.cb-lms .am-dashboard,
.cb-lms .am-course-outline,
.cb-lms .am-catalogue {
	font-family: var(--cb-body);
	font-size: var(--cb-t1);   /* T1 · was T2, retired 0.45.50 */
	line-height: var(--cb-lh-read);
	color: var(--cb-text);
	max-width: 880px;
	margin: 0 auto;
	padding: 2.4rem 1.4rem 4rem;
}

/* ---- Typography ---- */
.cb-lms h1,
.cb-lms h2,
.cb-lms h3,
.cb-lms .am-dash-title,
.cb-lms .am-module-title {
	font-family: var(--cb-display);
	font-weight: 700;
	letter-spacing: 0.2px;
	line-height: var(--cb-lh-head);
}

/* 🔴 THE AUTHOR'S COLOUR WINS — B, 29 Aug 2026. The full measurement and
 * the reasoning are at the light/dark blankets below; this is the same
 * law applied to the one other rule that paints bare headings.
 *
 * `color` is SPLIT OUT of the rule above and guarded, so colouring a
 * heading — or anything wrapping one — is not silently eaten. Font,
 * weight, tracking and leading stay unguarded: they are the design
 * system's, and an author who picked a colour did not ask to lose the
 * typeface.
 *
 * Written out per selector, NOT folded into one `:is()`, so each of the
 * five keeps the exact specificity it had — (0,1,1) for the three
 * elements, (0,2,0) for the two classes. `:where()` is worth zero, so the
 * guard filters without moving anything. Verified in Chromium via
 * CSS.getMatchedStylesForNode, not predicted. */
.cb-lms h1:where(:not(.has-text-color):not(.has-text-color *)),
.cb-lms h2:where(:not(.has-text-color):not(.has-text-color *)),
.cb-lms h3:where(:not(.has-text-color):not(.has-text-color *)),
.cb-lms .am-dash-title:where(:not(.has-text-color):not(.has-text-color *)),
.cb-lms .am-module-title:where(:not(.has-text-color):not(.has-text-color *)) {
	color: var(--cb-text);
}

/* 🔴 THESE ARE THE RULES THAT DEFEATED THE RAIL. `.cb-lms h1, h2, h3…` at
 * (0,1,1) took the FACE and the TRACKING off `.am-focus-module-title` and made
 * it a Playfair display serif at 11.52px for the whole life of the design
 * (NAV-CHROME §1). They stay — removing them is a separate card with its own
 * blast radius — but they are now ON THE SCALE, so when they win they win with
 * a step rather than with a locally-chosen clamp. */
.cb-lms h1 { font-size: var(--cb-t7); }   /* 0.45.50 · the title step */
.cb-lms h2 { font-size: var(--cb-t6); }   /* 0.45.50 · was T5 */

.cb-lms .am-dash-title,
.cb-lms .am-course-outline > h2 {
	position: relative;
	padding-bottom: 0.6rem;
	margin-bottom: 1.6rem;
}
.cb-lms .am-dash-title::after,
.cb-lms .am-course-outline > h2::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 64px;
	height: 3px;
	background: var(--cb-accent);
}

/* Lesson body content (rendered through the theme) */
.cb-lms .am-lesson-controls,
.cb-lms .entry-content,
.cb-lms .lesson-content {
	font-family: var(--cb-body);
	font-size: var(--cb-t3);
	line-height: var(--cb-lh-read);
}

.cb-lms blockquote {
	border-left: 3px solid var(--cb-accent);
	margin: 1.8rem 0;
	padding: 0.4rem 0 0.4rem 1.4rem;
	font-style: italic;
}
/* Same guard, same reason — see the blankets below. */
.cb-lms blockquote:where(:not(.has-text-color):not(.has-text-color *)) {
	color: var(--cb-text);
}

.cb-lms .am-eyebrow,
.cb-lms .am-progress-label,
.cb-lms .am-lesson-dur,
.cb-lms .am-cat-price {
	font-family: var(--cb-sans);
	font-size: var(--cb-t1);
	letter-spacing: 1.5px;
	text-transform: uppercase;
}

/* ---- Buttons ---- */
.cb-lms .am-btn {
	font-family: var(--cb-sans);
	font-size: var(--cb-t1);
	letter-spacing: 1px;
	text-transform: uppercase;
	padding: 0.85rem 1.6rem;
	border-radius: 2px;
	background: transparent;
	border: 1px solid var(--cb-line);
	color: var(--cb-text);
	transition: all 0.18s ease;
}

.cb-lms .am-btn-gold {
	background: linear-gradient(180deg, #e6c14e, var(--cb-accent));
	border-color: var(--cb-accent);
	color: #1a1508;
	font-weight: 500;
	box-shadow: 0 6px 22px rgba(212, 175, 55, 0.22);
}

.cb-lms .am-btn-gold:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 30px rgba(212, 175, 55, 0.34);
}

/* ---- Cards (dashboard + catalogue) ---- */
.cb-lms .am-course-card,
.cb-lms .am-catalogue-card {
	background: linear-gradient(180deg, var(--cb-surface-2), var(--cb-surface));
	border: 1px solid var(--cb-line);
	border-radius: 10px;
	padding: 1.8rem 2rem;
	margin-bottom: 1.4rem;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.cb-lms.cb-light .am-course-card,
.cb-lms.cb-light .am-catalogue-card {
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.cb-lms .am-catalogue {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 1.4rem;
	max-width: 1000px;
}

.cb-lms .am-catalogue-card img {
	border-radius: 6px;
	margin-bottom: 0.8rem;
}

/* ---- Progress bar ---- */
.cb-lms .am-progress-bar {
	height: 8px;
	background: rgba(255, 255, 255, 0.08);
	border-radius: 6px;
	overflow: hidden;
	margin: 0.8rem 0 0.4rem;
}
.cb-lms.cb-light .am-progress-bar { background: rgba(0, 0, 0, 0.08); }

.cb-lms .am-progress-bar span {
	background: linear-gradient(90deg, #b8932e, var(--cb-accent));
	box-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
}

.cb-lms .am-progress-label { color: var(--cb-muted); }

/* ---- Lesson outline ---- */
.cb-lms .am-module-title {
	border-bottom: 1px solid var(--cb-line);
	padding-bottom: 0.5rem;
	margin-top: 2rem;
}

.cb-lms .am-lesson-item {
	border-bottom: 1px solid var(--cb-line);
	padding: 0.7rem 0;
}

.cb-lms .am-lesson-item a {
	color: var(--cb-text);
	text-decoration: none;
}
.cb-lms .am-lesson-item a:hover { color: var(--cb-accent); }

.cb-lms .am-lesson-status { color: var(--cb-accent); }
.cb-lms .am-lesson-item.is-complete a { color: var(--cb-muted); }
.cb-lms .am-lesson-dur { color: var(--cb-muted); }

/* ---- Lesson UI: web app slot, complete, buy, locked ---- */
.cb-lms .am-webapp-slot {
	border: 1px solid var(--cb-line);
	border-radius: 10px;
	overflow: hidden;
	margin: 2.4rem 0;
	background: var(--cb-surface);
}

.cb-lms .am-complete-lesson {
	margin: 3rem 0;
	text-align: center;
	padding-top: 2rem;
	border-top: 1px solid var(--cb-line);
}

.cb-lms .am-done-badge {
	font-family: var(--cb-sans);
	font-size: var(--cb-t1);
	letter-spacing: 1.5px;
	text-transform: uppercase;
	background: rgba(212, 175, 55, 0.12);
	color: var(--cb-accent);
	border: 1px solid var(--cb-line);
	padding: 0.5rem 1rem;
	border-radius: 2px;
}

.cb-lms .am-buy-form { margin: 1.4rem 0; }

.cb-lms .am-locked-notice {
	background: rgba(212, 175, 55, 0.08);
	border: 1px solid var(--cb-line);
	border-left: 3px solid var(--cb-accent);
	border-radius: 6px;
	padding: 1rem 1.3rem;
	color: var(--cb-text);
	font-family: var(--cb-body);
}

.cb-lms .am-empty { color: var(--cb-muted); }

/* ---- Dark-mode hardening ----
 * When the dark canvas applies but the active theme paints its own (dark)
 * text/link/button colours into the content, force readable colours for
 * everything inside the LMS scope. Fixes dark-on-dark under light themes.
 */
/* 🔴 THE AUTHOR'S COLOUR WINS — B, 29 Aug 2026, measured not predicted.
 *
 * THE BUG. Core emits `.has-gold-color { color: … !important }`, so an
 * author who colours a PARAGRAPH gets their colour. An author who colours
 * a CONTAINER — a section panel, or anything wrapping a run — gets
 * nothing, because these blankets set `color` DIRECTLY on every p / li /
 * heading / cell inside it, and a direct declaration beats inheritance at
 * ANY specificity. The author's choice was not out-ranked; it never
 * entered the contest. That is why it looked like a broken control rather
 * than a cascade loss.
 *
 * WHAT IT COST, measured in Chromium against the real stylesheet stack
 * (design.css + focus.css + patterns.css + type.css + lesson-components.css
 * + core's emitted preset classes): a container carrying
 * `has-ink-background-color has-text-light-color` painted #141210 behind
 * text these blankets forced to #1c1a16. Near-black on near-black. The
 * design system was not protecting legibility there; it was destroying it,
 * silently. 18 of the 19 generic elements tested were affected.
 *
 * THE :where(:not(.has-text-color):not(.has-text-color *)). `:where(:not(.has-text-color):not(.has-text-color *))` — the
 * blanket steps aside for an element the author coloured and for anything
 * inside one, and applies exactly as before everywhere else.
 *
 * WHY `:where()` AROUND THE `:not()`, and not a bare `:not()`: `:not()`
 * contributes the specificity of its most specific argument, which would
 * lift these rules from (0,2,2) to (0,3,2) and put them above rules
 * nobody re-measured. `:where()` is worth zero, so the selector filters
 * MORE while weighing the SAME. Confirmed with
 * CSS.getMatchedStylesForNode: still (0,2,2) after the change, and the
 * (0,4,0) component rules named in lesson-components.css's cascade-floor
 * note still win — the eyebrow measured gold + mono before and after.
 *
 * The `:is()` list is exact here because every argument is an element, so
 * the group's specificity is the same (0,0,1) each selector carried
 * alone. The typography rule above cannot use `:is()` for that reason —
 * it mixes elements and classes — and is written out instead.
 *
 * NOT :where(:not(.has-text-color):not(.has-text-color *))ED, deliberately: `background` and `font-family`. Backgrounds
 * do not inherit, so they were never in this fight — an author's ground
 * already reached the page. The typeface is the design system's, and an
 * author picking a colour did not ask to lose it. Both measured winning
 * before the change and still win after it.
 *
 * NOT OVERRIDDEN, deliberately: the customer's THEME. theme.json's
 * `elements.heading.color` paints headings inside a coloured container
 * from `:root :where(h1…)`, and after this change that rule is what a
 * nested heading takes. That is WordPress behaving as WordPress on every
 * site; the theme owns the palette (see D); and the author's remedy is to
 * colour the heading itself, which works. We stop overriding the AUTHOR.
 * We do not start overriding their THEME. */
body.cb-lms.cb-dark
	:is(h1, h2, h3, h4, h5, p, li, label, legend, td, th, blockquote, figcaption):where(:not(.has-text-color):not(.has-text-color *)) {
	color: var(--cb-text);
}

/* 🔴 :not(.cb-spine, .cb-spine *) — L8 SHAPE FIX (card, 3 Aug 2026).
 *
 * The Two-Switches card (31 Jul) scoped this module's TOKEN rules away
 * from focus mode but left this "dark-mode hardening" block unscoped, so
 * on a lesson (`body.am-focus.cb-lms.cb-dark` — confirmed live) these
 * rules still reach in. Every other rule in this block sits below the
 * (0,4,0) cascade floor and loses harmlessly. This one does not: `:not()`
 * carries its argument's specificity, so it computes (0,5,2) and beats
 * the floor — the first rule in the estate to do so, and the sixth
 * recurrence of "the theme repaints links".
 *
 * Measured on staging lesson 336 in dark, before → after:
 *   .cb-app-embed__open   #c8a96e 8.33:1 → --cb-band-text #ece7da 15.14:1
 *   .cb-downloads__btn    #c8a96e 8.13:1 → --cb-text      #ece7da 14.78:1
 * (the downloads pill draws `border: solid currentColor`, so its BORDER
 * was gold too — that component had the same defect and was never
 * reported.) Neither failed a contrast floor; both defeated a component's
 * deliberate refusal of gold on its only interactive control.
 *
 * Author-written prose links INSIDE components are deliberately NOT
 * affected: `focus.css`'s `.am-focus-body a` at (0,1,1) already paints
 * them, so narrowing this rule hands them over rather than stripping
 * them — measured live, identical rgb before and after. Light is
 * untouched by construction (this rule is `.cb-dark`-scoped).
 *
 * ⚑ FLAGGED, NOT FIXED: the `:hover` rule below is (0,4,2) and loses to
 * this rule's (0,5,2) — dark link hover is inert across the WHOLE cb-lms
 * surface (dashboard, catalogue, course landing), not just lessons.
 * Pre-existing, wider than this card, owner-deferred to its own card. */
body.cb-lms.cb-dark a:not(.am-btn):not(.wp-element-button):not(.wp-block-button__link):not(.cb-spine, .cb-spine *) {
	color: var(--cb-accent);
}
body.cb-lms.cb-dark a:not(.am-btn):hover {
	color: var(--cb-text);
}

body.cb-lms.cb-dark .wp-element-button,
body.cb-lms.cb-dark .wp-block-button__link {
	background: var(--cb-accent);
	color: #141210;
	border-color: var(--cb-accent);
}

body.cb-lms.cb-dark input[type="text"],
body.cb-lms.cb-dark input[type="email"],
body.cb-lms.cb-dark input[type="password"],
body.cb-lms.cb-dark input[type="number"],
body.cb-lms.cb-dark input[type="search"],
body.cb-lms.cb-dark textarea,
body.cb-lms.cb-dark select {
	background: var(--cb-surface-2);
	color: var(--cb-text);
	border: 1px solid var(--cb-line);
}

/* Mirror: light canvas under dark themes. Guarded, same as the dark
 * blanket above and for the same measured reason. */
body.cb-lms.cb-light
	:is(h1, h2, h3, h4, p, li, label, legend, td, th):where(:not(.has-text-color):not(.has-text-color *)) {
	color: var(--cb-text);
}
