/*
 * styles.css — thesolarpayback.com
 * Mobile-first · fast · INP/CLS-safe · WCAG 2.2 AA contrast · one theme.
 *
 * CLS protection: every ad slot and the result panel reserve height up front.
 * INP protection: no heavy selectors, no animation on interaction-critical nodes.
 * --ad-gap is the single source of truth for the ≥150px ad↔control moat (INV-3).
 */

:root {
  --ad-gap: 150px;                 /* INV-3 moat: ads ≥150px from any control/result */

  /* Palette — all text/background pairs meet WCAG 2.2 AA (≥4.5:1). */
  --bg:        #ffffff;
  --surface:   #f5f7fa;
  --surface-2: #eaeef3;
  --ink:       #15202b;            /* on --bg: 15.8:1 */
  --ink-soft:  #44515e;            /* on --bg: 7.9:1 */
  --line:      #cdd6e0;
  --brand:     #0b6b4f;            /* deep solar-green; on --bg 5.9:1 */
  --brand-ink: #073f2f;
  --brand-bg:  #e6f4ee;
  --accent:    #b25e00;            /* amber for the headline number; on --bg 4.6:1 */
  --result-bg: #0b3d2e;            /* result panel; white text 11.7:1 */
  --result-ink:#ffffff;
  --focus:     #1457d6;
  --warn-bg:   #fff4e5;
  --warn-ink:  #6b3b00;

  --radius: 10px;
  --maxw: 880px;
  --measure: 68ch;                 /* readable prose line length (webdesign-ux F2) */
  --gap: 1rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

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

/* ── Skip link (WCAG 2.4.1) ── */
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: #fff; padding: .6rem 1rem; z-index: 100;
}
.skip:focus { left: 0; }

/* ── Header / nav ── */
.site-header { background: var(--brand); color: #fff; }
.site-header .wrap { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1.25rem; padding-top: .7rem; padding-bottom: .7rem; }
.brand { font-weight: 700; font-size: 1.15rem; color: #fff; text-decoration: none; letter-spacing: -.01em; }
.brand span { opacity: .85; font-weight: 400; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-left: auto; }
.nav a { color: #eafff6; text-decoration: none; font-size: .95rem; padding: .15rem 0; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a:focus { border-bottom-color: #eafff6; }

/* Brand subtitle hidden on narrowest screens to protect the wordmark (webdesign-ux F10) */
@media (max-width: 420px) { .brand span { display: none; } }

/* ── Headings & prose ── */
h1 { font-size: 1.7rem; line-height: 1.2; margin: 1.2rem 0 .5rem; letter-spacing: -.02em; }
h2 { font-size: 1.3rem; margin: 2rem 0 .6rem; letter-spacing: -.01em; }
h3 { font-size: 1.08rem; margin: 1.4rem 0 .4rem; }
p { margin: .7rem 0; }
a { color: var(--brand); }

/* Lead: full-ink, slightly larger/looser, constrained measure (webdesign-ux F5/F2) */
.lead { font-size: 1.15rem; color: var(--ink); line-height: 1.5; max-width: var(--measure); }
.muted { color: var(--ink-soft); }
small, .small { font-size: .86rem; }

/* Constrain prose measure for readability/dwell; tools + tables keep full width
 * (webdesign-ux F2). Inline elements inherit, so these never affect calc hooks. */
main > p,
.section > p,
.section > ul,
.section > ol,
.faq,
.answer-block,
.defs { max-width: var(--measure); }
.data-table,
.state-grid,
.calc,
.result,
.rail { max-width: none; }

/* ── Answer block (AEO/GEO extractable) ── */
.answer-block {
  background: var(--brand-bg);
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.1rem;
  margin: 1rem 0 1.5rem;
  font-size: 1.06rem;
  color: var(--brand-ink);
}

/* ── Semantic-element styling ───────────────────────────────────────────────
 * <mark>, <data>, <abbr>, <dl> are wrapped around existing copy / calc hooks
 * by the HTML fixes. All inline + inherit → zero layout/CLS impact. */

/* <mark class="hl"> — reset the UA yellow; it is a SEMANTIC highlight only,
 * the visual emphasis stays with surrounding weight/colour (semantic 1.1). */
mark.hl,
.result-headline mark.hl,
.answer-block mark.hl { background: transparent; color: inherit; }

/* <data> — purely machine-readable; render exactly like its text context. */
data { font: inherit; color: inherit; }

/* First-use abbreviations: subtle dotted underline, no colour change (semantic 7.1) */
abbr[title] {
  text-decoration: underline dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: help;
}

/* "Key solar terms, defined" definition list (aeo F6) */
.defs { margin: 1rem 0; }
.defs dt { font-weight: 700; color: var(--brand-ink); margin-top: .7rem; }
.defs dt:first-child { margin-top: 0; }
.defs dd { margin: .15rem 0 0; color: var(--ink); }

/* The four-inputs ordered list (semantic 4.1) */
.input-list { margin: 1rem 0; padding-left: 1.4rem; }
.input-list li { margin: .45rem 0; }
.input-list li strong { color: var(--brand-ink); }

/* National-coverage line + article byline reuse .muted .small; no extra rules
 * needed (geo FIX 5, semantic 5.2). .coverage/.byline kept for hook clarity. */
.coverage, .byline { color: var(--ink-soft); }

/* ── Breadcrumb (serp C2/C3, seo P1-2) ── */
.breadcrumb { margin: .6rem 0 .2rem; font-size: .9rem; }
.breadcrumb ol {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem;
}
.breadcrumb li { display: flex; align-items: center; gap: .35rem; }
.breadcrumb li + li::before { content: "›"; color: var(--ink-soft); }
.breadcrumb a { color: var(--brand); text-decoration: none; }
.breadcrumb a:hover, .breadcrumb a:focus { text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--ink-soft); }

/* ── Calculator ── */
.calc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin: 1rem 0;
}
.calc-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 620px) { .calc-grid { grid-template-columns: 1fr 1fr; } }

.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-weight: 600; font-size: .95rem; }
.field .hint { font-size: .82rem; color: var(--ink-soft); }

/* Progressive-disclosure advanced fields (webdesign-ux F6). <details> spanning
 * the full calc-grid row; no animation → INP-safe; clear summary affordance. */
.adv-fields { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: .6rem; }
.adv-fields > summary {
  cursor: pointer; font-weight: 600; font-size: .95rem; color: var(--brand-ink);
  list-style: none; padding: .35rem 0; display: inline-flex; align-items: center; gap: .4rem;
}
.adv-fields > summary::-webkit-details-marker { display: none; }
.adv-fields > summary::before { content: "▸"; color: var(--brand); }
.adv-fields[open] > summary::before { content: "▾"; }
.adv-fields > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.adv-fields .calc-grid { margin-top: .8rem; }

input[type="number"], select {
  font: inherit; font-size: 1rem;
  padding: .6rem .65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff; color: var(--ink);
  min-height: 44px;             /* WCAG 2.5.8 target size */
}
input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--brand); }

/* slider + typed alternative (WCAG 2.5.7 dragging alternative) */
.slider-row { display: flex; align-items: center; gap: .6rem; }
.slider-row input[type="range"] { flex: 1; }

/* Slider value badge — emphasised, tabular (webdesign-ux F7) */
.slider-val {
  min-width: 4.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--brand-ink);
  background: var(--brand-bg);
  border-radius: 6px;
  padding: .1rem .45rem;
  text-align: center;
}
.stepper { display: inline-flex; gap: .25rem; }
.stepper button {
  font: inherit; min-width: 44px; min-height: 44px;
  border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer;
}
.stepper button:hover { background: var(--surface-2); }

.toggle-row { display: flex; align-items: center; gap: .6rem; }
.toggle-row input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--brand); }

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

/* ── Result panel (reserves height → no CLS) ── */
.result {
  background: var(--result-bg);
  color: var(--result-ink);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin: 1rem 0;
  min-height: 220px;            /* reserved → no layout shift on recompute */
}
.result h2 { color: #fff; margin-top: 0; font-size: 1.15rem; }
.result-headline { font-size: 2.5rem; font-weight: 800; line-height: 1.05; color: #ffd9a6; margin: .2rem 0; }
.result-sub { font-size: 1.05rem; color: #d7eee5; }

/* Result stats as a 2→4 col grid. Works for both the <div> and the optional
 * <dl>/<dt>/<dd> variant: order CSS puts the value (<dd>) above the label
 * (<dt>) without changing the inner *-val ids calc.js writes to (semantic 3.1). */
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1rem; margin: 1rem 0 .4rem; }
@media (min-width: 620px) { .result-stats { grid-template-columns: repeat(4, 1fr); } }

/* Stat tile: divider rule + padding for scannability (webdesign-ux F8) */
.result-stats .stat,
dl.result-stats > .stat {
  border-left: 2px solid rgba(255, 255, 255, .18);
  padding-left: .7rem;
}
/* <dl> variant: each stat is a dt+dd pair; flip order so the number reads first */
dl.result-stats { gap: .9rem 1rem; }
dl.result-stats .stat { display: flex; flex-direction: column; }
dl.result-stats .stat dd { order: 1; margin: 0; }
dl.result-stats .stat dt { order: 2; }

.stat .stat-num,
dl.result-stats dd {
  font-size: 1.3rem; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums;   /* aligned digits on recompute */
}
.stat .stat-label,
dl.result-stats dt { font-size: .8rem; color: #bcdfd2; }

/* Self-contained units-inline result sentence for AEO lift (aeo F7) */
.result-summary {
  font-size: .92rem;
  line-height: 1.5;
  color: #d7eee5;
  margin: .6rem 0 0;
}
.result-summary mark.hl { background: transparent; color: #fff; font-weight: 600; }

.result .disclaimer { font-size: .82rem; color: #bcdfd2; margin-top: .8rem; }
.result-warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: .7rem .9rem; }

/* On mobile the result is intentionally NOT sticky — a tall result panel would
 * cover half the screen as the user scrolls. It sits directly under the inputs
 * and scrolls normally. Only wide desktop (>=1024px), where the result sits
 * beside the form, gets a sticky treatment (see the rule further below). */

/* ── Tables ── */
.data-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .95rem; }
.data-table th, .data-table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
.data-table th { background: var(--surface-2); font-size: .85rem; }
.data-table td data { font-variant-numeric: tabular-nums; }
.data-table tr:hover td { background: var(--surface); }
.data-table caption { text-align: left; font-size: .82rem; color: var(--ink-soft); margin-bottom: .4rem; }

/* figure/figcaption (if used to frame a table or chart) */
figure { margin: 1rem 0; }
figcaption { font-size: .82rem; color: var(--ink-soft); margin-top: .4rem; }

/* ── Ad slots: reserved height, labelled, isolated by the moat ─────────────
 * NO ad code present — placeholder only. Auto Ads FORBIDDEN.
 * The vertical margin enforces the ≥150px separation from controls/result.
 * width:100% + per-breakpoint reserved height kill CLS on responsive fill. */
.ad-slot {
  margin: var(--ad-gap) auto;
  width: 100%;
  background: repeating-linear-gradient(45deg, #f1f3f6, #f1f3f6 12px, #eaeef3 12px, #eaeef3 24px);
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
  text-align: center;
}
.ad-slot .ad-label { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }

/* Leaderboard / in-content unit — reserved height per breakpoint (ad-rpm F4) */
.ad-slot--leaderboard { min-height: 250px; max-width: 728px; }
.ad-slot--inline { min-height: 280px; }
@media (min-width: 620px) {
  .ad-slot--leaderboard { min-height: 90px; }   /* leaderboard renders shorter on desktop */
  .ad-slot--inline { min-height: 250px; }
}

/* Above-the-fold unit — mobile-capped so it never pushes the calc off-screen;
 * --ad-gap still holds the ≥150px moat to #stateCode (ad-rpm F2). */
.ad-slot--atf { min-height: 100px; max-width: 728px; }
@media (min-width: 620px) { .ad-slot--atf { min-height: 90px; } }

.ad-divider { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* Desktop right-rail (ad-rpm F3). Hidden on mobile. Appears ONLY at ≥1024px,
 * sticky WITHIN #main, with a top offset that keeps it below the result row so
 * it never sits beside #result or any control — the moat is held by the offset
 * + horizontal column gap, NOT by --ad-gap margins (which are zeroed here). */
.rail { display: none; }
@media (min-width: 1024px) {
  .has-rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 2.5rem;
    align-items: start;
  }
  .rail { display: block; }
  .rail .ad-slot--rail {
    position: sticky;
    top: 620px;                  /* offset below the result row → no control adjacency */
    min-height: 600px;           /* 300×600 reserved */
    max-width: 300px;
    margin: 0;                   /* moat held by offset + column gap, not margin */
  }
}

/* ── FAQ ── */
.faq details {
  border: 1px solid var(--line); border-radius: 8px; padding: .2rem .9rem; margin: .5rem 0; background: var(--surface);
}
.faq summary { cursor: pointer; font-weight: 600; padding: .6rem 0; }
.faq summary:focus-visible { outline: 3px solid var(--focus); }

/* ── State cards / links ── */
.state-grid { display: grid; grid-template-columns: 1fr; gap: .8rem; margin: 1rem 0; }
@media (min-width: 620px) { .state-grid { grid-template-columns: 1fr 1fr; } }
.state-card { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; background: #fff; text-decoration: none; color: var(--ink); }
.state-card:hover, .state-card:focus { border-color: var(--brand); background: var(--brand-bg); }
.state-card strong { color: var(--brand-ink); }

/* ── Sources / methodology ── */
.sources { font-size: .88rem; color: var(--ink-soft); }
.sources li { margin: .3rem 0; }
.verified { display: inline-block; background: var(--brand-bg); color: var(--brand-ink); border-radius: 6px; padding: .15rem .5rem; font-size: .82rem; font-weight: 600; }
.verified time { color: inherit; }

/* ── Footer ── */
.site-footer { background: var(--surface-2); margin-top: 3rem; padding: 1.5rem 0; font-size: .9rem; color: var(--ink-soft); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.site-footer a { color: var(--brand-ink); }

/* ── Consent banner (CMP hook; no third-party tag) ── */
.consent {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: var(--ink); color: #fff; padding: .9rem 1rem;
  display: none;                 /* shown by JS only if no prior choice */
}
.consent.show { display: block; }
.consent .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 1rem; }
.consent p { margin: 0; flex: 1 1 280px; font-size: .9rem; }
.consent button {
  font: inherit; font-size: .92rem; padding: .55rem 1rem; min-height: 44px;
  border-radius: 8px; border: 1px solid #fff; cursor: pointer;
}
.consent .accept { background: #fff; color: var(--ink); }
.consent .reject { background: transparent; color: #fff; }

/* ── Utility ── */
.section { margin: 2rem 0; }
.btn {
  display: inline-block; background: var(--brand); color: #fff; text-decoration: none;
  padding: .7rem 1.2rem; border-radius: 8px; font-weight: 600; min-height: 44px;
}
.btn:hover, .btn:focus { background: var(--brand-ink); }

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

/* Ad placeholders hidden until AdSense approval — delete this rule when live ad code is added */
.ad-slot{display:none !important}
