/* ==========================================================================
   Lab Companion — web calculators
   Ports the app's calculator layout onto the site's tokens. Two rules that are
   not negotiable here:
     - amber is a wash behind dark ink, never coloured text on a light tint
       (#FFB703 as text is ~1.6:1). --amber/--amber-wash already encode that.
     - every field keeps a real <label>, so nothing depends on a placeholder.
   ========================================================================== */

/* Fields and results are toggled with the hidden attribute; the display rules
   below would otherwise win and leave them on screen forever. */
[hidden] { display: none !important; }

.calc-section + .calc-section { margin-top: var(--sp-8); }

.calc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
}

.calc-formula {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--sea-wash);
  color: var(--sea);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Segmented control — real radios, so it is keyboard operable by default
   -------------------------------------------------------------------------- */
.calc-fieldset {
  margin: 0 0 var(--sp-5);
  padding: 0;
  border: 0;
}

.calc-legend {
  padding: 0;
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: var(--sp-2);
}

.calc-seg {
  display: flex;
  gap: var(--sp-2);
}

.calc-seg-item {
  position: relative;   /* contains the visually hidden radio */
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: var(--step--1);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.calc-seg-item:hover { color: var(--ink); }

.calc-seg-item input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.calc-seg-item:has(input:checked) {
  border-color: var(--sea);
  background: var(--sea-wash);
  color: var(--ink);
}

.calc-seg-item:has(input:focus-visible) {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

.calc-detail {
  margin-top: var(--sp-3);
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   Inputs
   -------------------------------------------------------------------------- */
.calc-fields {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.calc-field label,
.calc-label {
  display: block;
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: var(--sp-2);
}

.calc-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.calc-input,
.calc-unit,
.calc-seq {
  min-height: 46px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
}

.calc-input {
  flex: 1 1 6rem;
  min-width: 0;
  padding: 0 var(--sp-3);
  font-variant-numeric: tabular-nums;
}

.calc-unit {
  flex: 0 0 auto;
  min-width: 5.5rem;
  padding: 0 var(--sp-2);
}

/* Fixed unit, not a choice — the app shows mM and µM as plain labels here. */
.calc-unit-static {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
}

.calc-fields-next { margin-top: var(--sp-4); }

.calc-seq {
  display: block;
  width: 100%;
  padding: var(--sp-3);
  font-family: var(--font-mono);
  line-height: 1.5;
  resize: vertical;
  word-break: break-all;
}

.calc-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  margin-top: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   Output
   -------------------------------------------------------------------------- */
.calc-out {
  display: grid;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

.calc-hint {
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* Echoes the app's ResultCard: a wash of the accent at ~8% with a 25% border.
   --sea stands in for the app's teal, which only reaches 2.1:1 on this paper
   and so cannot carry text or a border here. */
.calc-result {
  padding: var(--sp-4);
  border: 1px solid color-mix(in srgb, var(--sea) 35%, transparent);
  border-radius: var(--r-md);
  background: var(--sea-wash);
}

.calc-result-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-4);
}

.calc-result-label {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.calc-value {
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: var(--sp-1);
}

.calc-value .calc-value-unit {
  font-size: var(--step-1);
  font-weight: 600;
  color: var(--ink-muted);
  margin-left: 0.2em;
}

.calc-secondary {
  list-style: none;
  margin: var(--sp-4) 0 0;
  padding: 0;
  font-size: var(--step--1);
}

.calc-secondary li {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--hairline);
}

.calc-secondary li span:first-child { color: var(--ink-muted); }

.calc-secondary li span:last-child {
  font-weight: 650;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.calc-copy {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease);
}

.calc-copy:hover { border-color: var(--ink-muted); }

/* Warning, not an error: the input is understandable, it just cannot be a
   dilution. Dark ink on an amber wash, never amber text. */
.calc-note {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border-left: 3px solid var(--amber);
  background: var(--amber-wash);
  color: var(--ink);
  font-size: var(--step--1);
}

/* --------------------------------------------------------------------------
   About / formula disclosure
   -------------------------------------------------------------------------- */
.calc-about {
  margin-top: var(--sp-5);
  border-top: 1px solid var(--hairline);
  padding-top: var(--sp-4);
  font-size: var(--step--1);
}

.calc-about summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.calc-about .calc-prose {
  margin-top: var(--sp-3);
  color: var(--ink-muted);
  max-width: var(--measure);
}

.calc-about .calc-prose p + p { margin-top: var(--sp-3); }

/* --------------------------------------------------------------------------
   App upsell
   -------------------------------------------------------------------------- */
.upsell-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  margin-top: var(--sp-5);
}

.upsell-tier h3 {
  font-size: var(--step-1);
  margin-bottom: var(--sp-4);
}

.upsell-tier .price-list { gap: var(--sp-3); }

.upsell-foot {
  margin-top: var(--sp-5);
  display: grid;
  gap: var(--sp-3);
}

.upsell-foot .calc-hint { max-width: var(--measure); }
