/* =====================================================
   WattSage — Home Energy Independence Guide
   Modern minimalist stylesheet with dark mode support
   Last updated: 2026
   ===================================================== */

/* ---------- 1. Design Tokens ---------- */
:root {
  /* Light mode (default) */
  --bg:            #FAFAF7;
  --bg-elevated:   #FFFFFF;
  --bg-subtle:     #F2F1EC;
  --text:          #15171A;
  --text-muted:    #5A6470;
  --border:        #E5E3DC;
  --accent:        #E8702A;   /* solar amber */
  --accent-hover:  #C85B1B;
  --accent-soft:   #FCE9D9;
  --secondary:     #2D5F4E;   /* deep forest */
  --secondary-soft:#E1ECE7;
  --shadow-sm:     0 1px 2px rgba(20,22,26,.04), 0 1px 1px rgba(20,22,26,.03);
  --shadow-md:     0 4px 12px rgba(20,22,26,.06), 0 2px 4px rgba(20,22,26,.04);
  --shadow-lg:     0 12px 32px rgba(20,22,26,.10), 0 4px 12px rgba(20,22,26,.06);
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --radius-xl:     24px;
  --max-w:         1200px;
  --max-w-prose:   720px;
  --transition:    180ms cubic-bezier(.2,.8,.2,1);
  --font-display:  "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body:     system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg:            #0F1419;
  --bg-elevated:   #161C23;
  --bg-subtle:     #1C232C;
  --text:          #E8E6E1;
  --text-muted:    #9AA4AE;
  --border:        #232B33;
  --accent:        #F4A155;
  --accent-hover:  #FFB872;
  --accent-soft:   #2A1F14;
  --secondary:     #4A9D82;
  --secondary-soft:#16241F;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.30);
  --shadow-md:     0 4px 12px rgba(0,0,0,.40);
  --shadow-lg:     0 12px 32px rgba(0,0,0,.55);
}

/* ---------- 2. Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  font-size: 17px;
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}

img, svg { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--text);
}

h1 { font-size: clamp(2.1rem, 5vw, 3.2rem); margin-bottom: 1rem; }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); margin: 2.5rem 0 1rem; }
h3 { font-size: clamp(1.2rem, 2.5vw, 1.45rem); margin: 2rem 0 .75rem; }
h4 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }

p { margin-bottom: 1.1rem; }
ul, ol { margin: 0 0 1.1rem 1.4rem; }
li { margin-bottom: .4rem; }

/* ---------- 3. Layout Helpers ---------- */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
}
.prose { max-width: var(--max-w-prose); margin: 0 auto; }
.section { padding: 4rem 0; }
.section-sm { padding: 2.5rem 0; }

/* ---------- 4. Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 247, .85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}
[data-theme="dark"] .site-header {
  background: rgba(15, 20, 25, .85);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  font-size: 1rem;
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: .35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  color: var(--text-muted);
  font-size: .92rem;
  font-weight: 500;
  padding: .5rem .8rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.nav-links a:hover { color: var(--text); background: var(--bg-subtle); }
.nav-links a.active { color: var(--accent); }

.nav-actions { display: flex; align-items: center; gap: .5rem; }

/* Theme toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
  transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .8rem 1.4rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .95rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-lg { padding: 1rem 1.75rem; font-size: 1.05rem; }

/* ---------- 6. Hero ---------- */
.hero {
  padding: 5rem 0 4rem;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  top: -20%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 65%);
  opacity: .8;
  z-index: -1;
  pointer-events: none;
}
.hero-inner {
  max-width: 820px;
  margin: 0 auto;
  text-align: center;
}
.hero-eyebrow {
  display: inline-block;
  padding: .35rem .9rem;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .02em;
  margin-bottom: 1.25rem;
}
[data-theme="dark"] .hero-eyebrow { color: var(--accent); }
.hero h1 { margin-bottom: 1.25rem; }
.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto 2rem;
}
.hero-cta {
  display: flex;
  gap: .75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- 7. Cards / Article Grid ---------- */
.grid {
  display: grid;
  gap: 1.5rem;
}
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.card-eyebrow {
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .75rem;
}
.card h3 { margin: 0 0 .65rem; font-size: 1.25rem; }
.card p { color: var(--text-muted); font-size: .95rem; margin-bottom: 1rem; }
.card-link {
  margin-top: auto;
  font-weight: 600;
  font-size: .92rem;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.card-link::after { content: "→"; transition: transform var(--transition); }
.card:hover .card-link::after { transform: translateX(4px); }

/* ---------- 8. Section Headers ---------- */
.section-header {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 3rem;
}
.section-header h2 { margin: 0 0 .75rem; }
.section-header p { color: var(--text-muted); font-size: 1.1rem; margin: 0; }

/* ---------- 9. Article Layout ---------- */
.article-header {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: .88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.article-meta span { display: inline-flex; align-items: center; gap: .4rem; }
.article-meta .tag {
  background: var(--secondary-soft);
  color: var(--secondary);
  padding: .2rem .7rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: .8rem;
}
[data-theme="dark"] .article-meta .tag { color: var(--secondary); }
.article-body { font-size: 1.05rem; }
.article-body h2 { padding-top: 1rem; border-top: 1px solid var(--border); margin-top: 3rem; }
.article-body h2:first-of-type { border-top: none; padding-top: 0; }
.article-body p, .article-body ul, .article-body ol { color: var(--text); }
.article-body ul, .article-body ol { padding-left: 1.4rem; }
.article-body li { margin-bottom: .6rem; }
.article-body blockquote {
  border-left: 4px solid var(--accent);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: italic;
  color: var(--text);
}
.article-body strong { color: var(--text); font-weight: 700; }

/* Table of contents */
.toc {
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin: 2rem 0;
  border-left: 4px solid var(--accent);
}
.toc-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: .75rem;
  color: var(--text);
}
.toc ol { margin: 0; padding-left: 1.2rem; }
.toc a { color: var(--text-muted); font-size: .92rem; }
.toc a:hover { color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; border-radius: var(--radius-md); border: 1px solid var(--border); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  background: var(--bg-elevated);
}
th, td {
  padding: .85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-family: var(--font-display);
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-subtle); }

/* Callouts */
.callout {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 1.75rem 0;
}
.callout-title {
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--accent-hover);
}
[data-theme="dark"] .callout-title { color: var(--accent); }
.callout p:last-child { margin-bottom: 0; }

/* FAQ */
.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
}
.faq-item summary {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  list-style: none;
  position: relative;
  padding-right: 2rem;
  color: var(--text);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 0;
  font-size: 1.4rem;
  color: var(--accent);
  transition: transform var(--transition);
}
.faq-item[open] summary::after { content: "−"; }
.faq-item p { margin-top: .75rem; color: var(--text-muted); }

/* Article footer CTA */
.article-cta {
  background: linear-gradient(135deg, var(--secondary-soft), var(--accent-soft));
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  margin: 3rem 0;
  text-align: center;
}
.article-cta h3 { margin-top: 0; }
.article-cta p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* Related articles */
.related { padding-top: 2rem; border-top: 1px solid var(--border); margin-top: 3rem; }
.related h3 { margin-top: 0; margin-bottom: 1.5rem; }

/* ---------- 10. Stats band ---------- */
.stats-band {
  background: var(--secondary);
  color: #fff;
  padding: 3rem 0;
  border-radius: var(--radius-xl);
  margin: 2rem 0;
}
.stats-band .grid-3 { gap: 2rem; }
.stat { text-align: center; }
.stat-num {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  color: #fff;
  margin-bottom: .25rem;
  letter-spacing: -0.03em;
}
.stat-label { color: rgba(255,255,255,.85); font-size: .95rem; }

/* ---------- 11. Footer ---------- */
.site-footer {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 3rem 0 2rem;
  margin-top: 4rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 2rem;
}
.footer-brand p { color: var(--text-muted); font-size: .92rem; margin-top: .75rem; max-width: 320px; }
.footer-col h4 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: .85rem; }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: .5rem; }
.footer-col a { color: var(--text); font-size: .92rem; }
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: .85rem;
  color: var(--text-muted);
}

/* ---------- 12. Newsletter ---------- */
.newsletter {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 3rem;
  text-align: center;
  margin: 3rem 0;
}
.newsletter h2 { margin-top: 0; }
.newsletter p { color: var(--text-muted); margin-bottom: 1.5rem; }
.newsletter-form {
  display: flex;
  gap: .5rem;
  max-width: 440px;
  margin: 0 auto;
  flex-wrap: wrap;
}
.newsletter-form input {
  flex: 1;
  min-width: 220px;
  padding: .8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .95rem;
  transition: border-color var(--transition);
}
.newsletter-form input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- 13. Forms (contact) ---------- */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .4rem;
  color: var(--text);
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .95rem;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 14. Utility ---------- */
.text-center { text-align: center; }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
.lead { font-size: 1.15rem; color: var(--text-muted); }
.divider { height: 1px; background: var(--border); margin: 3rem 0; border: none; }
.muted { color: var(--text-muted); }
.badge {
  display: inline-block;
  padding: .25rem .65rem;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
[data-theme="dark"] .badge { color: var(--accent); }

/* ---------- 15. Responsive ---------- */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  html { font-size: 16px; }
  .nav-links {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateY(-150%);
    transition: transform var(--transition);
    gap: 0;
  }
  .nav-links.open { transform: translateY(0); }
  .nav-links a { padding: .85rem 1rem; border-radius: 0; }
  .nav-toggle { display: flex; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .section { padding: 2.75rem 0; }
  .hero { padding: 3rem 0 2.5rem; }
  .newsletter { padding: 2rem 1.25rem; }
  .article-cta { padding: 1.75rem; }
  .stats-band { padding: 2rem 1rem; }
  .footer-bottom { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 16. Print ---------- */
@media print {
  .site-header, .site-footer, .article-cta, .newsletter, .nav-toggle, .theme-toggle { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; text-decoration: underline; }
}
