/* ============================================================
   Peptide Reconstitution Reference Chart — page styles
   Depends on shared.css for theme tokens and base components.
   ============================================================ */

.calc-shell--chart {
  max-width: 820px;
}

/* ---------- Toggles ---------- */
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 28px;
  margin: 0 0 22px;
}

.chart-control {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.chart-control__label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.seg-group {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  width: fit-content;
}

.seg {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.seg:hover { color: var(--text); }

.seg.on,
.seg[aria-checked="true"] {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.seg:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- The matrix ---------- */
.chart-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.recon-chart {
  width: 100%;
  /* Fixed layout so every dose column (presets + custom) is the same width,
     instead of the browser handing leftover slack to roomier columns. */
  table-layout: fixed;
  min-width: 560px;        /* keeps cells readable; the wrapper scrolls on mobile */
  border-collapse: collapse;
  font-size: 0.9rem;
}

/* First column (vial label / custom-vial input) is pinned; the remaining
   dose columns split the rest of the width equally under fixed layout. */
.recon-chart .rc-corner { width: 150px; }

.recon-chart th,
.recon-chart td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
}

.recon-chart tr > *:last-child { border-right: 0; }
.recon-chart tbody tr:last-child > * { border-bottom: 0; }

/* Column + row headers */
.recon-chart thead th {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 11px 12px;
  white-space: nowrap;
}

.recon-chart .rc-corner {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  text-align: left;
}

.recon-chart .rc-rowhead {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 10px 14px;
  white-space: nowrap;
  text-align: left;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* Data cells */
.recon-chart .rc-cell { padding: 0; }

.rc-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 11px 12px;
  min-height: 56px;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.12s ease;
}

.rc-link:hover {
  background: var(--accent-soft);
  color: inherit;
}

.rc-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 6px;
}

.rc-bac {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.rc-u {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Over-100-unit cells: flagged as not feasible, never a normal draw */
.rc-cell--over { background: var(--danger-soft); }
.rc-cell--over .rc-link:hover { background: var(--danger-soft); }
.rc-warn { color: var(--danger); font-weight: 700; }

.rc-incompat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--danger);
  line-height: 1.25;
  padding: 0 4px;
  text-align: center;
}

.rc-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  color: var(--text-faint);
}

/* ---------- Custom vial row ---------- */
.rc-custom-row .rc-rowhead--custom {
  padding: 8px 10px;
  background: var(--accent-soft);
}

/* Editable custom-dose column header — sized to match the other dose columns */
.rc-customdose-head {
  background: var(--accent-soft) !important;
  padding: 8px 7px !important;
}

/* Fill variant: input spans the column (no inline unit chip; unit is the
   placeholder), so the column collapses to the same width as the preset
   dose columns instead of being forced wide by a fixed-width input. */
.rc-custom-field--fill {
  display: flex;
  width: 100%;
}
.rc-custom-field--fill input {
  width: 100%;
  text-align: center;
}

.rc-custom-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rc-custom-field input {
  width: 6.5em;
  min-width: 0;
  padding: 7px 9px;
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  -moz-appearance: textfield;
}

.rc-custom-field input::placeholder {
  color: var(--text-faint);
  opacity: 1;
}

.rc-custom-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.rc-custom-unit {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ---------- Legend + hint ---------- */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 16px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chart-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
}
.chart-swatch--bac { background: var(--accent); }
.chart-swatch--u { background: var(--text-faint); }
.chart-legend__item--over { color: var(--danger); }

.chart-hint {
  margin: 12px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------- Below-tool reference section ---------- */
.section-divider {
  max-width: 720px;
  margin: 56px auto 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.reference {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 22px 8px;
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.reference h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.reference h3 {
  margin: 24px 0 6px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.reference p { margin: 0 0 12px; }
.reference strong { color: var(--text); font-weight: 600; }

.reference .ref-formula {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
}

.reference .ref-disclaimer {
  font-size: 0.85rem;
  border-left: 3px solid var(--border-strong);
  padding-left: 14px;
}

.reference .related-tools {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.reference .related-tools li { margin: 0 0 8px; }

/* ---------- Footer disclaimer ---------- */
.footer-disclaimer {
  max-width: 720px;
  margin: 0 auto 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .calc-shell.calc-shell--chart {
    padding: 0 16px;
    margin-top: 80px;
  }
  .recon-chart { font-size: 0.82rem; }
  .recon-chart thead th { padding: 9px 9px; }
  .recon-chart .rc-rowhead { padding: 9px 10px; }
  .rc-link { padding: 9px 8px; min-height: 50px; }
  .rc-bac { font-size: 0.88rem; }
  .rc-custom-field input { width: 5.5em; }
  .reference { padding: 28px 16px 8px; }
  .section-divider { margin-top: 40px; }
}
