/* ==========================================================================
   HomeCalcKit — shared stylesheet (single source of truth for all pages)
   Design tokens → base → layout → components → page sections → responsive
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #212b36;
  --muted: #5c6b7a;
  --border: #dfe5eb;
  --primary: #1b4f72;        /* deep navy — trust, professionalism */
  --primary-strong: #143c56;
  --primary-tint: #eaf1f7;
  --accent: #e8890c;         /* amber — construction, action */
  --accent-strong: #c97508;
  --accent-tint: #fdf3e3;
  --success: #1e7b4f;
  --danger: #b3261e;
  --danger-tint: #fdecea;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(20, 60, 86, 0.08), 0 4px 14px rgba(20, 60, 86, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  line-height: 1.25;
  color: var(--primary-strong);
  margin: 0 0 0.6em;
}

h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); }
h2 { font-size: 1.45rem; margin-top: 2.4rem; }
h3 { font-size: 1.12rem; margin-top: 1.6rem; }

p { margin: 0 0 1em; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header / nav (injected by js/common.js) ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-strong);
}
.brand:hover { text-decoration: none; }
.brand svg { flex: 0 0 auto; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  display: block;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
}
.nav-links a:hover { background: var(--primary-tint); color: var(--primary-strong); text-decoration: none; }

@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    padding-bottom: 8px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 8px; border-bottom: 1px solid var(--border); border-radius: 0; }
}

/* ---------- Buttons ---------- */
.btn-calc {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  padding: 12px 32px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-calc:hover { background: var(--accent-strong); }

.btn-reset {
  display: inline-block;
  background: none;
  color: var(--muted);
  font-size: 0.95rem;
  font-family: inherit;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface);
}
.btn-reset:hover { border-color: var(--muted); color: var(--text); }

/* ---------- Article typography ---------- */
article .intro {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 72ch;
}

.note {
  background: var(--primary-tint);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.95rem;
}

.warning {
  background: var(--accent-tint);
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.95rem;
}

/* ---------- Calculator panel ---------- */
.calc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin: 28px 0;
}

.calc h2 {
  margin-top: 0;
  font-size: 1.3rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--primary-strong);
}

.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.field .hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

.calc-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.calc-results {
  background: var(--primary-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
}

.calc-results .result-headline {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-strong);
  margin: 0 0 8px;
}

.calc-results ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.calc-results li {
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.calc-results li:last-child { border-bottom: none; }

.calc-results li span:last-child { font-weight: 600; white-space: nowrap; }

.calc-results .result-note {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.calc-error {
  background: var(--danger-tint);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-weight: 600;
}

/* ---------- AdSense slots (empty until owner pastes code after approval) ---------- */
.ad-slot { margin: 28px 0; text-align: center; min-height: 90px; }
.ad-slot:empty { display: none; }

/* ---------- FAQ ---------- */
.faq-item { margin-bottom: 1.4rem; }
.faq-item h3 { margin-bottom: 0.4rem; }

/* ---------- Related tools ---------- */
.related-tools {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  margin-top: 2.4rem;
}
.related-tools h2 { margin-top: 0; }
.related-tools ul { margin: 0; padding-left: 1.2em; }
.related-tools li { margin-bottom: 8px; }

/* ---------- Homepage ---------- */
.hero {
  background: linear-gradient(135deg, var(--primary-strong) 0%, var(--primary) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 44px 36px;
  margin: 32px 0 8px;
}
.hero h1 { color: #fff; margin-bottom: 0.35em; }
.hero p { color: #dbe7f0; font-size: 1.1rem; max-width: 60ch; margin-bottom: 0; }

.category {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  margin: 26px 0;
}
.category h2 {
  margin-top: 0;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.tool-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.tool-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  background: var(--bg);
}
.tool-card a { font-weight: 600; font-size: 1.02rem; }
.tool-card p { margin: 6px 0 0; font-size: 0.92rem; color: var(--muted); }

/* ---------- Footer (injected by js/common.js) ---------- */
.site-footer {
  background: var(--primary-strong);
  color: #c8d6e2;
  margin-top: 56px;
  padding: 40px 0 28px;
  font-size: 0.95rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
}

.site-footer h3 {
  color: #fff;
  font-size: 1rem;
  margin-bottom: 12px;
}

.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 8px; }
.site-footer a { color: #c8d6e2; }
.site-footer a:hover { color: #fff; }

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin-top: 28px;
  padding-top: 18px;
  font-size: 0.85rem;
  color: #9db2c2;
}

@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr; gap: 20px; }
  .calc { padding: 20px; }
  .hero { padding: 32px 22px; }
}

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
