/* hcc-theme.css — House Construction Cost Calculator
   White base, deep navy brand, warm terracotta accent.
   Component classes used by index.html, calc.js, wizard-steps.js and estimate-sidebar.js
   are all defined here. Tailwind utilities come from the Tailwind browser build declared
   in the page head. */

:root {
  --paper: #ffffff;
  --surface: #fbfbfd;
  --sunken: #f3f4f8;
  --hairline: #e4e7ee;
  --hairline-strong: #cfd4df;

  --ink: #1b2233;
  --ink-soft: #55607a;
  --ink-faint: #8a93a8;

  --brand: #e5ebf6;
  --brand-mid: #b9c7e2;
  --brand-deep: #1c2d4f;
  --brand-ink: #0f1a30;

  --accent: #f6e2d6;
  --accent-mid: #e8b79e;
  --accent-deep: #c4552d;
  --accent-ink: #8f3a1c;

  --support: #e3f0ea;
  --support-deep: #2c6b4f;

  --ring: 0 0 0 4px rgba(28, 45, 79, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(27, 34, 51, 0.04), 0 8px 24px -12px rgba(27, 34, 51, 0.12);
}

html { scroll-behavior: smooth; background: var(--paper); }
body { background: var(--paper); color: var(--ink); font-family: "Karla", ui-sans-serif, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, .font-display { font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif; letter-spacing: -0.015em; }
strong, b { font-weight: 700; }
em, i { font-style: italic; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-deep); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; } }

/* ---------- navigation ---------- */
.nav-link { border-radius: 10px; padding: 0.5rem 0.85rem; font-size: 0.9rem; font-weight: 600; color: var(--ink-soft); }
.nav-link:hover { background: var(--sunken); color: var(--ink); }
.nav-link-active { background: var(--brand); color: var(--brand-deep); }
.mobile-nav-link { display: block; border-radius: 10px; padding: 0.65rem 0.85rem; font-weight: 600; color: var(--ink-soft); }
.mobile-nav-link:hover, .mobile-nav-link-active { background: var(--brand); color: var(--brand-deep); }
.mobile-nav-link-cta { margin-top: 0.35rem; text-align: center; background: var(--accent-deep); color: #fff; }
.mobile-nav-link-cta:hover { background: var(--accent-ink); color: #fff; }
.footer-link { border-radius: 8px; padding: 0.35rem 0.6rem; font-size: 0.85rem; color: var(--ink-soft); }
.footer-link:hover { color: var(--brand-deep); background: var(--sunken); }

/* ---------- cards & headings ---------- */
.card { background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.card-sm { background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 1rem; }
.section-heading { font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif; font-weight: 700; font-size: 1.25rem; letter-spacing: -0.015em; color: var(--ink); }
.results-subheading { margin-top: 0.15rem; font-size: 0.85rem; color: var(--ink-soft); }
.eyebrow { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-deep); }
.eyebrow::before { content: ""; width: 1.25rem; height: 2px; background: var(--accent-deep); border-radius: 2px; }

/* ---------- buttons ---------- */
.btn-primary, .btn-secondary, .btn-accent, .btn-on-dark { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; border-radius: 11px; padding: 0.7rem 1.1rem; font-size: 0.9rem; font-weight: 700; line-height: 1.2; transition: background-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s; cursor: pointer; }
.btn-primary { background: var(--brand-deep); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--hairline-strong); }
.btn-secondary:hover { background: var(--sunken); }
.btn-accent { background: var(--accent-deep); color: #fff; }
.btn-accent:hover { background: var(--accent-ink); }
.btn-on-dark { background: rgba(255, 255, 255, 0.12); color: #fff; border: 1px solid rgba(255, 255, 255, 0.25); }
.btn-on-dark:hover { background: rgba(255, 255, 255, 0.2); }
.btn-primary:active, .btn-secondary:active, .btn-accent:active { transform: translateY(1px); }

/* ---------- form fields ---------- */
.field-section {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  grid-template-areas: "badge heading" "rest rest";
  column-gap: 0.6rem;
  row-gap: 0.35rem;
  align-items: center;
}
.field-section-index { grid-area: badge; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--brand-deep); color: #fff; font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 0.72rem; }
.field-section-heading { grid-area: heading; min-width: 0; }
.field-section-body { grid-area: rest; min-width: 0; }
@media (min-width: 640px) {
  .field-section { grid-template-columns: 2.25rem minmax(0, 1fr); grid-template-areas: "badge heading" "badge rest"; column-gap: 1rem; row-gap: 0; align-items: start; }
  .field-section-index { width: 2.25rem; height: 2.25rem; font-size: 0.95rem; }
}
.field-block + .field-block { margin-top: 1.4rem; }
.field-group[hidden], .field-hidden { display: none !important; }
.field-label { display: block; margin-bottom: 0.5rem; font-size: 0.875rem; font-weight: 600; color: var(--ink); }
.field-hint { margin-top: 0.45rem; font-size: 0.78rem; color: var(--ink-soft); }
.field-optional { font-size: 0.72rem; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em; }

.form-select { width: 100%; appearance: none; border: 1px solid var(--hairline-strong); border-radius: 11px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2355607a' stroke-width='1.8'%3E%3Cpath d='m6 8 4 4 4-4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0.75rem center / 1.1rem; padding: 0.7rem 2.5rem 0.7rem 0.9rem; font-size: 0.95rem; color: var(--ink); }
.form-select:focus { outline: none; border-color: var(--brand-deep); box-shadow: var(--ring); }

.input-group { display: flex; align-items: stretch; border: 1px solid var(--hairline-strong); border-radius: 11px; background: #fff; overflow: hidden; }
.input-group:focus-within { border-color: var(--brand-deep); box-shadow: var(--ring); }
.input-group input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0.7rem 0.9rem; font-family: "Bricolage Grotesque", sans-serif; font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.input-group input:focus { outline: none; }
.input-group-addon { display: flex; align-items: center; padding: 0 0.9rem; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); background: var(--sunken); border-left: 1px solid var(--hairline); }

.custom-radio, .custom-checkbox { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.custom-radio-compact { gap: 0.25rem; }
.pill-choice { position: relative; display: inline-flex; align-items: center; gap: 0.45rem; border: 1px solid var(--hairline-strong); border-radius: 999px; background: #fff; padding: 0.5rem 0.95rem; font-size: 0.875rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: background-color 0.15s, border-color 0.15s, color 0.15s; user-select: none; }
.pill-choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.pill-choice:hover { border-color: var(--brand-mid); color: var(--ink); }
.pill-choice:has(input:checked) { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.pill-choice:has(input:focus-visible) { box-shadow: var(--ring); }
.pill-choice-lg { padding: 0.75rem 1.2rem; font-size: 0.95rem; border-radius: 12px; }
.pill-choice-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.pill-choice-addon:has(input:checked) { background: var(--accent-deep); border-color: var(--accent-deep); }
.pill-choice svg { flex: none; }
#quality-cards .pill-choice { flex: 1 1 calc(50% - 0.5rem); justify-content: center; border-radius: 12px; }
@media (min-width: 640px) { #quality-cards .pill-choice { flex: 1 1 0; } }
#property-tabs .pill-choice { flex: 1 1 0; justify-content: center; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; background: var(--brand-mid); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--brand-deep); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--brand-deep); cursor: pointer; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring); }

/* ---------- wizard (mobile only) ---------- */
.wizard-progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; margin-bottom: 1.25rem; }
.wizard-progress-item { display: flex; flex-direction: column; gap: 0.35rem; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; }
.wizard-progress-item::before { content: ""; height: 4px; border-radius: 999px; background: var(--hairline); }
.wizard-progress-item span { font-size: 0.72rem; font-weight: 600; color: var(--ink-faint); }
.wizard-progress-item[data-state="current"]::before { background: var(--accent-deep); }
.wizard-progress-item[data-state="current"] span { color: var(--ink); }
.wizard-progress-item[data-state="done"]::before { background: var(--brand-deep); }
.wizard-step { border: 0; padding: 0; margin: 0; min-width: 0; }
.wizard-step + .wizard-step { margin-top: 1.75rem; padding-top: 1.75rem; border-top: 1px solid var(--hairline); }
.wizard-step legend { padding: 0; }
.wizard-nav { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 1.5rem; }
@media (min-width: 1024px) {
  .wizard-progress, .wizard-nav { display: none; }
}
/* Tailwind's preflight hides [hidden] with !important inside @layer base; override in the same layer. */
@layer base {
  @media (min-width: 1024px) { .wizard-step[hidden] { display: block !important; } }
}
@media (max-width: 1023px) { .wizard-step + .wizard-step { margin-top: 0; padding-top: 0; border-top: 0; } }

/* ---------- estimate dock ---------- */
.estimate-dock { background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden; }
.estimate-final { background: var(--brand-deep); color: #fff; padding: 1.25rem 1.35rem; }
.estimate-final-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: rgba(255, 255, 255, 0.7); }
.estimate-final-value { display: block; margin-top: 0.25rem; font-family: "Bricolage Grotesque", sans-serif; font-size: 2rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.estimate-final-note { margin-top: 0.4rem; font-size: 0.78rem; color: rgba(255, 255, 255, 0.75); }
.derivation { padding: 0.5rem 1.35rem 0; }
.derivation-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px dashed var(--hairline); font-size: 0.85rem; }
.derivation-label { color: var(--ink-soft); }
.derivation-value { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; color: var(--ink); text-align: right; white-space: nowrap; }
.derivation-row[data-emphasis="addon"] .derivation-value { color: var(--accent-deep); }
.derivation-total { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: 0.5rem -1.35rem 0; padding: 1rem 1.35rem; background: var(--accent); border-top: 2px solid var(--accent-deep); }
.derivation-total-label { font-weight: 700; color: var(--accent-ink); }
.derivation-total-value { font-family: "Bricolage Grotesque", sans-serif; font-size: 1.35rem; font-weight: 800; color: var(--accent-ink); }

.mobile-estimate-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--brand-deep); color: #fff; padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px -12px rgba(0, 0, 0, 0.35); }
@media (min-width: 1024px) { .mobile-estimate-bar { display: none; } }
body { padding-bottom: 5rem; }
@media (min-width: 1024px) { body { padding-bottom: 0; } }

/* ---------- results ---------- */
.results-panel { padding: 1.5rem; }
@media (min-width: 640px) { .results-panel { padding: 2rem; } }
.result-card { background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 1.25rem; }
.result-card h3 { font-family: "Bricolage Grotesque", sans-serif; font-size: 1rem; font-weight: 700; color: var(--ink); }
.result-stat { border-radius: var(--radius-sm); padding: 1rem 1.1rem; background: var(--sunken); }
.result-stat-label { font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); }
.result-stat-value { display: block; margin-top: 0.15rem; font-family: "Bricolage Grotesque", sans-serif; font-size: 1.35rem; font-weight: 800; color: var(--ink); }

.reference-table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.reference-table th, .reference-table td { padding: 0.55rem 0.75rem; text-align: right; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.reference-table th { font-weight: 600; color: var(--ink-soft); background: var(--sunken); }
.reference-table th:first-child, .reference-table td:first-child { text-align: left; }
.reference-table .ref-active-col { color: var(--brand-deep); }
.reference-table .ref-active-row td { background: var(--brand); font-weight: 600; }
.reference-table .ref-active-cell { background: var(--accent-deep) !important; color: #fff; border-radius: 6px; font-weight: 700; }

.legend-swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 3px; flex: none; }
.timeline-row-track { position: relative; height: 10px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.timeline-bar { position: absolute; top: 0; bottom: 0; border-radius: 999px; }

.result-table-container { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
.results-table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.results-table th { text-align: left; padding: 0.6rem 0.75rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); background: var(--sunken); white-space: nowrap; }
.results-table td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.results-table tfoot td { border-bottom: 0; border-top: 2px solid var(--hairline-strong); font-weight: 700; }
.results-table .amount-cell { text-align: right; font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; white-space: nowrap; }
.material-icon { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; background: var(--brand); color: var(--brand-deep); margin-right: 0.5rem; vertical-align: middle; }
.material-icon svg { width: 1rem; height: 1rem; }
.qty-pill-group { display: inline-flex; gap: 0.2rem; }
.qty-pill { border: 1px solid var(--hairline-strong); border-radius: 999px; background: #fff; padding: 0.15rem 0.5rem; font-size: 0.7rem; font-weight: 700; color: var(--ink-soft); cursor: pointer; }
.qty-pill:hover { border-color: var(--brand-mid); }
.qty-pill.active, .qty-pill[aria-pressed="true"] { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }

/* ---------- long-form content ---------- */
.steps-grid { display: grid; gap: 1rem; }
@media (min-width: 768px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.authority-grid { display: grid; gap: 1rem; }
@media (min-width: 768px) { .authority-grid { grid-template-columns: repeat(2, 1fr); } }
.commandment-item { display: flex; gap: 0.85rem; padding: 1rem; border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--paper); }
.hidden-cost-item { padding: 1rem; border-left: 3px solid var(--accent-deep); background: var(--sunken); border-radius: 0 10px 10px 0; }

.preset-card { background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); }
.preset-card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--hairline); background: var(--surface); }
.preset-card-title { display: flex; align-items: center; gap: 0.5rem; font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; color: var(--ink); }
.preset-rate-value { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; color: var(--brand-deep); }
.preset-table-wrapper { overflow-x: auto; overflow-y: auto; max-height: 360px; padding: 0 1.25rem 1.25rem; }
.preset-table-wrapper.rate-matrix-wrapper { max-height: 480px; }
.preset-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.preset-table th { text-align: left; padding: 0.5rem 0.6rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); border-bottom: 1px solid var(--hairline-strong); position: sticky; top: 0; background: var(--paper); }
.preset-table td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--hairline); }
.preset-table td:not(:first-child), .preset-table th:not(:first-child) { text-align: right; }

.guide-article h2 { margin-top: 2.5rem; font-size: 1.5rem; font-weight: 700; }
.guide-article h3 { margin-top: 1.75rem; padding-left: 0.75rem; border-left: 3px solid var(--accent-deep); font-size: 1.15rem; font-weight: 700; }
.guide-article h4 { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--hairline); font-size: 1rem; font-weight: 700; color: var(--ink); }
.guide-article p, .guide-article li { font-size: 0.98rem; line-height: 1.7; color: var(--ink-soft); }
.guide-formula { margin: 1.25rem 0; padding: 0.9rem 1.25rem; border-radius: var(--radius-sm); background: var(--sunken); border-left: 4px solid var(--accent-deep); text-align: center; font-family: "SFMono-Regular", ui-monospace, Menlo, monospace; font-size: 0.85rem; color: var(--ink); overflow-x: auto; }
.guide-article code { font-family: "SFMono-Regular", ui-monospace, Menlo, monospace; font-size: 0.88em; background: var(--sunken); border: 1px solid var(--hairline); border-radius: 4px; padding: 0.1em 0.4em; color: var(--ink); }
.guide-article p + p { margin-top: 1rem; }
.guide-article strong { color: var(--ink); }
.guide-article a { color: var(--brand-deep); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.guide-article ul, .guide-article ol { margin: 1rem 0; padding-left: 0.25rem; list-style: none; }
.guide-article li { margin: 0.5rem 0; position: relative; padding-left: 1.5rem; }
.guide-article ul li::before { content: ""; position: absolute; left: 0.1rem; top: 0.7em; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--accent-deep); }
.guide-article ol { counter-reset: guide-ol; }
.guide-article ol li { counter-increment: guide-ol; }
.guide-article ol li::before { content: counter(guide-ol); position: absolute; left: 0; top: 0.05em; width: 1.15rem; height: 1.15rem; border-radius: 50%; background: var(--accent-deep); color: #fff; font-size: 0.68rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.guide-article table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; font-size: 0.9rem; }
.guide-article th, .guide-article table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--hairline); text-align: left; }
.guide-article th { background: var(--sunken); font-weight: 600; color: var(--ink); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.guide-article tr:first-child th:first-child { border-top-left-radius: 8px; }
.guide-article tr:first-child th:last-child { border-top-right-radius: 8px; }
.guide-article tbody tr:nth-child(even) td, .guide-article tr:nth-child(even) td { background: var(--surface); }
.guide-article tr:hover td { background: var(--sunken); }
.guide-callout { margin: 1.5rem 0; padding: 1.25rem 1.5rem; border-radius: var(--radius); background: var(--brand); border-left: 4px solid var(--brand-deep); }
.guide-timeline-step { position: relative; padding-left: 2.5rem; padding-bottom: 1.5rem; }
.guide-timeline-step::before { content: ""; position: absolute; left: 0.6rem; top: 0.4rem; bottom: 0; width: 2px; background: var(--hairline); }
.guide-timeline-step::after { content: ""; position: absolute; left: 0.25rem; top: 0.35rem; width: 0.9rem; height: 0.9rem; border-radius: 50%; background: var(--accent-deep); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--accent-deep); }
.guide-timeline-step:last-child::before { display: none; }

.faq-item { border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--paper); }
.faq-item + .faq-item { margin-top: 0.6rem; }
.faq-summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; font-weight: 700; color: var(--ink); cursor: pointer; list-style: none; }
.faq-summary::-webkit-details-marker { display: none; }
.faq-summary::after { content: "+"; font-size: 1.25rem; color: var(--accent-deep); flex: none; }
.faq-item[open] .faq-summary::after { content: "\2212"; }
.faq-answer { padding: 0 1.25rem 1.25rem; color: var(--ink-soft); line-height: 1.65; font-size: 0.95rem; }

/* ---------- print ---------- */
.print-header { display: none; }
.print-total { font-size: 1.1rem; margin-top: 0.5rem; }
@media print {
  body { padding: 0; background: #fff; }
  header, footer, .no-print, .estimate-dock, .mobile-estimate-bar, #site-content-below-calc, #calc-form, .wizard-progress, button { display: none !important; }
  .print-header { display: block; margin-bottom: 1.5rem; }
  .results-panel { border: 0; box-shadow: none; padding: 0; }
  .result-card { break-inside: avoid; border: 1px solid #ccc; }
}
