/* ==========================================================================
   D04 Evidence Hub — page styles
   Hero + KPI strip, filterable study library, forest plot, and three
   overlays: HCP gate, study drawer, clinical-summary download.
   Behaviour: assets/js/pages/d04-evidence-hub.js
   ========================================================================== */

.evidence-page {
  position: relative;
  min-height: 100vh;
  background: var(--graphite-50);
}

/* ── Hero ───────────────────────────────────────────────────────────────── */

.evidence-hero {
  position: relative;
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(32px, 5vw, 64px) clamp(20px, 4.2vw, 60px) clamp(40px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.evidence-hero__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}

.evidence-hero__titles {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 780px;
}

.evidence-hero__title {
  margin: 0;
  font: 500 clamp(48px, 1.4rem + 5.4vw, 112px)/.94 'Geist', sans-serif;
  letter-spacing: -.045em;
}
.evidence-hero__title .serif-accent { font-size: 1.1em; letter-spacing: inherit; }

.btn--lg.evidence-hero__cta { padding: 0 26px; }

/* KPI strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  border-top: 1px solid var(--ink-a12);
}

.kpi {
  padding: 22px 20px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-right: 1px solid var(--ink-a08);
}

.kpi__value {
  font: 500 clamp(40px, 1.6rem + 2vw, 64px)/1 'Geist', sans-serif;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.kpi__unit {
  margin-left: 4px;
  font: 500 15px 'Geist Mono', monospace;
  color: var(--graphite-500);
}

.kpi__text {
  font: 400 14px/1.4 'Geist', sans-serif;
  color: var(--graphite-600);
}

/* ── Study library ──────────────────────────────────────────────────────── */

.library {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4.2vw, 60px) clamp(64px, 8vw, 112px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.library__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink-a12);
}

.library__count {
  font: 500 13px/1 'Geist Mono', monospace;
  color: var(--graphite-600);
  font-variant-numeric: tabular-nums;
}

.library__filters {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--ink-a20);
  border-radius: var(--radius-pill);
  background: var(--graphite-0);
}
.search-field:focus-within { border-color: var(--graphite-900); }

.search-field__icon {
  flex: none;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--graphite-600);
  border-radius: 50%;
}

.search-field__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: 400 16px/1 'Geist', sans-serif;
}

/* Facet rows */
.facet {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.facet__label {
  width: 92px;
  font: 500 11px/1 'Geist Mono', monospace;
  letter-spacing: .08em;
  color: var(--graphite-500);
}

.facet-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--ink-a20);
  border-radius: var(--radius-pill);
  background: var(--graphite-0);
  color: var(--graphite-900);
  font: 500 14px/1 'Geist', sans-serif;
  cursor: pointer;
}

.facet-chip[aria-pressed="true"] {
  border-color: var(--graphite-900);
  background: var(--graphite-900);
  color: var(--graphite-50);
}
/* The (empty) mark is its own flex item, so it always adds one 6px gap */
.facet-chip[aria-pressed="true"] .facet-chip__mark::before { content: '✓'; }

.facet-chip__count {
  font: 400 11px/1 'Geist Mono', monospace;
  opacity: .7;
}

.library__clear {
  align-self: flex-start;
  height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--graphite-900);
  font: 500 14px/1 'Geist', sans-serif;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Study cards */
.study-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

.study {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--ink-a12);
  border-radius: var(--radius-l);
  background: var(--graphite-0);
}

.study__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.study__tag {
  height: 22px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--ink-a20);
  border-radius: var(--radius-s);
  font: 500 11px/1 'Geist Mono', monospace;
}

.study__tag--hcp {
  border: 0;
  background: var(--status-medium-bg);
  color: var(--status-medium-fg);
}

.study__title {
  margin: 0;
  font: 500 18px/1.3 'Geist', sans-serif;
  letter-spacing: -.01em;
}

.study__facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font: 400 13px/1.4 'Geist', sans-serif;
}

.study__key { color: var(--graphite-500); }
.study__n { font-variant-numeric: tabular-nums; }
.study__result { font: 500 13px/1.4 'Geist Mono', monospace; }

.study__foot {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--ink-a10);
  font: 400 12px/1 'Geist Mono', monospace;
  color: var(--graphite-500);
}

.study__details {
  height: 36px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--scrub-600);
  font: 500 14px/1 'Geist', sans-serif;
  cursor: pointer;
}

/* Empty state */
.library__empty {
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border: 1px dashed var(--ink-a24);
  border-radius: var(--radius-l);
  text-align: center;
}

.library__empty-title { font: 500 18px/1.3 'Geist', sans-serif; }

.library__empty-text {
  font: 400 15px/1.5 'Geist', sans-serif;
  color: var(--graphite-600);
}

.library__empty-btn {
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--graphite-900);
  border-radius: var(--radius-pill);
  background: var(--graphite-0);
  color: var(--graphite-900);
  cursor: pointer;
}

/* ── Forest plot ────────────────────────────────────────────────────────── */

.forest-section {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4.2vw, 60px) clamp(72px, 9vw, 128px);
}

.forest {
  margin: 0;
  padding: clamp(24px, 3vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--ink-a12);
  border-radius: var(--radius-l);
  background: var(--graphite-0);
}

.forest__head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.forest__title {
  margin: 0;
  font: 500 clamp(24px, 1.2rem + 1vw, 34px)/1.15 'Geist', sans-serif;
  letter-spacing: -.02em;
}

.forest__axis-label,
.forest__n {
  font: 400 12px/1 'Geist Mono', monospace;
  color: var(--graphite-500);
}
.forest__n { font-size: 11px; }

.forest__rows {
  display: flex;
  flex-direction: column;
}

.forest__row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 2.4fr) 120px;
  gap: 16px;
  align-items: center;
  min-height: 40px;
  border-bottom: 1px solid rgba(10, 18, 22, .06);
}

.forest__study { font: 400 14px/1.2 'Geist', sans-serif; }

.forest__value {
  font: 400 13px/1 'Geist Mono', monospace;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.forest__row--pooled .forest__study,
.forest__row--pooled .forest__value { font-weight: 500; }

.forest__plot {
  position: relative;
  height: 20px;
}

/* Line of no effect at 0 (= 25% of the −5…+15 axis) */
.forest__zero {
  position: absolute;
  left: 25%;
  top: -10px;
  bottom: -10px;
  width: 1px;
  background: rgba(10, 18, 22, .4);
}

.forest__ci {
  position: absolute;
  left: var(--lo);
  top: 50%;
  width: var(--ci);
  height: 1px;
  background: var(--graphite-900);
}

.forest__point {
  position: absolute;
  left: var(--pt);
  top: 50%;
  width: var(--size);
  height: var(--size);
  background: var(--graphite-900);
  transform: translate(-50%, -50%);
}
.forest__row--pooled .forest__point {
  background: var(--scrub-600);
  transform: translate(-50%, -50%) rotate(45deg);
}

.forest__caption {
  font: 400 12px/1.5 'Geist Mono', monospace;
  color: var(--graphite-500);
}

/* ── Overlays ───────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.modal-backdrop--gate,
.modal-backdrop--download {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop--gate { background: rgba(10, 18, 22, .45); }
.modal-backdrop--drawer { background: var(--ink-a30); }
.modal-backdrop--download { z-index: 70; background: rgba(10, 18, 22, .4); }

/* HCP gate */
.gate {
  width: min(520px, 100%);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-radius: var(--radius-l);
  background: var(--graphite-0);
}

.gate__label {
  font: 500 11px/1 'Geist Mono', monospace;
  letter-spacing: .08em;
  color: var(--status-medium-fg);
}

.gate__title {
  margin: 0;
  font: 500 24px/1.25 'Geist', sans-serif;
}

.gate__text {
  margin: 0;
  font: 400 15px/1.55 'Geist', sans-serif;
  color: var(--graphite-750);
}

.gate__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gate__btn {
  height: 52px;
  border-radius: var(--radius-pill);
  font: 500 16px/1 'Geist', sans-serif;
  cursor: pointer;
}

.gate__btn--confirm {
  border: 0;
  background: var(--graphite-900);
  color: var(--graphite-50);
}

.gate__btn--doccheck {
  border: 1px solid var(--ink-a24);
  background: var(--graphite-0);
  color: var(--graphite-900);
}

.gate__exit,
.gate__exit:hover {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--graphite-900);
  font: 500 15px/1 'Geist', sans-serif;
}

/* Study drawer */
.study-drawer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(560px, 100%);
  box-sizing: border-box;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
  background: var(--graphite-0);
  box-shadow: -24px 0 60px -30px rgba(10, 18, 22, .4);
}

.study-drawer__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.study-drawer__close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font: 400 20px/1 'Geist Mono', monospace;
  cursor: pointer;
}

.study-drawer__title {
  margin: 0;
  font: 500 28px/1.2 'Geist', sans-serif;
  letter-spacing: -.02em;
}

.study-drawer__facts {
  margin: 0;
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px 16px;
  font: 400 15px/1.45 'Geist', sans-serif;
}
.study-drawer__facts dt { color: var(--graphite-500); }
.study-drawer__facts dd { margin: 0; }
.study-drawer__facts .study-drawer__result { font-family: 'Geist Mono', monospace; }

.study-drawer__summary {
  margin: 0;
  padding: 16px;
  border-radius: var(--radius-m);
  background: var(--graphite-50);
  font: 400 14px/1.6 'Geist', sans-serif;
  color: var(--graphite-750);
}

.study-drawer__ref {
  font: 400 12px/1.5 'Geist Mono', monospace;
  color: var(--graphite-500);
}

.study-drawer__actions {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.study-drawer__download { background: var(--graphite-0); }

.study-drawer__cta {
  padding: 0 20px;
  font-size: 15px;
}

/* Clinical summary download */
.download {
  width: min(520px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: var(--radius-l);
  background: rgba(245, 246, 243, .95);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  box-shadow: 0 24px 60px -20px rgba(10, 18, 22, .4);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Form parts join the dialog's flex column directly */
.download__form,
.download__fields {
  display: contents;
}

.download__title {
  margin: 0;
  font: 500 26px/1.2 'Geist', sans-serif;
  letter-spacing: -.02em;
}

.download__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.download__field-label { font: 500 14px/1 'Geist', sans-serif; }

.download__input {
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--ink-a24);
  border-radius: var(--input-radius);
  background: var(--graphite-0);
  font: 400 16px/1 'Geist', sans-serif;
}

.download__optin {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font: 400 14px/1.45 'Geist', sans-serif;
  cursor: pointer;
}

.download__checkbox {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--scrub-600);
}

.download__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.download__cancel {
  height: 48px;
  padding: 0 16px;
  border: 0;
  background: none;
  font: 500 15px/1 'Geist', sans-serif;
  cursor: pointer;
}
.download__cancel--close { padding: 0 14px; }

.download__privacy {
  font: 400 12px/1.4 'Geist', sans-serif;
  color: var(--graphite-500);
}

.download__done {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.download__check {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--status-success-bg);
  color: var(--status-success-fg);
  font: 600 20px/1 'Geist', sans-serif;
}

.download__done-title { font: 500 22px/1.25 'Geist', sans-serif; }

.download__done-text {
  font: 400 15px/1.5 'Geist', sans-serif;
  color: var(--graphite-600);
}

.download__done-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
