/* ============================================================
   Aventurine — tools: the calculator pages and their hub

   Loaded only by tools.html and the three calculator pages, after
   base.css → components.css → sections.css. Everything here is namespaced
   .calc-* so it cannot collide with the marketing sections.

   The panels borrow .form-panel's ground, outline and radius so a calculator
   reads as the same family of surface as the feature-request form.

   Spacing sits on a 4px scale throughout (.25rem steps against the 16px root).
   ============================================================ */

/* ---------- page shell ---------- */
.calc-section { padding: 2.5rem 0 4rem }

.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

/* The inputs follow the reader down the results column, which on a long page
   is what stops them scrolling back up to change one number. */
.calc-sticky {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}

.calc-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.calc-results { display: flex; flex-direction: column; gap: 1.5rem }

.calc-panel h2 {
  font-size: 1.15rem;
  margin-bottom: 1rem;
}
/* a panel heading that opens a .form: the form's gap already spaces it, and
   this file loads after components.css, so the rule above would win */
.calc-panel .form > h2 { margin-bottom: 0 }
.calc-panel h3 {
  font-family: 'Manrope', sans-serif;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

/* ---------- forms ----------
   The form, its fields and the segmented control are the shared form family
   (components.css). */

/* ---------- headline result ---------- */
.calc-headline {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.calc-headline-label {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.calc-headline-value {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: clamp(2.25rem, 6vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.calc-headline-note { font-size: .9rem; color: var(--text-muted) }

/* ---------- stat tiles ---------- */
.calc-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}
.calc-stat {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .75rem 1rem;
  background: var(--surface-2);
  border-radius: var(--radius-md);
}
.calc-stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500 }
.calc-stat-value {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- stacked split bar + its key ----------
   The 2px gap is the surface showing through between segments, so two similar
   greens never melt into one block. */
.calc-split {
  display: flex;
  gap: 2px;
  height: 14px;
  margin-bottom: 1rem;
}
.calc-split span {
  border-radius: 3px;
  min-width: 3px;
}

.calc-key { list-style: none; display: flex; flex-direction: column; gap: .5rem }
.calc-key li {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
}
.calc-key-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}
.calc-key-name { color: var(--text-muted) }
.calc-key-value {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- chart ---------- */
.calc-chart { position: relative; margin-top: .5rem }
.calc-chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y }
.calc-chart-grid { stroke: var(--border); stroke-width: 1 }
.calc-chart-tick {
  fill: var(--text-muted);
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 11px;
}
.calc-chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round }
.calc-chart-cross { stroke: var(--color-aventurine-400); stroke-width: 1; stroke-dasharray: 3 3 }
.calc-chart-dot { stroke: var(--surface); stroke-width: 2 }   /* 2px ring over the line */

.calc-chart-tip {
  position: absolute;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  background: var(--surface-inverse);
  color: var(--text-light);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  font-size: .8rem;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-pop);
  z-index: 2;
}
.calc-tip-head { font-weight: 600; color: var(--accent-soft) }
.calc-tip-row { display: flex; align-items: center; gap: .5rem }
.calc-tip-row b { margin-left: auto; font-variant-numeric: tabular-nums }

/* ---------- alerts ---------- */
.calc-alerts { display: flex; flex-direction: column; gap: .75rem }
/* Nothing to report means no element at all, so the column gap closes up
   rather than leaving a hole where a panel would have been. */
.calc-alerts:empty { display: none }

.calc-alert {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  font-size: .875rem;
  line-height: 1.5;
  border-radius: var(--radius-lg);
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  background: var(--accent-wash);
  color: var(--text-muted);
}
.calc-alert svg { width: 18px; height: 18px; flex: none; color: var(--accent); margin-top: .125rem }
.calc-alert strong { color: var(--text) }
.calc-alert.is-warning { background: color-mix(in srgb, var(--danger) 8%, transparent); border-color: color-mix(in srgb, var(--danger) 30%, transparent) }
.calc-alert.is-warning svg { color: var(--danger) }
.calc-alert.is-win { background: color-mix(in srgb, var(--accent-gold) 12%, transparent); border-color: color-mix(in srgb, var(--accent-gold) 38%, transparent) }
.calc-alert.is-win svg { color: var(--accent-gold) }

/* ---------- schedule table ---------- */
.calc-details { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem }
.calc-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  color: var(--accent);
  list-style-position: outside;
  padding: .25rem 0;
}
.calc-details summary:hover { color: var(--accent-strong) }
.calc-details summary:focus-visible { outline: var(--focus-ring); outline-offset: 3px; border-radius: var(--radius-xs) }

.calc-scroll { overflow-x: auto; margin-top: 1rem }
.calc-table { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 460px }
.calc-table th, .calc-table td {
  padding: .5rem .75rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.calc-table th:first-child, .calc-table td:first-child { text-align: left }
.calc-table thead th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 600;
}
.calc-table tbody tr:hover { background: var(--surface-2) }

/* ---------- debt list ---------- */
.calc-debts { display: flex; flex-direction: column; gap: .75rem }
.calc-debt {
  position: relative;                    /* corner for the remove button */
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .5rem;
  align-items: end;
  padding: .75rem;
  background: var(--surface-2);
  border-radius: var(--radius-md);
}
/* The name row reserves the corner so its input never runs under the button. */
.calc-debt .calc-debt-name { grid-column: 1 / -1; padding-right: 2.25rem }
.calc-debt-remove {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
/* The painted box is 30px; this stretches the tap target to 44px. */
.calc-debt-remove::after { content: ""; position: absolute; inset: -7px }
.calc-debt-remove svg { width: 14px; height: 14px }
.calc-debt-remove:hover { background: var(--surface); border-color: var(--danger); color: var(--danger) }
.calc-debt-remove:active { background: color-mix(in srgb, var(--danger) 10%, transparent) }
.calc-debt-remove:focus-visible { outline: var(--focus-ring); outline-offset: 2px }
.calc-debt-remove:disabled { opacity: .4; cursor: not-allowed }
.calc-debt-remove:disabled:hover { border-color: var(--border); color: var(--text-muted) }

.calc-order { list-style: none; counter-reset: payoff; display: flex; flex-direction: column; gap: .5rem }
.calc-order li {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem .75rem;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  font-size: .9rem;
}
.calc-order li::before {
  counter-increment: payoff;
  content: counter(payoff);
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface);
  font-size: .72rem;
  font-weight: 700;
}
.calc-order-name { font-weight: 600 }
.calc-order-when { margin-left: auto; color: var(--text-muted); font-variant-numeric: tabular-nums }

/* ---------- the row of other calculators ---------- */
.calc-switch { border-top: 1px solid var(--border); padding: 2.5rem 0 }
.calc-switch h2 { font-size: 1.25rem; margin-bottom: 1.5rem }
.calc-switch-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

/* ---------- hub + switch cards ---------- */
.calc-card {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.calc-card:hover {
  border-color: var(--accent);
  background: var(--panel-raised);
  box-shadow: var(--shadow-frame);
}
.calc-card:focus-visible { outline: var(--focus-ring); outline-offset: 3px }
.calc-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--color-aventurine-50);
  margin-bottom: .25rem;
}
.calc-card-icon svg { width: 20px; height: 20px }
.calc-card h3 { font-size: 1.05rem; font-family: 'Manrope', sans-serif; font-weight: 600 }
.calc-card p { font-size: .9rem; color: var(--text-muted); line-height: 1.5 }
.calc-card-go {
  margin-top: .25rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: .375rem;
}
.calc-card-go svg { width: 14px; height: 14px; transition: transform .15s ease }
.calc-card:hover .calc-card-go svg { transform: translateX(3px) }

.calc-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* ---------- FAQ ---------- */
.calc-faq { border-top: 1px solid var(--border); padding: 2.5rem 0 }
.calc-faq h2 { font-size: 1.5rem; margin-bottom: 1.5rem }
.calc-faq-item { border-bottom: 1px solid var(--border); padding: 1rem 0 }
.calc-faq-item h3 {
  font-family: 'Manrope', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .5rem;
}
.calc-faq-item p { color: var(--text-muted); font-size: .95rem }
.calc-faq-item p + p { margin-top: .5rem }

/* ---------- closing call to action ---------- */
.calc-cta {
  background: var(--surface-inverse);
  color: var(--text-light);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  justify-content: space-between;
  margin: 2.5rem 0;
}
.calc-cta h2 { font-size: 1.5rem; color: var(--text-light) }
.calc-cta p { color: var(--color-aventurine-300); font-size: .95rem; margin-top: .5rem; max-width: 52ch }
.calc-cta .btn { flex: none }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .calc-grid { grid-template-columns: 1fr }
  .calc-sticky { position: static }
}

@media (max-width: 560px) {
  .calc-panel { padding: 1.25rem }
  .calc-debt { grid-template-columns: 1fr 1fr }
  .calc-cta { flex-direction: column; align-items: flex-start }
}

@media (prefers-reduced-motion: reduce) {
  .calc-card, .calc-card-go svg,
  .calc-debt-remove { transition: none }
}
