/* =============================================================
   Secondwave Clinical Conditions — Shared Stylesheet
   Brand: #FF0049 as the only true brand color.
   Substrate: paper-white / cool slate / cool gray.
   Status accents: green (queries), cool blue (HCC), amber (warning).
   ============================================================= */

:root {
  /* Brand */
  --brand:        #FF0049;
  --brand-soft:   #FFE5ED;
  --brand-dim:    #FFB0C2;
  --brand-deep:   #C4003A;

  /* Substrate */
  --bg:           #f7f7f9;
  --card:         #ffffff;
  --text:         #0f1117;
  --text-2:       #2c2e33;
  --muted:        #6b7280;
  --line:         #e5e7eb;
  --line-soft:    #f1f3f7;

  /* Status accents (chosen to pair with #FF0049 without clashing) */
  --good:         #ECFDF3;
  --good-text:    #027A48;
  --good-line:    rgba(2, 122, 72, 0.18);

  --info:         #EFF6FF;
  --info-text:    #1D4ED8;

  --purple:       #F4F3FF;
  --purple-text:  #5925DC;

  --warn:         #FFF7ED;
  --warn-text:    #9A3412;

  --neutral:      #F1F5F9;
  --neutral-text: #475569;

  /* Shape */
  --radius-lg:    18px;
  --radius-md:    14px;
  --radius-sm:    10px;
  --radius-pill:  999px;

  /* Shadows */
  --shadow:       0 10px 25px rgba(15, 17, 23, 0.06);
  --shadow-sm:    0 4px 12px rgba(15, 17, 23, 0.04);

  /* Type */
  --font-sans:    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* =============================================================
   Page shell
   ============================================================= */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
}

/* =============================================================
   Hero
   ============================================================= */

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 18px 20px;
  background: linear-gradient(135deg, #ffffff 0%, #FFF5F8 100%);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  letter-spacing: -0.025em;
  color: var(--text);
  font-weight: 750;
}

.hero .subline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero .compact-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 760px;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 8px;
  min-width: 300px;
}

.metric {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
}

.metric strong {
  display: block;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  color: var(--text);
  font-weight: 750;
}

.metric span {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* =============================================================
   Pills
   ============================================================= */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: var(--neutral);
  color: var(--neutral-text);
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap;
  text-decoration: none;
}

.pill.brand   { background: var(--brand-soft); color: var(--brand-deep); }   /* Outpatient setting pill */
.pill.blue    { background: var(--info);       color: var(--info-text); }    /* Inpatient setting pill, CMS-HCC v28 */
.pill.green   { background: var(--good);       color: var(--good-text); }    /* Sample query, success */
.pill.purple  { background: var(--purple);     color: var(--purple-text); }  /* HHS-HCC */
.pill.amber   { background: var(--warn);       color: var(--warn-text); }    /* Elixhauser, low confidence */

.pill.outline {
  background: transparent;
  border: 1px solid var(--brand);
  color: var(--brand);
}

.pill.outline:hover {
  background: var(--brand);
  color: white;
}

/* Cross-link pill in hero subline */
.pill.cross-link {
  background: white;
  border: 1px solid var(--brand-dim);
  color: var(--brand-deep);
  font-size: 0.78rem;
  transition: background 0.12s ease, color 0.12s ease;
}

.pill.cross-link:hover {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

/* =============================================================
   Two-column body grid
   ============================================================= */

.grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 14px;
  margin-top: 14px;
}

/* =============================================================
   Cards
   ============================================================= */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  /* overflow: visible so absolutely-positioned tooltips can escape card bounds.
     Internal rounded-corner clipping isn't needed because no children fill the
     full card width with backgrounds. */
  overflow: visible;
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.card-header h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.015em;
  color: var(--text);
  font-weight: 700;
}

.card-body { padding: 12px 14px; }

/* Info tooltip button (used to replace persistent hint text) */
.info-tip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  font-size: 0.74rem;
  line-height: 1;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.info-tip:hover,
.info-tip:focus-visible {
  color: var(--brand);
  border-color: var(--brand-dim);
  outline: none;
}

.info-tip:hover::after,
.info-tip:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  right: 0;
  top: 130%;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  background: #101828;
  color: white;
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: 400;
  font-size: 0.78rem;
  line-height: 1.4;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 5;
  white-space: normal;
  text-align: left;
}

.compact-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* =============================================================
   Risk / Methodology Impact (OP)
   ============================================================= */

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

.impact {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: #fbfcff;
}

.impact b {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.impact span {
  display: block;
  font-weight: 750;
  font-size: 0.95rem;
  color: var(--text);
}

.impact .compact-note { margin-top: 4px; }

/* =============================================================
   Concept cards (definition split)
   ============================================================= */

.definition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 9px;
}

.mini-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px;
  background: #ffffff;
  min-height: 118px;
}

.mini-box h3 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  letter-spacing: -0.015em;
  color: var(--text);
  font-weight: 700;
}

.mini-box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* Acid-Base style: inline-label mini-box */
.mini-box.inline {
  min-height: auto;
  padding: 10px 12px;
}

.mini-box.inline b {
  color: var(--text);
  font-weight: 700;
  margin-right: 6px;
}

/* =============================================================
   Severity / Diagnostic snapshot grid
   ============================================================= */

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

.severity {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px;
  background: #ffffff;
}

.severity h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 700;
}

.severity .value {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 0.75rem;
  font-weight: 700;
}

.severity ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.severity p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* Disorder grid (Acid-Base style: 3 cols) */
.disorder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.disorder {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px;
  background: #ffffff;
}

.disorder h3 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 700;
}

/* Generic value pill (used in disorder grids, severity grids, and inline in body copy) */
.value {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--neutral);
  color: var(--neutral-text);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Inside disorder/severity tile cards, the value gets a margin */
.disorder .value,
.severity .value { margin-bottom: 6px; font-size: 0.74rem; }

/* Comparator-aware value pills (apply via class .gt / .lt) */
.value.gt { background: var(--warn); color: var(--warn-text); }
.value.lt { background: var(--info); color: var(--info-text); }

.disorder p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* =============================================================
   Model coefficients (OP)
   ============================================================= */

.score-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.score {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 4px;
  text-align: center;
  background: #fbfcff;
}

.score b {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-weight: 700;
}

.score span {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text);
}

/* =============================================================
   Collapsibles
   ============================================================= */

details {
  border-top: 1px solid var(--line);
}

details:first-child { border-top: 0; }

summary {
  cursor: pointer;
  list-style: none;
  padding: 11px 14px;
  font-weight: 700;
  font-size: 0.93rem;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

summary::-webkit-details-marker { display: none; }

summary::after {
  content: "+";
  color: var(--brand);
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1;
}

details[open] summary::after { content: "–"; }

.detail-content {
  padding: 0 14px 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.detail-content p { margin: 0 0 8px; }
.detail-content p:last-child { margin-bottom: 0; }
.detail-content b { color: var(--text); }

/* =============================================================
   ICD code chips with hover notes
   ============================================================= */

.code-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.code-chip {
  border: 1px solid var(--line);
  background: #fbfcff;
  border-radius: var(--radius-pill);
  padding: 5px 10px;
  font-size: 0.78rem;
  cursor: help;
  position: relative;
  color: var(--text);
}

.code-chip b { color: var(--brand-deep); font-weight: 750; }

.code-chip:hover::after,
.code-chip:focus::after {
  content: attr(data-notes);
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #101828;
  color: white;
  font-size: 0.78rem;
  line-height: 1.45;
  box-shadow: var(--shadow);
  font-weight: 400;
  text-align: left;
  white-space: normal;
  pointer-events: none;
}

/* ICD code group (collapsible details element used to group large code lists) */
.code-group { margin-bottom: 10px; }
.code-group:last-child { margin-bottom: 0; }

/* Static (non-collapsible) group header — used when group is just a div */
.code-group-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

/* Collapsible code group — same look as static header but with +/- toggle */
details.code-group {
  border-top: 0;
  margin-bottom: 10px;
}

details.code-group:last-child { margin-bottom: 0; }

details.code-group > summary {
  padding: 0 0 6px 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 0;
}

details.code-group > summary::-webkit-details-marker { display: none; }

details.code-group > summary::after {
  content: "+";
  color: var(--brand);
  font-weight: 800;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1;
}

details.code-group[open] > summary::after { content: "–"; }

details.code-group > summary:hover { color: var(--text); }

/* =============================================================
   Sample query
   ============================================================= */

.query-box {
  border-radius: var(--radius-md);
  background: var(--good);
  color: var(--good-text);
  padding: 14px;
  font-size: 0.88rem;
}

.query-box h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--good-text);
  font-weight: 750;
}

.query-box p {
  margin: 0 0 10px;
  line-height: 1.5;
  color: var(--good-text);
}

.query-options {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.option {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--good-line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-weight: 700;
  color: var(--good-text);
  font-size: 0.87rem;
}

/* "Show more options" expander, only used when 4+ options */
.options-more {
  margin-top: 6px;
}

.options-more summary {
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px dashed var(--good-line);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--good-text);
  font-weight: 700;
  display: inline-flex;
  cursor: pointer;
}

.options-more summary::after { content: ""; }
.options-more[open] summary { display: none; }
.options-more .query-options { margin-top: 6px; }

/* =============================================================
   References
   ============================================================= */

.refs {
  display: grid;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.refs a {
  color: var(--brand-deep);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid var(--brand-dim);
}

.refs a:hover {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* =============================================================
   Reference tables (when 5+ tables → group + collapse)
   ============================================================= */

.table-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #ffffff;
}

.table-card:last-child { margin-bottom: 0; }

.table-card h4 {
  margin: 0 0 6px;
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 700;
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.table-card th,
.table-card td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  color: var(--text);
}

.table-card th {
  font-weight: 700;
  color: var(--text-2);
  background: var(--neutral);
}

.table-card tr:last-child td { border-bottom: 0; }

/* =============================================================
   Footer meta
   ============================================================= */

.footer-meta {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  align-items: center;
}

.footer-meta .pill { font-size: 0.72rem; }

/* =============================================================
   Index landing page
   ============================================================= */

.landing-hero {
  padding: 24px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #ffffff 0%, #FFF5F8 100%);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.landing-hero h1 {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  letter-spacing: -0.025em;
  font-weight: 750;
}

.landing-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.search-bar {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.search-bar input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: white;
  color: var(--text);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.search-bar input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0;
}

.tab-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px;
  background: white;
}

.tab-group button {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.tab-group button.active {
  background: var(--brand);
  color: white;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px;
  background: white;
}

.view-toggle button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.view-toggle button.active {
  background: var(--neutral);
  color: var(--text);
}

.condition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.condition-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.condition-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--brand-dim);
}

.condition-card .row1 {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.condition-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -0.015em;
  font-weight: 700;
}

.condition-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  align-items: center;
}

.condition-card .meta b {
  color: var(--text);
  font-weight: 700;
}

/* Count chip: matches pill geometry but reads as metadata, not a clickable filter */
.count-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.count-chip b {
  color: var(--text);
  font-weight: 750;
}

.condition-rows {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.condition-rows .row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft);
  align-items: center;
  text-decoration: none;
  color: inherit;
  font-size: 0.88rem;
}

.condition-rows .row:first-child { border-top: 0; }
.condition-rows .row:hover { background: var(--neutral); }

.condition-rows .row b { color: var(--text); font-weight: 700; }
.condition-rows .row .dim { color: var(--muted); font-size: 0.8rem; }

/* =============================================================
   Responsive
   ============================================================= */

@media (max-width: 960px) {
  .hero, .grid { grid-template-columns: 1fr; }
  .hero-metrics { min-width: 0; }
}

@media (max-width: 700px) {
  .page { padding: 10px; }
  .impact-grid,
  .definition-grid,
  .severity-grid,
  .disorder-grid {
    grid-template-columns: 1fr;
  }
  .score-row { grid-template-columns: repeat(3, 1fr); }
  .hero-metrics { grid-template-columns: repeat(3, 1fr); }
  .metric { padding: 8px 5px; }
  .card-header { align-items: flex-start; flex-direction: column; }
  .condition-rows .row { grid-template-columns: 1fr; gap: 4px; }
}
