/* Backup Power Math. Mobile first, no framework. */

:root {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #1b2420;
  --muted: #4a5750;
  --border: #c9d1c9;
  --input-border: #6b756e;
  --accent: #0b5c47;
  --accent-text: #ffffff;
  --accent-soft: #dcefe7;
  --focus: #1a4fd8;
  --ok: #0b6b2e;
  --ok-bg: #e1f3e6;
  --bad: #a3231b;
  --bad-bg: #fbe7e5;
  --warn: #6d4a00;
  --warn-bg: #fff2cc;
  --radius: 10px;
  --gutter: 16px;
  --max: 72rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121714;
    --surface: #1a211d;
    --surface-2: #232c27;
    --text: #e8eee9;
    --muted: #b3c0b8;
    --border: #3a4740;
    --input-border: #7f8c84;
    --accent: #6fd3ae;
    --accent-text: #08231a;
    --accent-soft: #1d3a2f;
    --focus: #8fb2ff;
    --ok: #7fe0a1;
    --ok-bg: #173523;
    --bad: #ff9d94;
    --bad-bg: #3d1b18;
    --warn: #ffd978;
    --warn-bg: #3a2f10;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 var(--font);
}

img, svg { max-width: 100%; }

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

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

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  z-index: 10;
}
.skip-link:focus { top: var(--gutter); }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

/* Header and footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.site-header nav ul { list-style: none; display: flex; gap: 1.25rem; margin: 0; padding: 0; }

.breadcrumb { font-size: 0.9rem; color: var(--muted); padding: 0.75rem 0 0; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: 0.4rem; color: var(--muted); }

.site-footer { margin-top: 3rem; padding: 2rem 0 3rem; background: var(--surface); border-top: 1px solid var(--border); font-size: 0.95rem; }
.site-footer p { margin: 0 0 0.75rem; max-width: 60rem; }
.site-footer ul { list-style: none; display: flex; flex-wrap: wrap; gap: 1.25rem; margin: 0 0 1rem; padding: 0; }

/* Typography */
h1 { font-size: 1.75rem; line-height: 1.2; margin: 1rem 0 0.75rem; }
h2 { font-size: 1.4rem; line-height: 1.25; margin: 2rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
p, ul, ol { margin: 0 0 1rem; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 46rem; }
.meta-line { color: var(--muted); font-size: 0.9rem; }

/* Cards and notices */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.notice { border: 1px solid var(--border); border-left-width: 6px; border-radius: var(--radius); background: var(--surface); padding: 0.75rem 1rem; margin: 1rem 0; }
.notice strong:first-child { display: inline-block; margin-right: 0.35rem; }
.notice-warn { border-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.notice-error { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.notice-info { border-color: var(--accent); background: var(--accent-soft); }
.notice-warn a, .notice-error a { color: inherit; }
.notice ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }

/* Tool layout */
.tool { display: grid; gap: 1.5rem; }
@media (min-width: 62rem) {
  .tool { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  .results-col { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
}

fieldset { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 0 0 1rem; padding: 0.75rem 1rem 1rem; min-width: 0; }
legend { font-weight: 700; padding: 0 0.4rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0 0.5rem; }
/* Consistent spacing: a helper line inside a field ends that field, and every stacked field starts
   0.85rem below the one before (helper line or not). Grids such as .load-fields keep their own gap. */
.field > .hint { margin: 0; }
:not(.load-fields) > .field + .field, .choice-row + .field { margin-top: 0.85rem; }

label { display: inline-block; }
.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field > label { font-size: 0.9rem; font-weight: 600; }

input[type="number"], input[type="text"], select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--input-border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  min-height: 2.75rem;
  width: 100%;
  min-width: 0;
}
input[aria-invalid="true"] { border-color: var(--bad); background: var(--bad-bg); }

input[type="checkbox"], input[type="radio"] { width: 1.35rem; height: 1.35rem; accent-color: var(--accent); flex: none; margin: 0; }

.choice { display: flex; align-items: center; gap: 0.6rem; min-height: 2.75rem; }
.choice label { font-weight: 600; cursor: pointer; }
.choice-row { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }

button, .btn {
  font: inherit;
  font-weight: 700;
  display: inline-block;
  min-height: 2.75rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
button.secondary, .btn.secondary { background: var(--surface); color: var(--accent); }
button:hover, .btn:hover { filter: brightness(1.08); }

/* Appliance rows */
.load-list { list-style: none; margin: 0; padding: 0; }
.load { border-top: 1px solid var(--border); padding: 0.5rem 0; }
.load:first-child { border-top: 0; }
.load-head { display: flex; align-items: center; gap: 0.6rem; min-height: 2.75rem; }
.load-head label { font-weight: 600; cursor: pointer; flex: 1; }
.typical { display: block; font-weight: 400; font-size: 0.85rem; color: var(--muted); }
.tag { display: inline-block; font-size: 0.75rem; font-weight: 700; border: 1px solid currentColor; border-radius: 999px; padding: 0 0.5rem; margin-left: 0.4rem; color: var(--warn); background: var(--warn-bg); white-space: nowrap; }
.load-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; padding: 0.25rem 0 0.5rem 2rem; }
.load-fields[hidden] { display: none; }
.load-fields .wide { grid-column: 1 / -1; }
.load-note { grid-column: 1 / -1; font-size: 0.85rem; color: var(--muted); margin: 0; }
@media (min-width: 40rem) {
  .load-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.custom-load { border: 1px dashed var(--border); border-radius: var(--radius); padding: 0.75rem; margin-top: 0.75rem; }
.custom-load .load-fields { padding-left: 0; }

/* Results */
.stats { display: grid; gap: 0.75rem; margin: 0 0 1rem; }
@media (min-width: 40rem) and (max-width: 61.99rem) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--accent-soft); border: 2px solid var(--accent); border-radius: var(--radius); padding: 0.75rem 1rem; }
.stat .label { display: block; font-weight: 700; }
.stat .value { display: block; font-size: 2.6rem; line-height: 1.1; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.stat .unit { font-size: 1.1rem; font-weight: 700; margin-left: 0.25rem; }
.stat .sub { display: block; font-size: 0.85rem; color: var(--muted); }

details { margin: 0 0 1rem; }
summary { cursor: pointer; font-weight: 700; min-height: 2.75rem; display: flex; align-items: center; }
.breakdown { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.breakdown th, .breakdown td { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.breakdown td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* Product shortlist */
.products { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.product { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.product h4 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.badge { display: inline-block; font-weight: 700; font-size: 0.9rem; border-radius: 999px; padding: 0.1rem 0.7rem; border: 2px solid currentColor; margin: 0 0.4rem 0.4rem 0; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-bad { color: var(--bad); background: var(--bad-bg); }
.badge-info { color: var(--warn); background: var(--warn-bg); }
.checks { list-style: none; margin: 0.5rem 0; padding: 0; font-size: 0.95rem; }
.checks li { padding-left: 1.6rem; position: relative; margin-bottom: 0.2rem; }
.checks .mark { position: absolute; left: 0; font-weight: 800; }
.checks .pass .mark { color: var(--ok); }
.checks .fail .mark { color: var(--bad); }
.spec-line { font-size: 0.9rem; color: var(--muted); margin: 0.25rem 0; }
.disclosure { font-size: 0.9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 0.6rem 0.8rem; margin: 0 0 1rem; }
.product-actions { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }

.installer { margin-top: 1.5rem; }
.installer h3 { margin-top: 0; }

/* Article content */
.content { max-width: 46rem; }
.content h2:first-child { margin-top: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; margin: 0 0 1.25rem; }
table.data caption { text-align: left; font-weight: 700; padding-bottom: 0.4rem; }
table.data th, table.data td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
table.data thead th { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

.tool-cards { display: grid; gap: 1rem; margin: 1.5rem 0; padding: 0; list-style: none; }
.tool-cards h3 { margin-top: 0; }
@media (min-width: 40rem) { .tool-cards { grid-template-columns: repeat(2, 1fr); } }

@media (min-width: 40rem) {
  h1 { font-size: 2.2rem; }
  h2 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media print {
  .site-header, .site-footer, .skip-link, button { display: none; }
}
