/* ============================================================
   CAPTIA Tech — páginas de caso (es/casos/, en/cases/, pt/casos/)
   Escena fijada al hacer scroll («a mano» frente a «automatizado») y
   calculadora de horas recuperadas. Lógica en assets/js/caso.js.
   Hoja aparte, como servicio.css: styles.css va immutable a un año y subir su
   ?v= obliga a tocar todas las páginas. Prefijo cs- para no chocar con las
   clases genéricas (.doc, .row, .status, .btn...).
   Sin JS o con reduced-motion no hay escena: se ve la cabecera de cada columna
   y la tabla estática con los mismos pasos (html sin la clase .cs-motion).
   ============================================================ */
:root {
  --cs-paper: var(--gray-light);
  --cs-paper-2: #fafbfd;
  --cs-dark: var(--navy-deep);
  --cs-dark-2: #13213d;
  --cs-dark-line: rgba(214, 226, 242, 0.14);
  --cs-on-dark: #e7edf6;
  --cs-on-dark-2: #a9b8cc;
  --cs-line: rgba(18, 35, 71, 0.14);
  --cs-ok: #5fd3a0;
  --cs-warn: #c2410c;
  --cs-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --cs-head: 72px;
}
body { background: var(--cs-dark); }
main { background: var(--bg); }
.cs-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Escena fijada ---------- */
.cs-duel { position: relative; padding-top: var(--cs-head); background: var(--cs-dark); }
.cs-motion .cs-duel { height: 720vh; }
.cs-stage {
  --split: 0.5;
  position: relative; overflow: hidden; display: grid;
  grid-template-columns: calc(var(--split) * 100%) 1fr;
}
.cs-motion .cs-stage { position: sticky; top: var(--cs-head); height: calc(100vh - var(--cs-head)); height: calc(100svh - var(--cs-head)); }
.cs-col {
  position: relative; overflow: hidden; min-width: 0; display: flex; flex-direction: column;
  padding: clamp(56px, 8vh, 88px) clamp(20px, 4vw, 64px) clamp(20px, 4vh, 36px);
}
.cs-col--m { background: var(--cs-paper); color: var(--ink); }
.cs-col--a { background: var(--cs-dark); color: var(--cs-on-dark); }
.cs-inner {
  position: relative; flex: 1; display: grid; grid-template-rows: auto 1fr auto;
  gap: clamp(12px, 2.5vh, 24px); min-height: 0; min-width: min(40vw, 560px); max-width: 640px; width: 100%;
}
.cs-col--m .cs-inner { margin-left: auto; }

.cs-crumb { position: absolute; top: 22px; left: clamp(20px, 4vw, 64px); font-size: 0.8rem; color: var(--gray); white-space: nowrap; }
.cs-crumb a { color: var(--navy); font-weight: 600; }
.cs-crumb a:hover { color: var(--orange-dark); }

/* capas de texto: solo una visible a la vez */
.cs-copy { position: relative; }
.cs-layer { transition: opacity 0.45s ease, transform 0.45s ease; }
.cs-layer[aria-hidden="true"] { position: absolute; inset: 0 0 auto 0; opacity: 0; transform: translateY(10px); pointer-events: none; visibility: hidden; }
.cs-duel h1, .cs-big-line {
  font-size: clamp(1.6rem, min(3vw, 5.2vh), 2.8rem); line-height: 1.08; letter-spacing: -0.025em; font-weight: 800; max-width: 17ch;
}
.cs-duel h1 { color: var(--white); }
.cs-col--m .cs-big-line { color: var(--navy); }
.cs-col--a .cs-big-line { color: var(--white); max-width: 20ch; }
.cs-lede { margin-top: 14px; font-size: clamp(0.98rem, 1.15vw, 1.12rem); line-height: 1.55; max-width: 42ch; color: var(--gray); }
.cs-col--a .cs-lede { color: var(--cs-on-dark-2); }
.cs-cta { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.cs-link { font-weight: 600; font-size: 0.95rem; color: var(--cs-on-dark); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: rgba(252, 150, 49, 0.6); }
.cs-link:hover { color: var(--orange); }
.cs-duel :focus-visible, .cs-calc :focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }
.cs-label { font-family: var(--cs-mono); font-size: 0.8rem; color: var(--gray); }
.cs-col--a .cs-label { color: var(--cs-on-dark-2); }
.cs-title { font-size: clamp(1.3rem, min(2.3vw, 4.2vh), 2.1rem); line-height: 1.12; letter-spacing: -0.02em; font-weight: 800; margin-top: 4px; color: var(--navy); }
.cs-col--a .cs-title { color: var(--white); }
.cs-text { margin-top: 8px; max-width: 44ch; font-size: clamp(0.94rem, 1.1vw, 1.05rem); line-height: 1.5; color: var(--gray); }
.cs-col--a .cs-text { color: var(--cs-on-dark-2); }

/* documentos */
.cs-desk { position: relative; display: flex; align-items: flex-start; justify-content: center; min-height: 0; padding-top: clamp(12px, 4vh, 40px); transition: opacity 0.4s; }
.cs-sheet { position: absolute; width: min(380px, 92%); height: min(330px, 86%); border-radius: 6px; box-shadow: 0 1px 0 rgba(18, 35, 71, 0.06), 0 18px 40px -18px rgba(18, 35, 71, 0.35); }
.cs-sheet.s1 { transform: translate(calc(-14px + var(--d1, 0px)), calc(-18px + var(--d1, 0px))) rotate(-5deg); background: #f2f4f7; }
.cs-sheet.s2 { transform: translate(calc(16px + var(--d2, 0px)), calc(-6px + var(--d2, 0px))) rotate(4deg); background: #f8f9fb; }
.cs-doc { position: relative; width: min(380px, 92%); border-radius: 8px; padding: 18px 20px; font-size: 0.8rem; transform: translateY(var(--d0, 0px)) scale(var(--ds, 1)); }
.cs-col--m .cs-doc { background: var(--cs-paper-2); color: var(--ink); rotate: -1.2deg; box-shadow: 0 2px 0 rgba(18, 35, 71, 0.05), 0 26px 50px -22px rgba(18, 35, 71, 0.45); }
.cs-col--a .cs-doc { background: var(--cs-dark-2); color: var(--cs-on-dark); border: 1px solid var(--cs-dark-line); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.7); }
.cs-doc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.cs-doc-title { font-weight: 800; font-size: 0.92rem; }
.cs-col--m .cs-doc-title { color: var(--navy); }
.cs-doc-tag { font-family: var(--cs-mono); font-size: 0.7rem; color: var(--gray); }
.cs-col--a .cs-doc-tag { color: var(--cs-on-dark-2); }
.cs-rows { display: grid; gap: 6px; }
.cs-row { display: grid; grid-template-columns: 96px 1fr 16px; align-items: center; gap: 8px; min-height: 21px; }
.cs-row dt { font-size: 0.75rem; color: var(--gray); }
.cs-col--a .cs-row dt { color: var(--cs-on-dark-2); }
.cs-row dd { font-family: var(--cs-mono); font-size: 0.78rem; white-space: nowrap; overflow: hidden; min-height: 20px; padding-bottom: 1px; border-bottom: 1px dashed rgba(18, 35, 71, 0.18); }
.cs-col--a .cs-row dd { border-bottom-color: var(--cs-dark-line); }
.cs-row dd.err { color: var(--cs-warn); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.cs-caret { display: inline-block; width: 7px; height: 13px; background: var(--ink); vertical-align: -2px; margin-left: 1px; animation: cs-blink 1s steps(1) infinite; }
@keyframes cs-blink { 50% { opacity: 0; } }
.cs-tick { opacity: 0; transition: opacity 0.25s; }
.cs-row.ok .cs-tick { opacity: 1; }
.cs-tick svg { display: block; width: 15px; height: 15px; }
.cs-status { margin-top: 12px; display: flex; gap: 8px; align-items: center; font-size: 0.78rem; font-weight: 600; min-height: 20px; }
.cs-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); flex: none; }
.cs-col--a .cs-status .dot { background: var(--cs-ok); }
.cs-status.bad { color: var(--cs-warn); }
.cs-status.bad .dot { background: var(--cs-warn); }
.cs-human { margin-top: 6px; font-size: 0.75rem; color: var(--cs-on-dark-2); }

/* relojes */
.cs-clock { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; border-top: 1px solid var(--cs-line); padding-top: 12px; }
.cs-col--a .cs-clock { border-top-color: var(--cs-dark-line); }
.cs-clock-k { font-size: 0.8rem; font-weight: 600; color: var(--gray); }
.cs-col--a .cs-clock-k { color: var(--cs-on-dark-2); }
.cs-clock-v { font-family: var(--cs-mono); font-weight: 500; font-size: clamp(1.4rem, min(2.4vw, 4.4vh), 2.3rem); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--navy); }
.cs-col--a .cs-clock-v { color: var(--orange); }

/* divisor: el único adorno */
.cs-divider { position: absolute; top: 0; bottom: 0; left: calc(var(--split) * 100%); width: 0; z-index: 5; pointer-events: none; }
.cs-divider .line { position: absolute; top: 0; bottom: 0; left: -0.5px; width: 1px; background: rgba(18, 35, 71, 0.18); }
.cs-divider .fill { position: absolute; top: 0; left: -1px; width: 2px; height: calc(var(--prog, 0) * 100%); background: var(--orange); }
.cs-d-top { position: absolute; top: 22px; left: 0; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.cs-d-top span { position: absolute; top: 0; padding: 0 14px; }
.cs-d-top .l { right: 0; color: var(--navy); }
.cs-d-top .r { left: 0; color: var(--cs-on-dark); }
.cs-chip { position: absolute; top: 50%; left: 0; transform: translate(-50%, -50%); background: var(--orange); color: var(--navy-deep); font-family: var(--cs-mono); font-size: 0.72rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }

/* cierre: totales */
.cs-big-total { font-family: var(--cs-mono); font-size: clamp(2.6rem, min(6vw, 11vh), 5.6rem); line-height: 1; letter-spacing: -0.04em; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--navy); margin-top: 6px; }
.cs-col--a .cs-big-total { color: var(--orange); }
.cs-total-note { margin-top: 12px; font-size: clamp(0.98rem, 1.15vw, 1.12rem); max-width: 36ch; color: var(--gray); }
.cs-col--a .cs-total-note { color: var(--cs-on-dark-2); }

/* fases */
.cs-stage[data-phase="resolve"] .cs-inner, .cs-stage[data-phase="collapse"] .cs-inner { grid-template-rows: 1fr auto; }
.cs-stage[data-phase="resolve"] .cs-desk, .cs-stage[data-phase="collapse"] .cs-desk { display: none; }
.cs-stage[data-phase="resolve"] .cs-copy, .cs-stage[data-phase="collapse"] .cs-copy { padding-top: 12vh; }
.cs-stage[data-phase="collapse"] .cs-divider { opacity: calc(1 - var(--cp, 0)); }
.cs-stage[data-phase="collapse"] .cs-col--m > * { opacity: calc(1 - var(--cp, 0) * 2); }
.cs-stage[data-phase="collapse"] .cs-col--a .cs-clock { opacity: calc(1 - var(--cp, 0) * 2); }
@media (max-height: 780px) and (min-width: 761px) {
  .cs-stage[data-phase="hero"] .cs-doc, .cs-stage[data-phase="hero"] .cs-sheet { scale: 0.8; transform-origin: 50% 0; }
  .cs-stage[data-phase="hero"] .cs-desk { padding-top: 4px; }
  .cs-doc { padding: 12px 16px; }
  .cs-rows { gap: 3px; }
  .cs-row { min-height: 19px; }
  .cs-doc-head { margin-bottom: 8px; }
  .cs-status { margin-top: 8px; }
  .cs-human { margin-top: 4px; }
  .cs-sheet { height: min(290px, 86%); }
}

/* ---------- Sin escena (sin JS o reduced-motion) ---------- */
html:not(.cs-motion) .cs-desk, html:not(.cs-motion) .cs-clock, html:not(.cs-motion) .cs-chip { display: none; }
html:not(.cs-motion) .cs-col { padding-bottom: 56px; }
html:not(.cs-motion) .cs-inner { grid-template-rows: auto; }
.cs-static { display: none; background: var(--bg-soft); padding: clamp(3rem, 6vw, 4.5rem) 0; }
html:not(.cs-motion) .cs-static { display: block; }
.cs-static h2 { margin-bottom: 1.5rem; }
.cs-table-wrap { overflow-x: auto; }
.cs-static table { width: 100%; border-collapse: collapse; font-size: 0.98rem; background: var(--white); border-radius: var(--radius); }
.cs-static th, .cs-static td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--cs-line); vertical-align: top; }
.cs-static th { color: var(--navy); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.cs-static td { color: var(--gray); }
.cs-static td strong { color: var(--navy); }
.cs-static .t { display: block; margin-top: 4px; font-family: var(--cs-mono); color: var(--navy); white-space: nowrap; }
.cs-static .cs-fine { margin-top: 1rem; font-size: 0.85rem; color: var(--gray); }

/* ---------- Calculadora ---------- */
.cs-calc { background: var(--cs-dark); color: var(--cs-on-dark); padding: clamp(4.5rem, 9vw, 8rem) 0 clamp(4rem, 7vw, 6rem); }
.cs-calc-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(2rem, 6vw, 6rem); align-items: start; }
.cs-calc .kicker { color: var(--orange); }
.cs-calc h2 { color: var(--white); max-width: 14ch; }
.cs-intro { color: var(--cs-on-dark-2); max-width: 44ch; }
.cs-inputs { margin-top: 2.4rem; display: grid; gap: 1.6rem; }
.cs-field label { display: flex; justify-content: space-between; gap: 12px; font-size: 0.98rem; font-weight: 600; color: var(--white); }
.cs-field output { font-family: var(--cs-mono); font-weight: 500; color: var(--cs-on-dark); white-space: nowrap; }
.cs-field small { display: block; color: var(--cs-on-dark-2); font-size: 0.85rem; margin-top: 2px; }
.cs-field input[type="range"] { width: 100%; margin-top: 10px; accent-color: var(--orange); height: 28px; cursor: pointer; }
.cs-results { position: sticky; top: calc(var(--cs-head) + 32px); background: var(--cs-dark-2); border: 1px solid var(--cs-dark-line); border-radius: var(--radius); padding: clamp(1.5rem, 3vw, 2.5rem); }
.cs-res-k { font-size: 0.88rem; color: var(--cs-on-dark-2); font-weight: 600; }
.cs-res-v { font-family: var(--cs-mono); font-size: clamp(2.5rem, 4.6vw, 4.2rem); line-height: 1.05; letter-spacing: -0.035em; color: var(--orange); font-variant-numeric: tabular-nums; margin-top: 4px; }
.cs-res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--cs-dark-line); }
.cs-res-grid .v { font-family: var(--cs-mono); font-size: clamp(1.25rem, 1.8vw, 1.6rem); margin-top: 2px; color: var(--white); font-variant-numeric: tabular-nums; }
.cs-payback { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--cs-dark-line); line-height: 1.55; color: var(--cs-on-dark); }
.cs-payback strong { font-family: var(--cs-mono); font-weight: 500; color: var(--white); white-space: nowrap; }
.cs-results .cs-cta { margin-top: 1.75rem; }
.cs-radar { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.cs-fine { margin-top: 1.25rem; font-size: 0.8rem; line-height: 1.5; color: var(--cs-on-dark-2); }

/* ---------- Móvil: columnas apiladas ---------- */
@media (max-width: 760px) {
  .cs-stage { grid-template-columns: 1fr; grid-template-rows: calc(var(--split) * 100%) 1fr; }
  html:not(.cs-motion) .cs-stage { grid-template-rows: auto auto; }
  .cs-col { padding: 18px 18px 14px; }
  html:not(.cs-motion) .cs-col { padding: 28px 18px 32px; }
  .cs-col--a { padding-top: 26px; }
  .cs-inner { min-width: 0; gap: 10px; }
  .cs-col--m .cs-inner { margin-left: 0; }
  .cs-crumb { display: none; }
  .cs-motion .cs-copy { min-height: 112px; }
  .cs-duel h1, .cs-big-line { font-size: clamp(1.3rem, 6.2vw, 1.75rem); max-width: 22ch; }
  .cs-lede { margin-top: 6px; font-size: 0.9rem; }
  .cs-motion .cs-col--m .cs-lede, .cs-motion .cs-col--a .cs-lede { display: none; }
  .cs-cta { margin-top: 10px; }
  .cs-duel .btn { padding: 0.7rem 1.1rem; font-size: 0.9rem; }
  .cs-motion .cs-col--a .cs-cta .cs-link { display: none; }
  .cs-title { font-size: 1.2rem; margin-top: 2px; }
  .cs-text { font-size: 0.85rem; margin-top: 4px; }
  .cs-desk { overflow: hidden; padding-top: 4px; }
  .cs-col--m .cs-doc { rotate: 0deg; }
  .cs-doc { padding: 10px 14px; font-size: 0.75rem; width: 100%; }
  .cs-row { grid-template-columns: 80px 1fr 16px; min-height: 18px; }
  .cs-row.opt, .cs-human, .cs-sheet, .cs-d-top { display: none; }
  .cs-rows { gap: 3px; }
  .cs-doc-head { margin-bottom: 6px; }
  .cs-status { margin-top: 6px; font-size: 0.75rem; }
  .cs-clock { padding-top: 6px; }
  .cs-clock-v { font-size: 1.35rem; }
  .cs-divider { left: 0; right: 0; top: calc(var(--split) * 100%); bottom: auto; height: 0; width: auto; }
  .cs-divider .line { left: 0; right: 0; top: -0.5px; bottom: auto; width: auto; height: 1px; }
  .cs-divider .fill { top: -1px; left: 0; height: 2px; width: calc(var(--prog, 0) * 100%); }
  .cs-chip { top: 0; left: 50%; transform: translate(-50%, -50%); font-size: 0.68rem; }
  .cs-stage[data-phase="resolve"] .cs-copy, .cs-stage[data-phase="collapse"] .cs-copy { padding-top: 3vh; }
  .cs-big-total { font-size: 2.6rem; }
  .cs-total-note { font-size: 0.88rem; }
  .cs-calc-wrap { grid-template-columns: 1fr; }
  .cs-results { position: relative; top: 0; }
  .cs-res-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) and (max-height: 840px) {
  .cs-row.opt2 { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-layer { transition: none; }
  .cs-caret { animation: none; }
}
