/* ==========================================================================
   UK Care Reference — design system
   Mobile-first, WCAG 2.2 AA, dark mode via html[data-theme], zero webfonts.
   ========================================================================== */

/* ---- Tokens ---------------------------------------------------------- */

:root {
  /* light theme */
  --bg: #f4f7fb;
  --bg-2: #e9eef7;
  --text: #17233a;
  --muted: #4c5c76;
  --surface: rgba(255, 255, 255, 0.68);
  --surface-solid: #ffffff;
  --surface-2: rgba(255, 255, 255, 0.88);
  --line: rgba(23, 35, 58, 0.13);
  --line-strong: rgba(23, 35, 58, 0.26);
  --accent: #0b6d80;          /* teal ink — 5:1 on --bg */
  --accent-soft: rgba(11, 109, 128, 0.1);
  --g1: #4f46e5;              /* gradient start (indigo) */
  --g2: #0a94a6;              /* gradient end (teal) — 3.4:1 on --bg for large text */
  --g2-deep: #0a7a8a;
  --focus: #4f46e5;
  --warn-bg: rgba(180, 83, 9, 0.09);
  --warn-line: rgba(180, 83, 9, 0.4);
  --warn-ink: #8a3d05;
  --ok-bg: rgba(5, 122, 85, 0.1);
  --ok-ink: #04543b;
  --shadow: 0 10px 30px -12px rgba(23, 35, 58, 0.18);
  --shadow-lg: 0 24px 60px -20px rgba(23, 35, 58, 0.28);
  --blob-a: rgba(79, 70, 229, 0.12);
  --blob-b: rgba(10, 148, 166, 0.14);
  --blob-c: rgba(217, 70, 160, 0.07);
  --mark: rgba(79, 70, 229, 0.16);
  color-scheme: light;
}

html[data-theme='dark'] {
  --bg: #0b1220;
  --bg-2: #0e1729;
  --text: #e7edf7;
  --muted: #a3b2c9;
  --surface: rgba(21, 32, 54, 0.62);
  --surface-solid: #141f36;
  --surface-2: rgba(24, 37, 62, 0.9);
  --line: rgba(231, 237, 247, 0.13);
  --line-strong: rgba(231, 237, 247, 0.3);
  --accent: #52cfe0;
  --accent-soft: rgba(82, 207, 224, 0.12);
  --g1: #8b8cf8;
  --g2: #38d3e5;
  --g2-deep: #0a7a8a;
  --focus: #9aa0ff;
  --warn-bg: rgba(251, 191, 36, 0.1);
  --warn-line: rgba(251, 191, 36, 0.45);
  --warn-ink: #fbd38d;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --ok-ink: #7ee2bc;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
  --blob-a: rgba(99, 91, 255, 0.17);
  --blob-b: rgba(21, 184, 205, 0.13);
  --blob-c: rgba(217, 70, 160, 0.09);
  --mark: rgba(139, 140, 248, 0.3);
  color-scheme: dark;
}

/* ---- Reset & base ----------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.68;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* soft gradient mesh behind everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(42rem 30rem at 12% -4%, var(--blob-a), transparent 62%),
    radial-gradient(46rem 32rem at 96% 12%, var(--blob-b), transparent 60%),
    radial-gradient(38rem 30rem at 55% 108%, var(--blob-c), transparent 62%),
    linear-gradient(var(--bg), var(--bg-2));
  pointer-events: none;
}

main {
  flex: 1;
}

img,
svg {
  max-width: 100%;
  vertical-align: middle;
}

h1, h2, h3, h4 {
  line-height: 1.18;
  letter-spacing: -0.015em;
  font-weight: 750;
  margin: 0 0 0.6em;
  text-wrap: balance;
}

h1 { font-size: clamp(1.85rem, 1.3rem + 2.2vw, 2.8rem); }
h2 { font-size: clamp(1.3rem, 1.1rem + 0.9vw, 1.7rem); }
h3 { font-size: 1.14rem; }

p { margin: 0 0 1em; }

ul, ol { padding-left: 1.35rem; margin: 0 0 1em; }
li { margin-bottom: 0.45em; }
li::marker { color: var(--accent); }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-thickness: 2px; }

strong { font-weight: 680; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 100;
  background: var(--surface-solid);
  color: var(--text);
  padding: 0.7rem 1.1rem;
  border-radius: 0.6rem;
  box-shadow: var(--shadow);
  transition: top 0.2s ease;
}
.skip-link:focus { top: 1rem; }

.wrap {
  width: min(72rem, 100% - 2.5rem);
  margin-inline: auto;
}

/* ---- Buttons & chips --------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: inherit;
  font-weight: 640;
  font-size: 0.97rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.62rem 1.1rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn svg { width: 1.05em; height: 1.05em; }

.btn-primary {
  background: linear-gradient(120deg, var(--g1), var(--g2-deep));
  border: none;
  color: #fff;
}
.btn-ghost { background: transparent; }
.btn-lg { padding: 0.85rem 1.4rem; font-size: 1.05rem; border-radius: 0.9rem; }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.86rem; border-radius: 0.6rem; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  color: var(--text);
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.btn-icon:hover { background: var(--accent-soft); }
.btn-icon svg { width: 1.25rem; height: 1.25rem; }

.btn-plain {
  font: inherit;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0.4rem 0.6rem;
}

.link-btn {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.kbd-hint {
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  border-radius: 0.35rem;
  padding: 0.1rem 0.4rem;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  padding: 0.28rem 0.75rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

/* category tints — dark text on soft tint keeps AA contrast in both themes */
.chip-law        { background: rgba(79, 70, 229, 0.13);  border-color: rgba(79, 70, 229, 0.35); }
.chip-rights     { background: rgba(219, 39, 119, 0.11); border-color: rgba(219, 39, 119, 0.32); }
.chip-practice   { background: rgba(10, 148, 166, 0.13); border-color: rgba(10, 148, 166, 0.4); }
.chip-safety     { background: rgba(217, 119, 6, 0.13);  border-color: rgba(217, 119, 6, 0.4); }
.chip-governance { background: rgba(124, 58, 237, 0.12); border-color: rgba(124, 58, 237, 0.35); }
.chip-workforce  { background: rgba(5, 150, 105, 0.13);  border-color: rgba(5, 150, 105, 0.4); }

.chip-filter { cursor: pointer; font-size: 0.86rem; padding: 0.42rem 0.95rem; transition: transform 0.15s ease; }
.chip-filter:hover { transform: translateY(-1px); }
.chip-filter.is-active {
  background: linear-gradient(120deg, var(--g1), var(--g2-deep));
  color: #fff;
  border-color: transparent;
}
.chip-filter.is-active .chip-count { color: rgba(255, 255, 255, 0.85); }
.chip-count { font-weight: 500; color: var(--muted); }

/* ---- Header ------------------------------------------------------------ */

.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  border-bottom: 1px solid var(--line);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-head { background: var(--surface-solid); }
}

.head-in {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 4rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 760;
  letter-spacing: -0.01em;
  font-size: 1.08rem;
  white-space: nowrap;
}
.logo { width: 1.7rem; height: 1.7rem; flex: none; }

.site-nav { margin-left: auto; }
.site-nav ul {
  display: flex;
  gap: 0.3rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav a {
  display: block;
  padding: 0.5rem 0.85rem;
  border-radius: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 560;
  font-size: 0.97rem;
}
.site-nav a:hover { background: var(--accent-soft); }
.site-nav a[aria-current='page'] { background: var(--accent-soft); color: var(--accent); }

.head-actions { display: flex; align-items: center; gap: 0.15rem; }

.theme-toggle .i-moon { display: none; }
html[data-theme='dark'] .theme-toggle .i-sun { display: none; }
html[data-theme='dark'] .theme-toggle .i-moon { display: inline; }

.nav-toggle { display: none; }

@media (max-width: 56rem) {
  .nav-toggle { display: inline-flex; }
  .kbd-hint { display: none; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    padding: 0.6rem 1.25rem 1rem;
    box-shadow: var(--shadow);
  }
  body.nav-open .site-nav { display: block; }
  .site-nav ul { flex-direction: column; gap: 0.1rem; }
  .site-nav a { padding: 0.75rem 0.85rem; font-size: 1.05rem; }
}

/* ---- Hero -------------------------------------------------------------- */

.hero { padding: clamp(3rem, 8vw, 6rem) 0 clamp(2rem, 5vw, 3.5rem); text-align: center; }

.hero h1 { font-size: clamp(2.1rem, 1.4rem + 3.4vw, 3.7rem); margin-bottom: 0.4em; }

.grad {
  background: linear-gradient(100deg, var(--g1), var(--g2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 620;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 0.35rem 0.95rem;
  border-radius: 99px;
  margin-bottom: 1.4rem;
}

.lead {
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.22rem);
  color: var(--muted);
  max-width: 46rem;
}
.hero .lead { margin-inline: auto; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
  margin: 1.8rem 0 1.4rem;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  justify-content: center;
  list-style: none;
  padding: 0;
  margin: 1.6rem 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}
.hero-stats strong { color: var(--text); font-size: 1.15rem; margin-right: 0.25rem; }

.hero-404 { padding-top: clamp(4rem, 12vw, 8rem); padding-bottom: clamp(4rem, 12vw, 8rem); }

/* ---- Sections & grids --------------------------------------------------- */

.section-head { max-width: 44rem; margin: clamp(2rem, 5vw, 3.4rem) 0 1.3rem; }
.section-head p { color: var(--muted); }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.filter-search { max-width: 30rem; margin-bottom: 1.4rem; }

input[type='search'],
input[type='text'] {
  font: inherit;
  width: 100%;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.7rem 1rem;
}
input[type='search']::placeholder { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: var(--shadow);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card { background: var(--surface-solid); }
}

.topic-grid,
.tool-grid,
.related-grid {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}

.topic-card article,
.tool-card article {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.15rem 1.25rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.topic-card article:hover,
.tool-card article:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
}
.topic-card h3, .tool-card h3, .tool-card h2 { margin: 0; font-size: 1.08rem; }
.topic-card a, .tool-card a { color: var(--text); text-decoration: none; }
.topic-card a:hover, .tool-card a:hover { color: var(--accent); }
/* make the whole card clickable without breaking text selection of summary */
.topic-card article { position: relative; }
.topic-card h3 a::after { content: ''; position: absolute; inset: 0; border-radius: 1.1rem; }
.tool-card article { position: relative; }
.tool-card a::after { content: ''; position: absolute; inset: 0; border-radius: 1.1rem; }
.topic-card p, .tool-card p { margin: 0; font-size: 0.94rem; color: var(--muted); }
.topic-card .chip { align-self: flex-start; }
.card-meta { margin-top: auto !important; font-size: 0.82rem !important; padding-top: 0.5rem; }

.grid-empty { color: var(--muted); padding: 1.5rem 0; }

.about-band { padding: clamp(1.5rem, 4vw, 2.6rem); margin: clamp(2rem, 5vw, 3.5rem) 0; }
.about-band p { color: var(--muted); max-width: 52rem; }
.about-band .btn { margin-top: 0.4rem; }

/* ---- Breadcrumbs, article layout ---------------------------------------- */

.crumbs { margin: 1.4rem 0 0.6rem; font-size: 0.88rem; }
.crumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0;
  margin: 0;
  color: var(--muted);
}
.crumbs li + li::before { content: '/'; margin-right: 0.35rem; color: var(--line-strong); }
.crumbs a { color: var(--muted); }
.crumbs [aria-current='page'] { color: var(--text); font-weight: 600; }

.article-wrap { max-width: 50rem; padding-bottom: 3rem; }

.topic-head { margin: 1rem 0 1.6rem; }
.topic-head .lead { margin-bottom: 0.8rem; }

.topic-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.meta-gap { flex: 1; }

.keypoints {
  padding: 1.3rem 1.5rem 1rem;
  margin-bottom: 1.6rem;
  border-left: 4px solid;
  border-image: linear-gradient(var(--g1), var(--g2)) 1;
}
.keypoints h2 { font-size: 1.02rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.keypoints ul { margin-bottom: 0.3rem; }
.keypoints li { margin-bottom: 0.55em; }

/* quick-reference mode: show key points only */
.qr-mode .sections,
.qr-mode .refs,
.qr-mode .related { display: none; }
.qr-mode .keypoints { box-shadow: var(--shadow-lg); }

/* ---- Collapsible sections ------------------------------------------------ */

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  margin-bottom: 0.9rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}

.section summary {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.section summary::-webkit-details-marker { display: none; }
.section summary:hover { background: var(--accent-soft); }

.s-num {
  font-size: 0.82rem;
  font-weight: 760;
  background: linear-gradient(120deg, var(--g1), var(--g2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  min-width: 1.6rem;
}

.s-title { font-weight: 700; font-size: 1.14rem; letter-spacing: -0.01em; flex: 1; }

.chev { width: 1.15rem; height: 1.15rem; color: var(--muted); transition: transform 0.25s ease; flex: none; }
.section[open] > summary .chev { transform: rotate(180deg); }

.s-body { padding: 0.2rem 1.35rem 1.15rem; }
.s-body > :first-child { margin-top: 0.2rem; }
.s-body h3 { margin-top: 1.3em; }
.s-body table { width: 100%; border-collapse: collapse; font-size: 0.95rem; margin-bottom: 1em; }
.s-body th, .s-body td { text-align: left; padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.s-body th { color: var(--muted); font-weight: 650; }

/* ---- Callouts & notes ----------------------------------------------------- */

.callout {
  border: 1px solid var(--line-strong);
  border-radius: 0.9rem;
  background: var(--surface-2);
  padding: 0.9rem 1.2rem;
  margin: 0 0 1.3rem;
  font-size: 0.97rem;
}
.callout-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.callout-warn strong { color: var(--warn-ink); }

.note-strip {
  border: 1px dashed var(--line-strong);
  border-radius: 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.8rem 1.1rem;
  margin: 1.8rem 0;
}

/* ---- References ------------------------------------------------------------ */

.refs { margin-top: 2rem; }
.ref-list { list-style: none; padding: 0; }
.ref-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.7rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.ref-list a { font-weight: 560; }
.ref-list .ext { width: 0.8em; height: 0.8em; margin-left: 0.3em; }
.ref-domain { font-size: 0.8rem; color: var(--muted); }

/* ---- Related & prev/next ----------------------------------------------------- */

.related { margin-top: 2.2rem; }
.related-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.related-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.related-card .chip { align-self: flex-start; }

.prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2rem;
}
.pn {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.pn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.pn span { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.pn-next { text-align: right; }
@media (max-width: 40rem) { .prevnext { grid-template-columns: 1fr; } .pn-next { text-align: left; } }

/* ---- Reading progress --------------------------------------------------------- */

.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 60;
  background: transparent;
  pointer-events: none;
}
.progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--g1), var(--g2));
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* ---- Search dialog --------------------------------------------------------------- */

.search-dialog {
  border: none;
  border-radius: 1.1rem;
  padding: 0;
  width: min(42rem, 92vw);
  margin: 10vh auto auto;
  background: var(--surface-2);
  color: var(--text);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  box-shadow: var(--shadow-lg);
}
.search-dialog::backdrop { background: rgba(9, 14, 26, 0.45); backdrop-filter: blur(3px); }

.search-box { padding: 1rem 1.1rem 1.1rem; }
.search-row { display: flex; align-items: center; gap: 0.7rem; }
.search-row > svg { width: 1.2rem; height: 1.2rem; color: var(--muted); flex: none; }
.search-row input { border: none; background: transparent; padding: 0.55rem 0.2rem; font-size: 1.08rem; }
.search-row input:focus-visible { outline: none; }
.search-row { border-bottom: 1px solid var(--line); padding-bottom: 0.5rem; }

.search-status { font-size: 0.85rem; color: var(--muted); margin: 0.6rem 0.2rem 0.2rem; min-height: 1.2em; }

.search-results {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  max-height: 52vh;
  overflow-y: auto;
}
.search-results li { margin: 0; }
.search-results a {
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: 0.7rem;
  text-decoration: none;
  color: var(--text);
}
.search-results a:hover { background: var(--accent-soft); }
.search-results li[aria-selected='true'] a { background: var(--accent-soft); outline: 2px solid var(--focus); outline-offset: -2px; }
.search-results .r-title { font-weight: 650; }
.search-results .r-meta { display: block; font-size: 0.83rem; color: var(--muted); margin-top: 0.1rem; }
.search-results mark { background: var(--mark); color: inherit; border-radius: 0.2em; padding: 0 0.08em; }

/* ---- Interactive tool flows -------------------------------------------------------- */

.flow { padding: clamp(1.2rem, 3vw, 2rem); margin: 1.6rem 0; }
.flow-progress { font-size: 0.82rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.7rem; }
.flow-q { font-size: 1.25rem; font-weight: 720; letter-spacing: -0.01em; margin-bottom: 0.35rem; }
.flow-help { color: var(--muted); font-size: 0.95rem; margin-bottom: 1.1rem; }

.flow-opts { display: grid; gap: 0.6rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.flow-opt {
  font: inherit;
  text-align: left;
  padding: 0.8rem 1.05rem;
  border-radius: 0.8rem;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.flow-opt:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: var(--shadow); }
.flow-opt strong { display: block; }
.flow-opt span { color: var(--muted); font-size: 0.9rem; }

.flow-result { border-radius: 0.9rem; padding: 1.1rem 1.3rem; margin-bottom: 1rem; border: 1px solid var(--line-strong); }
.flow-result.ok { background: var(--ok-bg); }
.flow-result.ok h3 { color: var(--ok-ink); }
.flow-result.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.flow-result.warn h3 { color: var(--warn-ink); }
.flow-result.info { background: var(--accent-soft); }
.flow-result h3 { margin-bottom: 0.5rem; }
.flow-result ul { margin-bottom: 0.4rem; }

.flow-trail { list-style: none; padding: 0; margin: 0 0 1rem; font-size: 0.88rem; color: var(--muted); }
.flow-trail li { border-left: 3px solid var(--line-strong); padding: 0.15rem 0 0.15rem 0.8rem; margin: 0; }
.flow-trail strong { color: var(--text); }

.flow-nav { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---- Quick reference page ------------------------------------------------------------ */

.qr-group { margin-bottom: 2rem; }
.qr-group h2 { margin: 1.6rem 0 0.8rem; }
.qr-item summary { padding: 0.8rem 1.1rem; }
.qr-item .s-title { font-size: 1.02rem; }

/* ---- Printable templates --------------------------------------------------------------- */

.printable .tpl-table { width: 100%; border-collapse: collapse; margin-bottom: 1.2rem; font-size: 0.95rem; }
.printable .tpl-table th,
.printable .tpl-table td { border: 1px solid var(--line-strong); padding: 0.55rem 0.7rem; text-align: left; vertical-align: top; }
.printable .tpl-table th { background: var(--accent-soft); font-weight: 650; width: 32%; }
.printable .tpl-lines td { height: 2.4em; }
.printable h2 { margin-top: 1.8rem; font-size: 1.15rem; }
.tpl-foot { font-size: 0.8rem; color: var(--muted); }
.print-only { display: none; }

/* body map figures and column widths (no inline styles — CSP-safe) */
.tpl-figures { display: flex; gap: 2rem; justify-content: center; flex-wrap: wrap; margin: 1rem 0; }
.tpl-figures figure { text-align: center; margin: 0; }
.body-svg { max-width: 150px; }
.printable .tpl-table th.tpl-w8 { width: 8%; }
.printable .tpl-table th.tpl-w15 { width: 15%; }
.printable .tpl-table th.tpl-w20 { width: 20%; }
.printable .tpl-table th.tpl-w22 { width: 22%; }
.printable .tpl-table th.tpl-w25 { width: 25%; }

/* ---- Footer ------------------------------------------------------------------------------ */

.site-foot {
  margin-top: clamp(2.5rem, 7vw, 5rem);
  border-top: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 0.94rem;
}
.foot-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
  padding: 2.4rem 0 1.6rem;
}
.foot-brand p { color: var(--muted); margin-top: 0.9rem; max-width: 26rem; }
.foot-disclaimer { font-size: 0.84rem; }
.site-foot h2 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.7rem; }
.site-foot ul { list-style: none; padding: 0; margin: 0; }
.site-foot li { margin-bottom: 0.45rem; }
.site-foot a { color: var(--text); text-decoration: none; }
.site-foot a:hover { color: var(--accent); text-decoration: underline; }
.foot-bar { border-top: 1px solid var(--line); padding: 1rem 0 1.2rem; color: var(--muted); font-size: 0.84rem; }
.foot-bar p { margin: 0; }

@media (max-width: 56rem) {
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-brand { grid-column: 1 / -1; }
}

/* ---- Reveal animation ---------------------------------------------------------------------- */

/* hidden state only applies once JS has confirmed it is running (html.js),
   so content is never invisible for no-JS visitors */
html.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.55s ease, transform 0.55s ease; }
html.js .reveal.in { opacity: 1; transform: none; }

/* ---- Reduced motion --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---- Print ------------------------------------------------------------------------------------- */

@media print {
  body { background: #fff; color: #000; font-size: 10.5pt; }
  body::before, .site-head, .site-foot, .search-dialog, .progress, .crumbs,
  .note-strip, .btn, .prevnext, .no-print, .hero-actions, .chev { display: none !important; }
  .card, .section, .callout { box-shadow: none; border: 1px solid #999; background: #fff; }
  .section summary { padding: 0.5rem 0.8rem; }
  a { color: #000; text-decoration: none; }
  .refs a::after { content: ' (' attr(href) ')'; font-size: 0.8em; color: #444; }
  .print-only { display: block; }
  .printable .tpl-table th, .printable .tpl-table td { border-color: #333; }
  .keypoints { border-left-color: #333; }
  h1 { font-size: 18pt; }
  .article-wrap { max-width: none; }
}
