/* ==========================================================================
   Amortization Calculator — amortization.css
   Page-specific styles for calculators/amortization.php
   Inherits design tokens from styles.css (:root vars)
   ========================================================================== */

/* ── Layout ─────────────────────────────────────────────── */

.amort-page{
  min-height:100vh;
  background:var(--bg);
  color:var(--text);
  padding-top:56px; /* top bar height */
}

.amort-wrap{
  max-width:var(--maxw);
  margin:0 auto;
  padding:32px 20px 64px;
}

.amort-hero{
  text-align:center;
  margin-bottom:36px;
}
.amort-hero h1{
  font-family:"DM Serif Display",serif;
  font-size:clamp(1.75rem,4vw,2.5rem);
  color:var(--white);
  margin:0 0 8px;
}
.amort-hero p{
  color:var(--text-muted);
  font-size:1rem;
  max-width:560px;
  margin:0 auto;
}

/* ── Inputs Card ────────────────────────────────────────── */

.amort-inputs{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow2);
  padding:28px 24px;
  margin-bottom:28px;
  border:1px solid var(--border);
}

.input-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:20px 24px;
}
@media(max-width:600px){
  .input-grid{ grid-template-columns:1fr; }
}

.input-group{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.input-group label{
  font-size:.85rem;
  font-weight:600;
  color:var(--text);
  display:flex;
  align-items:center;
  gap:6px;
}
.input-group input,
.input-group select{
  height:44px;
  padding:0 14px;
  border:1px solid var(--border);
  border-radius:var(--radius2);
  font-size:16px; /* prevent iOS zoom */
  font-family:inherit;
  color:var(--text);
  background:var(--card);
  transition:border-color .15s;
}
.input-group input:focus,
.input-group select:focus{
  outline:none;
  border-color:var(--brand);
  box-shadow:0 0 0 3px rgba(15,95,255,.15);
}
.input-group .input-hint{
  font-size:.75rem;
  color:var(--text-muted);
}

.extra-section{
  margin-top:20px;
  padding-top:20px;
  border-top:1px solid var(--border);
}
.extra-section h3{
  font-family:"DM Serif Display",serif;
  font-size:1.1rem;
  margin:0 0 16px;
  color:var(--text);
}

.lump-month-row{
  transition:opacity .2s, max-height .2s;
  overflow:hidden;
}
.lump-month-row.hidden{
  opacity:0;
  max-height:0;
  margin:0;
  padding:0;
}

/* ── Summary Banner ─────────────────────────────────────── */

.amort-summary{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow2);
  padding:20px 24px;
  margin-bottom:28px;
  border:1px solid var(--border);
  position:sticky;
  top:56px;
  z-index:90;
}

.summary-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:16px;
  text-align:center;
}
@media(max-width:600px){
  .summary-grid{ grid-template-columns:repeat(2,1fr); }
}

.summary-stat{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.summary-stat .stat-label{
  font-size:.75rem;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:.04em;
  color:var(--text-muted);
}
.summary-stat .stat-value{
  font-family:"DM Serif Display",serif;
  font-size:clamp(1.15rem,2.5vw,1.5rem);
  color:var(--text);
}
.summary-stat .stat-accel{
  font-size:.8rem;
  color:var(--green);
  font-weight:600;
}

/* ── Milestone Cards ────────────────────────────────────── */

.milestone-row{
  display:flex;
  gap:16px;
  margin-bottom:28px;
  flex-wrap:wrap;
}
.milestone-card{
  flex:1;
  min-width:200px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius2);
  padding:16px 20px;
  display:flex;
  flex-direction:column;
  gap:4px;
  box-shadow:var(--shadow2);
}
.milestone-card .ms-icon{
  font-size:1.25rem;
}
.milestone-card .ms-label{
  font-size:.8rem;
  color:var(--text-muted);
  font-weight:500;
}
.milestone-card .ms-value{
  font-family:"DM Serif Display",serif;
  font-size:1.15rem;
  color:var(--text);
}

/* ── Charts ─────────────────────────────────────────────── */

.chart-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:24px;
  margin-bottom:28px;
}
@media(max-width:700px){
  .chart-row{ grid-template-columns:1fr; }
}

.chart-card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:20px;
  box-shadow:var(--shadow2);
}
.chart-card h3{
  font-family:"DM Serif Display",serif;
  font-size:1rem;
  margin:0 0 12px;
  color:var(--text);
}
.chart-card canvas{
  width:100% !important;
  max-height:280px;
}

/* ── Tables ─────────────────────────────────────────────── */

.table-card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:20px 24px;
  box-shadow:var(--shadow2);
  margin-bottom:24px;
  overflow-x:auto;
}
.table-card h3{
  font-family:"DM Serif Display",serif;
  font-size:1.1rem;
  margin:0 0 16px;
  color:var(--text);
}

.amort-table{
  width:100%;
  border-collapse:collapse;
  font-size:.875rem;
}
.amort-table th{
  text-align:left;
  font-size:.75rem;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:.04em;
  color:var(--text-muted);
  padding:10px 12px;
  border-bottom:2px solid var(--border);
  white-space:nowrap;
}
.amort-table td{
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  color:var(--text);
  white-space:nowrap;
}
.amort-table tbody tr:hover{
  background:rgba(15,95,255,.04);
}
.amort-table tr.crossover-row{
  background:rgba(18,183,106,.08);
  font-weight:600;
}
.amort-table tr.crossover-row td{
  color:var(--green);
}

/* Monthly detail toggle */
.detail-toggle{
  display:inline-flex;
  align-items:center;
  gap:8px;
  background:none;
  border:1px solid var(--border);
  border-radius:var(--radius2);
  padding:10px 20px;
  font-size:.9rem;
  font-weight:500;
  color:var(--text);
  cursor:pointer;
  margin-bottom:20px;
  transition:background .15s;
}
.detail-toggle:hover{
  background:rgba(15,95,255,.06);
}
.detail-toggle .arrow{
  transition:transform .2s;
}
.detail-toggle.open .arrow{
  transform:rotate(180deg);
}

.monthly-wrap{
  max-height:0;
  overflow:hidden;
  transition:max-height .3s ease;
}
.monthly-wrap.open{
  max-height:none;
}

.load-more-btn{
  display:block;
  margin:16px auto 0;
  padding:10px 28px;
  border:1px solid var(--border);
  border-radius:var(--radius2);
  background:var(--card);
  color:var(--text);
  font-size:.875rem;
  font-weight:500;
  cursor:pointer;
  transition:background .15s;
}
.load-more-btn:hover{
  background:rgba(15,95,255,.06);
}

/* ── Actions ────────────────────────────────────────────── */

.amort-actions{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  margin-top:28px;
}
.btn-action{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:12px 24px;
  border-radius:var(--radius2);
  font-size:.9rem;
  font-weight:600;
  cursor:pointer;
  border:none;
  transition:transform .1s, box-shadow .15s;
  min-height:44px;
}
.btn-action:hover{
  transform:translateY(-1px);
  box-shadow:var(--shadow2);
}
.btn-action:active{
  transform:translateY(0);
}
.btn-primary{
  background:var(--brand);
  color:#fff;
}
.btn-secondary{
  background:var(--card);
  color:var(--text);
  border:1px solid var(--border);
}

/* ── Tooltips ───────────────────────────────────────────── */

.tooltip-trigger{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:18px;
  border-radius:50%;
  border:1px solid var(--border);
  background:transparent;
  font-size:.7rem;
  font-weight:700;
  color:var(--text-muted);
  cursor:help;
  padding:0;
  line-height:1;
  flex-shrink:0;
}
.tooltip-trigger:hover,
.tooltip-trigger:focus{
  background:rgba(15,95,255,.08);
  border-color:var(--brand);
  color:var(--brand);
}

.tooltip-content{
  display:none;
  position:absolute;
  z-index:200;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:10px;
  padding:12px 16px;
  max-width:280px;
  font-size:.8rem;
  line-height:1.5;
  color:var(--text);
  box-shadow:var(--shadow);
  pointer-events:none;
}
.tooltip-content.visible{
  display:block;
}

/* ── PDF Overlay ────────────────────────────────────────── */

.pdf-overlay{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.5);
  z-index:9999;
  place-items:center;
}
.pdf-overlay.active{ display:grid; }
.pdf-spinner{
  text-align:center;
  color:#fff;
  font-size:1rem;
}

/* ── Dark mode overrides ────────────────────────────────── */

[data-theme="dark"] .amort-inputs,
[data-theme="dark"] .amort-summary,
[data-theme="dark"] .milestone-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .table-card{
  background:var(--card);
  border-color:var(--border);
}
[data-theme="dark"] .amort-page{
  background:var(--bg);
}
[data-theme="dark"] .input-group input,
[data-theme="dark"] .input-group select{
  background:var(--bg);
  color:var(--text);
  border-color:var(--border);
}
[data-theme="dark"] .amort-table tbody tr:hover{
  background:rgba(255,255,255,.04);
}
[data-theme="dark"] .detail-toggle:hover,
[data-theme="dark"] .load-more-btn:hover{
  background:rgba(255,255,255,.06);
}
[data-theme="dark"] .btn-secondary{
  background:var(--card);
  color:var(--text);
  border-color:var(--border);
}

/* ── Calculator Hub Cards ──────────────────────────────── */

.calc-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:20px;
}
@media(max-width:600px){
  .calc-grid{ grid-template-columns:1fr; }
}

.calc-card{
  display:flex;
  flex-direction:column;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:24px;
  text-decoration:none;
  color:var(--text);
  box-shadow:var(--shadow2);
  transition:transform .15s, box-shadow .15s;
  min-height:160px;
}
.calc-card:hover{
  transform:translateY(-2px);
  box-shadow:var(--shadow);
}
.calc-card--soon{
  opacity:.65;
  pointer-events:none;
}

.calc-card__icon{
  font-size:1.75rem;
  margin-bottom:12px;
  line-height:1;
}

.calc-card__body{
  flex:1;
}

.calc-card__badge{
  display:inline-block;
  padding:2px 10px;
  border-radius:20px;
  font-size:.7rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.04em;
  background:var(--brand);
  color:#fff;
  margin-bottom:8px;
}
.calc-card__badge--soon{
  background:var(--text-muted);
}

.calc-card__title{
  font-family:"DM Serif Display",serif;
  font-size:1.15rem;
  margin:0 0 6px;
  color:var(--text);
}

.calc-card__desc{
  font-size:.875rem;
  color:var(--text-muted);
  line-height:1.5;
  margin:0;
}

.calc-card__cta{
  margin-top:16px;
  font-size:.85rem;
  font-weight:600;
  color:var(--brand);
}

/* Dark mode */
[data-theme="dark"] .calc-card{
  background:var(--card);
  border-color:var(--border);
}
[data-theme="dark"] .calc-card:hover{
  box-shadow:0 8px 24px rgba(0,0,0,.3);
}
