/* SolarSizr — styles. Theme-aware, no external assets. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1a1d24;
  --muted: #5c6470;
  --border: #e2e6ec;
  --brand: #f59e0b;
  --brand-dark: #d97706;
  --brand-ink: #7c4a03;
  --accent: #0e7490;
  --good: #16a34a;
  --danger: #dc2626;
  --headline-ink: #b45309;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 14px;
  --maxw: 900px;
}

/* Dark token set, shared by system preference and the manual toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1319;
    --surface: #171c24;
    --surface-2: #1e242e;
    --text: #e8ecf2;
    --muted: #9aa4b2;
    --border: #2a313c;
    --brand: #fbbf24;
    --brand-dark: #f59e0b;
    --brand-ink: #fde68a;
    --accent: #22d3ee;
    --good: #4ade80;
    --danger: #f87171;
    --headline-ink: #fde68a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1319;
  --surface: #171c24;
  --surface-2: #1e242e;
  --text: #e8ecf2;
  --muted: #9aa4b2;
  --border: #2a313c;
  --brand: #fbbf24;
  --brand-dark: #f59e0b;
  --brand-ink: #fde68a;
  --accent: #22d3ee;
  --good: #4ade80;
  --danger: #f87171;
  --headline-ink: #fde68a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent); }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; padding-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; color: var(--text); text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: grid; place-items: center; color: #3d2600; font-size: 18px;
}
.brand .tag { color: var(--brand-dark); }
.nav { display: flex; align-items: center; gap: 18px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.nav a:hover { color: var(--text); }
.theme-toggle {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  width: 38px; height: 38px; cursor: pointer; font-size: 17px; line-height: 1;
  display: grid; place-items: center; color: var(--text);
}
.theme-toggle:hover { border-color: var(--brand); }
@media (max-width: 480px) { .nav a { display: none; } }

/* Hero */
.hero { padding: 40px 0 8px; }
.hero h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.12; letter-spacing: -.03em; margin: 0 0 12px; }
.hero p.lead { font-size: 18px; color: var(--muted); margin: 0 0 4px; max-width: 640px; }

/* Calculator card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 24px 0;
}
.calc-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
label.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.row > * { flex: 1 1 180px; }

input[type="number"], input[type="text"], select {
  width: 100%; padding: 12px 14px; font-size: 16px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(245, 158, 11, .2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; font-size: 16px; font-weight: 700; cursor: pointer;
  border-radius: 10px; border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #3a2400; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--brand); }
.btn:disabled { opacity: .6; cursor: default; }

.sep { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 2px 0; }
.sep::before, .sep::after { content: ""; height: 1px; background: var(--border); flex: 1; }

.error { color: var(--danger); font-size: 14px; margin-top: 4px; font-weight: 600; }

/* Results */
.results { margin-top: 8px; }
.results h2 { font-size: 22px; letter-spacing: -.02em; margin: 0 0 4px; }
.result-lead { color: var(--muted); margin: 0 0 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 620px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; text-align: center;
}
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.stat .v { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.stat.headline { background: linear-gradient(135deg, rgba(245,158,11,.14), rgba(217,119,6,.06)); border-color: var(--brand); }
.stat.headline .v { color: var(--headline-ink); }

.facing {
  margin: 16px 0 4px; padding: 12px 16px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 15px;
}
.facing strong { color: var(--text); }

/* Chart + table */
.two-col { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 20px; }
@media (min-width: 720px) { .two-col { grid-template-columns: 1.4fr 1fr; } }
.subhead { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }

.chart { width: 100%; height: auto; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .bar { fill: var(--brand); }
.chart .barval { fill: var(--muted); font-size: 11px; font-weight: 700; }
.chart .xtick, .chart .ytick { fill: var(--muted); font-size: 11px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td:last-child, th:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* Content sections */
.section { padding: 20px 0 12px; }
.section + .section { margin-top: 12px; }
.section h2 { font-size: 26px; letter-spacing: -.02em; margin: 36px 0 12px; }
#faq { margin-top: 40px; padding-top: 36px; border-top: 1px solid var(--border); }
.section h3 { font-size: 18px; margin: 22px 0 6px; }
.section p, .section li { color: var(--text); }
.section .muted { color: var(--muted); }
.formula {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px; overflow-x: auto; margin: 10px 0;
}

/* FAQ */
.faq-item { border-bottom: 1px solid var(--border); }
.faq-q {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 16px 30px 16px 0; font-size: 16px; font-weight: 700; color: var(--text); position: relative;
}
.faq-q::after { content: "+"; position: absolute; right: 4px; top: 14px; font-size: 22px; color: var(--brand-dark); font-weight: 700; }
.faq-item.open .faq-q::after { content: "\2212"; }
.faq-a { display: none; padding: 0 0 16px; color: var(--muted); }
.faq-item.open .faq-a { display: block; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 28px 0; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.disclaimer { font-size: 13px; margin-top: 6px; max-width: 640px; }

/* Ad slots (reserved space, filled once AdSense is approved) */
.ad-slot {
  margin: 24px 0; min-height: 90px; border: 1px dashed var(--border); border-radius: 10px;
  display: grid; place-items: center; color: var(--muted); font-size: 12px; letter-spacing: .05em; text-transform: uppercase;
}
