/* ==========================================================================
   the patient audit — stylesheet
   Design: quiet, light, line-driven. Pale grey-white ground, a single thin
   periwinkle accent, content sections that read as equal in weight. Mobile
   layout is enforced on every viewport (including desktop) — a fixed-width
   column, centered.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600&family=Inter:wght@400;500;600&display=swap');

:root {
  /* Color tokens — pale grey-white ground, soft periwinkle accent */
  --ink: #2b2d33;
  --ink-dim: #4a4d56;
  --ink-faint: #9498a3;
  --paper: #fbfbfa;
  --paper-raised: #f4f4f6;
  --paper-line: #e3e3e8;
  --accent: #6b6fd6;
  --accent-soft: #8d90e0;

  /* Type */
  --font-display: 'Source Serif 4', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Layout */
  --col-width: 440px;
  --gutter: 20px;
}

* { box-sizing: border-box; }

html {
  background: #e9e9ed;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: #e9e9ed;
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-weight: 400;
}

/* Force a single mobile-width column on every viewport, including desktop. */
.viewport {
  width: 100%;
  max-width: var(--col-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
  position: relative;
  /* Clear the phone's own status bar (signal / wifi / battery icons) when
     the site is opened full-screen or added to the home screen. Falls back
     to a small fixed gap on devices/browsers that don't report a safe area. */
  padding-top: max(16px, env(safe-area-inset-top, 16px));
}

@media (min-width: 540px) {
  body {
    padding: 32px 16px;
  }
  .viewport {
    min-height: calc(100vh - 64px);
    border: 1px solid var(--paper-line);
    /* On desktop the viewport is a centered card, not a real phone screen —
       no status bar to clear, so drop back to the design's normal spacing. */
    padding-top: 0;
  }
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

::selection { background: var(--accent-soft); color: #fff; }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Header / masthead — homepage only
   -------------------------------------------------------------------------- */

.masthead {
  padding: 26px var(--gutter) 16px;
  border-bottom: 1px solid var(--paper-line);
}

.masthead__brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: fit-content;
}

.masthead__brand:hover .masthead__name {
  color: var(--accent);
}

.masthead__mark {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.masthead__name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  text-transform: lowercase;
}

.masthead__tagline {
  margin: 5px 0 0;
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Back navigation — case & detail pages
   -------------------------------------------------------------------------- */

.case-page__back,
.detail-page__back {
  display: block;
  margin: 22px var(--gutter) 0;
  font-size: 13px;
  color: var(--ink-faint);
}

.case-page__back:hover,
.detail-page__back:hover { color: var(--accent); }

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

.search {
  padding: 16px var(--gutter);
  border-bottom: 1px solid var(--paper-line);
}

.search__field {
  position: relative;
}

.search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  stroke: var(--ink-faint);
  pointer-events: none;
}

.search input[type="text"] {
  width: 100%;
  padding: 10px 34px 10px 34px;
  background: transparent;
  border: 1px solid var(--paper-line);
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
}

.search input[type="text"]::placeholder {
  color: var(--ink-faint);
}

.search input[type="text"]:focus {
  border-color: var(--accent-soft);
}

.search__clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.search__clear[hidden] {
  display: none;
}

.search__clear svg {
  width: 13px;
  height: 13px;
  stroke: var(--ink-faint);
}

.search__clear:hover {
  background: var(--paper-raised);
}

.search__clear:hover svg {
  stroke: var(--ink);
}

#search-results { margin-top: 10px; }

.search-empty {
  font-size: 13px;
  color: var(--ink-faint);
  padding: 8px 0;
}

.search-result {
  display: block;
  padding: 12px 0;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--paper-line);
}

.search-result:first-child {
  padding-top: 4px;
}

.search-result__title {
  display: block;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

.search-result:hover .search-result__title {
  color: var(--accent);
}

.search-result__title mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}

.search-result__excerpt {
  display: block;
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  /* Clamp long excerpts to two lines so results stay scannable and don't
     visually run into one another. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result__excerpt mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Case directory (home page)
   -------------------------------------------------------------------------- */

.directory {
  padding: 0 0 24px;
}

.case-row {
  display: block;
  padding: 16px var(--gutter);
  border-bottom: 1px solid var(--paper-line);
}

.case-row__title {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

.case-row__arrow {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-faint);
}

.case-row:hover .case-row__title { color: var(--accent); }

.directory__empty {
  padding: 40px var(--gutter);
  text-align: center;
  color: var(--ink-faint);
  font-size: 14px;
}

/* --------------------------------------------------------------------------
   Case page (level 2) & Detail page (level 3) — shared content rhythm
   -------------------------------------------------------------------------- */

.case-page__title,
.detail-page__title {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.45;
  margin: 18px var(--gutter) 0;
  color: var(--ink);
}

.detail-page__eyebrow {
  margin: 22px var(--gutter) 0;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.detail-page__title { margin-top: 6px; }

.section {
  padding: 20px var(--gutter);
  border-bottom: 1px solid var(--paper-line);
}

.section__heading {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 10px;
  font-weight: 500;
}

.section__body {
  font-size: 14.5px;
  color: var(--ink-dim);
  white-space: pre-line;
}

.section__body p { margin: 0 0 12px; }
.section__body p:last-child { margin-bottom: 0; }

/* Outcome of treatment reads as plain text, same weight as every other
   section — no pill, no badge. */
.outcome-text {
  font-size: 14.5px;
  color: var(--ink-dim);
}

/* The one interactive link inside a case page: plain text plus a trailing
   arrow, no card, no border, no background — just enough to signal that
   it leads somewhere. */
.detail-link {
  display: block;
  font-size: 14.5px;
  color: var(--ink-dim);
}

.detail-link:hover { color: var(--accent); }

.detail-link__arrow {
  color: var(--ink-faint);
  margin-left: 4px;
}

.detail-link:hover .detail-link__arrow { color: var(--accent); }

/* EDI block — same quiet plain-text rhythm as Summary / Outcome Analysis,
   formatted close to the raw source list rather than as a table. */
.edi-list {
  font-size: 14.5px;
  color: var(--ink-dim);
}

.edi-list__row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
}

.edi-list__name { color: var(--ink-dim); }
.edi-list__score { color: var(--ink-faint); flex-shrink: 0; }

.edi-list__total {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0 0;
  margin-top: 6px;
  border-top: 1px solid var(--paper-line);
  color: var(--ink);
}

/* --------------------------------------------------------------------------
   Detail page body (level 3)
   -------------------------------------------------------------------------- */

.detail-page__body {
  padding: 20px var(--gutter) 32px;
  font-size: 14.5px;
  color: var(--ink-dim);
}

.detail-page__body p {
  margin: 0 0 14px;
  white-space: pre-line;
}

.detail-page__divider {
  margin: 16px 0;
  border: none;
  border-top: 1px solid var(--paper-line);
}

.detail-page__footer-back {
  margin: 8px var(--gutter) 28px;
}

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

.site-footer {
  padding: 22px var(--gutter) 28px;
  font-size: 11px;
  color: var(--ink-faint);
  text-align: center;
  border-top: 1px solid var(--paper-line);
}

.site-footer__home:hover {
  color: var(--accent);
}
