/* Página de curso: Análisis de datos con Python. Identidad propia: notebook claro con celdas In [n],
   dataframes como salida y los colores de Python (azul y amarillo). */
.c-analisis-datos-python {
  --py-blue: #2f6ea5; --py-yellow: #f2c230; --py-yel-soft: #fff4c7;
  --nb-paper: #ffffff; --nb-cell: #f5f7fa; --nb-str: #a8551b; --nb-kw: #7b2fb8; --nb-ink: #1d2b3a;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] .c-analisis-datos-python { --py-blue: #7fb4e6; --py-yel-soft: #3a3214; --nb-paper: #0f1b28; --nb-cell: #16263a; --nb-str: #f0a872; --nb-kw: #c9a2ff; --nb-ink: #dde8f2; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .c-analisis-datos-python { --py-blue: #7fb4e6; --py-yel-soft: #3a3214; --nb-paper: #0f1b28; --nb-cell: #16263a; --nb-str: #f0a872; --nb-kw: #c9a2ff; --nb-ink: #dde8f2; }
}

/* Detalle tipográfico: el <em> del título subrayado con el amarillo de Python, y pasos como prompts */
.c-analisis-datos-python .c-hero h1 { font-size: clamp(2.2rem, 1.3rem + 2.8vw, 3.5rem); max-width: 18ch; }
.c-analisis-datos-python h1 em, .c-analisis-datos-python h2 em { color: var(--py-blue); }
.c-analisis-datos-python .c-hero h1 em { background: linear-gradient(transparent 68%, color-mix(in srgb, var(--py-yellow) 55%, transparent) 68% 92%, transparent 92%); width: fit-content; }
.c-analisis-datos-python .cs-step-n { font-family: var(--mono); color: var(--py-blue); letter-spacing: 0; }

/* ---------- Portada: celda flotante que se ejecuta ---------- */
.an-cell {
  position: absolute; left: -24px; bottom: -30px; width: min(80%, 370px); border-radius: 14px; overflow: hidden;
  background: var(--nb-paper); color: var(--nb-ink); border: 1px solid var(--line); border-left: 5px solid var(--py-blue);
  box-shadow: 0 24px 50px -20px rgba(10, 30, 60, .5); font-family: var(--mono); font-size: .74rem;
  animation: c-in .8s .5s cubic-bezier(.2, .8, .2, 1) both;
}
.an-cell-in { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 10px 12px; background: var(--nb-cell); }
.an-cell-in pre { margin: 0; white-space: pre-wrap; min-height: 2.8em; font: inherit; line-height: 1.5; }
.an-prompt { font-family: var(--mono); font-size: .7rem; color: var(--py-blue); white-space: nowrap; padding-top: 1px; }
.an-caret { display: inline-block; width: 6px; height: 1em; vertical-align: -2px; background: var(--py-blue); animation: an-blink 1s steps(1) infinite; }
.an-cell-out { padding: 8px 12px 10px 12px; min-height: 5.6em; opacity: 0; transition: opacity .4s; }
.an-cell-out.on { opacity: 1; }
.an-cell-out .r { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 2px 0; font-variant-numeric: tabular-nums; }
.an-cell-out .r.h { color: var(--muted); border-bottom: 1px solid var(--line); }
.an-cell-out .r:nth-child(even):not(.h) { background: color-mix(in srgb, var(--py-blue) 6%, transparent); }
.an-cell code b, .an-nb code b { color: var(--nb-kw); font-weight: 600; }
.an-cell code u, .an-nb code u { color: var(--nb-str); text-decoration: none; }
@keyframes an-blink { 50% { opacity: 0; } }

/* ---------- Historia ---------- */
.an-stage { font-size: .86rem; }
.c-analisis-datos-python .s1 { background: repeating-linear-gradient(0deg, transparent 0 27px, color-mix(in srgb, var(--line) 45%, transparent) 27px 28px); }
.c-analisis-datos-python .s2, .c-analisis-datos-python .s4 { display: block; }
.c-analisis-datos-python .s5 { padding: 7%; }
.c-analisis-datos-python .s2, .c-analisis-datos-python .s3, .c-analisis-datos-python .s4, .c-analisis-datos-python .s5 { background: var(--nb-paper); }

/* Escena 1 */
.an-todo { position: absolute; left: 7%; top: 9%; width: 72%; padding: 16px 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.an-todo header { font-weight: 700; font-size: .9rem; display: flex; gap: 8px; align-items: baseline; }
.an-todo header b { font-size: .72rem; padding: 2px 8px; border-radius: 999px; color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--surface)); }
.an-todo ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 7px; }
.an-todo li { display: flex; gap: 10px; align-items: center; font-size: .8rem; color: var(--muted); }
.an-todo li::before { content: ""; flex: none; width: 13px; height: 13px; border-radius: 3px; border: 1.6px solid var(--faint); }
.an-todo code { font-family: var(--mono); font-size: .72rem; color: #1d7044; }
:root[data-theme="dark"] .an-todo code { color: #7fd19e; }
.an-timer { position: absolute; right: 7%; bottom: 9%; display: grid; padding: 12px 16px; border-radius: 14px; background: var(--deep); color: var(--on-deep); --d: .25s; }
.an-timer b { font-family: var(--f-display); font-size: 1.9rem; line-height: 1; color: var(--py-yellow); }
.an-timer span { font-size: .74rem; opacity: .85; }
.cs-stage:not([data-step="1"]) .s1 .an-todo { opacity: 0; transform: translateY(24px); }
.cs-stage:not([data-step="1"]) .s1 .an-timer { opacity: 0; transform: scale(.85); }

/* Notebook genérico de las escenas */
.an-nb { display: grid; gap: 8px; font-family: var(--mono); color: var(--nb-ink); }
.an-row { display: grid; grid-template-columns: 4.6em 1fr; gap: 6px; align-items: start; padding: 8px 10px; border-radius: 8px; background: var(--nb-cell); border-left: 4px solid transparent; }
.an-row:last-of-type { border-left-color: var(--py-blue); }
.an-row pre { margin: 0; white-space: pre-wrap; font: inherit; font-size: .74rem; line-height: 1.55; }
.an-out { margin-left: 5.6em; font-size: .74rem; --d: .3s; }
.cs-stage .scene .an-nb > * { transition: opacity .5s, transform .6s cubic-bezier(.2, .8, .2, 1); }
.cs-stage .scene .an-nb > :nth-child(2) { transition-delay: .15s; } .cs-stage .scene .an-nb > :nth-child(3) { transition-delay: .3s; } .cs-stage .scene .an-nb > :nth-child(4) { transition-delay: .45s; }
.cs-stage:not([data-step="2"]) .s2 .an-nb > *, .cs-stage:not([data-step="3"]) .s3 .an-nb > *,
.cs-stage:not([data-step="4"]) .s4 .an-nb > *, .cs-stage:not([data-step="5"]) .s5 .an-nb > * { opacity: 0; transform: translateY(12px); }

.an-info p { margin: 0 0 6px; color: var(--muted); }
.an-info dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 16px; }
.an-info dt { color: var(--nb-ink); } .an-info dd { margin: 0; color: var(--py-blue); }

.an-df { border-collapse: collapse; font-variant-numeric: tabular-nums; width: 100%; }
.an-df th, .an-df td { padding: 5px 9px; text-align: right; border-bottom: 1px solid var(--line); }
.an-df thead th { color: var(--muted); font-weight: 600; }
.an-df tbody th { text-align: left; font-weight: 600; }
.an-df tbody tr:nth-child(odd) { background: color-mix(in srgb, var(--py-blue) 6%, transparent); }
.an-df td:nth-child(4) { color: var(--py-blue); }

.an-desc { display: grid; grid-template-columns: auto auto auto auto; gap: 3px 14px; justify-content: start; }
.an-desc span { color: var(--muted); } .an-desc b { font-weight: 600; text-align: right; }
.an-corr { display: flex; align-items: center; gap: 12px; }
.an-corr b { font-size: 1.5rem; font-family: var(--f-display); color: var(--py-blue); }
.an-corr span { font-family: var(--f-body); color: var(--muted); font-size: .8rem; padding: 6px 10px; border-radius: 8px; background: var(--py-yel-soft); }

.an-plot { position: relative; padding: 8px 0 0; }
.an-plot svg { width: 100%; height: 130px; display: block; }
.an-grid path { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.an-line { fill: none; stroke: var(--py-blue); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-dasharray: 600; stroke-dashoffset: 600; transition: stroke-dashoffset 1.4s .5s ease; }
.cs-stage[data-step="5"] .an-line { stroke-dashoffset: 0; }
.an-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .66rem; }
.an-run { position: absolute; left: 7%; right: 7%; bottom: 7%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--py-yel-soft); color: var(--nb-ink); font-weight: 700; font-size: .84rem; --d: .9s; }
.an-run small { font-weight: 500; color: var(--muted); font-size: .74rem; }
.an-play { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--py-blue); color: #fff; font-size: .7rem; }
:root[data-theme="dark"] .an-play { color: #0f1b28; }
.cs-stage:not([data-step="5"]) .s5 .an-run { opacity: 0; transform: translateY(14px); }

/* ---------- Programa ---------- */
.c-analisis-datos-python .unit-n { font-family: var(--mono); text-transform: none; letter-spacing: 0; color: var(--py-blue); }
.c-analisis-datos-python .unit-n::before { content: "# "; opacity: .6; }
.c-analisis-datos-python .unit li::before { background: var(--py-yellow); }
.c-analisis-datos-python .unit code { font-family: var(--mono); font-size: .86em; padding: 1px 5px; border-radius: 5px; color: var(--py-blue); background: color-mix(in srgb, var(--py-blue) 10%, var(--surface)); }
.c-analisis-datos-python .an-unit-main { background: var(--nb-paper); border-left: 5px solid var(--py-blue); }
.unit--span2 { grid-column: span 2; }
.an-chips { display: flex !important; flex-wrap: wrap; gap: 8px !important; }
.an-chips li { padding: 6px 12px !important; border-radius: 999px; background: var(--py-yel-soft); color: var(--ink); }
.an-chips li::before { display: none; }
.an-road { grid-template-columns: 1.5fr 1fr 1fr; }
.an-road .dots { grid-template-columns: repeat(12, 1fr); }
.an-path-note { margin-top: 18px; color: var(--muted); }
.an-path-note a { color: var(--accent); font-weight: 600; }

@media (max-width: 900px) {
  .an-cell { left: -10px; bottom: -24px; width: 76%; }
  .an-road { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .unit--span2 { grid-column: auto; }
  .an-stage { font-size: .76rem; }
  .an-cell { font-size: .64rem; } .an-cell-out { min-height: 4.8em; }
  .an-todo { width: 84%; padding: 10px 12px; top: 6%; } .an-todo header { font-size: .76rem; } .an-todo ul { gap: 4px; margin-top: 6px; } .an-todo li { font-size: .66rem; } .an-todo code { font-size: .6rem; }
  .an-timer { padding: 8px 12px; } .an-timer b { font-size: 1.3rem; } .an-timer span { font-size: .64rem; }
  .an-nb { gap: 5px; }
  .an-row { grid-template-columns: 1fr; gap: 1px; padding: 5px 8px; }
  .an-prompt { font-size: .58rem; }
  .an-row pre { font-size: .6rem; line-height: 1.4; }
  .an-out { margin-left: 0; font-size: .62rem; }
  .an-df th, .an-df td { padding: 3px 5px; }
  .an-corr b { font-size: 1.1rem; } .an-corr span { font-size: .64rem; padding: 4px 8px; }
  .an-plot svg { height: 70px; }
  .an-run { font-size: .7rem; padding: 7px 10px; } .an-run small { font-size: .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .an-cell, .an-caret { animation: none !important; }
  .an-line, .an-cell-out, .cs-stage .scene .an-nb > * { transition: none !important; }
}

/* Barra del notebook y tamaño en escritorio */
.an-nb::before { content: "ventas.ipynb  ·  Python 3"; display: block; padding: 0 0 8px; margin-bottom: 2px; border-bottom: 1px solid var(--line); font-size: .7rem; color: var(--muted); white-space: pre; }
@media (min-width: 901px) {
  .an-row pre, .an-out { font-size: .82rem; }
  .an-plot svg { height: 170px; }
}
:root[data-theme="dark"] .c-analisis-datos-python .c-hero h1 em { background: linear-gradient(transparent 70%, color-mix(in srgb, var(--py-yellow) 30%, transparent) 70% 92%, transparent 92%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .c-analisis-datos-python .c-hero h1 em { background: linear-gradient(transparent 70%, color-mix(in srgb, var(--py-yellow) 30%, transparent) 70% 92%, transparent 92%); } }
