/* ============================================================
   Public reader - neutral, matches the private app.
   White surface, zinc grays, Inter sans throughout.
   ============================================================ */

:root {
  /* Surface */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-raised: #fefefe;
  --surface-tint: #fafafa;

  /* Ink */
  --text: #18181b;
  --text-secondary: #3f3f46;
  --text-muted: #71717a;
  --text-subtle: #a1a1aa;

  /* Lines */
  --border: #e4e4e7;
  --border-subtle: #f4f4f5;
  --border-strong: #d4d4d8;

  /* Accent (matches private app: muted zinc, not colorful) */
  --accent: #52525b;
  --accent-hover: #3f3f46;
  --accent-soft: #f4f4f5;

  /* States */
  --mark: #fde68a;
  --mark-soft: #fef3c7;
  --mark-strong: #facc15;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;

  /* Type */
  --font-sans: "InterVariable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Geometry */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --max-read: 42rem;
  --max-page: 78rem;
  --header-h: 3.25rem;
  /* Total height of the pinned chrome above scrolling content: just the back
     bar by default; the desktop brand bar adds a second header height (set in
     the >=768px block). In-page sticky elements (toolbar, nav) offset by this. */
  --stack-h: var(--header-h);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-fast: 120ms;
  --t-med: 200ms;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 125%; }

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ============================================================
   Skip link + focus
   ============================================================ */

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.55rem 0.85rem;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transform: translateY(-150%);
  transition: transform var(--t-fast) var(--ease);
  z-index: 100;
}
.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

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

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================================================
   Brand bar - desktop only. The neola compass + site title,
   mirroring the private app's menubar lockup. Hidden on mobile.
   ============================================================ */

.brandbar { display: none; }

@media (min-width: 768px) {
  /* Pin the chrome on desktop: brand bar at the top, back bar stacked just
     below it, and bump --stack-h so the toolbar/nav offsets clear both bars. */
  :root {
    --stack-h: calc(var(--header-h) * 2);
  }
  .brandbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    background: linear-gradient(
      to bottom,
      color-mix(in oklab, #333333, white 12%) 0%,
      #333333 55%,
      color-mix(in oklab, #333333, black 14%) 100%
    );
    border-bottom: 1px solid rgb(255 255 255 / 0.08);
  }
  .brandbar-inner {
    max-width: var(--max-page);
    width: 100%;
    margin: 0 auto;
    padding: 0.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: var(--header-h);
  }
  .brandbar-logo {
    display: flex;
    align-items: center;
    height: 1.75rem;
    color: #ffffff;
    flex-shrink: 0;
  }
  .brandbar-logo svg {
    height: 100%;
    width: auto;
    display: block;
  }
  .brandbar-divider {
    width: 1px;
    height: 1.5rem;
    background: rgb(255 255 255 / 0.16);
    flex-shrink: 0;
  }
  .brandbar-title {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  /* Push login chrome to the far right of the brand bar. */
  .brandbar-login {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
  }
  .brandbar-email {
    font-size: 0.85rem;
    color: rgb(255 255 255 / 0.7);
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brandbar-login-link,
  .brandbar-logout {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgb(255 255 255 / 0.85);
    padding: 0.3rem 0.65rem;
    border: 1px solid rgb(255 255 255 / 0.2);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  }
  .brandbar-login-link:hover,
  .brandbar-logout:hover {
    background: rgb(255 255 255 / 0.12);
    color: #ffffff;
    text-decoration: none;
  }
}

/* ============================================================
   Header - minimal, just a back button on the left
   ============================================================ */

.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
/* On desktop the brand bar is pinned at top:0, so the back bar sticks just
   below it. Declared after the base rule so it wins by source order (same
   specificity); the brandbar @media block above runs earlier. */
@media (min-width: 768px) {
  .site-header {
    top: var(--header-h);
  }
}

.site-header-inner {
  max-width: var(--max-page);
  margin: 0 auto;
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  min-height: var(--header-h);
}

/* When there's no back link, collapse the header so it doesn't take space. */
.site-header-inner:empty { min-height: 0; padding: 0; }
.site-header:has(.site-header-inner:empty) { border-bottom: none; }

/* Login chrome in the site-header (mobile-visible, hidden on desktop where
   the brandbar takes over). Right-aligned via margin-left: auto. */
.site-header-login {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.site-header-login-link,
.site-header-logout {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.site-header-login-link:hover,
.site-header-logout:hover {
  background: var(--surface-tint);
  color: var(--text);
  text-decoration: none;
}
/* On desktop the brandbar handles login chrome; hide it in the site-header. */
@media (min-width: 768px) {
  .site-header-login { display: none; }
}

.site-header .back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  max-width: 100%;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.45rem 0.65rem 0.45rem 0.25rem;
  border-radius: var(--radius-sm);
  min-height: 36px;
  line-height: 1;
}
.site-header .back:hover {
  color: var(--text);
  background: var(--surface-tint);
  text-decoration: none;
}
.site-header .back:active { transform: translateY(1px); }
.site-header .back-chevron {
  width: 0.55em;
  height: 0.9em;
  flex: 0 0 auto;
  transition: transform var(--t-fast) var(--ease);
}
.site-header .back:hover .back-chevron { transform: translateX(-2px); }
.site-header .back > span:not(.back-chevron) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   Container + page title
   ============================================================ */

.container {
  max-width: var(--max-page);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}
@media (min-width: 768px) {
  .container { padding: 2.25rem 2rem 5rem; }
}

.page-title {
  margin: 0 0 0.35rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(1.4rem, 1rem + 1.4vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.012em;
  color: var(--text);
}

main:has(.book-layout) .page-title,
main:has(.results-count) .page-title,
main:has(.landing-hero) .page-title {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.page-subtitle {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.page-description {
  margin: 0.25rem 0 1.75rem;
  max-width: 42rem;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* ============================================================
   Landing hero - app-level intro page
   ============================================================ */

.landing-hero {
  padding: 1rem 0 1.25rem;
  margin: 0 0 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}
@media (min-width: 768px) {
  .landing-hero { padding: 1.5rem 0 1.75rem; margin-bottom: 2rem; }
}

.eyebrow {
  margin: 0 0 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0.7rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--accent-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
}
.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
}

.hero-title {
  margin: 0;
  font-weight: 600;
  font-size: clamp(1.85rem, 1.3rem + 2.2vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  max-width: 26ch;
}

.hero-description {
  margin: 1rem 0 0;
  max-width: 48rem;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--text-secondary);
  /* Honor author line breaks from the textarea while still wrapping
     long lines normally. */
  white-space: pre-line;
}

.section-eyebrow {
  margin: 0 0 0.85rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================================
   Book list - cards (refined for landing page)
   ============================================================ */

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cards a {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: start;
  position: relative;
  padding: 1.15rem 1.25rem;
  min-height: 6.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition:
    border-color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}
.cards a::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1.1rem;
  width: 0.55rem;
  height: 0.55rem;
  border-top: 1.5px solid var(--text-muted);
  border-right: 1.5px solid var(--text-muted);
  transform: translateY(-50%) rotate(45deg);
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.cards a:hover,
.cards a:focus-visible {
  border-color: var(--text-secondary);
  background: var(--surface-tint);
  text-decoration: none;
}
.cards a:hover::after,
.cards a:focus-visible::after {
  border-color: var(--text);
  transform: translate(2px, -50%) rotate(45deg);
}

.cards .book-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-secondary);
  flex: 0 0 auto;
}
.cards .book-icon svg { width: 1.25rem; height: 1.25rem; }

.book-card-body { min-width: 0; padding-right: 1.25rem; }

.cards .title {
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.3;
  color: var(--text);
}
.book-card-desc {
  margin-top: 0.3rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}
.book-card-meta {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.85rem;
}
.book-card-meta .count {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.book-card-meta .published {
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

@media (min-width: 640px) {
  .cards { grid-template-columns: 1fr 1fr; gap: 1rem; }
}
@media (min-width: 1024px) {
  .cards { grid-template-columns: 1fr 1fr 1fr; }
}

/* ============================================================
   Book detail layout - toolbar + sidebar + main
   ============================================================ */

.book-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "toolbar"
    "nav"
    "main";
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* min-width: 0 on every grid area so a long child (the horizontal
   section-chips row, a long policy title) can't push the grid item
   wider than the viewport. Default min-width: auto on grid items
   honours intrinsic content width and forces page-level overflow. */
.book-toolbar { grid-area: toolbar; min-width: 0; }
.book-nav     { grid-area: nav;     min-width: 0; }
.book-main    { grid-area: main;    min-width: 0; }

@media (min-width: 960px) {
  .book-layout {
    grid-template-columns: 15rem minmax(0, 1fr);
    grid-template-areas:
      "nav toolbar"
      "nav main";
    column-gap: 2.5rem;
    row-gap: 1rem;
  }
}

/* Toolbar - sticky on both mobile and desktop, anchored under the site
   header. On mobile the chip rail nests inside, so the combined block
   reads as one piece of chrome. */
.book-toolbar {
  position: sticky;
  top: var(--stack-h);
  z-index: 10;
  background: var(--bg);
  padding: 0.6rem 1.25rem 0.6rem;
  margin: 0 -1.25rem;
}
@media (min-width: 960px) {
  .book-toolbar {
    margin: 0;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
  }
}

/* Mobile-only section chip rail. Nested inside .book-toolbar in the
   HTML so it shares the toolbar's sticky context - no separate sticky
   block, no top-offset arithmetic to keep in sync with the toolbar's
   actual height. */
.section-chips-mobile {
  margin: 0.55rem -1.25rem 0;
  padding: 0 1.25rem 0.1rem;
}

/* Desktop sidebar */
.book-nav {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.book-nav-heading {
  display: none; /* labels are obvious from the pill row on mobile */
}

@media (min-width: 960px) {
  .book-nav {
    position: sticky;
    top: calc(var(--stack-h) + 1rem);
    align-self: start;
    max-height: calc(100vh - var(--stack-h) - 2.5rem);
    overflow-y: auto;
    padding-right: 0.5rem;
    scrollbar-width: thin;
  }
  .book-nav-heading {
    display: block;
    margin: 0;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
}

/* Section chips - horizontal row on mobile, vertical column on desktop */
.section-chips {
  display: flex;
  flex-direction: row;
  gap: 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 0.25rem 1.25rem 0.4rem;
  margin: 0 -1.25rem;
}
.section-chips a {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.825rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-height: 32px;
  transition: all var(--t-fast) var(--ease);
}
.section-chips a:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-tint);
  text-decoration: none;
}
.section-chips .chip-num {
  font-weight: 600;
  color: var(--text);
}
.section-chips .chip-name { display: none; }

@media (min-width: 960px) {
  .section-chips {
    flex-direction: column;
    gap: 0.1rem;
    margin: 0;
    padding: 0;
    overflow: visible;
  }
  .section-chips a {
    width: 100%;
    border: none;
    border-radius: var(--radius-sm);
    border-left: 2px solid transparent;
    background: transparent;
    padding: 0.45rem 0.75rem 0.45rem 0.85rem;
    font-size: 0.875rem;
    min-height: 0;
    color: var(--text-secondary);
    align-items: baseline;
    gap: 0.6rem;
  }
  .section-chips a:hover {
    background: var(--accent-soft);
    border-left-color: var(--border-strong);
    color: var(--text);
  }
  .section-chips .chip-num {
    flex: 0 0 auto;
    min-width: 2.4rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
  }
  .section-chips .chip-name {
    display: inline;
    color: inherit;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Show only the right variant for each viewport. Placed AFTER the
   base .section-chips rules so this `display:` value wins. */
.section-chips-desktop { display: none; }
@media (min-width: 960px) {
  .section-chips-mobile  { display: none; }
  .section-chips-desktop { display: flex; }
}

/* PDF link */
.book-pdf-link {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
}
.book-pdf-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem 0.4rem 0;
  color: var(--text-secondary);
  font-weight: 500;
}
.book-pdf-link a:hover { color: var(--text); text-decoration: none; }
.book-pdf-link svg { width: 0.95rem; height: 0.95rem; flex: 0 0 auto; }

/* ============================================================
   Policy detail layout - sibling nav rail + content (desktop only)
   ============================================================ */

/* When the rail is present the global page title is hidden and re-shown as
   .policy-title inside the content column (so it aligns with the body).
   display:none drops it from the a11y tree too, leaving .policy-title the
   single h1 - unlike .book-layout, which keeps a clipped h1 for a11y. */
main:has(.policy-layout) .page-title { display: none; }

.policy-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "main";
  margin-top: 0.25rem;
}
.policy-nav  { grid-area: nav;  min-width: 0; display: none; }
.policy-main { grid-area: main; min-width: 0; }

/* Mirrors .page-title so the in-content title reads identically on mobile,
   where the rail is hidden and this is the only title shown. */
.policy-title {
  margin: 0 0 0.35rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(1.4rem, 1rem + 1.4vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.012em;
  color: var(--text);
}

.policy-nav-heading { display: none; }

@media (min-width: 960px) {
  .policy-layout {
    grid-template-columns: 16rem minmax(0, 1fr);
    grid-template-areas: "nav main";
    column-gap: 2.5rem;
  }
  .policy-nav {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    position: sticky;
    top: calc(var(--stack-h) + 1rem);
    align-self: start;
    max-height: calc(100vh - var(--stack-h) - 2.5rem);
    overflow-y: auto;
    padding-right: 0.5rem;
    scrollbar-width: thin;
  }
  .policy-nav-heading {
    display: block;
    margin: 0;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  .policy-chips a[aria-current] {
    background: var(--accent-soft);
    border-left-color: var(--accent);
    color: var(--text);
    font-weight: 600;
  }
  .policy-chips a[aria-current] .chip-num { color: var(--text); }
}

/* ============================================================
   Search
   ============================================================ */

.search-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin: 0;
}
.search-row .search { flex: 1; margin: 0; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  /* min-width: 0 so this flex item can shrink to its track instead of being
     held at the input's intrinsic width, which forced page-level horizontal
     scroll at narrow widths / 400% zoom (WCAG 1.4.10 Reflow). */
  min-width: 0;
  margin: 0;
}
.search svg {
  position: absolute;
  left: 0.75rem;
  width: 16px; height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}
.search input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 0.5rem 0.75rem 0.5rem 2.35rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.search input[type="search"]::placeholder { color: var(--text-muted); }
/* When the search field has any text, tint the bg with the same soft
   blue used to highlight matches in the results - ties the input
   visually to the marked text. :placeholder-shown is the CSS-native
   "is empty" test, so this turns on automatically. */
.search input[type="search"]:not(:placeholder-shown) {
  background: #eff6ff;
}
.search input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(82 82 91 / 0.15);
}

/* ============================================================
   Section headers
   ============================================================ */

.section-header {
  margin: 2rem 0 0.75rem;
  padding: 0 0 0.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  /* clears the pinned chrome + sticky toolbar (search + mobile chip rail) */
  scroll-margin-top: calc(var(--stack-h) + 7rem);
}
.section-header:first-child { margin-top: 0.25rem; }

@media (min-width: 960px) {
  .section-header {
    margin-top: 1.75rem;
    /* clears the pinned chrome + sticky toolbar (search input) */
    scroll-margin-top: calc(var(--stack-h) + 5rem);
  }
}

/* ============================================================
   Policy list
   ============================================================ */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li {
  border-bottom: 1px solid var(--border-subtle);
}
.list li:last-child { border-bottom: none; }
.list a {
  display: grid;
  /* minmax(0, 1fr) (not bare 1fr) so the label column can shrink below its
     content width and wrap, instead of forcing page-level horizontal scroll
     at narrow widths / 400% zoom (WCAG 1.4.10 Reflow). */
  grid-template-columns: 4rem minmax(0, 1fr);
  gap: 0.25rem 0.85rem;
  align-items: baseline;
  padding: 0.85rem 0.5rem;
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: background var(--t-fast) var(--ease);
}
.list a:hover,
.list a:focus-visible {
  background: var(--surface-tint);
  text-decoration: none;
}
.list .num {
  grid-row: span 2;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.list .label {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text);
}
.list a:has(.num) .label { grid-column: 2; }
.list a:not(:has(.num)) {
  grid-template-columns: 1fr;
}

.list li.focus-flash {
  animation: focus-flash 1.4s ease-out;
}
@keyframes focus-flash {
  0%   { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* Search-results variations */
.section-tag {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}
.snippet {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
  font-weight: 400;
}
.snippet mark {
  background: #eff6ff;
  color: #1e3a8a;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}
.list a:hover .snippet mark {
  background: #dbeafe;
}

.results-count {
  margin: 0.5rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.results-count strong { color: var(--text); font-weight: 600; }
.results-count .clear {
  margin-left: 0.45rem;
  font-size: 0.8rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text-secondary);
}
.results-count .clear:hover {
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
}

.empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem 0;
}

/* ============================================================
   Policy detail
   ============================================================ */

.policy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.85rem;
  margin: 0.25rem 0 1.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.policy-meta .number {
  padding: 0.15rem 0.55rem;
  background: var(--accent-soft);
  color: var(--text-secondary);
  border-radius: 999px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
}
.policy-meta .status {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 500;
  background: var(--surface);
}

.policy-meta .lifecycle-date {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  text-transform: none;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.policy-meta .lifecycle-date .label {
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.highlight-banner {
  margin: 0 0 1.25rem;
  padding: 0.6rem 0.85rem;
  background: var(--mark-soft);
  border: 1px solid var(--mark-strong);
  border-left: 4px solid var(--mark-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
}
.highlight-banner strong {
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 600;
  padding: 0 2px;
  border-radius: 2px;
}
.highlight-banner .clear {
  margin-left: 0.45rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.05);
  color: var(--text);
  font-size: 0.8rem;
}
.highlight-banner .clear:hover {
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
}

.policy-content {
  max-width: var(--max-read);
  margin: 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
}
@media (min-width: 768px) {
  .policy-content { font-size: 1.05rem; }
}

.policy-content mark {
  background: #eff6ff;
  color: #1e3a8a;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

.policy-content h1,
.policy-content h2,
.policy-content h3,
.policy-content h4 {
  font-family: inherit;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1.5em;
  margin-bottom: 0.4em;
  color: var(--text);
}
.policy-content h2 { font-size: 1.3em; }
.policy-content h3 { font-size: 1.15em; }
.policy-content h4 { font-size: 1.05em; }

.policy-content p { margin: 0.85em 0; }
.policy-content ul, .policy-content ol { padding-left: 1.5em; }
.policy-content li { margin: 0.3em 0; }

.policy-content a {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}
.policy-content a:hover { text-decoration-color: var(--text); }

.policy-content blockquote {
  margin: 1.1em 0;
  padding: 0.25em 0 0.25em 1em;
  border-left: 3px solid var(--border-strong);
  color: var(--text-secondary);
}

.policy-content table {
  border-collapse: collapse;
  max-width: 100%;
  margin: 1em 0;
  font-size: 0.9rem;
}
.policy-content th,
.policy-content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
.policy-content th {
  background: var(--surface-tint);
  font-weight: 600;
}

/* ============================================================
   Policy attachments
   ============================================================ */

.policy-attachments {
  max-width: var(--max-read);
  margin: 2rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.policy-attachments h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.policy-attachments ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.policy-attachments li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}
.attachment-link {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  word-break: break-word;
}
.attachment-link:hover { text-decoration-color: var(--text); }
.attachment-size {
  flex: none;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Reduced motion + forced colors + print
   ============================================================ */

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

@media (forced-colors: active) {
  .cards a, .search input[type="search"],
  .section-chips a {
    border: 1px solid CanvasText;
  }
  :focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}

@media print {
  .site-header, .book-toolbar, .book-nav,
  .skip-link, .highlight-banner .clear {
    display: none !important;
  }
  body {
    background: white;
    color: black;
    font-size: 11pt;
  }
  .container { padding: 0; max-width: none; }
  .policy-content { max-width: none; font-size: 11pt; line-height: 1.5; }
  a { color: inherit; text-decoration: underline; }
  .section-header { break-after: avoid; }
  .list li { break-inside: avoid; }
}

.site-landing { max-width: 60rem; margin: 0 auto; padding: 2rem 1rem; }
.site-landing-hero h1 { margin: 0 0 0.5rem; }
.site-landing-lead { color: var(--text-secondary); margin: 0 0 2rem; }
.site-app-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem; }
.site-app-card { display: flex; flex-direction: column; gap: 0.25rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: 0.5rem; text-decoration: none; color: inherit; }
.site-app-card:hover { border-color: var(--text-secondary); }
.site-app-card-name { font-weight: 600; }
.site-app-card-type { font-size: 0.85rem; color: var(--text-muted); }

