/* Calculadoras para insertar en otras webs (/insertar/...). Ligero a propósito:
   solo Atkinson (la cifra grande usa la serif del sistema) y lo que necesitan el formulario y el resultado. */

@font-face {
  font-family: "Atkinson";
  src: url("/assets/fonts/atkinson.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #f5f0e6;
  --card: #fbf8f2;
  --white: #ffffff;
  --ink: #1d2823;
  --muted: #5d665f;
  --line: #ddd4c3;
  --green: #1f3d31;
  --accent: #c2622d;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Atkinson", Verdana, sans-serif; font-size: 16px; line-height: 1.5; color: var(--ink); background: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.w { max-width: 640px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.w-head { padding: 14px 16px 0; }
.w-title { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.3rem; line-height: 1.2; }
form { padding: 12px 16px 2px; }

.field { margin-bottom: 12px; }
.field > label, .field > .label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 5px; }
.input-wrap { position: relative; }
.input-wrap .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
input, select { width: 100%; font: inherit; font-size: 1.05rem; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--ink); }
.input-wrap input { padding-right: 52px; }
input:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(31, 61, 49, .18); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 270px) { .row2 { grid-template-columns: 1fr; gap: 0; } }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { position: relative; flex: 1 1 auto; text-align: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); cursor: pointer; font-size: .93rem; white-space: nowrap; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--green); border-color: var(--green); color: var(--paper); font-weight: 700; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.seg.desliza { position: relative; }
.seg.desliza::before { content: ""; position: absolute; left: 0; top: 0; width: var(--w, 0); height: var(--h, 0); transform: translate(var(--x, 0), var(--y, 0)); background: var(--green); border-radius: 8px; z-index: 0; }
.seg.desliza.listo::before { transition: transform .22s cubic-bezier(.2, 0, 0, 1), width .22s cubic-bezier(.2, 0, 0, 1); }
.seg.desliza label { z-index: 1; background: transparent; transition: color .22s; }
.seg.desliza label:has(input:checked) { background: transparent; }

.result { background: var(--green); color: var(--paper); padding: 16px 16px 14px; }
.big-label { margin: 0; font-family: var(--serif); font-size: 1.05rem; }
.big { font-family: var(--serif); font-size: clamp(2.2rem, 10vw, 3rem); line-height: 1; letter-spacing: -0.02em; margin: 4px 0 12px; font-variant-numeric: lining-nums tabular-nums; overflow-wrap: anywhere; }
.kv { list-style: none; margin: 0; padding: 0; }
.kv li { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-top: 1px solid rgba(245, 240, 230, .18); font-size: .93rem; }
.kv li span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.kv li::after { content: ""; position: absolute; inset: 0 -8px; border-radius: 4px; background: var(--paper); opacity: 0; pointer-events: none; }
.kv li.cambio::after { animation: destello .6s cubic-bezier(.16, 1, .3, 1); }
@keyframes destello { from { opacity: .16; } to { opacity: 0; } }
.bar { position: relative; height: 10px; border-radius: 4px; overflow: hidden; margin: 12px 0 6px; background: rgba(245, 240, 230, .15); }
.bar i { position: absolute; inset: 0; transform-origin: left center; transform: translateX(var(--d, 0)) scaleX(var(--p, 0)); transition: transform .3s cubic-bezier(.22, 1, .36, 1); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .8rem; }
.legend b { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.c1 { background: var(--paper); }
.c2 { background: var(--accent); }
.c3 { background: #8fb39d; }
.nota { margin: 10px 0 0; font-size: .8rem; opacity: .85; }
.nota:empty { display: none; }

/* Atribución: siempre visible, abre la web en otra pestaña */
.firma { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; padding: 9px 16px; font-size: .82rem; color: var(--muted); border-top: 1px solid var(--line); }
.firma a { color: var(--ink); font-weight: 700; text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .bar i, .seg.desliza.listo::before, .seg.desliza label { transition: none; }
  .kv li.cambio::after { animation: none; }
}
