/* ==========================================================================
   style.css — Mortgage Calculator (responsive, accessible, WCAG 2.1 AA)
   Palette: #1a365d (navy) · #2b6cb0 (blue) · #4299e1 (light blue)
   Layout: mobile-first
   ========================================================================== */

/* ---------- 1. Reset & tokens ---------- */
:root {
  --navy: #1a365d;
  --navy-dark: #14294a;
  --blue: #2b6cb0;
  --blue-light: #4299e1;
  --sky: #63b3ed;
  --bg: #f7fafc;
  --surface: #ffffff;
  --text: #2d3748;
  --text-muted: #5a6b7e;
  --border: #e2e8f0;
  --green: #2f855a;
  --focus: #3182ce;
  --shadow: 0 2px 12px rgba(26, 54, 93, 0.08);
  --radius: 12px;
  --max-width: 1180px;
}

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

html { scroll-behavior: smooth; }

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

/* ---------- 2. Accessibility ---------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  background: var(--navy);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
}
.skip-link:focus { left: 8px; }

/* ---------- 3. Header ---------- */
.site-header {
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand .logo-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue-light), var(--blue));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.main-nav ul {
  list-style: none;
  display: flex;
  gap: 18px;
  margin: 0; padding: 0;
}
.main-nav a {
  color: #dbe9f7;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 6px 2px;
}
.main-nav a:hover { color: #fff; }
.main-nav a.active { color: #fff; border-bottom: 2px solid var(--blue-light); }

/* Language selector */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #dbe9f7;
  font-size: 0.9rem;
}
.lang-switch select {
  background: var(--navy-dark);
  color: #fff;
  border: 1px solid #3b5b8c;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ---------- 4. Ad containers ---------- */
.ad-container {
  margin: 20px auto;
  text-align: center;
  min-height: 90px;
  background: #eef3f8;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.ad-container--tall { min-height: 250px; }
.ad-container--hidden-label { font-size: 0; }
.ad-container--hidden-label::before {
  content: "";
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- 5. Main layout ---------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.page-title {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  color: var(--navy);
  margin: 0 0 8px;
  line-height: 1.25;
}
.page-intro {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 0 28px;
}

/* ---------- 6. Calculator grid ---------- */
.calculator-wrapper {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 900px) {
  .calculator-wrapper {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: start;
  }
}

/* ---------- 7. Form (inputs) ---------- */
.input-section,
.results-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--blue);
  height: 26px;
  cursor: pointer;
}

.input-row input[type="number"] {
  width: 130px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
}
.input-row input[type="number"]:focus {
  border-color: var(--blue);
}

.helper {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.helper strong { color: var(--navy); }

select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.btn {
  padding: 12px 22px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--blue);
  color: #fff;
  flex: 1;
}
.btn-primary:hover { background: var(--navy); }
.btn-secondary {
  background: #edf2f7;
  color: var(--navy);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e2e8f0; }

/* ---------- 8. Results ---------- */
.results-section h2 {
  font-size: 1.25rem;
  color: var(--navy);
  margin: 0 0 16px;
}

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

.result-card {
  background: #f0f6fc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.result-card--main {
  grid-column: 1 / -1;
  background: var(--navy);
  border-color: var(--navy);
}
.result-card--main .result-label { color: #bcd6f0; }
.result-card--main .result-value { color: #fff; font-size: 1.7rem; }

.result-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.result-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
}
.result-value small {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.breakdown {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: #cfe0f2;
}
.breakdown span { white-space: nowrap; }
.breakdown .tax { color: #a8d3ff; }
.breakdown .ins { color: #a8d3ff; }

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin: 20px 0;
}
@media (min-width: 700px) {
  .chart-grid { grid-template-columns: 1fr 1fr; }
}
.chart-box { position: relative; }
.chart-box h3 {
  font-size: 0.95rem;
  color: var(--navy);
  margin: 0 0 8px;
  text-align: center;
}
.chart-canvas {
  position: relative;
  width: 100%;
  height: 240px;
}

/* Amortization table */
.schedule h2 {
  font-size: 1.25rem;
  color: var(--navy);
  margin: 0 0 6px;
}
.schedule-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.table-scroll {
  overflow: auto;
  max-height: 360px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
table.amortization {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 520px;
}
table.amortization thead th {
  position: sticky;
  top: 0;
  background: var(--navy);
  color: #fff;
  text-align: right;
  padding: 10px 12px;
  font-size: 0.85rem;
}
table.amortization thead th:first-child { text-align: left; }
table.amortization tbody td {
  padding: 8px 12px;
  text-align: right;
  border-top: 1px solid #edf2f7;
}
table.amortization tbody td:first-child { text-align: left; color: var(--text-muted); }
table.amortization tbody tr:nth-child(even) { background: #f7fafc; }

.schedule-footer { margin: 10px 0; }

/* Affiliate CTA box */
.cta-box {
  margin-top: 20px;
  background: #eef6ff;
  border: 1px solid #bcd8f5;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.cta-box h3 {
  margin: 0 0 4px;
  color: var(--navy);
  font-size: 1rem;
}
.cta-box p { margin: 0 0 12px; font-size: 0.9rem; color: var(--text-muted); }

/* Amortization formula */
.formula {
  margin: 12px 0;
  padding: 12px 16px;
  background: #f7fafc;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  overflow-x: auto;
}

/* Related guides */
.related-guides {
  margin-top: 24px;
  padding: 16px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}
.related-guides h3 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 1rem;
}
.related-guides ul {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}
.related-guides li { margin: 0 0 6px; }
.related-guides li::before { content: '→ '; color: var(--blue); }
.related-guides li a { color: var(--blue); text-decoration: none; }
.related-guides li a:hover { text-decoration: underline; }
.related-guides .btn { display: inline-block; }
.cta-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.cta-links .btn { flex: 1 1 200px; }
.btn-affiliate {
  background: var(--green);
  color: #fff;
}
.btn-affiliate:hover { background: #276749; }
.btn-outline {
  background: #fff;
  color: var(--blue);
  border: 2px solid var(--blue);
}
.btn-outline:hover { background: #eef6ff; }

/* Share row */
.share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 0;
}
.share-row span { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.share-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  text-decoration: none;
}
.share-btn:hover { background: #f0f6fc; }

/* ---------- 9. SEO content sections ---------- */
.seo-section {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.seo-section h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.6rem);
  color: var(--navy);
  margin: 0 0 12px;
  line-height: 1.35;
}
.seo-section h3 {
  font-size: 1.1rem;
  color: var(--blue);
  margin: 20px 0 8px;
}
.seo-section p {
  margin: 0 0 14px;
  color: var(--text);
}
.seo-section ul { padding-left: 22px; }

/* FAQ */
.faq-list { margin-top: 16px; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  background: var(--surface);
}
.faq-item summary {
  padding: 14px 16px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  list-style-position: inside;
  background: #f7fafc;
}
.faq-item summary:hover { background: #eef3f8; }
.faq-item summary::-webkit-details-marker { color: var(--blue); }
.faq-item p { padding: 0 16px 14px; margin: 0; }

/* ---------- 10. Footer ---------- */
.site-footer {
  background: var(--navy-dark);
  color: #bcd6f0;
  padding: 28px 20px 40px;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  text-align: center;
}
.footer-nav {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-nav a {
  color: #dbe9f7;
  text-decoration: none;
  font-size: 0.9rem;
}
.footer-nav a:hover { color: #fff; text-decoration: underline; }
.footer-disclaimer {
  font-size: 0.8rem;
  color: #8ba9c9;
  max-width: 720px;
  margin: 0;
}
.footer-copy { font-size: 0.85rem; margin: 0; }

.footer-copy { font-size: 0.85rem; margin: 0; }

/* ---------- 11b. Content pages (blog / about / contact / 404) ---------- */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.blog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.blog-card time {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.blog-card h2 {
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--navy);
  margin: 0 0 10px;
}
.blog-card p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.feature-list li {
  position: relative;
  padding: 8px 0 8px 28px;
  color: var(--text);
}
.feature-list li::before {
  content: "✓";
  position: absolute;
  left: 4px;
  color: var(--green);
  font-weight: 700;
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.notice {
  display: none;
  margin-top: 16px;
  padding: 12px 16px;
  background: #f0fff4;
  border: 1px solid #9ae6b4;
  border-radius: 10px;
  color: #22543d;
}
.notice--visible { display: block; }
.notice--error {
  background: #fff5f5;
  border-color: #fc8181;
  color: #742a2a;
}

/* ---------- Contact form (FormSubmit) ---------- */
.contact-section {
  max-width: 700px;
  margin: 0 auto;
}

.contact-form {
  background: #f7fafc;
  padding: 30px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.contact-form .form-group { margin-bottom: 20px; }

.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  font-family: inherit;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: #2b6cb0;
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.btn-submit {
  display: block;
  width: 100%;
  padding: 14px 30px;
  background: #2b6cb0;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.btn-submit:hover { background: #1a365d; }
.btn-submit:disabled { opacity: 0.6; cursor: wait; }

.contact-info {
  text-align: center;
  margin-top: 30px;
  background: #edf2f7;
  padding: 20px;
  border-radius: 8px;
  color: var(--text);
}
.contact-info a { color: var(--navy); }

@media (max-width: 480px) {
  .contact-form { padding: 20px; }
}

@media (min-width: 760px) {
  .contact-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- 12. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
