/* ══════════════════════════════════════════════════════════════════════
   Almanac atoms (docs/design-specs/almanac-desk-and-sheets.md §6)
   ══════════════════════════════════════════════════════════════════════
   The shared component layer every page phase builds on: badge, meta line,
   chips, tags, text actions, the secondary button, dividers, rows, the
   inquiry line, rails, segmented controls, notices — and the card face (§6.7).
   layout.css stays the shell (desk, sidebar, sheet, band); page sheets keep
   their own layout (library.css, home.css, …). Loaded on every page by
   BaseLayout, after layout.css.

   Rules of the system (spec §2): elevation is a hairline, never a shadow;
   metadata is mono, uppercase, tracked; one accent per kind; hover moves a
   border colour and nothing else. Headings stay Georgia 400 (owner feedback
   45685b4e): the `--type-*-title` composites carry the 400 themselves, so a
   title rule takes the shorthand and nothing else. */

/* ── 6.1 Kind badge ───────────────────────────────────────────────── */
/* Outlined in the kind's colour; the label text is always present, so the
   badge never relies on colour alone (spec §10). `--kind-*` are certified at
   ≥4.5:1 on --bg-card / --bg-page only (Maren ruling 5) — badges sit on those
   two surfaces and nowhere else (never on the inset, the desk or a tint). */
.badge {
	display: inline-block;
	flex-shrink: 0;
	padding: var(--space-1) var(--space-2);
	font: var(--type-badge);
	letter-spacing: var(--track-badge);
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--text-secondary);
	border: 1px solid currentColor;
	border-radius: var(--radius-xs);
}
.badge--article {
	color: var(--kind-article);
}
.badge--link {
	color: var(--kind-link);
}
.badge--note {
	color: var(--kind-note);
}
.badge--list {
	color: var(--kind-list);
}
.badge--video {
	color: var(--kind-video);
}
.badge--image {
	color: var(--kind-image);
}
.badge--social {
	color: var(--kind-social);
}
.badge--product {
	color: var(--kind-product);
}
/* Provenance (Curated, a cluster's type, Shared on a collection's owner side):
   ember is allowed to mark these (spec §6.1). */
.badge--accent {
	color: var(--accent);
}

/* ── 6.2 Meta line ────────────────────────────────────────────────── */
/* --text-muted on cards and the sheet; --text-secondary anywhere else
   (muted fails on the desk and the inset — Maren ruling 3). */
.meta,
.meta-sm {
	text-transform: uppercase;
	color: var(--text-muted);
}
.meta {
	font: var(--type-meta);
	letter-spacing: var(--track-meta);
}
.meta-sm {
	font: var(--type-meta-sm);
	letter-spacing: var(--track-meta-sm);
}
/* Facts separated by a middot. The dot is decoration: empty alt text, so a
   screen reader reads the facts, not "dot" (ruling 6). */
.meta-list > * + *::before {
	content: "\00b7" / "";
	margin-inline: 0.5em;
}

/* ── 6.3 Chips ────────────────────────────────────────────────────── */
/* `<a>` when they navigate (Library filters, Links pivots, Search scopes),
   `<button aria-pressed>` when they toggle. */
.chip {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	padding: var(--space-2) var(--space-3);
	font: var(--type-chip);
	letter-spacing: var(--track-chip);
	text-transform: uppercase;
	white-space: nowrap;
	text-decoration: none;
	color: var(--text-secondary);
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition:
		color var(--duration-fast) ease,
		border-color var(--duration-fast) ease;
}
.chip:hover {
	color: var(--text-primary);
	border-color: var(--text-muted);
}
.chip[aria-current="page"],
.chip[aria-current="true"],
.chip[aria-pressed="true"] {
	color: var(--text-primary);
	background: var(--bg-inset);
	border-color: var(--accent);
}
/* A count inside a chip (Links pivots). Ink 2: the active chip is on the
   inset, where muted fails. */
.chip-count {
	color: var(--text-secondary);
}
/* The 1px rule between chip groups. */
.chip-sep {
	flex-shrink: 0;
	width: 1px;
	height: var(--space-5);
	margin-inline: var(--space-1);
	background: var(--border);
}

/* ── 6.4 Tags ─────────────────────────────────────────────────────── */
/* Sunk and never coloured. Ink 2 on the inset (muted fails there). */
.tag {
	display: inline-block;
	padding: var(--space-1) var(--space-2);
	font: var(--type-meta);
	letter-spacing: var(--track-meta);
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--text-secondary);
	background: var(--bg-inset);
	border-radius: var(--radius-xs);
}

/* ── 6.5 Buttons: text action + secondary ─────────────────────────── */
/* A text action is a word, not an icon: `Read · 7 min`, `Try harder`,
   `Archive`. 500 11px mono uppercase, muted until hovered. */
.btn-text {
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	padding: 0;
	font: var(--type-action);
	letter-spacing: var(--track-chip);
	text-transform: uppercase;
	white-space: nowrap;
	text-decoration: none;
	color: var(--text-muted);
	background: none;
	border: 0;
	cursor: pointer;
	transition: color var(--duration-fast) ease;
}
.btn-text:hover {
	color: var(--text-primary);
}
.btn-text:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}
/* Destructive: warn ink (only ever beside or inside a warn slab, §6.5). */
.btn-text--danger {
	color: var(--warn-ink);
}
.btn-text--danger:hover {
	color: var(--text-primary);
}

/* The secondary button (spec §6.5): card paper + hairline, the badge type.
   OPT-IN via `.btn-almanac` (with `.btn-secondary`) on the P2 surfaces —
   Collections, a collection, a cluster — until Phases 5/6 restyle the primary
   buttons beside it: a global restyle turned Settings / Login / Feeds / Save
   secondaries into 10px mono caps beside sentence-case primaries and shrank
   them under 44px on phones (design-lead-maren, Sprint 149 review MAJOR 1). */
.btn-almanac {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	min-height: var(--space-8);
	padding: 0 var(--space-3);
	font: var(--type-badge);
	letter-spacing: var(--track-badge);
	text-transform: uppercase;
	white-space: nowrap;
	text-decoration: none;
	color: var(--text-primary);
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition: border-color var(--duration-fast) ease;
}
.btn-almanac:hover {
	background: var(--bg-card);
	border-color: var(--text-muted);
}
@media (max-width: 767px) {
	/* The house 44px touch floor (WCAG 2.5.5). */
	.btn-almanac {
		min-height: 44px;
	}
}

/* ── 6.6 Divider ──────────────────────────────────────────────────── */
/* A mono section label, a hairline to the edge, then optional facts and an
   onward action. Replaces `.section-header` and the `.t-label` headings. */
.divider {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-3) var(--space-4);
	margin: var(--space-8) 0 var(--space-5);
}
.divider:first-child {
	margin-top: 0;
}
.divider-label {
	margin: 0;
	font: var(--type-divider);
	letter-spacing: var(--track-divider);
	text-transform: uppercase;
	color: var(--text-primary);
}
.divider-rule {
	flex: 1;
	min-width: var(--space-8);
	height: 1px;
	background: var(--border);
}
.divider-link {
	font: var(--type-meta);
	letter-spacing: var(--track-meta);
	text-transform: uppercase;
	text-decoration: none;
	color: var(--link-color);
}

/* ── 6.8 Rows ─────────────────────────────────────────────────────── */
/* A hairline-topped grid row (the last one also gets the bottom rule). Each
   surface sets its own `grid-template-columns` recipe. */
.row {
	display: grid;
	align-items: center;
	gap: var(--space-6);
	padding: var(--space-4) 0;
	border-top: 1px solid var(--border);
}
.row:last-child {
	border-bottom: 1px solid var(--border);
}
.row-title {
	margin: 0;
	font: var(--type-row-title);
	color: var(--text-primary);
}
.row-dek {
	margin: 0;
	font: var(--type-card-body-sm);
	color: var(--text-secondary);
}

/* ── 6.9 Inquiry line ─────────────────────────────────────────────── */
/* Inputs are a rule, not a box. 16px reading face (the iOS focus-zoom floor:
   never smaller); 30px with the 2px emphatic rule on the Search page. */
.field {
	display: block;
	width: 100%;
	padding: var(--space-2) 0;
	font: 400 var(--input-min-touch) / 1.4 var(--font-reading);
	color: var(--text-primary);
	background: transparent;
	border: 0;
	border-bottom: 1px solid var(--border);
	border-radius: 0;
}
.field::placeholder {
	color: var(--text-muted);
}
.field:focus {
	border-bottom-color: var(--text-primary);
}
.field--hero {
	padding: var(--space-3) 0;
	font: var(--type-inquiry);
	border-bottom: 2px solid var(--border-emphatic);
}
.field--hero:focus {
	border-bottom-color: var(--border-emphatic);
}
.field-label {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

/* ── 6.10 Rails and segmented controls ────────────────────────────── */
.rail {
	display: flex;
	flex-direction: column;
	gap: var(--space-8);
	min-width: 0;
}
.rail-head {
	margin: 0 0 var(--space-3);
	padding-bottom: var(--space-2);
	font: var(--type-meta);
	letter-spacing: var(--track-meta);
	text-transform: uppercase;
	color: var(--text-primary);
	border-bottom: 1px solid var(--border);
}
.rail-list {
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
	list-style: none;
}
.rail-entry {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	/* WCAG 2.2 SC 2.5.8 target size (spec §6.10, amended 2026-11-15): the
	   11px line at 1.9 is a 21px pitch, so each entry gets a 24px floor
	   (44px on a phone, the house touch rule). */
	min-height: var(--space-6);
	min-width: 0;
	font: var(--type-meta);
	line-height: 1.9;
	letter-spacing: var(--track-meta);
	text-transform: uppercase;
	text-decoration: none;
	color: var(--text-muted);
}
.rail-entry > :first-child {
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}
a.rail-entry:hover {
	color: var(--text-secondary);
}
.rail-entry[aria-current] {
	color: var(--accent);
}
.rail-note {
	margin: 0;
	font: 400 var(--text-sm) / 1.55 var(--font-ui);
	color: var(--text-muted);
}

/* Segmented control. `<a aria-current>` when it navigates (Search's Match),
   `<button aria-pressed>` when it toggles. The pressed segment is on the
   inset, so its ink is primary, never muted. */
.seg {
	display: inline-flex;
	gap: var(--space-1);
}
.seg > a,
.seg > button {
	display: inline-flex;
	align-items: center;
	padding: var(--space-2) var(--space-3);
	font: var(--type-meta);
	letter-spacing: var(--track-chip);
	text-transform: uppercase;
	text-decoration: none;
	color: var(--text-muted);
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	cursor: pointer;
	transition:
		color var(--duration-fast) ease,
		border-color var(--duration-fast) ease;
}
.seg > a:hover,
.seg > button:hover {
	color: var(--text-primary);
}
.seg > [aria-current="true"],
.seg > [aria-current="page"],
.seg > [aria-pressed="true"] {
	color: var(--text-primary);
	background: var(--bg-inset);
	border-color: var(--text-muted);
}

/* ── 6.11 Notices and slabs ───────────────────────────────────────── */
/* Flat: no accent bar, no glyph. A notice is a card at 16/20 with a meta-sm
   label; the tints carry their own ink (note 6.81:1, warn 6.51:1 Paper). */
.notice {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	padding: var(--space-4) var(--space-5);
	color: var(--text-secondary);
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
}
.notice-label {
	font: var(--type-meta-sm);
	letter-spacing: var(--track-meta-sm);
	text-transform: uppercase;
	color: var(--text-primary);
}
.notice p {
	margin: 0;
	font: var(--type-card-body-sm);
}
.notice--note {
	color: var(--note-ink);
	background: var(--note-bg);
	border-color: var(--note-border);
}
.notice--note .notice-label {
	color: var(--note-ink);
}
.notice--warn {
	color: var(--warn-ink);
	background: var(--warn-bg);
	border-color: var(--warn-border);
}
.notice--warn .notice-label {
	color: var(--warn-ink);
}

/* ══════════════════════════════════════════════════════════════════════
   6.7 The card face
   ══════════════════════════════════════════════════════════════════════
   One face for the library family (library.tsx `CardPreview`) and the Home
   primitive (`card.tsx`). Paper, a hairline, 6px corners; hover moves the
   border to ink 3 at --duration-fast and NOTHING else: no transform, no
   shadow, no image zoom, no overlay band (library-card-hover-redesign.md is
   superseded). Tiers keep the card-system model with the 2:1 ratios:
   medium = 2:1 image over a 20/24 body; small = text tile (no image, 20 all
   round); hero = Home cover (2:1, image-left column at ≥1024 — Home P3). */
.card {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	color: var(--text-primary);
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	box-shadow: var(--card-highlight);
	transition: border-color var(--duration-fast) ease;
}
.card:hover {
	border-color: var(--text-muted);
}
/* Keyboard users get the hover state too (plus the link's own ring). */
.card:has(:focus-visible) {
	border-color: var(--text-muted);
}

/* The image frame — the ONLY element on a card that carries
   `view-transition-name: card-{id}` (spec §8.3): the image flies to the
   reader's lede, the title and body arrive with the sheet. Imageless cards
   name nothing. */
.card-media {
	position: relative;
	display: block;
	flex-shrink: 0;
	width: 100%;
	aspect-ratio: 2 / 1;
	overflow: hidden;
	background: var(--bg-inset);
	border-bottom: 1px solid var(--border);
}
.card-media > picture,
.card-media > img,
.card-media picture > img,
.card-media .card-image,
.card-media .card-media-img {
	display: block;
	width: 100%;
	height: 100%;
	aspect-ratio: auto;
	object-fit: cover;
}

.card-body {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	min-width: 0;
	padding: var(--space-5) var(--space-6) var(--space-3);
}

/* Eyebrow: kind badge + mono facts (`domain · 14 min`). */
/* One line, always: the facts take the remaining width and the source
   truncates inside them (wrapping broke 21/24 compact eyebrows onto two lines
   before the ellipsis was ever reached — design-lead-maren, Sprint 149 review
   MINOR 9). */
.card-eyebrow {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: var(--space-2) var(--space-3);
	min-width: 0;
}
.card-facts {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
	white-space: nowrap;
}
.card-facts > * {
	flex-shrink: 0;
}
/* The source is the fact that gives way: it truncates with an ellipsis (the
   `title` attribute carries the whole value). */
.card-facts > .card-source {
	flex-shrink: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}
.card-favicon {
	flex-shrink: 0;
	width: 12px;
	height: 12px;
	margin-right: var(--space-1);
	object-fit: cover;
	border-radius: var(--radius-xs);
}

.card-title {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	font: var(--type-card-title);
	color: var(--text-primary);
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	/* URL-as-title (just-saved, link cards) has no break opportunity: without
	   this the clamp hard-clips with no ellipsis. */
	overflow-wrap: anywhere;
}
.card-title a {
	color: inherit;
	text-decoration: none;
}
.card-title a:hover,
.card-title a:focus-visible {
	color: var(--kind-article);
}
.card-dek {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	font: var(--type-card-body);
	color: var(--text-secondary);
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow-wrap: anywhere;
}
.card-dek--empty {
	font-style: italic;
	color: var(--text-muted);
}

/* Footer row: the date left, the `···` menu right. Bottom-anchored so tiles
   in a row share a baseline for the date without any height matching. */
.card-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	margin-top: auto;
	padding: 0 var(--space-6) var(--space-4);
}
.card-footer > .meta {
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

/* ── Tiers ── */
.card--tier-small .card-body,
.card--text .card-body {
	padding: var(--space-5) var(--space-5) var(--space-3);
}
.card--tier-small .card-footer,
.card--text .card-footer {
	padding: 0 var(--space-5) var(--space-4);
}
.card--tier-small .card-title,
.card--text .card-title {
	font: var(--type-tile-title);
}
.card--tier-small .card-dek,
.card--text .card-dek {
	font: var(--type-card-body-sm);
}

/* ── Reading progress: a 2px rule (track hairline, fill ink 2) ── */
.card-progress {
	position: relative;
	height: 2px;
	overflow: hidden;
	background: var(--progress-track);
	border-radius: var(--radius-xs);
}
.card-progress-fill {
	display: block;
	height: 100%;
	background: var(--text-secondary);
}

/* A list's `x of y done`: the mono count over the 2px rule, flush with the
   badge and title. */
.card-list-meta {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

/* ── Note cards are tinted (spec §6.7) ── */
/* `--note-ink` on `--note-bg` holds 6.81:1 (Paper); every text token inside
   the tint moves to the note ink so no muted-on-tint pair is left behind. */
.card[data-card-type="note"],
.card.tc-note {
	color: var(--note-ink);
	background: var(--note-bg);
	border-color: var(--note-border);
}
.card[data-card-type="note"]:hover,
.card.tc-note:hover {
	border-color: var(--note-ink);
}
/* Inside the tint the ink tokens themselves become the note ink, so every
   consumer follows — including the shadow-DOM `···` trigger, which reads
   --text-muted through inheritance. */
.card[data-card-type="note"],
.card.tc-note {
	--text-primary: var(--note-ink);
	--text-secondary: var(--note-ink);
	--text-muted: var(--note-ink);
}
.card[data-card-type="note"] .card-title,
.card[data-card-type="note"] .card-dek,
.card[data-card-type="note"] .meta,
.card.tc-note .card-title,
.card.tc-note .card-dek,
.card.tc-note .meta {
	color: var(--note-ink);
}
.card[data-card-type="note"] .card-dek,
.card.tc-note .card-dek {
	font-family: var(--font-reading);
	font-style: italic;
	-webkit-line-clamp: 6;
}
/* The kind badge's colour is certified on card paper only — inside the tint
   it takes the note ink (same hue family, 6.81:1). */
.card[data-card-type="note"] .badge--note,
.card.tc-note .badge--note {
	color: var(--note-ink);
}

/* ── Processing: a 2px rule in the article kind + a mono status line ── */
/* Stays in the body flow (no cover): the title, the eyebrow and the menu stay
   visible and reachable while the pipeline works. The fill steps with the
   card's `data-enrichment-status`, which the poll keeps current. */
.card-processing-overlay {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}
.card-spinner {
	position: relative;
	height: 2px;
	overflow: hidden;
	background: var(--progress-track);
	border-radius: var(--radius-xs);
}
.card-spinner::after {
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	width: 15%;
	background: var(--kind-article);
}
.card[data-enrichment-status="extracting"] .card-spinner::after {
	width: 35%;
}
.card[data-enrichment-status="enriching"] .card-spinner::after {
	width: 60%;
}
.card[data-enrichment-status="embedding"] .card-spinner::after {
	width: 85%;
}
.card-processing-text {
	font: var(--type-meta-sm);
	letter-spacing: var(--track-meta-sm);
	text-transform: uppercase;
	color: var(--kind-article);
}
.card-processing .card-title {
	color: var(--text-secondary);
}

/* ── Honest states: a --warn-bg slab inside the body + text actions ── */
/* `resolveHonestState` is unchanged; this is `CardHonestOverlay` restyled.
   The legacy hook classes (`.card-failed-overlay` / `.card-blocked-overlay`)
   stay on the wrapper for library-init and the list/row rules. */
.card-honest {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	min-width: 0;
}
.card-honest-slab {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	padding: var(--space-3);
	color: var(--warn-ink);
	background: var(--warn-bg);
	border: 1px solid var(--warn-border);
	border-radius: var(--radius-sm);
}
.card-honest-label {
	font: var(--type-meta-sm);
	letter-spacing: var(--track-meta-sm);
	text-transform: uppercase;
	color: var(--warn-ink);
}
.card-honest-text {
	font: 400 var(--text-sm) / 1.5 var(--font-ui);
	color: var(--warn-ink);
}
.card-honest-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-2) var(--space-4);
}
.card-failed-actions {
	display: contents;
}

/* The title link is the card's one link and its ::after stretches over the
   whole card (the Search row's pattern): Tab reaches every card, Enter opens
   it, and the pointer target is the whole tile. The `···` menu and the honest
   slab's actions sit above it (design-lead-maren, Sprint 149 review MINOR 8).
   `.card` is the containing block (position: relative, layout.css). After
   the slab's own rules, so the more specific selector comes last. */
.card .card-link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}
.card theseus-card-menu,
.card .card-honest {
	position: relative;
	z-index: 2;
}

/* Phone: text actions inside a card get a 44px row (WCAG 2.5.5, the house
   touch-target rule). */
@media (max-width: 767px) {
	.card-honest-actions .btn-text,
	.divider .btn-text {
		min-height: 44px;
	}
	.rail-entry {
		min-height: 44px;
	}
	.chip {
		min-height: 44px;
	}
	.seg > a,
	.seg > button {
		min-height: 44px;
	}
}

/* Forced colours: the hairline is the only edge, so make the hover edge a
   real outline the system palette keeps. */
@media (forced-colors: active) {
	.card:hover,
	.card:has(:focus-visible) {
		outline: 1px solid CanvasText;
		outline-offset: -1px;
	}
}
