/* Página de curso: Software estadístico R (solo empresas). Identidad propia: los paneles de
   RStudio (consola, entorno, script y gráficos) y el operador de asignación <- como firma. */
.c-software-r {
  --rb: #2a68b8; --rb-soft: color-mix(in srgb, #2a68b8 12%, var(--surface)); --rb-str: #1d7f4e; --rb-kw: #8a3fb8;
  --rb-pane: var(--surface); --rb-bar: color-mix(in srgb, var(--line) 55%, var(--surface));
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] .c-software-r { --rb: #6aa5ee; --rb-str: #7fd6a3; --rb-kw: #d1a3f5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .c-software-r { --rb: #6aa5ee; --rb-str: #7fd6a3; --rb-kw: #d1a3f5; } }

.c-software-r .c-hero h1 { font-size: clamp(2.2rem, 1.3rem + 2.8vw, 3.6rem); max-width: 17ch; }
.c-software-r .c-hero h1 em, .c-software-r h2 em { color: var(--rb); }
.c-software-r .cs-step-n { font-family: var(--mono); font-size: .86rem; color: var(--rb); letter-spacing: 0; }
.c-software-r .gain-list span { -webkit-text-stroke-color: var(--rb); }

.c-solo-emp { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 6px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--ink); background: var(--rb-soft); border: 1px solid color-mix(in srgb, var(--rb) 40%, var(--line)); }
.c-solo-emp::before { content: "<-"; font-family: var(--mono); font-weight: 700; color: var(--rb); }

/* ---------- Portada: consola que escribe ---------- */
.rb-console { position: absolute; right: -20px; bottom: -26px; width: min(78%, 340px); border-radius: 14px; overflow: hidden; background: var(--rb-pane); border: 1px solid var(--line); box-shadow: var(--shadow); font-family: var(--mono); font-size: .76rem; animation: c-in .8s .5s cubic-bezier(.2, .8, .2, 1) both; }
.rb-console-bar { display: flex; justify-content: space-between; padding: 6px 12px; font-size: .68rem; color: var(--muted); background: var(--rb-bar); border-bottom: 1px solid var(--line); }
.rb-console pre { margin: 0; padding: 10px 12px; min-height: 5.2em; line-height: 1.55; white-space: pre-wrap; color: var(--ink); font: inherit; }
.rb-p { color: var(--rb); font-weight: 700; }
.rb-as { color: var(--rb-kw); font-weight: 700; }
.c-software-r u { text-decoration: none; color: var(--rb-str); }
.rb-caret { display: inline-block; width: 7px; height: 1.05em; vertical-align: -2px; background: var(--rb); animation: rb-blink 1s steps(1) infinite; }
@keyframes rb-blink { 50% { opacity: 0; } }

/* ---------- Historia ---------- */
.c-software-r .s2, .c-software-r .s4 { display: block; }
.c-software-r .s5 { padding: 7%; }
.c-software-r .s1.scene { background: repeating-linear-gradient(0deg, transparent 0 27px, color-mix(in srgb, var(--line) 50%, transparent) 27px 28px); }
.c-software-r .s2.scene, .c-software-r .s3.scene, .c-software-r .s4.scene, .c-software-r .s5.scene { background: var(--rb-bar); }
.rb-stage { font-size: .86rem; }
.rb-pane { position: absolute; border-radius: 10px; overflow: hidden; background: var(--rb-pane); border: 1px solid var(--line); box-shadow: 0 8px 20px -14px rgba(16, 42, 67, .45); font-family: var(--mono); font-size: .84rem; }
.rb-pane header { padding: 6px 12px; font-family: var(--f-body); font-size: .76rem; font-weight: 600; color: var(--muted); background: var(--rb-bar); border-bottom: 1px solid var(--line); }
.rb-pane pre { margin: 0; padding: 10px 12px; line-height: 1.6; white-space: pre-wrap; color: var(--ink); font: inherit; }

/* Escena 1 */
.rb-file { position: absolute; display: flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 20px -14px rgba(16, 42, 67, .5); font-family: var(--mono); font-size: .8rem; }
.rb-file b { padding: 2px 6px; border-radius: 5px; font-size: .62rem; color: #fff; background: var(--muted); }
.rb-file.f1 { left: 6%; top: 8%; rotate: -3deg; } .rb-file.f1 b { background: var(--accent); }
.rb-file.f2 { left: 14%; top: 24%; rotate: 2deg; --d: .1s; }
.rb-file.f3 { left: 7%; top: 40%; rotate: -1deg; --d: .2s; } .rb-file.f3 b { background: #1d7044; }
.rb-steps { position: absolute; right: 6%; top: 30%; width: 36%; padding: 12px 14px; border-radius: 10px; background: #fff7d6; color: #4a3b10; box-shadow: 0 10px 20px -14px rgba(0, 0, 0, .4); rotate: 2deg; font-size: .86rem; --d: .3s; }
.rb-steps p { margin: 0; padding: 3px 0; border-bottom: 1px dashed rgba(74, 59, 16, .25); }
.rb-again { position: absolute; left: 6%; bottom: 8%; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .82rem; color: #fff; background: var(--bad); --d: .5s; }
.cs-stage:not([data-step="1"]) .s1 .rb-file, .cs-stage:not([data-step="1"]) .s1 .rb-steps { opacity: 0; transform: translateY(16px); }
.cs-stage:not([data-step="1"]) .rb-again { opacity: 0; }

/* Escena 2 */
.rb-con { left: 5%; top: 6%; width: 56%; }
.rb-env { right: 5%; top: 6%; bottom: 6%; width: 34%; --d: .25s; font-size: .8rem; }
.rb-env p { margin: 0; display: grid; gap: 2px; padding: 8px 12px; border-top: 1px solid var(--line); }
.rb-env p:first-of-type { border-top: 0; }
.rb-env p.o b { color: var(--rb); }
.rb-env i { font-style: normal; color: var(--ink); padding-left: 10px; }
.rb-env span { color: var(--muted); font-size: .72rem; padding-left: 10px; }
.rb-env p.o span { padding-left: 0; }
.s2 .rb-con { top: 6%; }
.cs-stage:not([data-step="2"]) .s2 .rb-pane { opacity: 0; transform: translateY(14px); }

/* Escena 3 */
.rb-wide { left: 5%; right: 5%; top: 6%; width: auto; }
.rb-grid { position: absolute; left: 5%; right: 5%; bottom: 6%; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); font-family: var(--mono); font-size: .84rem; --d: .25s; }
.rb-grid .r, .rb-newcol .r { display: grid; grid-template-columns: repeat(3, 1fr); padding: 7px 14px; border-top: 1px solid var(--line); transition: background-color .5s .6s, opacity .5s .6s; }
.rb-grid .r.h, .rb-newcol .r.h { border-top: 0; font-weight: 700; background: var(--rb-bar); }
.cs-stage[data-step="3"] .rb-grid .r.hit { background: color-mix(in srgb, var(--rb) 16%, var(--surface)); }
.cs-stage[data-step="3"] .rb-grid .r:not(.h):not(.hit) { opacity: .35; }
.cs-stage:not([data-step="3"]) .s3 .rb-pane, .cs-stage:not([data-step="3"]) .s3 .rb-grid { opacity: 0; transform: translateY(14px); }

/* Escena 4 */
.rb-src { left: 5%; right: 5%; top: 6%; }
.rb-ln { display: inline-block; width: 1.6em; color: var(--faint); user-select: none; }
.rb-src b { color: var(--rb-kw); }
.rb-newcol { position: absolute; right: 5%; bottom: 6%; width: 52%; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); font-family: var(--mono); font-size: .84rem; --d: .3s; }
.rb-newcol .r { grid-template-columns: 1fr 1.3fr; }
.rb-newcol .n { color: var(--rb); font-weight: 700; transition: opacity .4s; }
.rb-newcol .r:nth-child(2) .n { transition-delay: .6s; } .rb-newcol .r:nth-child(3) .n { transition-delay: .75s; } .rb-newcol .r:nth-child(4) .n { transition-delay: .9s; } .rb-newcol .r:nth-child(5) .n { transition-delay: 1.05s; }
.cs-stage:not([data-step="4"]) .rb-newcol .n { opacity: 0; }
.cs-stage:not([data-step="4"]) .s4 .rb-pane, .cs-stage:not([data-step="4"]) .s4 .rb-newcol { opacity: 0; transform: translateY(14px); }

/* Escena 5 */
.rb-sum { left: 5%; right: 5%; top: 6%; }
.rb-sum pre { white-space: pre; overflow: hidden; font-size: .76rem; }
.rb-plot { left: 5%; bottom: 6%; width: 54%; height: 54%; display: grid; grid-template-rows: auto 1fr auto; --d: .2s; }
.rb-plot small { padding: 2px 10px 6px; font-size: .62rem; color: var(--muted); }
.rb-hist { display: flex; align-items: flex-end; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); margin: 0 10px; }
.rb-hist i { flex: 1; height: var(--h); background: color-mix(in srgb, var(--rb) 70%, var(--surface)); border: 1px solid var(--rb); border-bottom: 0; transform-origin: bottom; transition: transform .7s cubic-bezier(.2, .8, .2, 1); }
.rb-hist i:nth-child(2n) { transition-delay: .08s; } .rb-hist i:nth-child(3n) { transition-delay: .16s; }
.cs-stage:not([data-step="5"]) .rb-hist i { transform: scaleY(0); }
.rb-out { position: absolute; right: 5%; bottom: 6%; width: 36%; padding: 10px 12px; border-radius: 10px; background: var(--deep); color: var(--on-deep); font-family: var(--mono); font-size: .8rem; line-height: 1.45; --d: .5s; }
.rb-out u { color: #8fe0b0; } .rb-out .rb-p { color: var(--on-deep-accent); }
.rb-out b { color: #7ee2a8; }
.cs-stage:not([data-step="5"]) .s5 .rb-pane, .cs-stage:not([data-step="5"]) .s5 .rb-out { opacity: 0; transform: translateY(14px); }

/* ---------- Programa ---------- */
.c-software-r .unit-n { font-family: var(--mono); text-transform: none; letter-spacing: 0; color: var(--rb); }
.c-software-r .unit li::before { background: var(--rb); }
.c-software-r .unit code { font-family: var(--mono); font-size: .86em; padding: 1px 5px; border-radius: 5px; color: var(--rb); background: var(--rb-soft); }
.rb-dots { grid-template-columns: repeat(8, 1fr); max-width: 240px; gap: 6px; }
.c-software-r .road-classes.on .rb-dots i { background: var(--rb); }
.rb-ico { font-family: var(--mono); font-weight: 700; font-size: .95rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) { .rb-console { right: -8px; } }
@media (max-width: 560px) {
  .rb-stage { font-size: .72rem; }
  .rb-console { font-size: .66rem; width: 82%; bottom: -30px; }
  .rb-pane { font-size: .56rem; } .rb-pane header { font-size: .56rem; padding: 3px 8px; } .rb-pane pre { padding: 5px 8px; line-height: 1.45; }
  .rb-file { font-size: .58rem; padding: 5px 8px; gap: 5px; } .rb-file b { font-size: .5rem; }
  .rb-file.f2 { left: 18%; top: 22%; } .rb-file.f3 { left: 5%; top: 37%; }
  .rb-steps { font-size: .6rem; padding: 6px 8px; width: 42%; top: 28%; } .rb-steps p { padding: 2px 0; }
  .rb-again { font-size: .66rem; padding: 6px 10px; bottom: 6%; }
  .rb-con { width: 58%; } .rb-env { width: 34%; font-size: .54rem; bottom: auto; } .rb-env p { padding: 3px 6px; } .rb-env span { font-size: .5rem; padding-left: 6px; } .rb-env i { padding-left: 6px; }
  .rb-grid, .rb-newcol { font-size: .56rem; } .rb-grid .r, .rb-newcol .r { padding: 2px 8px; }
  .rb-sum pre { font-size: .48rem; } .rb-plot { height: 50%; }
  .rb-out { font-size: .54rem; padding: 6px 8px; width: 38%; }
}
@media (prefers-reduced-motion: reduce) {
  .rb-console, .rb-caret { animation: none !important; }
  .rb-hist i, .rb-newcol .n, .rb-grid .r { transition: none !important; }
}
