/* Casa en Cifras. Shape rule: everything 6px (inputs, buttons) or 10px (panels). One accent: cobalt. */
@font-face { font-family: "Bricolage"; src: url("/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --f-sans: "Bricolage", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --bg: #eef1f6; --surface: #fafbfd; --surface-2: #e4e8f0; --field: #ffffff;
  --ink: #0f1525; --muted: #4f5970; --line: #d4dae5; --line-strong: #aeb7c8;
  --accent: #2346c9; --accent-hover: #1b38a6; --accent-ink: #f5f7ff; --accent-text: #2140b5;
  --int: #9fb0e6; --ok: #11795a; --warn: #a15c00; --danger: #b42318;
  --r-s: 6px; --r-m: 10px; --r-btn: 6px;
  --shadow: 0 30px 60px -34px rgb(20 33 80 / .4), 0 1px 3px rgb(20 33 80 / .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0d15; --surface: #111624; --surface-2: #0d111c; --field: #0d1220;
    --ink: #e6eaf4; --muted: #99a3b8; --line: #1f2638; --line-strong: #323c55;
    --accent: #8aa4ff; --accent-hover: #a6baff; --accent-ink: #0a0f22; --accent-text: #9db3ff;
    --int: #34447a; --ok: #4ed3a0; --warn: #f5b454; --danger: #f97066;
    --shadow: 0 30px 60px -30px rgb(0 0 0 / .75);
  }
}
body { font-size: 1.05rem; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.03em; }
.lg-bg { fill: var(--accent); } .lg-fg { fill: var(--accent-ink); }

/* ------------------------------------------------------------------ tool hero */
.tool { padding-block: 36px 0; }
@media (min-width: 1024px) { .tool { padding-block: 56px 0; } }
.tool-top { display: grid; gap: 18px; align-items: end; margin-bottom: 28px; }
@media (min-width: 1024px) { .tool-top { grid-template-columns: 7fr 5fr; gap: 48px; } }
.tool h1 { font-size: clamp(2.3rem, 5.2vw, 4rem); line-height: 1; margin: 0; letter-spacing: -0.045em; }
.tool-lead { color: var(--muted); max-width: 48ch; margin: 14px 0 0; font-size: 1.1rem; }
.headline-figure { text-align: left; }
@media (min-width: 1024px) { .headline-figure { text-align: right; } }
.headline-figure p { margin: 0; color: var(--muted); }
.headline-figure .mega { color: var(--accent-text); margin-top: 4px; }
.mega { font-family: var(--f-mono); font-size: clamp(3rem, 8vw, 5.4rem); line-height: 1; letter-spacing: -0.06em; font-weight: 600; color: var(--accent-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mega small { font-size: .32em; letter-spacing: 0; color: var(--muted); font-weight: 400; margin-left: 6px; }

.panel { display: grid; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
@media (min-width: 1024px) { .panel { grid-template-columns: 340px 1fr; } }
.panel-inputs { padding: 24px; display: grid; gap: 18px; align-content: start; border-bottom: 1px solid var(--line); background: var(--surface-2); }
@media (min-width: 1024px) { .panel-inputs { border-bottom: 0; border-right: 1px solid var(--line); padding: 28px; } }
.panel-out { padding: 24px; display: grid; gap: 22px; align-content: start; min-width: 0; }
@media (min-width: 1024px) { .panel-out { padding: 32px; } }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 24px; margin: 0; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stats dt { font-size: .85rem; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-family: var(--f-mono); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stats dd[data-level="ok"] { color: var(--ok); } .stats dd[data-level="warn"] { color: var(--warn); } .stats dd[data-level="bad"] { color: var(--danger); }
.warn { margin: 0; padding: 10px 12px; border-radius: var(--r-s); background: color-mix(in srgb, var(--warn) 14%, transparent); font-size: .9rem; }

.chart-wrap { position: relative; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-legend .l-debt { height: 2px; border-radius: 0; background: var(--ink); }
svg.chart { width: 100%; height: auto; aspect-ratio: 8 / 3; overflow: visible; }
svg.chart rect.cap { fill: var(--accent); }
svg.chart rect.int { fill: var(--int); }
svg.chart rect { transition: y .6s cubic-bezier(.16,1,.3,1), height .6s cubic-bezier(.16,1,.3,1), x .4s, width .4s; transition-delay: var(--d, 0ms); }
svg.chart g.bars g { transition-delay: inherit; }
svg.chart path.debt { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
svg.chart .axis text { font-family: var(--f-mono); font-size: 13px; fill: var(--muted); }

/* breakdown list (gastos) */
.breakdown { list-style: none; margin: 0; padding: 0; display: grid; }
.breakdown li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.total-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.total-row .mega { font-size: clamp(2.4rem, 6vw, 3.6rem); }

/* ------------------------------------------------------------------ sections */
.sec { padding-block: 88px 0; }
.sec h2 { font-size: clamp(1.8rem, 3.6vw, 2.7rem); max-width: 20ch; }
.sec-lead { color: var(--muted); max-width: 60ch; margin-bottom: 32px; }

/* split checklist: big sticky title + numbered cards */
.checklist { display: grid; gap: 28px; }
@media (min-width: 900px) { .checklist { grid-template-columns: 5fr 7fr; gap: 64px; } .checklist > div:first-child { position: sticky; top: 100px; align-self: start; } }
.checks { display: grid; gap: 14px; counter-reset: c; }
.checks article { position: relative; padding: 22px 22px 22px 72px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
.checks article::before { counter-increment: c; content: counter(c, decimal-leading-zero); position: absolute; left: 22px; top: 22px; font-family: var(--f-mono); color: var(--accent-text); font-weight: 600; }
.checks h3 { font-size: 1.15rem; margin-bottom: .3em; }
.checks p { margin: 0; color: var(--muted); }

/* tool cards row (2 tiles, asymmetric) */
.tiles { display: grid; gap: 16px; }
@media (min-width: 820px) { .tiles { grid-template-columns: 7fr 5fr; } }
.tile { position: relative; display: grid; gap: 10px; align-content: end; min-height: 260px; padding: 28px; border-radius: var(--r-m); text-decoration: none; overflow: hidden; border: 1px solid var(--line); transition: transform .35s cubic-bezier(.16,1,.3,1), border-color .3s; }
.tile:hover { transform: translateY(-3px); border-color: var(--accent); }
.tile h3 { font-size: 1.6rem; margin: 0; }
.tile p { margin: 0; color: var(--muted); max-width: 40ch; }
.tile .i { position: absolute; top: 24px; right: 24px; width: 26px; height: 26px; color: var(--accent-text); transition: transform .3s; }
.tile:hover .i { transform: translate(3px, -3px); }
.tile-a { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tile-a p, .tile-a .i { color: var(--accent-ink); }
.tile-b { background: linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 28px, var(--surface); }
.tile .big-num { font-family: var(--f-mono); font-size: 3rem; letter-spacing: -0.05em; line-height: 1; }

.faq { display: grid; gap: 0; max-width: 860px; border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 22px 0; font-weight: 650; font-size: 1.1rem; list-style: none; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary .i { transition: transform .3s cubic-bezier(.16,1,.3,1); }
.faq details[open] summary .i { transform: rotate(45deg); }
.faq details > div { padding: 0 0 22px; color: var(--muted); max-width: 70ch; }

/* ------------------------------------------------------------------ articles */
.article { padding-block: 48px 0; }
.article-head { max-width: 780px; margin-bottom: 36px; }
.article-head h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); line-height: 1.02; letter-spacing: -0.045em; }
.article-head p { color: var(--muted); font-size: 1.12rem; }
.crumbs { font-size: .88rem; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); }
.callout { border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 14px 18px; background: var(--surface); border-radius: 0 var(--r-m) var(--r-m) 0; margin: 1.5em 0; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.itp-table td:nth-child(2) { font-family: var(--f-mono); font-size: .9rem; }

@media (prefers-reduced-motion: no-preference) {
  .tool-top > *, .panel { animation: up .8s cubic-bezier(.16,1,.3,1) both; }
  .headline-figure { animation-delay: .08s; } .panel { animation-delay: .14s; }
  @keyframes up { from { opacity: 0; transform: translateY(16px); } }
}
.stats dd.hint { font-family: var(--f-sans); font-size: .95rem; color: var(--muted); }
@media (max-width: 640px) { svg.chart .axis text { font-size: 30px; } }
