/* Página de curso: Calidad de datos. Identidad propia: la planilla con errores marcados con resaltador,
   que se mide, se limpia con OpenRefine y se cuida con normas. Verde de "dato válido" y marcas de corrección. */
.c-calidad-datos {
  --cd: #13845a; --cd-soft: #dcf3e8; --cd-ink: #0b5a3c; --cd-line: #b5e2cc;
  --cd-mark: #ffe066; --cd-dup: #ffd0c2; --cd-nul: #e3e8ee;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] .c-calidad-datos { --cd: #4fd29a; --cd-soft: #12382a; --cd-ink: #a8f0cf; --cd-line: #245c45; --cd-mark: #6b5a12; --cd-dup: #6a2f22; --cd-nul: #2a3a4c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .c-calidad-datos { --cd: #4fd29a; --cd-soft: #12382a; --cd-ink: #a8f0cf; --cd-line: #245c45; --cd-mark: #6b5a12; --cd-dup: #6a2f22; --cd-nul: #2a3a4c; }
}
.c-calidad-datos h1 em, .c-calidad-datos h2 em { color: var(--cd); }
/* Detalle tipográfico: el énfasis del título lleva un trazo de resaltador */
.c-calidad-datos .c-hero h1 em { background: linear-gradient(transparent 62%, color-mix(in srgb, var(--cd-mark) 75%, transparent) 62%, color-mix(in srgb, var(--cd-mark) 75%, transparent) 92%, transparent 92%); -webkit-box-decoration-break: clone; box-decoration-break: clone; display: inline; }
.c-calidad-datos .c-hero h1 { font-size: clamp(2.1rem, 1.2rem + 2.8vw, 3.5rem); max-width: 17ch; }
.c-calidad-datos .c-hero h1 em::before { content: ""; display: block; }
.c-calidad-datos .cs-step-n { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--cd); }
.c-calidad-datos .cs-step-n b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: .74rem; color: #fff; background: var(--cd); }
.c-calidad-datos .cs-step:first-child .cs-step-n { color: var(--bad); }
.c-calidad-datos .cs-step:first-child .cs-step-n b { background: var(--bad); }
.c-calidad-datos .gain-list span { -webkit-text-stroke-color: var(--cd); }
.c-calidad-datos .unit-n { color: var(--cd); }
.c-calidad-datos .unit li::before { content: "✓"; width: auto; height: auto; top: 0; background: none; color: var(--cd); font-weight: 700; font-size: .8rem; }

/* ---------- Portada: el puntaje de calidad que sube ---------- */
.cd-score {
  position: absolute; left: -24px; bottom: -28px; width: min(70%, 270px); padding: 14px 16px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 4px;
  animation: c-in .8s .5s cubic-bezier(.2, .8, .2, 1) both;
}
.cd-score small { font-size: .74rem; color: var(--muted); }
.cd-score b { font-family: var(--f-display); font-size: 2rem; line-height: 1.1; color: var(--bad); transition: color .4s; font-variant-numeric: tabular-nums; }
.cd-score b.good { color: var(--cd); }
.cd-score ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; font-size: .78rem; }
.cd-score li { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.cd-score li::before { content: ""; width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--line); box-sizing: border-box; transition: background-color .3s, border-color .3s; }
.cd-score li.on { color: var(--ink); }
.cd-score li.on::before { background: var(--cd); border-color: var(--cd); box-shadow: inset 0 0 0 2px var(--surface); }

/* ---------- Historia ---------- */
.cd-stage { font-size: .86rem; }
.c-calidad-datos .s1 { background: none; }
.c-calidad-datos .s2, .c-calidad-datos .s4 { display: block; }
.c-calidad-datos .s5 { padding: 7%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 16px; }

/* Escena 1: planilla con errores */
.cd-tab { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); font-size: .76rem; }
.cd-tab .r { display: grid; grid-template-columns: 1.1fr 1fr 1.3fr .9fr; border-top: 1px solid var(--line); }
.cd-tab .r span { padding: 8px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-tab .r span + span { border-left: 1px solid var(--line); }
.cd-tab .r.h { border-top: 0; background: var(--surface); font-family: var(--mono); font-size: .68rem; color: var(--muted); }
.cd-tab mark { padding: 1px 4px; border-radius: 3px; color: var(--ink); background: var(--cd-mark); text-decoration: underline wavy var(--bad); text-underline-offset: 3px; }
.cd-tab mark.dup { background: var(--cd-dup); text-decoration: none; }
.cd-tab mark.nul { background: var(--cd-nul); color: var(--muted); font-style: italic; text-decoration: none; }
.cd-tab .r { transition: opacity .5s, transform .5s; }
.cd-tab .r:nth-child(3) { transition-delay: .08s; } .cd-tab .r:nth-child(4) { transition-delay: .16s; } .cd-tab .r:nth-child(5) { transition-delay: .24s; }
.cd-legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .72rem; color: var(--muted); --d: .35s; }
.cd-legend li { display: flex; gap: 6px; align-items: center; }
.cd-legend li::before { content: ""; width: 12px; height: 12px; border-radius: 3px; }
.cd-legend .l-fmt::before { background: var(--cd-mark); } .cd-legend .l-dup::before { background: var(--cd-dup); } .cd-legend .l-nul::before { background: var(--cd-nul); }
.cd-alert { position: absolute; right: 7%; bottom: 8%; padding: 9px 14px; border-radius: 12px; background: var(--bad); color: #fff; font-size: .8rem; font-weight: 600; --d: .5s; }
.cs-stage:not([data-step="1"]) .s1 .cd-tab .r { opacity: 0; transform: translateY(12px); }
.cs-stage:not([data-step="1"]) .s1 .cd-legend, .cs-stage:not([data-step="1"]) .s1 .cd-alert { opacity: 0; }

/* Escena 2: medidores por dimensión */
.cd-t { margin: 0 0 16px; font-weight: 600; font-size: .9rem; }
.cd-dims { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.cd-dims li { display: grid; grid-template-columns: 1fr auto; gap: 6px; font-size: .84rem; }
.cd-dims b { font-family: var(--mono); color: var(--cd-ink); }
.cd-dims i { grid-column: 1 / -1; height: 10px; border-radius: 6px; background: var(--line); position: relative; overflow: hidden; }
.cd-dims i::after { content: ""; position: absolute; inset: 0; width: var(--v); border-radius: 6px; background: linear-gradient(90deg, var(--cd), color-mix(in srgb, var(--cd) 60%, var(--teal))); transform-origin: 0 50%; transition: transform .9s cubic-bezier(.2, .8, .2, 1); }
.cd-dims li:nth-child(2) i::after { transition-delay: .1s; } .cd-dims li:nth-child(3) i::after { transition-delay: .2s; } .cd-dims li:nth-child(4) i::after { transition-delay: .3s; }
.cd-dims li:nth-child(3) i::after { background: linear-gradient(90deg, #e8a700, #f0c24a); }
.cs-stage:not([data-step="2"]) .cd-dims i::after { transform: scaleX(0); }
.cd-foot { position: absolute; left: 7%; right: 7%; bottom: 7%; margin: 0; font-size: .78rem; color: var(--muted); --d: .5s; }
.cs-stage:not([data-step="2"]) .s2 .cd-foot, .cs-stage:not([data-step="2"]) .s2 .cd-t { opacity: 0; }

/* Escena 3: faceta y agrupamiento */
.c-calidad-datos .s3 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; gap: 14px; }
.cd-facet { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.cd-facet header { display: flex; justify-content: space-between; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: .72rem; color: var(--muted); }
.cd-facet header b { font-family: var(--mono); color: var(--ink); }
.cd-facet ul { list-style: none; margin: 0; padding: 6px; display: grid; gap: 3px; }
.cd-facet li { display: flex; justify-content: space-between; padding: 6px 8px; border-radius: 6px; font-family: var(--mono); font-size: .76rem; transition: background-color .5s, transform .6s, opacity .5s; }
.cd-facet li em { font-style: normal; color: var(--muted); }
.cd-facet li:first-child { background: var(--cd-soft); color: var(--cd-ink); font-weight: 700; }
.cs-stage[data-step="3"] .cd-facet li.sim { background: var(--cd-mark); transition-delay: .4s; }
.cd-merge { display: grid; gap: 4px; padding: 14px; border-radius: 14px; background: var(--cd); color: #fff; --d: .6s; }
:root[data-theme="dark"] .cd-merge { color: #062a1b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cd-merge { color: #062a1b; } }
.cd-merge small { font-size: .7rem; opacity: .85; } .cd-merge b { font-size: .96rem; } .cd-merge span { font-family: var(--mono); font-size: .8rem; }
.cs-stage:not([data-step="3"]) .s3 .cd-facet { opacity: 0; transform: translateY(14px); }
.cs-stage:not([data-step="3"]) .s3 .cd-merge { opacity: 0; transform: scale(.9); }

/* Escena 4: GREL y API */
.cd-grel { display: block; padding: 10px 14px; border-radius: 10px; background: var(--deep); color: #8ff0c2; font-family: var(--mono); font-size: .84rem; border: 1px solid color-mix(in srgb, var(--on-deep) 14%, transparent); }
.cd-ba { margin-top: 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; --d: .2s; }
.cd-ba > div { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.cd-ba small { font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cd-ba span { font-family: var(--mono); font-size: .78rem; white-space: pre; }
.cd-ba > div:first-child span { background: var(--cd-mark); justify-self: start; padding: 0 3px; border-radius: 3px; }
.cd-ba .ok { border-color: var(--cd); background: var(--cd-soft); color: var(--cd-ink); }
.cd-ba i { font-style: normal; color: var(--cd); font-weight: 700; }
.cd-api { position: absolute; left: 7%; right: 7%; bottom: 7%; display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1.5px dashed var(--cd); background: var(--surface); --d: .45s; }
.cd-api .tag { padding: 4px 8px; border-radius: 6px; font: 700 .7rem var(--mono); color: #fff; background: var(--teal); }
.cd-api div { display: grid; } .cd-api small { font-size: .68rem; color: var(--muted); } .cd-api b { font-size: .82rem; }
.cs-stage:not([data-step="4"]) .s4 > * { opacity: 0; transform: translateY(12px); }

/* Escena 5: ciclo y norma */
.cd-cycle { width: 100%; height: auto; max-height: 100%; overflow: visible; }
.cd-cycle .ring { fill: none; stroke: var(--line); stroke-width: 6; }
.cd-cycle .arc { fill: none; stroke: var(--cd); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 330; stroke-dashoffset: 330; transition: stroke-dashoffset 1.2s .2s ease; }
.cs-stage[data-step="5"] .cd-cycle .arc { stroke-dashoffset: 0; }
.cd-cycle .nd circle { fill: var(--surface); stroke: var(--cd); stroke-width: 2; }
.cd-cycle .nd text { font: 700 9.5px var(--f-body); fill: var(--ink); text-anchor: middle; }
.cd-norm { padding: 14px; border-radius: 6px 18px 6px 6px; background: var(--bg); border: 1px solid var(--line); box-shadow: 0 14px 30px -18px rgba(16, 42, 67, .45); display: grid; gap: 4px; --d: .4s; }
.cd-norm small { font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cd-norm b { font-size: .92rem; line-height: 1.25; }
.cd-norm ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 5px; font-size: .74rem; color: var(--muted); }
.cd-norm li::before { content: "✓ "; color: var(--cd); font-weight: 700; }
.cs-stage:not([data-step="5"]) .s5 .cd-cycle, .cs-stage:not([data-step="5"]) .s5 .cd-norm { opacity: 0; transform: translateY(14px); }

/* ---------- Programa ---------- */
.c-calidad-datos .cd-unit-org { grid-column: span 4; grid-row: auto; background: var(--cd-soft); border-color: var(--cd-line); }
.c-calidad-datos .cd-unit-org ul { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.c-calidad-datos .cd-unit-org li { padding: 12px 12px 12px 30px; border-radius: 12px; background: var(--surface); color: var(--ink); }
.c-calidad-datos .cd-unit-org li::before { left: 12px; top: 12px; }
@media (min-width: 901px) { .c-calidad-datos .road { grid-template-columns: 1.5fr 1fr; } }
.c-calidad-datos .dots { grid-template-columns: repeat(12, 1fr); max-width: 300px; }
.c-calidad-datos .road-classes.on .dots i { background: var(--cd); }

@media (max-width: 1000px) {
  .c-calidad-datos .cd-unit-org { grid-column: span 2; }
  .c-calidad-datos .cd-unit-org ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .cd-score { left: -10px; bottom: -22px; }
}
@media (max-width: 560px) {
  .cd-stage { font-size: .72rem; }
  .cd-score { padding: 10px 12px; } .cd-score b { font-size: 1.5rem; } .cd-score ul { font-size: .68rem; } .cd-score small { font-size: .64rem; }
  .cd-tab { font-size: .56rem; } .cd-tab .r span { padding: 5px 4px; } .cd-tab .r.h { font-size: .5rem; } .cd-tab mark { padding: 0 2px; }
  .cd-legend { font-size: .56rem; gap: 4px 8px; margin-top: 7px; } .cd-legend li::before { width: 9px; height: 9px; }
  .cd-alert { font-size: .62rem; padding: 6px 9px; bottom: 5%; right: 5%; }
  .cd-t { font-size: .72rem; margin-bottom: 8px; } .cd-dims { gap: 7px; } .cd-dims li { font-size: .66rem; gap: 3px; } .cd-dims i { height: 7px; } .cd-foot { display: none; }
  .c-calidad-datos .s3 { gap: 8px; } .cd-facet header { font-size: .56rem; padding: 5px 8px; } .cd-facet ul { padding: 4px; gap: 1px; } .cd-facet li { font-size: .58rem; padding: 3px 6px; }
  .cd-merge { padding: 9px; } .cd-merge b { font-size: .72rem; } .cd-merge small, .cd-merge span { font-size: .58rem; }
  .cd-grel { font-size: .64rem; padding: 7px 10px; } .cd-ba { margin-top: 8px; gap: 6px; } .cd-ba > div { padding: 6px 8px; } .cd-ba span { font-size: .6rem; } .cd-ba small { font-size: .52rem; }
  .cd-api { padding: 6px 8px; gap: 8px; bottom: 5%; left: 5%; right: 5%; } .cd-api b { font-size: .64rem; } .cd-api small { font-size: .54rem; } .cd-api .tag { font-size: .56rem; }
  .c-calidad-datos .s5 { gap: 8px; padding: 5%; } .cd-norm { padding: 8px; } .cd-norm b { font-size: .7rem; } .cd-norm ul { font-size: .58rem; gap: 3px; }
  .c-calidad-datos .cd-unit-org { grid-column: auto; } .c-calidad-datos .cd-unit-org ul { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .cd-score { animation: none !important; }
  .cd-tab .r, .cd-dims i::after, .cd-facet li, .cd-cycle .arc, .cd-score li::before, .cd-score b { transition: none !important; }
}
