/* ============================================================
   Torrens web funnel — truecost.aphelionengineering.com.au
   Dark-only, per the Aphelion studio token file (public/heroes/base.css),
   which Brand.swift copies verbatim. CLAUDE.md §12: do not invent hex values.
   The five bridge tokens chrome.css consumes (--text, --text-muted,
   --text-faint, --border-mid, --border-hair) are canonical names here, so the
   shared header/footer inherit the right palette with no shims.
   Typography §12: Bricolage Grotesque for display and headers ONLY; every
   figure, table and money value uses the system stack with tabular numerals.
   ============================================================ */

/* Self-hosted, latin subset, variable. SIL OFL 1.1. Self-hosting is a
   precondition of the site's privacy line: no third-party asset host, so no
   request leaves this origin after load. */
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: url("/assets/fonts/bricolage-grotesque-latin.woff2") format("woff2");
}

:root {
  --bg: #07080A;
  --surface: #0E1014;
  --surface-2: #0B0D11;
  --border-mid: #1A1D22;
  --border-hair: rgba(236, 237, 238, 0.08);
  --text: #ECEDEE;
  --text-mid: #B8BBC2;
  --text-muted: #8B8E94;
  /* The studio's --text-faint is #5A5D63, which measures 3.0:1 on --bg and
     fails AA for text at any size. Leaving it UNDEFINED does not protect
     anything: chrome.css reads it as `var(--text-faint, #5A5D63)`, so the
     literal still paints — and it painted the §9 advice disclaimer in the
     footer at 3.03:1. It is therefore defined here to the canonical
     --text-muted value (6.10:1 on --bg), so no fallback can reach the
     failing colour. One grey tier is worth a legible disclaimer. */
  --text-faint: #8B8E94;
  /* Interactive control boundaries need 3:1 (WCAG 1.4.11); --border-mid is
     1.15:1 on the field fill and is decorative-only for that reason. This is
     the canonical --text-muted value in a boundary role, not a new hex (§12). */
  --border-control: #8B8E94;
  --accent: #F4A340;
  --accent-hot: #FFE3B5;
  --accent-strong: var(--accent);
  /* Declared for §12 token-set completeness; referenced by NO rule in this
     build. WARNING before reaching for them: --accent-ink on --paper
     measures 3.09:1 and fails WCAG AA for body text (P5 evidence, "Known,
     not blocking"). Pair either with a surface it clears 4.5:1 against. */
  --accent-ink: #C17618;
  --paper: #F2EEE7;
  --ink: #0E1014;
  --pass: #4AA86B;
  --fail: #DB4F47;
  --warn: #E6A626;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --maxw: 60rem;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

/* The `hidden` attribute must win over any layout display value. Without this,
   `.field { display: flex }` beats the UA stylesheet's `[hidden] {display:none}`
   and conditionally hidden fields stay on screen. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.6;
}

body.has-fixed-chrome { padding-top: 3rem; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: .75rem 1rem;
  z-index: 100;
  border: 1px solid var(--border-mid);
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus-visible { left: 0; }

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem 1.25rem 5rem;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
  margin: 0 0 .5rem;
}
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem); }
h2 { font-size: 1.4rem; margin-top: 2.75rem; }
h3 { font-size: 1.05rem; margin-top: 1.5rem; }

p { margin: 0 0 1rem; max-width: 62ch; }
a { color: var(--accent); }
a:hover { color: var(--accent-hot); }

.lede {
  color: var(--text-mid);
  font-size: 1.075rem;
  max-width: 62ch;
}

.eyebrow {
  font-family: var(--display);
  font-size: .75rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 .35rem;
}

/* ---- Every figure on the page uses tabular numerals (§12) ---- */
.num, .money, output, td.num, th.num, caption, .working-formula,
.result-value, .working-value, .field-state {
  font-family: var(--body);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ---- Form ---- */
.calc-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  gap: 1rem 1.25rem;
  margin: 0 0 1.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
}

.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.span-all { grid-column: 1 / -1; }

.field label, .field .label {
  font-size: .875rem;
  color: var(--text-mid);
  font-weight: 500;
}

.field .hint {
  font-size: .8125rem;
  color: var(--text-muted);
}

input[type="text"], input[type="number"], input[type="date"], select {
  font: inherit;
  font-variant-numeric: tabular-nums;
  min-height: 44px; /* the app's minimum tap target */
  padding: .5rem .7rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-control);
  border-radius: 8px;
  width: 100%;
}
input:hover, select:hover { border-color: var(--text); }

/* Error state: identified in text and by a boundary that clears 3:1. */
input[aria-invalid="true"] { border-color: var(--fail); }

/* An edited value is distinguished by weight and colour AND by the text state
   line beside it — colour is never the only signal (§8.2). */
input.edited, select.edited {
  border-color: var(--accent);
  color: var(--accent-hot);
  font-weight: 600;
}

fieldset {
  border: 1px solid var(--border-control);
  border-radius: 8px;
  padding: .75rem 1rem 1rem;
  margin: 0;
  min-width: 0;
}
legend { font-size: .875rem; color: var(--text-mid); padding: 0 .35rem; }

.radio-row { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; }
.radio-row label {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  color: var(--text);
  font-size: .9375rem;
}

.field-state {
  font-size: .75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.field-state.is-edited { color: var(--accent); }

.reset-button {
  font: inherit;
  font-size: .75rem;
  background: none;
  border: 1px solid var(--border-control);
  color: var(--text-mid);
  border-radius: 6px;
  padding: .3rem .6rem;
  cursor: pointer;
  min-height: 44px;
}
.reset-button:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Results ---- */
.results { display: grid; gap: 1rem; }
.results > * { min-width: 0; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr));
  gap: 1rem;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}

.result-label {
  font-size: .8125rem;
  color: var(--text-muted);
  margin: 0 0 .3rem;
}

.result-value {
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  display: block;
}
.result-value.is-accent { color: var(--accent); }

.result-sub {
  font-size: .8125rem;
  color: var(--text-mid);
  margin: .35rem 0 0;
}

/* ---- Cost table ---- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9375rem; }
caption {
  text-align: left;
  color: var(--text-muted);
  font-size: .8125rem;
  padding-bottom: .5rem;
}
th, td {
  text-align: left;
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--border-hair);
  vertical-align: top;
}
th {
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tfoot td { border-top: 1px solid var(--border-mid); font-weight: 650; }

/* ---- Derivation inspector (§8.1) ---- */
details.working {
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 0;
  margin: 1rem 0 0;
}
details.working > summary {
  cursor: pointer;
  padding: .7rem 1rem;
  font-size: .875rem;
  color: var(--accent);
  list-style: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: .4rem;
}
details.working > summary::-webkit-details-marker { display: none; }
details.working > summary::before {
  content: "›";
  display: inline-block;
  transition: transform .15s ease;
  font-size: 1.1em;
}
details.working[open] > summary::before { transform: rotate(90deg); }
.working-body { padding: 0 1rem 1rem; }

.working-node {
  border-top: 1px solid var(--border-hair);
  padding: .7rem 0 .2rem;
}
.working-node-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.working-label { font-weight: 600; font-size: .9375rem; }
.working-value { font-size: .9375rem; color: var(--text); white-space: nowrap; }
.working-node[data-depth="0"] > .working-node-head > .working-value { color: var(--accent); }
.working-formula {
  font-size: .8125rem;
  color: var(--text-mid);
  margin: .2rem 0 0;
}
.working-formula.is-edited { color: var(--accent); }
.working-inputs {
  margin: .45rem 0 0;
  padding: .5rem .6rem;
  background: var(--surface);
  border-radius: 8px;
  font-size: .8125rem;
}
.working-inputs div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .1rem 0;
}
.working-inputs dt, .working-inputs .k { color: var(--text-muted); }
.working-inputs dd, .working-inputs .v {
  margin: 0;
  color: var(--text-mid);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.working-rates {
  font-size: .75rem;
  color: var(--accent);
  margin: .35rem 0 0;
}
.working-children { margin-left: .9rem; }

.working-section-heading {
  font-family: var(--display);
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 1.1rem 0 .3rem;
}

.source-row {
  border-top: 1px solid var(--border-hair);
  padding: .55rem 0;
  font-size: .8125rem;
}
.source-row .source-title { color: var(--accent); font-weight: 600; }
.source-row .source-meta { color: var(--text-muted); }

/* ---- Notices: honest refusals and labelled estimates ---- */
.notice {
  border: 1px solid var(--border-mid);
  border-left: 3px solid var(--text-muted);
  border-radius: 8px;
  padding: .8rem 1rem;
  margin: 1rem 0;
  font-size: .9375rem;
  color: var(--text-mid);
  background: var(--surface);
}
.notice strong { color: var(--text); }
.notice.is-blocking { border-left-color: var(--warn); }
.notice.is-estimate { border-left-color: var(--accent); }

/* ---- CTA ---- */
.cta {
  margin-top: 2.5rem;
  padding: 1.25rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
}
.cta h2 { margin-top: 0; font-size: 1.15rem; }
.cta .status {
  font-size: .875rem;
  color: var(--text-muted);
  margin: .5rem 0 0;
}

/* ---- /sources ---- */
.source-section {
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
  background: var(--surface);
}
.source-section h2 { margin-top: 0; }
.status-line { font-size: .875rem; color: var(--text-mid); margin: 0 0 .75rem; }
.badge {
  display: inline-block;
  font-size: .6875rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .12rem .45rem;
  border-radius: 4px;
  border: 1px solid currentColor;
  vertical-align: middle;
}
.badge.is-verified { color: var(--pass); }
.badge.is-estimate { color: var(--warn); }

.state-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr));
  gap: .75rem;
  padding: 0;
  list-style: none;
}
.state-list a {
  display: block;
  padding: .8rem 1rem;
  min-height: 44px;
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
}
.state-list a:hover { border-color: var(--accent); }
.state-list .state-sub { display: block; font-size: .8125rem; color: var(--text-muted); }

/* Reference sections: rate schedules, concessions and questions (P4). */
.rate-item, .faq-item {
  border-top: 1px solid var(--border-hair);
  padding: .9rem 0 .1rem;
}
.rate-item h3, .faq-item h3 { margin-top: 0; }
.faq-item p { color: var(--text-mid); }

.source-list { list-style: none; padding: 0; margin: 1rem 0; }
.source-list li {
  border-top: 1px solid var(--border-hair);
  padding: .55rem 0;
  font-size: .9375rem;
}
.source-list .source-meta { display: block; color: var(--text-muted); font-size: .8125rem; }

.advice-boundary { display: block; margin-bottom: .4rem; }

/* Replaces an inline style attribute: the production CSP sets style-src 'self'
   with no style-src-attr, so inline styles are blocked and the page would ship
   unstyled here. Keep presentation in this file, never in a style attribute. */
#assumption-fields { background: transparent; border: 0; padding: 0; }
.col-label-spaced { margin-top: 28px; }
.footer-legal .advice-boundary { margin-bottom: .5rem; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
