/* =============================================================
   Capitaliza — Calculadora de interés compuesto
   1. Tokens
   ============================================================= */
:root {
  --ink:        #0d1b3e;
  --ink-2:      #33405e;
  --ink-soft:   #5c6880;
  --bg:         #f4f6fb;
  --surface:    #ffffff;
  --surface-2:  #fbfcfe;
  --line:       #e2e7f0;
  --line-2:     #eef1f7;
  --accent:     #1552d0;
  --accent-ink: #0f3ea0;
  --c-inicial:  #0d3b66;
  --c-deposito: #4a90d9;
  --c-interes:  #17a673;
  --warn:       #b42318;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Manrope", var(--sans);

  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(13,27,62,.05), 0 12px 32px -12px rgba(13,27,62,.14);
  --shadow-s: 0 1px 2px rgba(13,27,62,.06);
  --gutter: 1.15rem;
  --maxw: 1080px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.62;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }   /* si no, un display: flex del CSS anula el atributo hidden */
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { text-wrap: pretty; }
h1, h2, h3 {
  font-family: var(--display);
  color: var(--ink);
  line-height: 1.14;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
  background: var(--line-2);
  padding: .1em .38em;
  border-radius: 5px;
  color: var(--ink);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: 2.6rem; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Header
   ============================================================= */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: .75rem; height: 60px; }
.logo { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; flex: 0 0 auto; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 28px; height: 28px; color: var(--ink); }
.logo-text { font-family: var(--display); font-weight: 800; font-size: 1.06rem; letter-spacing: -.02em; }

/* El menú se encoge y, si no cabe (móviles de 320 px), se desliza en horizontal
   dentro de su propio espacio en vez de desbordar la página. */
.site-nav {
  display: flex; gap: .9rem; font-size: .86rem;
  flex: 0 1 auto; min-width: 0;
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12px);
          mask-image: linear-gradient(to right, transparent 0, #000 12px);
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { color: var(--ink-soft); white-space: nowrap; }

/* =============================================================
   5. Hero
   ============================================================= */
.hero { padding-top: 1.9rem; padding-bottom: 1.1rem; text-align: center; }
h1 { font-size: clamp(1.72rem, 5.2vw, 2.6rem); font-weight: 800; }
.hero-sub { margin: .7rem auto 0; max-width: 46rem; color: var(--ink-soft); font-size: clamp(.98rem, 2.3vw, 1.06rem); }
.hero-sub strong { color: var(--ink-2); font-weight: 600; }

/* =============================================================
   6. Tool card
   ============================================================= */
.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem;
}
.tool-form { display: grid; grid-template-columns: 1fr; gap: .95rem; }
.field { min-width: 0; }
.field label {
  display: block;
  font-size: .875rem; font-weight: 600; color: var(--ink);
  margin-bottom: .32rem;
}
.input-wrap { position: relative; }
.input-wrap input, .input-wrap select {
  width: 100%;
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: .66rem .8rem;
  transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
.input-wrap[data-suffix] input { padding-right: 3.2rem; }
.input-wrap input:focus, .input-wrap select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21,82,208,.13);
}
.input-wrap[data-suffix]::after {
  content: attr(data-suffix);
  position: absolute; right: .8rem; top: 50%; transform: translateY(-50%);
  font-size: .85rem; font-weight: 600; color: var(--ink-soft); pointer-events: none;
}
.input-wrap--select { position: relative; }
.input-wrap--select select { appearance: none; padding-right: 2.4rem; cursor: pointer; }
.input-wrap--select::after {
  content: ""; position: absolute; right: 1rem; top: 50%;
  width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg); pointer-events: none;
}
.field-help { font-size: .78rem; color: var(--ink-soft); margin-top: .3rem; line-height: 1.45; }
.form-error {
  margin-top: .9rem; padding: .6rem .8rem;
  background: #fef3f2; border: 1px solid #fecdc9; border-radius: var(--radius-s);
  color: var(--warn); font-size: .88rem; font-weight: 500;
}

/* results */
.results {
  margin-top: 1.15rem;
  display: grid; grid-template-columns: 1fr; gap: .55rem;
  padding-top: 1.15rem; border-top: 1px solid var(--line-2);
}
.result {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: .55rem .75rem;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius-s);
}
.result-label { display: inline-flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--ink-soft); }
.result-value { font-family: var(--display); font-weight: 700; font-size: 1.02rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.result--total {
  background: var(--ink); border-color: var(--ink); padding: .85rem .95rem;
}
.result--total .result-label { color: rgba(255,255,255,.72); font-weight: 500; }
.result--total .result-value { color: #fff; font-size: clamp(1.35rem, 5vw, 1.75rem); }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; display: inline-block; }
.swatch--inicial { background: var(--c-inicial); }
.swatch--deposito { background: var(--c-deposito); }
.swatch--interes { background: var(--c-interes); }

/* chart */
.chart-block { margin: 1.3rem 0 0; }
.chart-title { font-family: var(--display); font-weight: 700; color: var(--ink); font-size: .98rem; margin-bottom: .6rem; }
.chart-holder { position: relative; width: 100%; height: 270px; }
#chart { width: 100%; height: 100%; touch-action: pan-y; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--ink); color: #fff; border-radius: 9px;
  padding: .5rem .65rem; font-size: .78rem; line-height: 1.5;
  box-shadow: 0 8px 20px -6px rgba(13,27,62,.4);
  transform: translate(-50%, -100%); white-space: nowrap;
}
.chart-tip b { font-weight: 600; }
.chart-tip .tip-row { display: flex; align-items: center; gap: .4rem; justify-content: space-between; }
.chart-tip .tip-row span:last-child { font-variant-numeric: tabular-nums; }
.legend { list-style: none; padding: 0; margin: .7rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; font-size: .82rem; color: var(--ink-soft); }
.legend li { display: inline-flex; align-items: center; gap: .42rem; }
.chart-fallback { font-size: .85rem; color: var(--ink-soft); margin-top: .6rem; }

/* table */
.table-block { margin-top: 1.1rem; }
.table-block summary {
  cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--accent);
  padding: .45rem 0; list-style: none;
}
.table-block summary::-webkit-details-marker { display: none; }
.table-block summary::before { content: "▸ "; }
.table-block details[open] summary::before { content: "▾ "; }
.table-scroll { overflow-x: auto; margin-top: .5rem; border: 1px solid var(--line); border-radius: var(--radius-s); }
.year-table { width: 100%; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
.year-table th, .year-table td { padding: .5rem .65rem; text-align: right; white-space: nowrap; }
.year-table th:first-child, .year-table td:first-child { text-align: left; }
.year-table thead th { background: var(--surface-2); color: var(--ink); font-weight: 600; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.year-table tbody tr + tr td { border-top: 1px solid var(--line-2); }

/* actions */
.tool-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .72rem 1.1rem; border-radius: var(--radius-s);
  font-weight: 600; font-size: .93rem;
  transition: background .18s var(--ease-out), transform .18s var(--ease-out), border-color .18s var(--ease-out);
}
.btn--primary { background: var(--accent); color: #fff; flex: 1 1 auto; min-height: 46px; }
.btn--primary:hover { background: var(--accent-ink); }
.btn--primary:active { transform: translateY(1px); }
.btn--ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn--ghost:hover { border-color: var(--ink-soft); }
.btn-icon { width: 18px; height: 18px; }

.noscript-note { margin-top: 1rem; padding: .7rem .85rem; background: #fffaeb; border: 1px solid #fedf89; border-radius: var(--radius-s); font-size: .9rem; color: #7a5b00; }
.calc-hint {
  margin-top: .6rem; font-size: .85rem; color: var(--ink-soft);
}
.calc-hint strong { color: var(--ink); font-weight: 600; }

.chart-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem; text-align: center; padding: 1rem;
  font-size: .88rem; color: var(--ink-soft);
  background: var(--surface-2); border: 1px dashed var(--line);
  border-radius: var(--radius-s);
}
.chart-empty svg { width: 34px; height: 34px; color: #b9c3d6; }

/* antes del primer cálculo: sin tabla y con los importes atenuados */
.tool-card[data-state="ready"] .table-block { display: none; }
.tool-card[data-state="ready"] .result-value { color: var(--ink-soft); }
.tool-card[data-state="ready"] .result--total .result-value { color: rgba(255,255,255,.55); }

.privacy-badge { margin-top: 1rem; font-size: .84rem; color: var(--ink-soft); }
.honest-limits { margin-top: .3rem; font-size: .78rem; color: var(--ink-soft); }

/* =============================================================
   7. Ad slots (placeholders — sin scripts de terceros)
   ============================================================= */
.ad-slot {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed #c3ccdd; border-radius: var(--radius-s);
  background: repeating-linear-gradient(135deg, #fbfcfe 0 10px, #f3f6fb 10px 20px);
  color: #93a0b8;
  overflow: hidden;          /* un anuncio más ancho de la cuenta no rompe la página */
}

/* En cuanto el hueco contiene un anuncio real, pierde el aspecto de hueco:
   fuera el borde discontinuo, el rayado y la palabra ANUNCIO. La altura mínima
   se mantiene para que la página no dé un salto mientras el anuncio carga. */
.ad-slot:has(ins.adsbygoogle) {
  display: block;
  border: 0;
  background: none;
  padding: 0;
}
.ad-slot:has(ins.adsbygoogle) .ad-label { display: none; }
.ad-slot ins.adsbygoogle { display: block; width: 100%; margin: 0 auto; }
.ad-label { font-size: .72rem; font-weight: 700; letter-spacing: .14em; }
.ad-slot--leaderboard { min-height: 100px; margin-block: 1.6rem; }
.ad-slot--incontent { min-height: 260px; margin-block: 1.2rem; }
.ad-slot--toast { min-height: 92px; width: 100%; }

.ad-toast {
  position: fixed; right: .8rem; bottom: .8rem; z-index: 40;
  width: min(300px, calc(100vw - 1.6rem));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .55rem;
  animation: toast-in .45s var(--ease-out) both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } }
.ad-toast-close {
  position: absolute; top: -10px; right: -10px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-s);
}


/* =============================================================
   8. Content sections
   ============================================================= */
h2 { font-size: clamp(1.32rem, 3.9vw, 1.72rem); font-weight: 800; margin-bottom: 1rem; }
h3 { font-size: 1.05rem; font-weight: 700; margin-top: 1.5rem; margin-bottom: .4rem; }

.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: .85rem; counter-reset: none; }
.step {
  position: relative;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.15rem 1.15rem 1.05rem;
  box-shadow: var(--shadow-s);
}
.step-num {
  position: absolute; top: 1.05rem; right: 1.05rem;
  font-family: var(--display); font-weight: 800; font-size: 1.6rem;
  color: var(--line); line-height: 1;
}
.step-icon { width: 26px; height: 26px; color: var(--accent); margin-bottom: .6rem; }
.step h3 { margin: 0 0 .3rem; font-size: 1rem; }
.step p { font-size: .92rem; color: var(--ink-soft); }

.article p { margin-bottom: .9rem; max-width: 68ch; }
.article h3 { max-width: 68ch; }

.faq details {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: .85rem 1rem; margin-bottom: .55rem;
}
.faq summary {
  cursor: pointer; font-weight: 600; color: var(--ink); font-size: .96rem;
  list-style: none; display: flex; justify-content: space-between; gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.2rem; line-height: 1; flex: 0 0 auto; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin-top: .6rem; font-size: .93rem; color: var(--ink-soft); }

.tools-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: .6rem; }
.tool-link {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
.tool-link:hover { border-color: var(--accent); box-shadow: var(--shadow-s); }
.tool-link > a, .tool-link > span:first-child {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1rem; text-decoration: none;
}
.tool-link > a:hover { text-decoration: none; }
.tool-link > a .tool-link-tag { color: var(--accent); }
.tool-link-name { font-weight: 600; color: var(--ink); font-size: .94rem; }
.tool-link-tag { font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft); }

.section-lead {
  max-width: 62ch; margin: -.4rem 0 1.1rem; color: var(--ink-soft);
  font-size: clamp(.95rem, 2.2vw, 1.02rem);
}
.section-lead strong { color: var(--ink-2); font-weight: 600; }

.tool-form--corta { grid-template-columns: 1fr; }
.field-nota {
  align-self: end; font-size: .82rem; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--radius-s); padding: .6rem .75rem; line-height: 1.5;
}

.nota-resultado {
  margin-top: .85rem; padding: .75rem .9rem;
  background: #f0f7f4; border: 1px solid #cfe8dd; border-radius: var(--radius-s);
  font-size: .9rem; color: #1c4a3c; line-height: 1.6;
}
.nota-resultado strong { color: #0f3c30; font-weight: 700; }

/* =============================================================
   9. Footer
   ============================================================= */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 2rem; padding-block: 1.6rem; }
.footer-inner { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.footer-brand { font-family: var(--display); font-weight: 700; color: var(--ink); font-size: .93rem; }
.footer-nav { display: flex; gap: 1rem; font-size: .88rem; }
.footer-note { font-size: .78rem; color: var(--ink-soft); }

/* legal pages */
.legal { padding-block: 2.2rem; }
.legal h1 { font-size: clamp(1.5rem, 4.5vw, 2rem); margin-bottom: 1rem; text-align: left; }
.legal p, .legal li { max-width: 68ch; margin-bottom: .8rem; }
.legal ul { padding-left: 1.2rem; }
.legal .todo { background: #fffaeb; border: 1px solid #fedf89; border-radius: 8px; padding: .6rem .8rem; font-size: .88rem; }

/* =============================================================
   10. Responsive
   ============================================================= */
@media (min-width: 540px) {
  :root { --gutter: 1.5rem; }
  .tool-form { grid-template-columns: 1fr 1fr; gap: .95rem 1.1rem; }
  .field--wide { grid-column: 1 / -1; }
  .results { grid-template-columns: 1fr 1fr; }
  .result--total { grid-column: 1 / -1; }
  .tool-card { padding: 1.5rem; }
  .footer-inner { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
}
@media (min-width: 720px) {
  .site-nav { font-size: .92rem; gap: 1.1rem; overflow-x: visible; -webkit-mask-image: none; mask-image: none; }
  .tool-form { grid-template-columns: 1fr 1fr; gap: 1.1rem 1.25rem; }
  .tool-form--corta { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); align-items: start; }
  .chart-holder { height: 320px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .tools-grid { grid-template-columns: repeat(3, 1fr); }
  .section { padding-block: 3.2rem; }
}
@media (min-width: 960px) {
  .tool-form { grid-template-columns: repeat(2, 1fr); }
  .field--wide { grid-column: 1 / -1; }
  .results { grid-template-columns: repeat(3, 1fr); }
  .result--total { grid-column: 1 / -1; }
  .chart-holder { height: 360px; }
  .ad-slot--leaderboard { min-height: 120px; }
}

/* =============================================================
   11. Reduced motion — solo efectos intrusivos
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ad-toast { animation: none; }
}

/* =============================================================
   12. Print
   ============================================================= */
@media print {
  .site-header, .site-nav, .ad-slot, .ad-toast, .tool-actions, .calc-hint, .site-footer { display: none !important; }
  body { background: #fff; }
  .tool-card { box-shadow: none; border: 0; }
  .table-block details { display: block; }
}
