/* ===========================================================
   Tooloq — shared stylesheet
   Clean, trustworthy finance-tool aesthetic.
=========================================================== */

:root {
  --primary: #1450A3;
  --primary-dark: #0B3A7A;
  --primary-light: #E8F0FD;
  --accent: #16A34A;
  --accent-dark: #0F7A37;
  --danger: #DC2626;
  --danger-light: #FDECEC;
  --bg: #F6F8FB;
  --surface: #FFFFFF;
  --text: #16202E;
  --text-muted: #5B6B82;
  --border: #E2E8F0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 30, 54, 0.06), 0 4px 16px rgba(16, 30, 54, 0.06);
  --max-width: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

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

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

h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; color: var(--text); }
h1 { font-size: clamp(1.7rem, 1.3rem + 1.5vw, 2.4rem); margin: 0 0 12px; }
h2 { font-size: 1.5rem; margin: 40px 0 14px; }
h3 { font-size: 1.15rem; margin: 24px 0 8px; }
p { margin: 0 0 14px; color: var(--text); }
.text-muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }

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

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--primary); color: #fff;
  padding: 10px 16px; z-index: 1000; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: block;
}
.brand-word { letter-spacing: -0.01em; }
.site-footer .brand-word { color: #fff; }

.main-nav { display: flex; align-items: center; gap: 4px; }
.main-nav ul, .main-nav li { list-style: none; margin: 0; padding: 0; }
.main-nav > ul { display: flex; align-items: center; gap: 2px; }
.main-nav a.nav-link {
  display: inline-block;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
}
.main-nav a.nav-link:hover, .main-nav a.nav-link.active { background: var(--primary-light); color: var(--primary); text-decoration: none; }

.nav-dropdown { position: relative; }
.nav-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  width: 620px;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.nav-dropdown:hover .nav-dropdown-panel,
.nav-dropdown:focus-within .nav-dropdown-panel { display: grid; }
.nav-dropdown-panel a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}
.nav-dropdown-panel a:hover { background: var(--primary-light); text-decoration: none; }
.nav-dropdown-panel .cal-icon { font-size: 1.05rem; }

.nav-toggle {
  display: none;
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  width: 42px; height: 42px; cursor: pointer;
  align-items: center; justify-content: center;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: ""; display: block; width: 20px; height: 2px; background: var(--text); position: relative;
  transition: 0.2s;
}
.nav-toggle span::before { position: absolute; top: -6px; }
.nav-toggle span::after { position: absolute; top: 6px; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(180deg, var(--primary-light), var(--bg));
  border-bottom: 1px solid var(--border);
  padding: 56px 0 44px;
}
.hero h1 { max-width: 780px; }
.hero p.lead { font-size: 1.1rem; color: var(--text-muted); max-width: 640px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.hero-badge {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px; font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
}

/* ---------- Calculator page hero (smaller) ---------- */
.calc-hero { padding: 36px 0 8px; }
.calc-hero .eyebrow { color: var(--primary); font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
.breadcrumbs { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.breadcrumbs a { color: var(--text-muted); }

/* ---------- Layout: calculator + content ---------- */
.page-body { padding: 28px 0 60px; }
.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 900px) {
  .calc-layout { grid-template-columns: 1fr; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card + .card { margin-top: 20px; }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
}
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-2 { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 0.88rem; color: var(--text); }
.field .hint { font-size: 0.78rem; color: var(--text-muted); }
.input-affix {
  display: flex; align-items: stretch; border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; background: #fff;
}
.input-affix:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.input-affix span {
  display: flex; align-items: center; padding: 0 12px; background: #F1F5F9; color: var(--text-muted);
  font-weight: 700; font-size: 0.9rem; border-right: 1px solid var(--border);
}
.input-affix span.suffix { border-right: none; border-left: 1px solid var(--border); }
.input-affix input, .input-affix select {
  border: none; outline: none; padding: 11px 12px; font-size: 0.95rem; width: 100%;
  font-family: var(--font); color: var(--text); background: transparent;
}
select {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px;
  font-size: 0.95rem; font-family: var(--font); background: #fff; color: var(--text); width: 100%;
}
input[type="range"] { width: 100%; accent-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 12px 20px; font-weight: 700; font-size: 0.95rem; cursor: pointer;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--primary); border: 1px solid var(--primary); }
.btn.secondary:hover { background: var(--primary-light); }
.btn.small { padding: 8px 14px; font-size: 0.85rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Results ---------- */
.result-panel {
  background: linear-gradient(180deg, #F5FAF7, #ffffff);
  border: 1px solid #CFE9DA;
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
}
.result-hero {
  display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px;
}
.result-hero .label { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.result-hero .value { font-size: 2.1rem; font-weight: 800; color: var(--accent-dark); }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px;
}
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.stat-tile .label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.stat-tile .value { font-size: 1.15rem; font-weight: 800; color: var(--text); }
.stat-tile .value.pos { color: var(--accent-dark); }
.stat-tile .value.neg { color: var(--danger); }

.alert {
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.88rem; margin: 14px 0;
  border: 1px solid var(--border); background: #F8FAFC;
}
.alert.warning { background: var(--danger-light); border-color: #F3C6C6; color: #8A1F1F; }
.alert.info { background: var(--primary-light); border-color: #C9DCF7; color: var(--primary-dark); }

/* ---------- Tables (amortization etc.) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 560px; }
table.data-table th, table.data-table td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data-table th:first-child, table.data-table td:first-child { text-align: left; }
table.data-table thead th { background: #F1F5F9; color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; position: sticky; top: 0; }
table.data-table tbody tr:hover { background: #FAFBFD; }
table.data-table tr.year-row td { background: #F8FAFC; font-weight: 700; }

/* ---------- Debt rows (dynamic) ---------- */
.debt-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 10px; }
@media (max-width: 700px) { .debt-row { grid-template-columns: 1fr 1fr; } }
.debt-row .field label { font-size: 0.78rem; }
.remove-row { background: none; border: 1px solid var(--border); color: var(--danger); border-radius: var(--radius-sm); width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem; }

/* ---------- Ad slots ---------- */
.ad-slot {
  border: 1px dashed #C6D3E3; border-radius: var(--radius-sm); background: #FBFCFE;
  color: var(--text-muted); font-size: 0.78rem; text-align: center; padding: 18px;
  min-height: 90px; display: flex; align-items: center; justify-content: center;
  margin: 20px 0; letter-spacing: 0.03em; text-transform: uppercase; font-weight: 700;
}
.sidebar .ad-slot { min-height: 250px; }

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 20px; }
.related-list a {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.92rem; color: var(--text);
}
.related-list a:last-child { border-bottom: none; }
.related-list a:hover { color: var(--primary); text-decoration: none; }

/* ---------- Content sections ---------- */
.content-section { max-width: 760px; }
.content-section h2:first-child { margin-top: 0; }

/* FAQ */
details.faq { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--surface); }
details.faq summary { padding: 14px 16px; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; font-size: 1.3rem; color: var(--primary); font-weight: 400; }
details.faq[open] summary::after { content: "\2212"; }
details.faq .faq-body { padding: 0 16px 16px; color: var(--text-muted); }

/* ---------- Calculator grid (homepage) ---------- */
/* Flex + justify-content:center (rather than CSS grid) so an incomplete last
   row of cards is centered instead of stretching or stranding a lone card. */
.calc-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; margin: 24px 0 40px; }
.calc-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
  flex: 1 1 260px; max-width: 320px;
}
.calc-card:hover { border-color: var(--primary); text-decoration: none; }
.calc-card .cal-icon-badge {
  width: 42px; height: 42px; border-radius: 10px; background: var(--primary-light);
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem; margin-bottom: 4px;
}
.calc-card h3 { margin: 0; font-size: 1.05rem; }
.calc-card p { margin: 0; font-size: 0.88rem; color: var(--text-muted); }
.category-label { display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary); background: var(--primary-light); padding: 3px 9px; border-radius: 999px; margin-bottom: 8px; width: fit-content; }

/* ---------- Trust strip ---------- */
.trust-strip { display: flex; flex-wrap: wrap; gap: 28px; justify-content: center; padding: 26px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); }
.trust-item { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-weight: 600; font-size: 0.9rem; }

/* ---------- Footer ---------- */
.site-footer { background: #0F2038; color: #C7D3E3; padding: 44px 0 24px; margin-top: 60px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 24px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.site-footer h4 { color: #fff; font-size: 0.9rem; margin: 0 0 12px; }
.site-footer a { color: #C7D3E3; }
.site-footer a:hover { color: #fff; }
.site-footer .brand { color: #fff; margin-bottom: 10px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.88rem; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.12); margin-top: 30px; padding-top: 18px; font-size: 0.8rem; color: #8FA1BC; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.disclaimer-note { font-size: 0.8rem; color: #8FA1BC; max-width: 640px; margin-top: 10px; }

/* ---------- Legal / static pages ---------- */
.static-page .content-section { max-width: 820px; margin: 0 auto; }

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

/* ---------- Mobile nav ---------- */
@media (max-width: 900px) {
  .nav-toggle { display: flex; }
  .main-nav {
    position: fixed; top: 68px; left: 0; right: 0; bottom: 0;
    background: var(--surface); flex-direction: column; align-items: stretch;
    padding: 16px 20px; display: none; overflow-y: auto;
  }
  .main-nav.open { display: flex; }
  .main-nav > ul { flex-direction: column; align-items: stretch; width: 100%; }
  .nav-dropdown-panel { display: grid !important; position: static; width: 100%; box-shadow: none; border: none; padding: 4px 0 4px 12px; grid-template-columns: 1fr; }
  .nav-dropdown-panel.collapsed { display: none !important; }
}
