/* Site improvement utilities (2026-10-28) */

/* Mobile-friendly tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 1rem; }
.table-scroll .rates-table { min-width: 560px; }

/* Centered section call-to-action */
.section-cta { text-align: center; margin-top: 1.5rem; }

/* Button inside a card */
.card-cta { margin-top: 1rem; }

/* Policy / trust cards */
.policy-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.policy-card { text-align: center; }
.policy-card img { max-width: 120px; max-height: 120px; margin-bottom: 1rem; }
.policy-card h3 { color: var(--primary); margin-bottom: 0.5rem; }
.policy-card p { color: var(--text-muted); font-size: 0.9rem; }

/* Container width variants */
.form-container-wide { max-width: 900px; }
.form-container-narrow { max-width: 600px; }
.form-container-nested { padding: 0; box-shadow: none; margin-bottom: 0.5rem; }

/* Alignment utilities */
.form-actions-start { justify-content: flex-start; }
.mt-05 { margin-top: 0.5rem; }
.mt-1 { margin-top: 1rem; }
.ml-05 { margin-left: 0.5rem; }
.mb-05 { margin-bottom: 0.5rem; }
.mb-075 { margin-bottom: 0.75rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-15 { margin-bottom: 1.5rem; }

/* Button variants */
.btn-outline-primary { border: 2px solid var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: rgba(15, 42, 74, 0.06); }
.btn-muted { color: var(--text); border-color: var(--border); }

/* Headings */
.form-title { color: var(--primary); margin-bottom: 1rem; }
.map-title { color: var(--primary); margin-bottom: 0.75rem; }
.how-title { color: var(--primary); margin: 1.5rem 0 0.75rem; }

/* Success / error boxes */
.success-cta { margin-top: 1.5rem; }
.error-box { background: #fff5f5; border-color: #fc8181; }
.error-title { color: #c53030; }

/* App page */
.app-logo-wrap { text-align: center; margin-bottom: 2rem; }
.app-logo { max-width: 150px; max-height: 150px; }

/* Calculators */
.amount-row-gap { margin-top: 0.5rem; }
.calc-details { margin-top: 1rem; }
.calc-summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.calc-note { color: var(--text-muted); font-size: 0.9rem; }

/* Search page */
.search-intro { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
.search-sub { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.5rem; }
.stack-grid { grid-template-columns: 1fr; gap: 1rem; }
.card-tight { padding: 1.25rem; }

/* ------------------------------------------------------------------ */
/* Standard-grade design system layer (2026-10-28)                     */
/* Additive only: refines existing components without changing markup. */
/* ------------------------------------------------------------------ */

:root {
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(15, 42, 74, 0.08);
  --shadow-md: 0 4px 14px rgba(15, 42, 74, 0.10);
  --focus-ring: 0 0 0 3px rgba(15, 42, 74, 0.35);
  --touch-min: 44px;
}

/* Typography rhythm */
h1, h2, h3, h4 { line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: clamp(1.1rem, 2.2vw, 1.3rem); }
p { line-height: 1.65; }

/* Accessible focus everywhere */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.skip-link:focus-visible { box-shadow: var(--focus-ring); }

/* Buttons: consistent size, radius, and touch target */
.btn {
  min-height: var(--touch-min);
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Cards: unified surface */
.card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card h3 { color: var(--primary); }

/* Tables: readable financial data */
.rates-table,
.amort-table {
  border-collapse: collapse;
  width: 100%;
}
.rates-table th,
.rates-table td,
.amort-table th,
.amort-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.rates-table thead th,
.amort-table thead th {
  background: rgba(15, 42, 74, 0.04);
  font-weight: 600;
  color: var(--primary);
}
.rates-table tbody tr:hover,
.amort-table tbody tr:hover {
  background: rgba(15, 42, 74, 0.03);
}

/* Forms: clear states */
.form-group label { font-weight: 600; }
input,
select,
textarea {
  border-radius: var(--radius-sm);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
}
input:user-invalid,
select:user-invalid,
textarea:user-invalid {
  border-color: #c53030;
}

/* Loading / empty feedback */
.is-loading { opacity: 0.6; pointer-events: none; }
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-5) var(--space-4);
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Small screens: keep tables and grids usable */
@media (max-width: 640px) {
  .card-grid { gap: var(--space-4); }
  .form-actions { flex-wrap: wrap; }
  .btn { width: auto; }
}

/* Contrast fix (2026-10-28): the previous muted gray (#64748b) was 4.43:1
   on the page background (#f5f7fa), just below the WCAG AA 4.5:1 threshold.
   #5b6b7e passes on both the page background (5.08:1) and white cards (5.46:1). */
:root {
  --text-muted: #5b6b7e;
}
