/* EveryCalc — shared stylesheet. Light theme, system font stack, mobile-first. */

:root {
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --accent: #15803d;
  --text: #1e293b;
  --muted: #64748b;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand {
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--primary-dark);
  text-decoration: none;
  white-space: nowrap;
}
.brand span { color: var(--accent); }
.main-nav {
  display: flex;
  gap: 0.15rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  white-space: nowrap;
}
.main-nav a:hover { background: #eff6ff; color: var(--primary-dark); }
.main-nav a.active { background: var(--primary); color: #fff; }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.narrow { max-width: 760px; }

.hero { text-align: center; padding: 2.5rem 1rem 1.5rem; }
.hero h1 { font-size: 2rem; margin: 0 0 0.5rem; color: var(--primary-dark); }
.hero p { color: var(--muted); max-width: 640px; margin: 0 auto; font-size: 1.05rem; }

h1 { font-size: 1.75rem; color: var(--primary-dark); margin: 0.5rem 0 0.75rem; line-height: 1.25; }
h2 { font-size: 1.3rem; color: var(--primary-dark); margin: 2rem 0 0.6rem; }
h3 { font-size: 1.1rem; margin: 1.25rem 0 0.4rem; }
p.lead { font-size: 1.05rem; color: var(--muted); }

/* ---------- Calculator card ---------- */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 1.25rem;
}
@media (min-width: 860px) {
  .calc-layout { grid-template-columns: 380px 1fr; align-items: start; }
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }

.field { margin-bottom: 0.9rem; }
.field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.field .hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.field input, .field select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
}
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.4rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.btn:hover { background: var(--primary-dark); }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0 1rem; }
.btn-chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.btn-chip.selected { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Results ---------- */
.result-hero {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  text-align: center;
}
.result-hero .label { font-size: 0.85rem; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.05em; }
.result-hero .value { font-size: 2.1rem; font-weight: 800; margin: 0.25rem 0; }
.result-hero .sub { font-size: 0.9rem; opacity: 0.85; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.result-box {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}
.result-box .label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.result-box .value { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.result-box .value.green { color: var(--accent); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0.75rem 0;
}
table.data th, table.data td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
}
table.data th { background: #f1f5f9; font-weight: 700; text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; }
.table-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.table-scroll table.data { margin: 0; }
.table-scroll thead th { position: sticky; top: 0; z-index: 1; }

/* ---------- Content / SEO sections ---------- */
.prose { margin-top: 2rem; }
.prose p { margin: 0.75rem 0; }
.formula {
  background: #f1f5f9;
  border-left: 4px solid var(--primary);
  padding: 0.9rem 1rem;
  border-radius: 0 8px 8px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  margin: 1rem 0;
  overflow-x: auto;
}
.example {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 1rem 1.15rem;
  margin: 1rem 0;
}
.example strong { color: var(--accent); }

/* ---------- FAQ ---------- */
.faq { margin-top: 2rem; }
.faq-item { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.6rem; background: var(--card); }
.faq-item summary { padding: 0.85rem 1rem; font-weight: 700; cursor: pointer; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; float: right; color: var(--primary); font-weight: 800; }
.faq-item[open] summary::after { content: "–"; }
.faq-item .answer { padding: 0 1rem 1rem; color: var(--text); }

/* ---------- Homepage cards ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}
@media (min-width: 640px) { .tool-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .tool-grid { grid-template-columns: 1fr 1fr 1fr 1fr; } }
.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12); }
.tool-card h3 { margin: 0 0 0.4rem; color: var(--primary-dark); font-size: 1.02rem; }
.tool-card p { margin: 0; font-size: 0.88rem; color: var(--muted); flex: 1; }
.tool-card .cta { margin-top: 0.75rem; font-weight: 700; font-size: 0.88rem; color: var(--primary); }

/* ---------- Ad placeholders (visible note only in source comments) ---------- */
.ad-slot {
  margin: 1.75rem 0;
  min-height: 0;
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--card); margin-top: 3rem; }
.footer-inner { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1rem; display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.footer-inner a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.footer-inner a:hover { color: var(--primary); text-decoration: underline; }
.copyright { width: 100%; font-size: 0.82rem; color: var(--muted); margin-top: 0.5rem; }

/* ---------- Misc ---------- */
canvas.chart { width: 100%; height: 260px; display: block; }
.legend { display: flex; gap: 1.25rem; font-size: 0.85rem; margin: 0.5rem 0; flex-wrap: wrap; }
.legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 0.35rem; vertical-align: baseline; }
.note { font-size: 0.85rem; color: var(--muted); }
.alert { background: #fef3c7; border: 1px solid #fcd34d; border-radius: 8px; padding: 0.85rem 1rem; margin: 1rem 0; font-size: 0.92rem; }
.breadcrumb { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
