/* ============================================================
   Making·Pro — Calculadora de retorno

   Hoja propia de la calculadora. Todo cuelga de .calc para que
   no pise a styles.css: la cabecera, el pie, los botones y los
   rótulos de sección son los del sitio y se heredan tal cual.
   Aquí sólo viven los componentes que la calculadora necesita y
   que no existen en el resto de la web: controles, tablas de
   resultados y el gráfico de caja acumulada.
   ============================================================ */

/* ── 1. VARIABLES PROPIAS ─────────────────────────────────────
   El resto (--bg, --text, --border, radios, sombras) sale de
   styles.css. Aquí sólo se añade lo que la web no necesita:
   el par a favor / en contra y los dos colores del gráfico. */
.calc {
  --pos:        #15803d;   /* cifras a favor */
  --pos-soft:   #f0f7f2;   /* fondo de los avisos en verde (4,6:1 con --pos) */
  --pos-line:   #d4e8dc;
  --neg:        #b91c1c;   /* cifras en contra */
  --chart-pos:  #15803d;   /* barras en positivo   (validado: ΔE 17.4 CVD) */
  --chart-wait: #8b8781;   /* barras recuperando   (contraste 3.3:1) */

  max-width: 1000px;
  margin: 0 auto;
  font-size: 15px;
}
.calc svg { display: block; max-width: 100%; }
.calc input { font-family: inherit; }

/* Los rótulos de sección de la web llevan 20px de margen inferior
   pensados para una cabecera centrada; aquí encabezan una columna
   de controles y ese aire sobra. */
.calc .section-tag { margin-bottom: 6px; }
.calc .section-tag--soft {
  color: var(--text-2);
  background: var(--bg-alt);
  border-color: var(--border);
}

/* ── 2. QUÉ ES LA HERRAMIENTA ─────────────────────────────── */
.calc .que-es {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 20px;
  margin-bottom: 56px;
}
@media (max-width: 820px) { .calc .que-es { grid-template-columns: 1fr; gap: 14px; } }
.calc .que-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 24px;
  transition: box-shadow .2s;
}
.calc .que-card:hover { box-shadow: var(--shadow-card); }
/* display:block es imprescindible: en un <span> en línea el alto no se aplica
   y el icono se sale de la tarjeta. */
.calc .que-card .ic { display: block; width: 26px; height: 26px; margin-bottom: 14px; color: var(--text); }
.calc .que-card .ic svg {
  width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.calc .que-card h3 { font-size: .95rem; font-weight: 600; margin-bottom: 8px; }
.calc .que-card p  { font-size: .85rem; line-height: 1.65; color: var(--text-2); }

/* ── 3. REJILLA ───────────────────────────────────────────── */
.calc .cols { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 48px; }
/* El veredicto acompaña al formulario en vez de quedarse arriba perdido.
   Los 84px son la cabecera pegajosa del sitio (60px) más el aire de siempre. */
.calc .panel { position: sticky; top: 84px; }
@media (max-width: 820px) {
  .calc .cols { grid-template-columns: 1fr; gap: 40px; }
  .calc .panel { position: static; }
}

/* Bloque de detalle, ya sin nada pegajoso: el mes por un lado y el año por otro. */
.calc .detalle {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 48px;
  margin-top: 64px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}
@media (max-width: 820px) { .calc .detalle { grid-template-columns: 1fr; gap: 36px; } }
.calc .detalle h2 {
  font-family: var(--font-serif); font-size: 1.15rem; font-weight: 600;
  letter-spacing: -.01em; margin-bottom: 4px;
}
.calc .detalle .intro { font-size: .82rem; line-height: 1.6; color: var(--text-2); margin-bottom: 16px; }

.calc .group + .group { margin-top: 36px; }
.calc .group .note { font-size: .8rem; color: var(--text-2); margin: 8px 0 4px; }

/* ── 4. CONTROLES ─────────────────────────────────────────── */
.calc .ctrl { padding: 16px 0; border-bottom: 1px solid var(--border-light); }
.calc .ctrl:last-child { border-bottom: none; }
.calc .ctrl .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.calc .ctrl label { font-size: .9rem; font-weight: 500; }
.calc .ctrl .hint,
.calc .dato .et .hint,
.calc .pago .et .hint {
  display: block; font-size: .78rem; font-weight: 400; color: var(--text-2);
  margin-top: 2px; max-width: 36ch; line-height: 1.5;
}
.calc .val { display: flex; align-items: center; gap: 5px; flex: none; padding-top: 2px; }
.calc .val input {
  width: 74px; text-align: right; font-size: .9rem; font-variant-numeric: tabular-nums;
  color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 5px 8px; transition: border-color .15s;
}
.calc .val input:hover { border-color: var(--text-3); }
.calc .val input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px var(--bg-alt); }
.calc .val .u { color: var(--text-2); font-size: .85rem; min-width: 18px; }

/* Dato fijo: mismo ritmo que un control, pero sin nada que tocar. */
.calc .dato { padding: 16px 0; border-bottom: 1px solid var(--border-light); }
.calc .dato .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.calc .dato .et { font-size: .9rem; font-weight: 500; }
.calc .dato .cifra {
  flex: none; font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 5px 10px; white-space: nowrap;
}

.calc input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 18px;
  margin: 12px 0 0; background: transparent; cursor: pointer;
}
.calc input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--border); border-radius: 2px; }
.calc input[type=range]::-moz-range-track { height: 2px; background: var(--border); border-radius: 2px; }
.calc input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--text); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--text); margin-top: -6px;
}
.calc input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border: 2px solid var(--bg); border-radius: 50%;
  background: var(--text); box-shadow: 0 0 0 1px var(--text);
}
.calc input:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.calc .auto { font-size: .78rem; color: var(--text-2); margin-top: 8px; }
.calc .auto button {
  font: inherit; color: var(--text); background: none; border: none; padding: 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--text-3);
}
.calc .auto button:hover { text-decoration-color: var(--text); }

/* Conmutador mensual / anual, con el aire de las píldoras de la web. */
.calc .pago { padding: 16px 0; border-bottom: 1px solid var(--border-light); }
.calc .pago .et { font-size: .9rem; font-weight: 500; line-height: 1.6; margin-bottom: 12px; }
.calc .seg {
  display: inline-flex; background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 3px; gap: 2px;
}
.calc .seg button {
  font-family: inherit; font-size: .82rem; font-weight: 500; padding: 6px 15px; border: 0;
  background: transparent; color: var(--text-2); border-radius: var(--r-pill); cursor: pointer;
  white-space: nowrap; transition: background .15s, color .15s;
}
.calc .seg button:hover { color: var(--text); }
.calc .seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.07); }
.calc .seg button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* Lo que se gana por adelantar el año, con el mismo aire que la nota de abajo. */
.calc .premio {
  margin-top: 14px; padding: 11px 14px; border-radius: var(--r-md);
  background: var(--pos-soft); border: 1px solid var(--pos-line);
  font-size: .85rem; line-height: 1.55; color: var(--text);
}
.calc .premio b { color: var(--pos); font-weight: 600; }

/* ── 5. RESULTADOS ────────────────────────────────────────── */
.calc .verdict {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 28px; margin-bottom: 24px; box-shadow: var(--shadow-card);
}
.calc .verdict .section-tag { margin-bottom: 14px; }
/* Las cifras grandes van en Lora, como los datos destacados de la web. */
.calc .verdict .big {
  font-family: var(--font-serif); font-size: 1.85rem; font-weight: 600;
  line-height: 1.25; letter-spacing: -.01em;
}
.calc .verdict.sin .big { font-size: 1.35rem; color: var(--text-2); }
.calc .verdict p { margin-top: 10px; font-size: .9rem; line-height: 1.65; color: var(--text-2); }
.calc .kpis { margin-top: 22px; padding-top: 6px; border-top: 1px solid var(--border); }
.calc .kpi {
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--border-light); font-size: .875rem;
}
.calc .kpi:last-child { border-bottom: none; padding-bottom: 0; }
.calc .kpi span { color: var(--text-2); }
.calc .kpi b { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc .kpi--total { border-top: 1px solid var(--border); margin-top: 2px; padding-top: 12px; }
.calc .kpi--total span { color: var(--text); font-weight: 500; }
.calc .kpi--total b {
  font-family: var(--font-serif); font-size: 1.25rem; font-weight: 600;
  letter-spacing: -.01em; font-variant-numeric: normal;
}
.calc .kpi--total b.pos { color: var(--pos); }
.calc .kpi--total b.neg { color: var(--neg); }
/* El mes de amortización juega en contra del pago anual, así que la ventaja
   real —lo que ahorra cada año— se dice aquí, al lado y en verde. */
/* min-height reserva el caso de dos líneas: el rótulo cambia con la forma de
   pago y, sin reserva, la tarjeta del veredicto daba un salto al conmutar. */
.calc .kpi--extra {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 64px; margin-top: 16px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--pos-soft); border: 1px solid var(--pos-line);
  font-size: .875rem; line-height: 1.4;
}
.calc .kpi--extra span { color: var(--text); }
/* En pago mensual la fila sigue ahí, pero apagada: es una invitación, no un dato. */
.calc .kpi--extra.pasiva { background: var(--bg-alt); border-color: var(--border); }
.calc .kpi--extra.pasiva span,
.calc .kpi--extra.pasiva b { color: var(--text-2); }
.calc .kpi--extra b {
  color: var(--pos); font-weight: 600; white-space: nowrap;
  font-family: var(--font-serif); font-size: 1.05rem; letter-spacing: -.01em;
}

.calc .rows { border-top: 1px solid var(--border); }
.calc .row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--border-light); font-size: .9rem;
}
.calc .row .k { color: var(--text-2); }
.calc .row .k small { display: block; font-size: .75rem; color: var(--text-3); line-height: 1.45; margin-top: 1px; }
.calc .row .v { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.calc .row.gap { margin-top: 14px; border-top: 1px solid var(--border); }
.calc .row.sub .k { color: var(--text); font-weight: 500; }
.calc .row.sub .v { font-weight: 600; }
.calc .row.strong { border-bottom-color: var(--border); }
.calc .row.strong .k { color: var(--text); font-weight: 500; }
.calc .row.strong .v { font-weight: 600; }
.calc .row .v.pos { color: var(--pos); }
.calc .row .v.neg { color: var(--neg); }

.calc .versus {
  margin-top: 22px; padding: 16px 18px; background: var(--bg-alt);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: .85rem; line-height: 1.6; color: var(--text-2);
}
.calc .versus b { color: var(--text); font-weight: 600; }

/* ── 6. GRÁFICO ───────────────────────────────────────────── */
.calc .chart { margin-top: 64px; padding-top: 40px; border-top: 1px solid var(--border); }
.calc .chart h2 {
  font-family: var(--font-serif); font-size: 1.3rem; font-weight: 600;
  letter-spacing: -.01em; margin-bottom: 4px;
}
.calc .chart .sub { font-size: .85rem; line-height: 1.6; color: var(--text-2); margin-bottom: 24px; }
.calc .plot { position: relative; }
.calc .plot-scroll { overflow-x: auto; overflow-y: hidden; }
.calc .plot-scroll svg { width: 100%; height: auto; }
.calc .legend { display: flex; gap: 22px; margin-top: 14px; font-size: .8rem; color: var(--text-2); flex-wrap: wrap; }
.calc .legend span { display: inline-flex; align-items: center; gap: 8px; }
.calc .legend i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
/* Globo de datos al pasar el ratón por una barra. */
.calc .tip {
  position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%,-100%);
  background: var(--text); color: var(--bg); font-size: .78rem; line-height: 1.45;
  padding: 6px 10px; border-radius: var(--r-sm); white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.calc .tip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.calc .tip[hidden] { display: none; }

.calc .cierre { display: flex; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.calc .cierre-et { font-size: .8rem; color: var(--text-2); }
.calc .seg--fin button { display: inline-flex; align-items: baseline; gap: 6px; padding: 7px 14px; }
.calc .seg--fin b { font-weight: 600; font-variant-numeric: tabular-nums; }
.calc .seg--fin i { font-style: normal; font-weight: 600; color: var(--pos); font-variant-numeric: tabular-nums; }
.calc .seg--fin button[aria-pressed="false"] i { opacity: .7; }

/* ── 7. BARRA DE HERRAMIENTAS ─────────────────────────────── */
.calc .tools {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--border);
}
.calc .tools .btn { font-size: .82rem; padding: 10px 18px; }
.calc .ok { font-size: .8rem; color: var(--pos); opacity: 0; transition: opacity .15s; }
.calc .ok.on { opacity: 1; }
/* El enlace con los números dentro es lo que se manda a un cliente, así que
   se explica: sin la nota, el botón parece un "copiar" más. */
.calc .tools-nota { flex-basis: 100%; font-size: .78rem; line-height: 1.6; color: var(--text-3); margin: 0; }

/* ── 8. CIERRE ────────────────────────────────────────────── */
.calc .pie { margin-top: 40px; font-size: .78rem; line-height: 1.6; color: var(--text-3); }

/* ── 9. AJUSTES FINOS ─────────────────────────────────────── */
/* Por debajo de esta anchura las etiquetas del eje se volverían ilegibles,
   así que el gráfico conserva su tamaño y se desplaza a lo ancho. */
@media (max-width: 700px) {
  .calc .plot-scroll svg { width: 660px; max-width: none; }
}
@media (max-width: 560px) {
  .calc .ctrl .top { flex-direction: column; gap: 8px; }
  .calc .val { align-self: flex-start; }
}
/* El navegador reajusta el scroll solo cuando cambia el contenido que hay a la
   vista (scroll anchoring): busca un nodo de referencia y lo mantiene quieto.
   Estas tres zonas se reescriben enteras al conmutar mensual/anual, así que
   perdía la referencia y movía la página aunque ningún alto cambiara. */
.calc .cols, .calc .detalle, .calc .chart { overflow-anchor: none; }

@media (prefers-reduced-motion: reduce) {
  .calc * { transition: none !important; animation: none !important; }
}
.calc .off { position: absolute; left: -9999px; }
