:root {
  --bg: #f5efe4;
  --bg-soft: rgba(255, 255, 255, 0.72);
  --surface: rgba(255, 252, 246, 0.88);
  --surface-strong: #fffaf1;
  --ink: #1f1e1a;
  --muted: #665d4f;
  --border: rgba(31, 30, 26, 0.12);
  --accent: #c75b39;
  --accent-strong: #a63d1f;
  --accent-cool: #1d6f70;
  --shadow: 0 22px 60px rgba(41, 30, 15, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@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;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  /* Self-hosted font stack — no Google Fonts CDN dependency (honours "data stays on device") */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(199, 91, 57, 0.16), transparent 32%),
    radial-gradient(circle at bottom right, rgba(29, 111, 112, 0.18), transparent 30%),
    linear-gradient(180deg, #f8f2e8 0%, #efe5d6 100%);
}

code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
  font-size: 0.92em;
}

.page-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.85fr);
  gap: 24px;
  align-items: stretch;
}

.hero-copy,
.hero-panel,
.controls-panel,
.panel-card,
.project-card {
  background: var(--bg-soft);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-copy,
.hero-panel {
  border-radius: var(--radius-xl);
  padding: 32px;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(29, 111, 112, 0.12);
  color: var(--accent-cool);
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  line-height: 0.98;
  max-width: 10ch;
}

.hero-text {
  max-width: 60ch;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
}

.button-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(199, 91, 57, 0.28);
}

.button-secondary {
  background: rgba(29, 111, 112, 0.12);
  color: var(--accent-cool);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.metric-card,
.tip-card {
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid rgba(31, 30, 26, 0.08);
  padding: 18px;
}

.metric-label,
.tip-title {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 2rem;
  line-height: 1;
}

.tip-card {
  margin-top: 14px;
}

.tip-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.controls-panel {
  margin-top: 24px;
  border-radius: var(--radius-xl);
  padding: 24px;
}

.controls-row {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
}

.search-field {
  display: grid;
  gap: 8px;
  flex: 1;
  font-size: 0.94rem;
  font-weight: 600;
}

.search-field input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
}

.search-field input:focus {
  outline: 2px solid rgba(199, 91, 57, 0.18);
  border-color: var(--accent);
}

.status-badge {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 16px;
  background: rgba(29, 111, 112, 0.12);
  color: var(--accent-cool);
  font-weight: 700;
  white-space: nowrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.filter-chip {
  min-height: 44px;
  padding: 0 14px;
  /* AV6-09: explicit ~3:1 border so inactive chips meet WCAG 1.4.11
     non-text-contrast against the cream panel. var(--border) at 0.12 was
     too translucent (~1.5:1) for SR-disabled visual users. */
  border: 1px solid rgba(31, 30, 26, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.filter-chip.is-active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

/* Shared focus-visible ring across interactive elements */
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, .filter-chip:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

/* WCAG 2.4.4 / 3.2.5 — externally-targeted links announce "(opens in new tab)"
   via this visually-hidden helper. The visual "↗" glyph carries the cue for
   sighted users (with aria-hidden); SR users hear the parenthetical. */
.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;
}

/* Skip-navigation link: visible only when focused */
.skip-link {
  position: absolute;
  top: 8px;
  left: -10000px;
  padding: 8px 16px;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 700;
  border-radius: 8px;
  z-index: 1000;
  text-decoration: none;
}
.skip-link:focus {
  left: 8px;
}

/* Dark-mode support — mirrors the palette used by inner apps. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141618;
    --bg-soft: rgba(28, 31, 35, 0.75);
    --surface: rgba(28, 31, 35, 0.88);
    --surface-strong: #1c1f23;
    --ink: #e7e4dc;
    --muted: #98a0ae;
    --border: rgba(231, 228, 220, 0.14);
    --accent: #e07c5a;
    --accent-strong: #f08d6a;
    --accent-cool: #6eb8b9;
  }
  body {
    background:
      radial-gradient(circle at top left, rgba(224, 124, 90, 0.14), transparent 32%),
      radial-gradient(circle at bottom right, rgba(110, 184, 185, 0.12), transparent 30%),
      linear-gradient(180deg, #141618 0%, #1a1d21 100%);
  }
  .filter-chip { background: rgba(231, 228, 220, 0.06); }
  /* WCAG 1.4.3 — light-mode pill colour (#2f52a0 on #1c1f23 = 1.7:1) fails on dark surfaces */
  .pill-new { background: rgba(138, 166, 224, 0.18); color: #b0c4ec; }
}

.featured-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

/* Featured strip ("Start here") — six anchor tools above the grid. */
.featured-strip { margin: 24px 0 12px; }
.featured-strip-heading {
  font-size: 1.4rem; margin-bottom: 6px;
}
.featured-strip-sub {
  color: var(--muted); font-family: system-ui, sans-serif;
  font-size: 0.9rem; margin-bottom: 14px;
}
.featured-strip-row {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.featured-card {
  display: flex; flex-direction: row; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: rgba(179, 80, 43, 0.08);
  border: 1px solid rgba(179, 80, 43, 0.42);
  border-radius: 12px;
  text-decoration: none; color: var(--ink);
  font-family: system-ui, sans-serif;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.featured-card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.featured-card:hover, .featured-card:focus {
  background: rgba(179, 80, 43, 0.14);
  border-color: rgba(179, 80, 43, 0.35);
  transform: translateY(-1px);
}
.featured-card-name { font-size: 0.95rem; font-weight: 600; }
.featured-card-cat { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
@media (prefers-color-scheme: dark) {
  .featured-card { background: rgba(224, 124, 90, 0.10); border-color: rgba(224, 124, 90, 0.20); }
  .featured-card:hover, .featured-card:focus { background: rgba(224, 124, 90, 0.16); border-color: rgba(224, 124, 90, 0.40); }
}

/* Filter chip count "(n)" — quieter than the label */
.filter-chip-count { opacity: 0.55; font-weight: 500; margin-left: 2px; }

/* Subcategory chip row — appears below the main filter bar when a category has
   subcategories (currently Evidence Synthesis only). Visually softer than the
   primary filter chips so the hierarchy is readable. */
.subfilters { margin-top: 8px; padding-left: 14px; border-left: 2px solid var(--accent-cool); }
.subfilters[hidden] { display: none; }
.filter-chip-sub {
  font-size: 0.78rem;
  padding: 4px 10px;
  background: rgba(29, 111, 112, 0.10);
  border-color: rgba(29, 111, 112, 0.48);
  color: var(--ink);
}
.filter-chip-sub.is-active {
  background: var(--accent-cool);
  color: #fff;
  border-color: var(--accent-cool);
}

/* Course cross-link in card actions — secondary action, dashed underline */
.project-link-course {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 10px;
  background: transparent; color: var(--accent-cool);
  border: none; padding: 8px 0;
  font-size: 0.85rem; font-weight: 500;
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
}
.project-link-course:hover, .project-link-course:focus {
  color: var(--accent-strong);
}

/* Featured-card highlight in the main catalogue grid (subtle gold hairline) */
.project-card-featured { border-color: rgba(212, 175, 55, 0.55); }

.panel-card {
  border-radius: var(--radius-lg);
  padding: 24px;
}

.panel-card h2 {
  margin: 0 0 10px;
  font-size: 1.3rem;
}

.panel-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.notes-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.project-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 22px;
}

.project-card::before {
  content: "";
  position: absolute;
  inset: auto -20% 76% 48%;
  height: 120px;
  background: radial-gradient(circle, rgba(199, 91, 57, 0.22), transparent 70%);
  pointer-events: none;
}

.project-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.project-head > div {
  flex: 1;
  min-width: 0;
}

.project-head h3 {
  margin: 0;
  font-size: 1.26rem;
}

/* Inline-SVG thumbnails. Each card and featured-card gets a category-coloured
   gradient panel with a category-specific SVG icon rendered via currentColor.
   No CDN, no external assets. */
.project-thumb {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #555, #333);
  box-shadow: 0 4px 12px rgba(0,0,0,0.10);
}
.project-thumb svg {
  width: 70%;
  height: 70%;
  display: block;
}
.project-thumb-lg {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

/* Category palettes — keep the same hue family per concept so the catalogue
   reads at a glance ("the warm-orange ones are heterogeneity",
   "the indigo-cyan ones are NMA" etc.). */
.project-thumb-pooling      { background: linear-gradient(135deg, #2c5e8a, #1d6f70); }
.project-thumb-heterogeneity{ background: linear-gradient(135deg, #c75b39, #a63d1f); }
.project-thumb-pubbias      { background: linear-gradient(135deg, #7d4f9c, #5a3a78); }
.project-thumb-nma          { background: linear-gradient(135deg, #1d6f70, #134d4f); }
.project-thumb-dta          { background: linear-gradient(135deg, #3a7a8c, #1f5566); }
.project-thumb-rob          { background: linear-gradient(135deg, #a34a12, #6e3208); }
.project-thumb-reporting    { background: linear-gradient(135deg, #2f52a0, #1c357a); }
.project-thumb-screening    { background: linear-gradient(135deg, #0d7a27, #0a5a1c); }
.project-thumb-search       { background: linear-gradient(135deg, #5a8aa8, #2c5e8a); }
.project-thumb-planning     { background: linear-gradient(135deg, #6b9a6e, #3f6f48); }
.project-thumb-rwasm        { background: linear-gradient(135deg, #1f1e1a, #444); }
.project-thumb-trial        { background: linear-gradient(135deg, #b05a1c, #7a3d10); }
.project-thumb-qualitative  { background: linear-gradient(135deg, #8a7d2c, #5a5118); }
.project-thumb-living       { background: linear-gradient(135deg, #c75b39, #1d6f70); }
.project-thumb-hta          { background: linear-gradient(135deg, #4a4a78, #2c2c5a); }
.project-thumb-productivity { background: linear-gradient(135deg, #5a8aa8, #1d6f70); }
.project-thumb-default      { background: linear-gradient(135deg, #5c6470, #2c333d); }

.project-folder {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill-ready {
  background: rgba(29, 111, 112, 0.12);
  color: var(--accent-cool);
}

.pill-server {
  background: rgba(199, 91, 57, 0.14);
  color: var(--accent-strong);
}

.pill-new {
  background: rgba(47, 82, 160, 0.12);
  color: #2f52a0;
}

.project-summary {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.meta-tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(31, 30, 26, 0.05);
  color: var(--ink);
  font-size: 0.78rem;
}

.project-note {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  line-height: 1.55;
}

.project-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.project-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 700;
}

.project-link-primary {
  background: var(--ink);
  color: #fff;
}

.project-link-secondary {
  background: rgba(31, 30, 26, 0.07);
  color: var(--ink);
}

.project-link-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1024px) {
  .hero,
  .featured-panel,
  .catalog-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 1240px);
    padding-top: 18px;
  }

  .hero-copy,
  .hero-panel,
  .controls-panel,
  .panel-card,
  .project-card {
    padding: 20px;
  }

  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .status-badge {
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* U-P1-06: cap the filter bar on mobile so 17 chips don't push the catalogue
     below 6 rows. Vertical scroll preserves discoverability without dominating
     the viewport. */
  .filters {
    max-height: 11.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Site footer (U-P1-01, U-P1-07) */
.site-footer {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}
.footer-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: 2fr 1fr;
  align-items: start;
}
@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr; }
}
.footer-credit { margin: 0 0 6px; }
.footer-cite { margin: 0 0 6px; font-style: normal; }
.footer-cite em { font-style: italic; color: var(--ink); }
.footer-press { margin: 6px 0 0; font-size: 0.85rem; }
.footer-press kbd {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 1px;
  font: inherit;
  font-size: 0.78rem;
  background: rgba(31,30,26,0.06);
  border: 1px solid rgba(31,30,26,0.18);
  border-radius: 4px;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  .footer-press kbd {
    background: rgba(231,228,220,0.08);
    border-color: rgba(231,228,220,0.18);
  }
}
.footer-h {
  margin: 0 0 6px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.footer-links { list-style: none; padding: 0; margin: 0; }
.footer-links li { margin-bottom: 4px; }
.footer-links a { color: var(--accent-cool); text-decoration: none; }
.footer-links a:hover, .footer-links a:focus-visible { text-decoration: underline; }
