/* Página de curso: Machine Learning I. Identidad propia: puntos que se agrupan en clusters, variables que
   ganan o pierden importancia y probabilidades que salen de un modelo. Acento magenta y colores de cluster. */
.c-machine-learning {
  --ml: #b8336f; --ml-soft: #fbe3ee; --ml-c1: #b8336f; --ml-c2: #1f9e8f; --ml-c3: #e08a1e; --ml-hi: #c2462e;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] .c-machine-learning { --ml: #f07aab; --ml-soft: #3a1c2a; --ml-c1: #f07aab; --ml-c2: #3cc4b8; --ml-c3: #ffb45c; --ml-hi: #ef7a62; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .c-machine-learning { --ml: #f07aab; --ml-soft: #3a1c2a; --ml-c1: #f07aab; --ml-c2: #3cc4b8; --ml-c3: #ffb45c; --ml-hi: #ef7a62; }
}

/* Detalle tipográfico: el <em> se apoya sobre una nube de puntos; pasos como iteraciones de entrenamiento */
.c-machine-learning .c-hero h1 { font-size: clamp(2.2rem, 1.3rem + 2.7vw, 3.4rem); max-width: 18ch; }
.c-machine-learning h1 em, .c-machine-learning h2 em { color: var(--ml); }
.c-machine-learning .c-hero h1 em { padding-bottom: .18em; background: radial-gradient(circle, var(--ml-c1) 1.6px, transparent 2.2px) 0 100% / 11px 7px repeat-x, radial-gradient(circle, var(--ml-c2) 1.6px, transparent 2.2px) 5px calc(100% - 4px) / 13px 7px repeat-x; width: fit-content; }
.c-machine-learning .cs-step-n { font-family: var(--mono); color: var(--ml); letter-spacing: 0; }

/* ---------- Portada: un cliente nuevo pasa por el modelo ---------- */
.ml-score {
  position: absolute; left: -24px; bottom: -34px; width: min(78%, 340px); padding: 12px 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 24px 50px -20px rgba(10, 30, 60, .5);
  font-size: .76rem; animation: c-in .8s .5s cubic-bezier(.2, .8, .2, 1) both;
}
.ml-score header { display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: .68rem; color: var(--muted); }
.ml-score header b { color: var(--ink); font-weight: 600; }
.ml-feats { margin: 8px 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 5px; transition: opacity .3s; }
.ml-feats li { padding: 3px 8px; border-radius: 999px; background: var(--sky); color: var(--muted); font-size: .68rem; }
.ml-feats b { color: var(--ink); }
.ml-prob { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.ml-prob i { display: block; height: 100%; width: calc(var(--p) * 100%); border-radius: 99px; background: linear-gradient(90deg, var(--ml-c2), var(--ml-c3) 55%, var(--ml-hi)); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.ml-out { margin: 7px 0 0; display: flex; align-items: center; gap: 8px; }
.ml-out span { font-family: var(--f-display); font-weight: 700; font-size: 1.2rem; }
.ml-out b { padding: 2px 8px; border-radius: 999px; font-size: .68rem; color: #fff; background: var(--ml-c2); }
.ml-out b.hi { background: var(--ml-hi); } .ml-out b.mid { background: var(--ml-c3); }
:root[data-theme="dark"] .ml-out b { color: #1a0f14; }

/* ---------- Historia ---------- */
.ml-stage { font-size: .86rem; }
.c-machine-learning .s1 { background: none; }
.c-machine-learning .s2, .c-machine-learning .s4 { display: block; }
.c-machine-learning .s5 { padding: 7%; }
.ml-cap { margin: 0 0 8px; font-family: var(--mono); font-size: .72rem; color: var(--ml); }

/* Escena 1 */
.ml-tbl { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); font-size: .78rem; }
.ml-tbl .r { display: grid; grid-template-columns: 1fr 1fr .8fr .9fr; padding: 7px 12px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; transition: opacity .4s, transform .5s; }
.ml-tbl .r.h { border-top: 0; background: var(--sky); color: var(--muted); font-weight: 600; }
.ml-tbl .r span:first-child { font-family: var(--mono); }
.ml-tbl .si { color: var(--ml-hi); font-weight: 700; } .ml-tbl .no { color: var(--muted); }
.ml-tbl .r.now { background: var(--ml-soft); }
.ml-tbl .q { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 700; color: #fff; background: var(--ml); animation: ml-pulse 1.8s ease-in-out infinite; }
:root[data-theme="dark"] .ml-tbl .q { color: #1a0f14; }
.ml-late { position: absolute; left: 7%; right: 7%; bottom: 7%; margin: 0; padding: 9px 14px; border-radius: 12px; background: var(--deep); color: var(--on-deep); font-size: .82rem; text-align: center; --d: .35s; }
.ml-late b { color: var(--on-deep-accent); }
.cs-stage:not([data-step="1"]) .s1 > * { opacity: 0; transform: translateY(18px); }
@keyframes ml-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ml) 0%, transparent); } 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ml) 40%, transparent); } }

/* Escena 2 */
.ml-newcols { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.ml-newcols span { padding: 6px 10px; border-radius: 8px; font-family: var(--mono); font-size: .72rem; background: var(--surface); border: 1px solid var(--line); transition: opacity .4s, transform .5s; }
.ml-newcols .n { border-color: var(--ml); background: var(--ml-soft); }
.ml-newcols .n::before { content: "+ "; color: var(--ml); font-weight: 700; }
.ml-newcols span:nth-child(2) { transition-delay: .15s; } .ml-newcols span:nth-child(3) { transition-delay: .3s; } .ml-newcols span:nth-child(4) { transition-delay: .45s; }
.cs-stage:not([data-step="2"]) .ml-newcols .n { opacity: 0; transform: translateY(10px); }
.ml-imp { display: grid; gap: 7px; }
.ml-imp div { display: grid; grid-template-columns: 9.5em 1fr; align-items: center; gap: 10px; font-family: var(--mono); font-size: .72rem; }
.ml-imp i { height: 14px; width: var(--w); border-radius: 0 6px 6px 0; background: var(--ml); transform-origin: 0 50%; transition: transform .8s .6s cubic-bezier(.2, .8, .2, 1); }
.ml-imp .off span { color: var(--faint); text-decoration: line-through; } .ml-imp .off i { background: var(--faint); }
.cs-stage:not([data-step="2"]) .ml-imp i { transform: scaleX(0); }
.cs-stage:not([data-step="2"]) .s2 .ml-cap, .cs-stage:not([data-step="2"]) .s2 .ml-imp { opacity: 0; }

/* Escena 3: clustering */
.ml-scatter { width: 100%; height: auto; max-height: 72%; display: block; }
.ml-axes path { fill: none; stroke: var(--line); stroke-width: 1.2; }
.ml-pts circle { fill: var(--faint); transition: fill .6s, transform .8s cubic-bezier(.2, .8, .2, 1); transform-box: fill-box; transform-origin: center; }
.cs-stage[data-step="3"] .ml-pts .c1 { fill: var(--ml-c1); transition-delay: .5s; }
.cs-stage[data-step="3"] .ml-pts .c2 { fill: var(--ml-c2); transition-delay: .7s; }
.cs-stage[data-step="3"] .ml-pts .c3 { fill: var(--ml-c3); transition-delay: .9s; }
.cs-stage:not([data-step="3"]) .ml-pts circle { transform: scale(.4); }
.ml-cent path { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; opacity: 0; transition: opacity .4s 1.2s; }
.cs-stage[data-step="3"] .ml-cent path { opacity: 1; }
.ml-groups { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; --d: 1.1s; }
.ml-groups li { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .74rem; }
.ml-groups li::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ml-c1); }
.ml-groups .g2::before { background: var(--ml-c2); } .ml-groups .g3::before { background: var(--ml-c3); }
.cs-stage:not([data-step="3"]) .s3 .ml-groups, .cs-stage:not([data-step="3"]) .s3 .ml-cap { opacity: 0; }

/* Escena 4: regresión y clasificación */
.ml-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ml-panel { display: grid; align-content: start; gap: 6px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); transition: opacity .5s, transform .6s cubic-bezier(.2, .8, .2, 1); }
.ml-panel:nth-child(2) { transition-delay: .15s; }
.ml-panel small { font-size: .7rem; color: var(--muted); }
.ml-panel svg { width: 100%; height: auto; }
.ml-reg circle { fill: var(--ml-c2); }
.ml-fit { stroke: var(--ml); stroke-width: 2.2; stroke-dasharray: 110; stroke-dashoffset: 110; transition: stroke-dashoffset 1s .6s ease; }
.cs-stage[data-step="4"] .ml-fit { stroke-dashoffset: 0; }
.ml-cm { display: grid; grid-template-columns: auto 1fr 1fr; gap: 3px; font-size: .66rem; }
.ml-cm .h { color: var(--muted); padding: 3px 4px; align-self: center; }
.ml-cm b { display: grid; place-items: center; padding: 10px 4px; border-radius: 6px; font-family: var(--mono); font-size: .82rem; background: var(--sky); }
.ml-cm b.ok { background: color-mix(in srgb, var(--ml-c2) 28%, var(--surface)); }
.ml-split { display: flex; margin-top: 14px; height: 26px; border-radius: 8px; overflow: hidden; font-family: var(--mono); font-size: .7rem; font-weight: 600; --d: .5s; }
.ml-split span { display: grid; place-items: center; }
.ml-split .tr { flex: 4; background: var(--ml); color: #fff; } .ml-split .te { flex: 1; background: var(--ml-c3); color: #1a1206; }
:root[data-theme="dark"] .ml-split .tr { color: #1a0f14; }
.cs-stage:not([data-step="4"]) .s4 .ml-panel { opacity: 0; transform: translateY(16px); }
.cs-stage:not([data-step="4"]) .s4 .ml-split { opacity: 0; }

/* Escena 5: producción */
.ml-flow { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; counter-reset: f; }
.ml-flow li { position: relative; padding: 9px 6px; border-radius: 10px; text-align: center; font-size: .72rem; font-weight: 600; background: var(--surface); border: 1px solid var(--line); transition: background .4s, border-color .4s, color .4s; }
.ml-flow li:not(:last-child)::after { content: "→"; position: absolute; right: -9px; top: 50%; translate: 0 -50%; color: var(--ml); font-size: .8rem; z-index: 1; }
.cs-stage[data-step="5"] .ml-flow li { border-color: var(--ml); }
.cs-stage[data-step="5"] .ml-flow li:nth-child(2) { transition-delay: .2s; } .cs-stage[data-step="5"] .ml-flow li:nth-child(3) { transition-delay: .4s; } .cs-stage[data-step="5"] .ml-flow li:nth-child(4) { transition-delay: .6s; }
.cs-stage[data-step="5"] .ml-flow .prod { background: var(--ml); color: #fff; }
:root[data-theme="dark"] .cs-stage[data-step="5"] .ml-flow .prod { color: #1a0f14; }
.ml-live { margin-top: 16px; display: grid; gap: 8px; --d: .6s; }
.ml-live .r { display: grid; grid-template-columns: 4.2em 1fr 3em; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-family: var(--mono); font-size: .74rem; }
.ml-live i { position: relative; height: 8px; border-radius: 99px; overflow: hidden; background: var(--line); }
.ml-live i::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--p) * 100%); border-radius: 99px; background: linear-gradient(90deg, var(--ml-c2), var(--ml-c3) 55%, var(--ml-hi)); transform-origin: 0 50%; transition: transform .9s .8s cubic-bezier(.2, .8, .2, 1); }
.cs-stage:not([data-step="5"]) .ml-live i::before { transform: scaleX(0); }
.ml-live b { text-align: right; } .ml-live b.hi { color: var(--ml-hi); } .ml-live b.mid { color: var(--ml-c3); }
.ml-v1 { position: absolute; right: 7%; bottom: 7%; margin: 0; padding: 8px 14px; border-radius: 999px; background: var(--deep); color: var(--on-deep); font-family: var(--mono); font-size: .74rem; --d: .9s; }
.ml-v1::before { content: "● "; color: #3ecf8e; }
.cs-stage:not([data-step="5"]) .s5 .ml-live, .cs-stage:not([data-step="5"]) .s5 .ml-v1 { opacity: 0; transform: translateY(14px); }

/* ---------- Programa ---------- */
.c-machine-learning .unit-n { font-family: var(--mono); text-transform: lowercase; letter-spacing: 0; color: var(--ml); }
.c-machine-learning .unit li::before { background: var(--ml); }
.ml-units .ml-unit-flow { grid-row: auto; background: var(--ml-soft); border-color: color-mix(in srgb, var(--ml) 30%, transparent); }
.ml-mini-flow { margin: 2px 0 4px; padding: 0; list-style: none; display: flex; gap: 22px; }
.ml-mini-flow li { position: relative; padding: 5px 12px; border-radius: 8px; font-family: var(--mono); font-size: .8rem; background: var(--surface); border: 1px solid var(--line); }
.ml-mini-flow li:first-child::after { content: "→"; position: absolute; right: -18px; color: var(--ml); }
.ml-road { grid-template-columns: 2fr 1fr; }

@media (max-width: 900px) {
  .ml-score { left: -10px; bottom: -26px; width: 74%; }
  .ml-road { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .ml-stage { font-size: .76rem; }
  .ml-score { font-size: .66rem; padding: 9px 11px; } .ml-feats { margin: 5px 0; } .ml-feats li { font-size: .58rem; padding: 2px 6px; } .ml-out span { font-size: .95rem; }
  .ml-cap { font-size: .6rem; margin-bottom: 5px; }
  .ml-tbl { font-size: .62rem; } .ml-tbl .r { padding: 3px 8px; } .ml-tbl .q { width: 16px; height: 16px; font-size: .6rem; }
  .ml-late { font-size: .64rem; padding: 6px 10px; bottom: 5%; }
  .ml-newcols { gap: 4px; margin-bottom: 10px; } .ml-newcols span { font-size: .56rem; padding: 3px 6px; }
  .ml-imp { gap: 4px; } .ml-imp div { grid-template-columns: 8.2em 1fr; font-size: .56rem; gap: 6px; } .ml-imp i { height: 9px; }
  .ml-scatter { max-height: 64%; } .ml-groups { gap: 4px; margin-top: 4px; } .ml-groups li { font-size: .58rem; padding: 2px 7px; }
  .ml-two { gap: 6px; } .ml-panel { padding: 7px; gap: 3px; } .ml-panel small { font-size: .56rem; } .ml-cm { font-size: .5rem; } .ml-cm b { padding: 4px 2px; font-size: .62rem; }
  .ml-split { margin-top: 7px; height: 18px; font-size: .56rem; }
  .ml-flow li { font-size: .52rem; padding: 6px 2px; } .ml-live { margin-top: 8px; gap: 4px; } .ml-live .r { padding: 4px 8px; font-size: .6rem; gap: 6px; }
  .ml-v1 { font-size: .6rem; padding: 5px 10px; bottom: 5%; }
}
@media (prefers-reduced-motion: reduce) {
  .ml-score, .ml-tbl .q { animation: none !important; }
  .ml-prob i, .ml-newcols span, .ml-imp i, .ml-pts circle, .ml-cent path, .ml-panel, .ml-fit, .ml-flow li, .ml-feats { transition: none !important; }
}
.ml-mini-flow li { padding-left: 12px !important; }
.ml-mini-flow li::before { display: none; }
.ml-road .dots { max-width: 420px; }
