/* ============================================================
   mortgage-refinance-calculator.css
   Tool-specific styles for the Mortgage Refinance Break-Even
   Calculator. Uses cluster CSS variables for theme awareness.
   ============================================================ */

/* ---------- Helpers & helper notes ---------- */
.evvy-refi-helper {
  font-size: 0.75rem;
  color: var(--evvy-text-secondary, #666);
  margin-top: 0.375rem;
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
}
.evvy-refi-helper i {
  color: var(--cluster-dark);
  margin-top: 0.125rem;
}

/* Two-column input grid (current loan + rate pairs) */
.evvy-refi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.evvy-refi-grid .form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.evvy-refi-grid .form-text {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* ---------- Rate row with "use current rate" button ---------- */
.evvy-refi-rate-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.625rem;
}
.evvy-use-rate-btn {
  background: var(--cluster-surface);
  color: var(--cluster-dark);
  border: 1px solid color-mix(in srgb, var(--cluster-dark) 25%, transparent);
  font-weight: 600;
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  transition: background 0.2s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.evvy-use-rate-btn:hover {
  background: color-mix(in srgb, var(--cluster-dark) 14%, var(--cluster-surface));
  transform: translateY(-1px);
}
[data-bs-theme="dark"] .evvy-use-rate-btn {
  background: color-mix(in srgb, var(--cluster-dark) 22%, transparent);
  color: #fff;
}

/* ---------- Live-rate badge (FRED / Freddie Mac) ---------- */
.evvy-rate-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  margin-right: 0.5rem;
  padding: 0.45rem 0.85rem;
  background: var(--cluster-surface);
  border: 1px solid color-mix(in srgb, var(--cluster-dark) 20%, transparent);
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--evvy-text-primary, #222);
}
.evvy-rate-badge i {
  color: var(--cluster-dark);
  font-size: 0.95rem;
}
.evvy-rate-badge strong {
  color: var(--cluster-dark);
  font-weight: 700;
}
.evvy-rate-badge-sub {
  color: var(--evvy-text-secondary, #666);
  font-weight: 500;
}
.evvy-rate-badge-alt {
  background: color-mix(in srgb, var(--cluster-dark) 6%, var(--bs-body-bg, #fff));
}
[data-bs-theme="dark"] .evvy-rate-badge {
  background: color-mix(in srgb, var(--cluster-dark) 18%, #1a1a2e);
  color: #fff;
}
[data-bs-theme="dark"] .evvy-rate-badge-sub {
  color: rgba(255,255,255,0.7);
}

/* ---------- Verdict badge (hero feature) ---------- */
.evvy-verdict-wrap {
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}
.evvy-verdict {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem 1.25rem;
  border-radius: var(--evvy-radius-lg, 14px);
  border: 1px solid var(--evvy-border-color, #DEE2E6);
  background: var(--bs-body-bg, #fff);
  transition: background 0.35s ease, border-color 0.35s ease, transform 0.35s ease;
  position: relative;
  overflow: hidden;
}
.evvy-verdict::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: linear-gradient(135deg,
    color-mix(in srgb, currentColor 10%, transparent),
    transparent 60%);
}
.evvy-verdict-neutral {
  background: var(--cluster-surface);
  border-color: color-mix(in srgb, var(--cluster-dark) 15%, transparent);
}
.evvy-verdict-green {
  background: color-mix(in srgb, #1f7a3c 10%, var(--bs-body-bg, #fff));
  border-color: color-mix(in srgb, #1f7a3c 40%, transparent);
  color: #14532d;
  animation: evvyVerdictIn 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.evvy-verdict-green::after { opacity: 1; }
.evvy-verdict-red {
  background: color-mix(in srgb, #b91c1c 8%, var(--bs-body-bg, #fff));
  border-color: color-mix(in srgb, #b91c1c 38%, transparent);
  color: #7f1d1d;
  animation: evvyVerdictIn 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.evvy-verdict-red::after { opacity: 1; }
@keyframes evvyVerdictIn {
  0%   { transform: scale(0.98); opacity: 0.3; }
  60%  { transform: scale(1.015); }
  100% { transform: scale(1); opacity: 1; }
}
.evvy-verdict-icon {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.evvy-verdict-green .evvy-verdict-icon {
  color: #1f7a3c;
  animation: evvyPulseIcon 1.8s ease-in-out infinite;
}
.evvy-verdict-red .evvy-verdict-icon {
  color: #b91c1c;
}
.evvy-verdict-neutral .evvy-verdict-icon {
  color: var(--cluster-dark);
}
@keyframes evvyPulseIcon {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 40%, transparent); }
  50%      { transform: scale(1.06); box-shadow: 0 0 0 10px color-mix(in srgb, currentColor 0%, transparent); }
}
.evvy-verdict-body {
  flex: 1;
  min-width: 0;
}
.evvy-verdict-title {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 0.125rem;
  line-height: 1.3;
}
.evvy-verdict-sub {
  font-size: 0.875rem;
  opacity: 0.85;
  line-height: 1.45;
}
[data-bs-theme="dark"] .evvy-verdict {
  background: var(--evvy-gray-100, #1E1E1E);
}
[data-bs-theme="dark"] .evvy-verdict-green {
  background: color-mix(in srgb, #34d399 14%, #121d18);
  color: #a7f3d0;
  border-color: color-mix(in srgb, #34d399 45%, transparent);
}
[data-bs-theme="dark"] .evvy-verdict-green .evvy-verdict-icon { color: #34d399; }
[data-bs-theme="dark"] .evvy-verdict-red {
  background: color-mix(in srgb, #f87171 14%, #1d1414);
  color: #fecaca;
  border-color: color-mix(in srgb, #f87171 45%, transparent);
}
[data-bs-theme="dark"] .evvy-verdict-red .evvy-verdict-icon { color: #f87171; }

/* ---------- Timeline bar ---------- */
.evvy-timeline {
  margin-top: 1rem;
  padding: 1rem 1.125rem 0.75rem;
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--evvy-border-color, #DEE2E6);
  border-radius: var(--evvy-radius-lg, 12px);
  display: none;
}
.evvy-timeline-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--evvy-text-secondary, #666);
  margin-bottom: 0.625rem;
}
.evvy-timeline-track {
  position: relative;
  height: 14px;
  background: color-mix(in srgb, var(--cluster-dark) 8%, transparent);
  border-radius: 999px;
  overflow: visible;
}
.evvy-timeline-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              background 0.3s ease;
  background: var(--cluster-dark);
}
.evvy-timeline-fill-green {
  background: linear-gradient(90deg, #16a34a, #22c55e);
  box-shadow: 0 0 10px color-mix(in srgb, #22c55e 45%, transparent);
}
.evvy-timeline-fill-red {
  background: linear-gradient(90deg, #b91c1c, #dc2626);
  box-shadow: 0 0 10px color-mix(in srgb, #dc2626 35%, transparent);
}
.evvy-timeline-marker {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bs-body-bg, #fff);
  border: 3px solid var(--cluster-dark);
  transition: left 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 2;
}
.evvy-timeline-marker-label {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--cluster-dark);
  white-space: nowrap;
  background: var(--cluster-surface);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.evvy-timeline-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 1.75rem;
  font-size: 0.6875rem;
  color: var(--evvy-text-secondary, #666);
}
[data-bs-theme="dark"] .evvy-timeline {
  background: var(--evvy-gray-100, #1E1E1E);
}
[data-bs-theme="dark"] .evvy-timeline-marker {
  background: #1E1E1E;
}

/* ---------- Closing cost breakdown ---------- */
.evvy-cc-breakdown {
  margin-top: 1rem;
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--evvy-border-color, #DEE2E6);
  border-radius: var(--evvy-radius-lg, 12px);
  padding: 1.125rem 1.375rem;
  font-size: 0.875rem;
  display: none;
}
.evvy-cc-breakdown-header {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--evvy-text-secondary, #666);
  margin-bottom: 0.75rem;
}
.evvy-bd-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.35rem 0;
}
.evvy-bd-row span:first-child {
  color: var(--evvy-text-secondary, #666);
}
.evvy-bd-row span:last-child {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.evvy-bd-row small {
  opacity: 0.65;
  font-weight: 400;
}
.evvy-bd-divider {
  border-top: 1px dashed var(--evvy-border-color, #DEE2E6);
  margin: 0.25rem 0;
}
.evvy-bd-total span:first-child {
  font-weight: 600;
  color: var(--evvy-text-primary, #333);
}
.evvy-bd-total span:last-child {
  font-weight: 700;
  color: var(--cluster-dark);
}
[data-bs-theme="dark"] .evvy-cc-breakdown {
  background: var(--evvy-gray-100, #1E1E1E);
}

/* ---------- Premium section cards ---------- */
.evvy-premium-section {
  background: color-mix(in srgb, var(--cluster-dark) 4%, var(--bs-body-bg, #fff));
  border: 1px solid color-mix(in srgb, var(--cluster-dark) 18%, transparent);
  border-radius: var(--evvy-radius-lg, 14px);
  padding: 1.125rem 1.25rem;
  margin-top: 1.25rem;
  margin-bottom: 0;
}
[data-bs-theme="dark"] .evvy-premium-section {
  background: color-mix(in srgb, var(--cluster-dark) 22%, #1a1a2e);
}

.evvy-premium-teaser {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  margin-top: 1.25rem;
  background: color-mix(in srgb, var(--evvy-subscriber-color, #d4a017) 12%, var(--bs-body-bg, #fff));
  border: 1px dashed color-mix(in srgb, var(--evvy-subscriber-color, #d4a017) 55%, transparent);
  border-radius: var(--evvy-radius-lg, 12px);
  font-size: 0.8125rem;
  color: var(--evvy-text-primary, #333);
  line-height: 1.45;
}
.evvy-premium-teaser i {
  color: var(--evvy-subscriber-color, #d4a017);
  font-size: 1rem;
  flex-shrink: 0;
}
[data-bs-theme="dark"] .evvy-premium-teaser {
  background: color-mix(in srgb, var(--evvy-subscriber-color, #d4a017) 20%, #1a1a2e);
  color: #fff;
}

/* ---------- No-CC compare cards ---------- */
.evvy-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.evvy-compare-card {
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--evvy-border-color, #DEE2E6);
  border-radius: var(--evvy-radius-lg, 12px);
  padding: 1rem 1.125rem;
  text-align: center;
}
.evvy-compare-card-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--evvy-text-secondary, #666);
  margin-bottom: 0.5rem;
}
.evvy-compare-card-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--cluster-dark);
  font-variant-numeric: tabular-nums;
}
.evvy-compare-card-sub {
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: var(--evvy-text-secondary, #666);
}
.evvy-compare-diff {
  text-align: center;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--cluster-surface);
  border-radius: var(--evvy-radius-lg, 12px);
  font-size: 0.875rem;
  font-weight: 600;
}
.evvy-compare-diff i {
  color: var(--cluster-dark);
  margin-right: 0.25rem;
}
.evvy-verdict-chip-green {
  background: color-mix(in srgb, #1f7a3c 14%, var(--bs-body-bg, #fff));
  color: #14532d;
}
.evvy-verdict-chip-red {
  background: color-mix(in srgb, #b91c1c 12%, var(--bs-body-bg, #fff));
  color: #7f1d1d;
}
[data-bs-theme="dark"] .evvy-compare-card {
  background: color-mix(in srgb, var(--cluster-dark) 15%, #1a1a2e);
}
[data-bs-theme="dark"] .evvy-verdict-chip-green {
  background: color-mix(in srgb, #34d399 18%, #1a1a2e);
  color: #a7f3d0;
}
[data-bs-theme="dark"] .evvy-verdict-chip-red {
  background: color-mix(in srgb, #f87171 18%, #1a1a2e);
  color: #fecaca;
}

/* ---------- 15-year grid ---------- */
.evvy-fifteen-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}
.evvy-fifteen-card {
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--evvy-border-color, #DEE2E6);
  border-radius: var(--evvy-radius-lg, 12px);
  padding: 0.875rem 0.875rem;
  text-align: center;
}
.evvy-fifteen-card-accent {
  background: var(--cluster-surface);
  border-color: color-mix(in srgb, var(--cluster-dark) 25%, transparent);
}
.evvy-fifteen-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--evvy-text-secondary, #666);
  margin-bottom: 0.375rem;
  line-height: 1.3;
}
.evvy-fifteen-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--cluster-dark);
  font-variant-numeric: tabular-nums;
}
.evvy-fifteen-card-accent .evvy-fifteen-value {
  font-size: 1.25rem;
}
[data-bs-theme="dark"] .evvy-fifteen-card {
  background: color-mix(in srgb, var(--cluster-dark) 15%, #1a1a2e);
}

/* ---------- Sensitivity table ---------- */
.evvy-sens-wrap {
  margin-top: 0.75rem;
  border: 1px solid var(--evvy-border-color, #DEE2E6);
  border-radius: var(--evvy-radius-lg, 12px);
  overflow-x: auto;
}
.evvy-sens-table {
  width: 100%;
  font-size: 0.8125rem;
  border-collapse: collapse;
  min-width: 520px;
}
.evvy-sens-table th {
  background: var(--cluster-dark);
  color: var(--cluster-text, #fff);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.625rem 0.75rem;
  text-align: right;
  white-space: nowrap;
}
.evvy-sens-table th:first-child { text-align: left; }
.evvy-sens-table td {
  padding: 0.55rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--evvy-border-color, #DEE2E6);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.evvy-sens-table td:first-child { text-align: left; font-weight: 500; }
.evvy-sens-table tbody tr:last-child td { border-bottom: none; }
.evvy-sens-table tbody tr:hover {
  background: color-mix(in srgb, var(--cluster-dark) 5%, transparent);
}
.evvy-sens-highlight {
  background: var(--cluster-surface);
  font-weight: 600;
}
.evvy-sens-highlight td:first-child::before {
  content: '\25B6';
  color: var(--cluster-dark);
  margin-right: 0.35rem;
  font-size: 0.625rem;
}
.evvy-sens-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.evvy-sens-green {
  background: color-mix(in srgb, #16a34a 18%, var(--bs-body-bg, #fff));
  color: #14532d;
}
.evvy-sens-red {
  background: color-mix(in srgb, #dc2626 14%, var(--bs-body-bg, #fff));
  color: #7f1d1d;
}
[data-bs-theme="dark"] .evvy-sens-table th {
  color: #1a1a2e;
}
[data-bs-theme="dark"] .evvy-sens-green {
  background: color-mix(in srgb, #34d399 22%, #1a1a2e);
  color: #a7f3d0;
}
[data-bs-theme="dark"] .evvy-sens-red {
  background: color-mix(in srgb, #f87171 22%, #1a1a2e);
  color: #fecaca;
}

/* ---------- Mobile responsive breakpoints ---------- */
@media (max-width: 767.98px) {
  .evvy-fifteen-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 575.98px) {
  .evvy-refi-grid { grid-template-columns: 1fr; }
  .evvy-compare-grid { grid-template-columns: 1fr; }
  .evvy-fifteen-grid { grid-template-columns: 1fr 1fr; }
  #results-area .evvy-results-row { grid-template-columns: 1fr !important; }
  .evvy-verdict {
    flex-direction: column;
    text-align: center;
    align-items: center;
    padding: 1rem;
  }
  .evvy-verdict-icon {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.25rem;
  }
  .evvy-verdict-title { font-size: 0.9375rem; }
  .evvy-verdict-sub { font-size: 0.8125rem; }
  .evvy-refi-rate-row { flex-direction: column; align-items: stretch; }
  .evvy-refi-rate-row .input-group { max-width: 100% !important; }
  .evvy-rate-badge { display: flex; }
  .evvy-timeline-marker-label { font-size: 0.625rem; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .evvy-verdict-green .evvy-verdict-icon { animation: none; }
  .evvy-verdict-green,
  .evvy-verdict-red { animation: none; }
  .evvy-timeline-fill,
  .evvy-timeline-marker { transition: none; }
}
