/**
 * Verifera Encyclopaedia — NAV bundle (shared nav-core surface).
 *
 * The home for navigation/discovery components that sit AROUND the entry content:
 *  - the faceted-browse PORTAL that replaces the flat 189-link facet wall
 *    (count-sorted collapsible accordions + top-N "show more" + search-within-facets),
 *  - the mobile "Filter" bottom-sheet so cards are the first content on small screens.
 *
 * PROGRESSIVE ENHANCEMENT: every collapsing/off-canvas behaviour is gated behind the
 * `.vf-js` class that nav.js adds to `.vf-enc` on boot. With JS off, all terms render
 * inline (today's behaviour) — never hidden with no way to reveal them.
 *
 * Token-driven (only existing --vf-* tokens defined in encyclopaedia.css `.vf-enc`), so
 * build_core.py re-keys it into the neutral --enc-* contract exactly like components.css.
 * Scoped under .vf-enc — theme-independent, no new hex (0-hex contract).
 */

/* ── single-entry three-column body: persistent entry-rail | article | "On this page" ── */
.vf-enc__layout--entry { grid-template-columns: 240px minmax(0, 1fr) 200px; }
.vf-entry-rail .vf-facet-group__list { max-height: 58vh; overflow-y: auto; } /* long type groups scroll in place */

/* ── search-within-facets (filters the browse list; distinct from the card filter) ── */
.vf-facet-find { position: relative; margin: 0 0 1.1rem; display: none; }
.vf-enc.vf-js .vf-facet-find { display: block; }   /* needs JS to do anything */
.vf-facet-find input {
	width: 100%; padding: .55rem .8rem .55rem 2rem; font: inherit; font-size: .9rem;
	border: 1px solid var(--vf-line); border-radius: var(--vf-radius-sm);
	background: var(--vf-card); color: var(--vf-ink);
}
.vf-facet-find input:focus { outline: none; border-color: var(--vf-navy-500); box-shadow: 0 0 0 3px rgba(27, 58, 122, .12); }
.vf-facet-find::before { content: "⌕"; position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: var(--vf-ink-soft); font-size: .95rem; }

/* ── facet group as a collapsible accordion (header is a button, was an <h3>) ── */
.vf-facet-group__h {
	display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%;
	margin: 0 0 .6rem; padding: 0 0 .4rem; background: none; border: 0; border-bottom: 1px solid var(--vf-line);
	cursor: pointer; text-align: left; font-family: var(--f-body); font-size: 12.5px; font-weight: 500;
	letter-spacing: .07em; text-transform: uppercase; color: var(--vf-ink-soft);
}
.vf-facet-group__h:hover { color: var(--vf-navy); }
.vf-facet-group__h:focus-visible { outline: 2px solid var(--vf-navy-500); outline-offset: 2px; border-radius: 3px; }
.vf-facet-group__count { font-size: 11px; font-weight: 500; color: var(--vf-ink-soft); background: var(--vf-cream); border: 1px solid var(--vf-line); border-radius: 999px; padding: .05rem .4rem; }
.vf-facet-group__caret { margin-left: .3rem; transition: transform .18s ease; flex: 0 0 auto; }
/* no-JS: header button is inert; don't imply it collapses */
.vf-enc:not(.vf-js) .vf-facet-group__caret { display: none; }

/* JS-only: collapse + top-N + show-more */
.vf-enc.vf-js .vf-facet-group[aria-collapsed="true"] .vf-facet-group__caret { transform: rotate(-90deg); }
.vf-enc.vf-js .vf-facet-group[aria-collapsed="true"] .vf-facet-group__list,
.vf-enc.vf-js .vf-facet-group[aria-collapsed="true"] .vf-facet-more { display: none; }
.vf-enc.vf-js .vf-facet-item.is-extra { display: none; }
.vf-enc.vf-js .vf-facet-group.is-expanded .vf-facet-item.is-extra { display: block; }
.vf-enc.vf-js .vf-facet-item.is-hidden { display: none; }        /* search-within no-match */

.vf-facet-more {
	display: none; margin: .35rem 0 0; padding: .25rem .5rem; background: none; border: 0; cursor: pointer;
	font: inherit; font-size: .82rem; color: var(--vf-green); border-radius: 6px;
}
.vf-enc.vf-js .vf-facet-more { display: inline-block; }
.vf-facet-more:hover { background: var(--vf-gold-pale); }
.vf-facet-more:focus-visible { outline: 2px solid var(--vf-navy-500); outline-offset: 2px; }
.vf-facet-group.is-expanded .vf-facet-more { color: var(--vf-ink-soft); }

.vf-facet-empty { display: none; padding: .5rem; font-size: .85rem; color: var(--vf-ink-soft); }
/* during search-within: reveal ALL items (override the top-N .is-extra collapse at higher
   specificity), THEN hide non-matches — so a matching term in the collapsed tail surfaces
   and a non-matching one stays hidden regardless of its top-N position. */
.vf-enc.vf-js .vf-enc__facets.is-finding .vf-facet-item { display: block; }
.vf-enc.vf-js .vf-enc__facets.is-finding .vf-facet-item.is-hidden { display: none; }
.vf-enc.vf-js .vf-enc__facets.is-finding .vf-facet-group:not(.has-match) { display: none; }
.vf-enc.vf-js .vf-enc__facets.is-finding.no-matches .vf-facet-empty { display: block; }

/* ── mobile "Filter" trigger + bottom-sheet (cards first on small screens; JS-only) ── */
.vf-facet-toggle, .vf-facet-sheet-bar, .vf-facet-backdrop { display: none; }

@media (max-width: 900px) {
	/* single-entry: stack to one column; article first, "On this page" below it (the entry-rail
	   becomes the bottom-sheet via the generic .vf-enc__facets rule below). */
	.vf-enc__layout--entry { grid-template-columns: 1fr; }
	.vf-enc__layout--entry .vf-toc { order: 2; }
	.vf-enc.vf-js .vf-facet-toggle {
		display: inline-flex; align-items: center; gap: .4rem; margin: 0 0 1rem; padding: .6rem 1rem;
		font: inherit; font-size: .9rem; font-weight: 500; color: var(--vf-navy);
		background: var(--vf-card); border: 1px solid var(--vf-line); border-radius: var(--vf-radius-sm);
		box-shadow: var(--vf-shadow); cursor: pointer;
	}
	.vf-enc.vf-js .vf-enc__facets {
		position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-height: 82vh; overflow-y: auto;
		margin: 0; padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
		background: var(--vf-cream); border-top-left-radius: 18px; border-top-right-radius: 18px;
		box-shadow: 0 -8px 40px rgba(6, 22, 69, .22);
		transform: translateY(101%); transition: transform .26s cubic-bezier(.4, 0, .2, 1); visibility: hidden;
	}
	.vf-enc.vf-js .vf-enc__facets.is-open { transform: translateY(0); visibility: visible; }
	.vf-enc.vf-js .vf-facet-sheet-bar { display: flex; align-items: center; justify-content: space-between; margin: 0 0 1rem; }
	.vf-facet-sheet-bar strong { font-family: var(--f-disp); font-size: 1.2rem; color: var(--vf-navy); }
	.vf-facet-close {
		width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
		font-size: 1.3rem; line-height: 1; background: var(--vf-card); border: 1px solid var(--vf-line);
		border-radius: 999px; color: var(--vf-ink); cursor: pointer;
	}
	.vf-enc.vf-js .vf-facet-backdrop {
		display: block; position: fixed; inset: 0; z-index: 55; background: rgba(6, 22, 69, .42);
		opacity: 0; visibility: hidden; transition: opacity .2s ease;
	}
	.vf-enc.vf-js .vf-facet-backdrop.is-open { opacity: 1; visibility: visible; }
}

@media (prefers-reduced-motion: reduce) {
	.vf-enc__facets, .vf-facet-group__caret, .vf-facet-backdrop { transition: none; }
}

/* ── ⌘K command palette (global encyclopaedia search) ── */
.vf-cmdk-trigger {
	position: fixed; right: 18px; bottom: 18px; z-index: 70; display: inline-flex; align-items: center; gap: .45rem;
	padding: .6rem .9rem; font: inherit; font-size: .9rem; font-weight: 500; color: var(--vf-navy);
	background: var(--vf-card); border: 1px solid var(--vf-line); border-radius: 999px; box-shadow: var(--vf-shadow); cursor: pointer;
}
.vf-cmdk-trigger:hover { border-color: var(--vf-navy-500); }
.vf-cmdk-trigger:focus-visible { outline: 2px solid var(--vf-navy-500); outline-offset: 2px; }
/* Visually hidden, still read and still the button's name: never display:none (that removes the name; axe button-name). */
.vf-cmdk-trigger__more { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.vf-cmdk-trigger kbd { font: inherit; font-size: .72rem; color: var(--vf-ink-soft); background: var(--vf-cream); border: 1px solid var(--vf-line); border-radius: 5px; padding: .05rem .35rem; }

.vf-cmdk { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; }
.vf-cmdk[hidden] { display: none; }
.vf-cmdk__backdrop { position: absolute; inset: 0; background: rgba(6, 22, 69, .42); }
.vf-cmdk__panel {
	position: relative; margin-top: 12vh; width: min(620px, 92vw); max-height: 70vh; display: flex; flex-direction: column;
	background: var(--vf-card); border: 1px solid var(--vf-line); border-radius: var(--vf-radius); box-shadow: 0 20px 60px rgba(6, 22, 69, .3); overflow: hidden;
}
.vf-cmdk__bar { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border-bottom: 1px solid var(--vf-line); }
.vf-cmdk__ic { color: var(--vf-ink-soft); flex: 0 0 auto; }
.vf-cmdk__input { flex: 1; min-width: 0; border: 0; outline: none; font: inherit; font-size: 1.05rem; color: var(--vf-ink); background: none; }
.vf-cmdk__esc { font: inherit; font-size: .72rem; color: var(--vf-ink-soft); background: var(--vf-cream); border: 1px solid var(--vf-line); border-radius: 5px; padding: .1rem .4rem; cursor: pointer; }
.vf-cmdk__list { list-style: none; margin: 0; padding: .4rem; overflow-y: auto; }
.vf-cmdk__group { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--vf-gold-ink); font-weight: 500; padding: .65rem .6rem .3rem; }
.vf-cmdk__opt { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; padding: .55rem .6rem; border-radius: 8px; cursor: pointer; }
.vf-cmdk__opt.is-active { background: var(--vf-gold-pale); }
.vf-cmdk__t { font-weight: 500; color: var(--vf-navy); }
.vf-cmdk__g { font-size: .78rem; color: var(--vf-ink-soft); flex: 0 0 auto; }
.vf-cmdk__empty { padding: 1.4rem .6rem; text-align: center; color: var(--vf-ink-soft); }
.vf-cmdk__foot { display: flex; gap: 1rem; padding: .5rem 1rem; border-top: 1px solid var(--vf-line); font-size: .75rem; color: var(--vf-ink-soft); }

@media (max-width: 600px) {
	.vf-cmdk__panel { margin-top: 0; width: 100vw; max-height: 100%; height: 100%; border-radius: 0; }
	/* Icon only on a phone: the word is visually hidden, NOT display:none - it is the button's only name (2026-11-13). */
	.vf-cmdk-trigger__label { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
}
@media (prefers-reduced-motion: no-preference) {
	.vf-cmdk__panel { animation: vf-cmdk-in .14s ease; }
	@keyframes vf-cmdk-in { from { opacity: 0; transform: translateY(-6px); } }
}

/* ── cross-document View Transitions: a subtle cross-fade between same-origin
   encyclopaedia navigations (archive ↔ single ↔ single). Both pages opt in via this
   bundle; non-encyclopaedia pages don't load it, so those navigations are unaffected. ── */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* ── hovercard preview (inline entry-link peek; mounted inside .vf-enc for tokens) ── */
.vf-hovercard {
	position: absolute; z-index: 75; width: 300px; max-width: 92vw; padding: .85rem 1rem;
	display: flex; flex-direction: column; gap: .35rem;
	background: var(--vf-card); border: 1px solid var(--vf-line); border-radius: var(--vf-radius);
	box-shadow: 0 8px 30px rgba(6, 22, 69, .16);
}
.vf-hovercard[hidden] { display: none; }
.vf-hovercard__type { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--vf-gold-ink); font-weight: 500; }
.vf-hovercard__t { font-family: var(--f-disp); font-size: 1.15rem; font-weight: 600; color: var(--vf-navy); line-height: 1.2; }
.vf-hovercard__e { font-size: .85rem; color: var(--vf-ink-soft); line-height: 1.5; }
.vf-hovercard .vf-mark { align-self: flex-start; margin-top: .15rem; }
@media (prefers-reduced-motion: no-preference) { .vf-hovercard { animation: vf-cmdk-in .12s ease; } }
