/*
  H2Prism calc-kit shared styles
  Source: LCOH calculator (site_prototype/lcoh/price/app.css, read-only reference) @font-face lines
  1-29 and :root tokens 33-128, copied verbatim except the font path (/calc-kit/fonts/). Components
  (number field, segmented toggle, chip, state tag, inline warning/error, result number, detail view)
  follow the LCOH look (.control, .origin, .field-error, .number, .unit-pill) redrawn lightly for the
  10-calculator seed scope. R2 (H2PRISM-CALC-TIDY-20260927 S1-R2): segmented control now uses the
  LCOH "unit-pill" grey-tray + raised-white-segment pattern (no black fill), added a breadcrumb,
  headline number, small-caps section label, and an in-box unit suffix for number fields; the result
  table grid is now an explicit two-column layout so it uses the full card width at 1440px; every
  pressable control (including inputs, selects, and links) is at least 44px tall.
*/
@font-face {
  font-family: "Newsreader";
  src: url("/calc-kit/fonts/newsreader-opsz-vf.woff2") format("woff2"),
       url("/calc-kit/fonts/newsreader-vf.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Satoshi";
  src: url("/calc-kit/fonts/satoshi-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Satoshi";
  src: url("/calc-kit/fonts/satoshi-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Satoshi";
  src: url("/calc-kit/fonts/satoshi-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-display: "Newsreader", Georgia, serif;
  --font-ui: "Satoshi", system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;

  --fs-cap: 11px;
  --fs-meta: 12px;
  --fs-sm: 13px;
  --fs-body: 14px;
  --fs-input: 16px;
  --fs-h3: 20px;
  --fs-h2: 28px;
  --fs-title: 24px;
  --fs-display: 56px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  --paper: #f6f3ed;
  --surface: #fffdf9;
  --surface-2: #f0ebe2;
  --rail: #e3dbcf;
  --ink: #1b1814;
  --ink-2: #57514a;
  --ink-3: #6b6358;
  --line: #e6dfd4;
  --line-2: #cfc5b6;

  --accent: #0f61d8;
  --accent-soft: rgba(15, 97, 216, 0.12);

  --warn: #8a4b12;
  --warn-soft: rgba(138, 75, 18, 0.12);
  --error: #b3261e;
  --error-soft: rgba(179, 38, 30, 0.10);

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 999px;
  --shadow-1: none;
  --shadow-pop: 0 8px 24px rgb(27 24 20 / 0.10);

  --ease-panel: cubic-bezier(0.23, 1, 0.32, 1);
  --dur-panel: 200ms;
  --dur-press: 120ms;

  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-ui);
  font-size: var(--fs-input);
  line-height: 1.45;
}
@media (max-width: 900px) {
  :root { --fs-display: 40px; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { word-break: keep-all; }
button:not(.kit-tab) { transition: transform var(--dur-press) ease-out; }
button:active { transform: scale(0.98); }

.kit-wrap { max-width: 1080px; margin: 0 auto; padding: var(--sp-6) var(--sp-5) var(--sp-8); }
.kit-crumb { margin: 0 0 4px; color: var(--ink-2); font-size: var(--fs-meta); letter-spacing: 0.01em; }
.kit-crumb span + span { margin-left: 8px; }
.kit-h1 { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-title); margin: 0 0 4px; }
.kit-sub { color: var(--ink-2); margin: 0 0 var(--sp-5); font-size: var(--fs-body); }
.kit-link { color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.kit-link:hover { text-decoration: underline; }

/* Related calculators block (calc-kit/related.js) */
.kit-related { margin-top: var(--sp-7); padding-top: var(--sp-5); border-top: 1px solid var(--line); }
.kit-related-all { margin-top: var(--sp-6); }
.kit-related-head { font-family: var(--font-display); font-size: var(--fs-h3); font-weight: 500; color: var(--ink); margin: 0 0 var(--sp-3); }
.kit-related-group + .kit-related-group { margin-top: var(--sp-4); }
.kit-related-title { font-size: var(--fs-cap); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin: 0 0 var(--sp-2); }
.kit-related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-2); }
.kit-related-card { display: flex; flex-direction: column; gap: 2px; min-height: 44px; padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); }
.kit-related-card:hover { border-color: var(--accent); }
.kit-related-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kit-related-card[aria-current="page"] { background: var(--surface-2); border-style: dashed; }
.kit-related-name { font-size: var(--fs-body); font-weight: 600; color: var(--accent); }
.kit-related-card[aria-current="page"] .kit-related-name { color: var(--ink); }
.kit-related-desc { font-size: var(--fs-meta); color: var(--ink-3); }

.kit-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-5); }
.kit-tab {
  border: 0; background: none; padding: var(--sp-3) var(--sp-4); font: inherit; color: var(--ink-2);
  cursor: pointer; border-bottom: 2px solid transparent; min-height: 44px; white-space: nowrap;
}
.kit-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }
/* At narrow widths (e.g. 390px) the tabs wrap onto their own rows instead of scrolling horizontally
   (.kit-tabs is flex-wrap:wrap); the select fallback below stays hidden except for assistive tech
   that prefers a single control. */
.kit-tab-select { display: none; }

.kit-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-5); margin-bottom: var(--sp-5); }
.kit-pane { display: none; }
.kit-pane[data-active="true"] { display: block; }

/* R1-04c: LCOH-style headline number for the tab's selected result. */
.kit-headline { margin-bottom: var(--sp-5); }
.kit-metric-name { font-size: var(--fs-meta); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin: 0 0 4px; }
.kit-number-row { display: flex; align-items: baseline; gap: var(--sp-3); margin: 0; min-height: 56px; }
.kit-number { font-family: var(--font-display); font-size: var(--fs-display); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kit-unit { color: var(--ink-2); font-size: var(--fs-input); }

/* R1-04d: section labels are a small-caps line, replacing ad hoc inline styles. */
.kit-section-label { font-size: var(--fs-cap); letter-spacing: 0.05em; color: var(--ink-3); text-transform: uppercase; font-weight: 500; margin: var(--sp-4) 0 4px; }

.kit-field { min-width: 0; margin-bottom: var(--sp-4); }
.kit-field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); margin-bottom: 6px; }
.kit-field label { font-size: var(--fs-sm); color: var(--ink-2); }
.kit-field-actions { display: flex; align-items: center; gap: var(--sp-2); }
.kit-control {
  display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; padding: 0 var(--sp-3);
  background: var(--surface); border-radius: var(--r-md); border: 0;
  box-shadow: inset 0 0 0 1px rgb(27 24 20 / 0.14);
  transition: box-shadow var(--dur-panel) ease-out;
}
.kit-control input, .kit-control select {
  border: 0; background: transparent; width: 100%; min-width: 0; padding: 0; height: 100%;
  font: inherit; font-size: var(--fs-input); font-variant-numeric: tabular-nums; color: var(--ink);
}
.kit-control select { flex: 0 1 auto; max-width: 55%; }
/* R1-04f: a static unit sits inside the box, at the right, instead of a separate label. */
.kit-control-unit { flex: none; color: var(--ink-3); font-size: var(--fs-sm); white-space: nowrap; }
.kit-control:has(input:focus), .kit-control:has(select:focus) { box-shadow: inset 0 0 0 2px var(--accent); }
.kit-control input:focus, .kit-control select:focus { outline: none; }
.kit-control:has(input[aria-invalid="true"]) { box-shadow: inset 0 0 0 1.5px var(--error); }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.kit-field-error { margin: 6px 0 0; font-size: var(--fs-meta); color: var(--error); }
.kit-field-error[hidden] { display: none; }
.kit-field-warn { margin: 6px 0 0; font-size: var(--fs-meta); color: var(--warn); }
.kit-field-warn[hidden] { display: none; }

.kit-origin {
  font-size: var(--fs-cap); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3);
  border: 0; border-radius: var(--r-sm); padding: 0; white-space: nowrap;
}
.kit-origin.user { color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 2px 6px; }
/* R1-02: unit-conversion definitions cannot be edited; tag them distinctly from Default/Your number. */
.kit-origin.definition { color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 2px 6px; }
/* R2-01/R2-03: a default with no public source (constants.js unsourced:true), same warn-soft chip LCOH uses. */
.kit-origin.unsourced { color: var(--warn); background: var(--warn-soft); border-radius: 4px; padding: 2px 6px; }
/* R6 (H2PRISM-CALC-TIDY-20260927 S1-R6): a default with a cited source that has not been opened and
   confirmed directly (constants.js unverified:true). Same pill family as .unsourced, different text
   and a dashed outline instead of a filled background so the two are not confused at a glance. */
.kit-origin.unverified { color: var(--ink-2); background: transparent; border: 1px dashed var(--line-2); border-radius: 4px; padding: 2px 6px; }
.kit-const-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.kit-const-source { margin: 2px 0 0; font-size: var(--fs-meta); color: var(--ink-3); flex-basis: 100%; }

.kit-reset {
  border: 0; background: none; padding: 2px 0; font-size: var(--fs-meta); color: var(--ink-2);
  text-decoration: none; line-height: 1.3; cursor: pointer; min-height: 24px;
}
.kit-reset:hover { text-decoration: underline; }
.kit-reset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kit-reset-all { border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r-sm); padding: 0 var(--sp-3); min-height: 44px; font: inherit; color: var(--ink-2); cursor: pointer; }
.kit-reset-all:hover { border-color: var(--accent); color: var(--accent); }

/* R1-04e: segmented toggle, LCOH "unit-pill" pattern -- a grey tray holds segments; the selected
   segment lifts onto --surface with a hairline border and soft shadow. No black fill. */
.kit-seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-md); background: var(--surface-2); }
.kit-seg button {
  border: 1px solid transparent; background: transparent; padding: 0 var(--sp-3); font: inherit; font-size: var(--fs-sm);
  cursor: pointer; min-height: 44px; color: var(--ink-2); border-radius: var(--r-md);
  transition: background var(--dur-panel) ease-out, box-shadow var(--dur-panel) ease-out, transform var(--dur-press) ease-out;
}
.kit-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); border-color: rgb(27 24 20 / 0.06); box-shadow: 0 1px 2px rgb(27 24 20 / 0.12); font-weight: 600; }
.kit-seg button:active { transform: scale(0.97); }

.kit-chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.kit-chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r-pill); padding: 0 var(--sp-3); min-height: 44px; font: inherit; font-size: var(--fs-sm); color: var(--ink-2); cursor: pointer; }
.kit-chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.kit-result { margin: var(--sp-2) 0; }
.kit-result-empty { color: var(--ink-2); font-size: var(--fs-body); margin: var(--sp-2) 0; }
.kit-result-reason { color: var(--error); font-size: var(--fs-sm); margin: 4px 0 0; }
.kit-result-warn-note { color: var(--warn); font-size: var(--fs-sm); margin: 4px 0 0; }

/* R1-05: an explicit two-column grid so the result table uses the full card width at 1440px
   instead of collapsing to a single narrow column (was: one flex column wrapped in the grid). */
.kit-table-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-5); margin-top: var(--sp-2); background: var(--surface-2); border-radius: var(--r-md); padding: var(--sp-1) var(--sp-4); }
.kit-table-row { display: flex; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); min-height: 40px; align-items: center; }
.kit-table-row:last-child, .kit-table-grid > .kit-table-row:nth-last-child(2) { border-bottom: 0; }
.kit-table-row .kit-k { color: var(--ink-2); font-size: var(--fs-sm); }
.kit-table-row .kit-v { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
@media (max-width: 640px) {
  .kit-table-grid { grid-template-columns: 1fr; }
  .kit-table-grid > .kit-table-row:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .kit-table-row:last-child { border-bottom: 0; }
}

.kit-detail-toggle {
  border: 0; background: none; padding: var(--sp-2) var(--sp-2); min-height: 44px; min-width: 44px; font: inherit; font-size: var(--fs-sm);
  color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.kit-detail-toggle:hover { color: var(--accent); }
.kit-detail-body { display: none; margin-top: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--surface-2); border-radius: var(--r-md); font-size: var(--fs-sm); color: var(--ink-2); }
.kit-detail-body[data-open="true"] { display: block; }
.kit-detail-body dt { color: var(--ink-3); font-size: var(--fs-meta); margin-top: var(--sp-2); }
.kit-detail-body dt:first-child { margin-top: 0; }
.kit-detail-body dd { margin: 2px 0 0; }
.kit-detail-body code { font-variant-numeric: tabular-nums; }

/* R1-04g: every pressable control, including plain inputs/selects/links, is at least 44px. */
button, select, input, a.kit-link { min-height: 44px; }
.kit-control, .kit-tab, .kit-chip, .kit-reset-all, .kit-detail-toggle { min-height: 44px; }

@media (max-width: 640px) {
  .kit-wrap { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
}
