/* CrewReady Academy — motor de presentaciones (sistema visual Nocturne).
   Lo comparten todas las decks de /academia; cada deck solo aporta contenido y diagramas. */

:root {
  --bg: #161826;
  --bg-2: #1c1e2e;
  --card: #232532;
  --card-2: #2a2d3e;
  --line: #34374c;
  --text: #e9e9ed;
  --text-2: #cfd3e5;
  --muted: #9397ab;
  --accent: #b5abfc;
  --accent-2: #9184d9;
  --accent-3: #796cbf;
  --kicker: #968ae0;
  --soft: #d2cefd;
  --num: #4c5397;
  --amber: #ffb547;
  --red: #ff5d6c;
  --ok: #3ddc84;
  --hero: radial-gradient(120% 120% at 12% 18%, #353b80 0%, #262a60 55%, #1e2150 100%);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --pad-x: clamp(16px, 5.7vw, 110px);
  --pad-top: clamp(64px, 7vh, 100px);
  --pad-bottom: clamp(72px, 7vh, 96px);
  --fs-hero: clamp(44px, 6.2vw, 104px);
  --fs-title: clamp(30px, 3.6vw, 64px);
  --fs-sub: clamp(20px, 2.2vw, 40px);
  --fs-body: clamp(16px, 1.45vw, 26px);
  --fs-small: clamp(12px, 1.1vw, 21px);
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- Barra superior ---------- */
.deck-top {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px var(--pad-x);
  background: linear-gradient(180deg, rgba(22, 24, 38, .92), rgba(22, 24, 38, 0));
  pointer-events: none;
}
.deck-top > * { pointer-events: auto; }
.deck-top .brand img { height: 26px; display: block; opacity: .9; }
.deck-top .crumb { font-size: var(--fs-small); color: var(--muted); letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-top .spacer { flex: 1; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 40px; height: 40px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line);
  background: rgba(35, 37, 50, .85); color: var(--text-2);
  cursor: pointer; font-size: 14px; backdrop-filter: blur(8px);
}
.icon-btn:hover { border-color: var(--accent-3); color: var(--text); }
.icon-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Progreso y navegación ---------- */
.deck-progress { position: fixed; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.06); z-index: 30; }
.deck-progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-3), var(--accent)); transition: width .45s cubic-bezier(.2,.7,.2,1); }
.deck-nav {
  position: fixed; right: var(--pad-x); bottom: 18px; z-index: 30;
  display: flex; align-items: center; gap: 10px;
}
.deck-counter { font-family: var(--mono); font-size: 14px; color: var(--muted); min-width: 64px; text-align: center; }

/* ---------- Índice ---------- */
.deck-toc {
  position: fixed; inset: 0 auto 0 0; width: min(380px, 88vw); z-index: 40;
  background: var(--bg-2); border-right: 1px solid var(--line);
  transform: translateX(-102%); transition: transform .35s cubic-bezier(.2,.7,.2,1);
  display: flex; flex-direction: column; padding: 20px 0;
}
.deck-toc.open { transform: none; }
.deck-toc h2 { margin: 0 24px 14px; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--kicker); font-weight: 600; }
.deck-toc ol { list-style: none; margin: 0; padding: 0 12px; overflow: auto; }
.deck-toc li button {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  display: flex; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); font-size: 15px; line-height: 1.3;
}
.deck-toc li button:hover { background: var(--card); }
.deck-toc li button[aria-current="true"] { background: var(--card-2); color: var(--text); }
.deck-toc li .n { font-family: var(--mono); color: var(--num); min-width: 24px; }
.deck-toc li.sec button { color: var(--accent); font-weight: 600; margin-top: 6px; }
.deck-scrim { position: fixed; inset: 0; background: rgba(8, 9, 16, .55); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .3s; }
.deck-scrim.open { opacity: 1; pointer-events: auto; }

/* ---------- Diapositivas ---------- */
.deck { position: fixed; inset: 0; }
.slide {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: var(--pad-top) var(--pad-x) var(--pad-bottom);
  overflow-y: auto; overflow-x: hidden;
  background: var(--bg);
  opacity: 0; visibility: hidden; transform: translateX(40px);
  transition: opacity .45s ease, transform .55s cubic-bezier(.2,.7,.2,1), visibility 0s linear .55s;
}
.slide.is-before { transform: translateX(-40px); }
.slide.is-active { opacity: 1; visibility: visible; transform: none; transition: opacity .45s ease, transform .55s cubic-bezier(.2,.7,.2,1), visibility 0s; }
.slide.hero, .slide.section { background: var(--hero); }
.slide > .inner { width: 100%; max-width: 1700px; margin: auto; display: flex; flex-direction: column; }
.slide .foot-logo { display: none; }
/* Difuminado detrás de la navegación cuando la diapositiva tiene scroll. */
.deck-fade { position: fixed; left: 0; right: 0; bottom: 0; height: 88px; z-index: 25; pointer-events: none; background: linear-gradient(0deg, rgba(22,24,38,.96) 45%, rgba(22,24,38,0)); opacity: 0; transition: opacity .3s; }
.deck-fade.on { opacity: 1; }

/* Entradas escalonadas al activar la diapositiva */
.slide [data-in] { opacity: 0; transform: translateY(18px); }
.slide.is-active [data-in] { animation: cr-in .7s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: calc(var(--d, 0) * 90ms + 120ms); }
@keyframes cr-in { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .slide, .slide.is-active [data-in] { transition: none; animation: none; opacity: 1; transform: none; }
  .slide:not(.is-active) { opacity: 0; }
}

/* ---------- Tipografía ---------- */
.kicker { font-size: var(--fs-small); letter-spacing: .16em; text-transform: uppercase; color: var(--kicker); margin: 0 0 14px; font-weight: 600; }
.hero .kicker { color: var(--soft); letter-spacing: .18em; }
h1.title-hero { font-size: var(--fs-hero); font-weight: 500; line-height: 1.02; margin: 0; letter-spacing: -.02em; }
h2.title { font-size: var(--fs-title); font-weight: 500; line-height: 1.08; margin: 0 0 clamp(20px, 3vh, 44px); letter-spacing: -.01em; text-wrap: balance; }
.subtitle { font-size: var(--fs-sub); color: var(--accent); line-height: 1.3; margin: 18px 0 0; font-weight: 400; }
/* :where() deja la especificidad en cero para que .lead, .small, .note, etc. sí apliquen. */
.body, :where(.slide) p { font-size: var(--fs-body); line-height: 1.5; color: var(--text-2); }
:where(.slide) p { margin: 0 0 .8em; }
.lead { font-size: calc(var(--fs-body) * 1.12); color: var(--text-2); max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); }
.hl { color: var(--accent); }
.divider { height: 1px; margin: clamp(24px, 4vh, 48px) 0; background: linear-gradient(90deg, transparent, #5d5294 48px, #5d5294 calc(100% - 48px), transparent); }
.sec-num { font-size: var(--fs-hero); font-weight: 500; color: var(--num); margin: 0 0 8px; line-height: 1; font-family: var(--mono); }

/* ---------- Bloques ---------- */
.grid { display: grid; gap: clamp(14px, 2vw, 28px); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: clamp(20px, 4vw, 70px); align-items: center; }
.split.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(16px, 1.8vw, 30px); }
.card h3 { margin: 0 0 10px; font-size: calc(var(--fs-body) * 1.15); font-weight: 600; color: var(--text); }
.card p, .card li { font-size: calc(var(--fs-body) * .86); }
.card ul { margin: 0; padding-left: 1.1em; color: var(--text-2); line-height: 1.5; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; letter-spacing: .04em; border: 1px solid currentColor; }
.note { border-left: 3px solid var(--accent-3); padding: 10px 16px; background: rgba(121,108,191,.1); border-radius: 0 10px 10px 0; color: var(--text-2); font-size: calc(var(--fs-body) * .85); }
.note.warn { border-color: var(--amber); background: rgba(255,181,71,.08); }
.big-stat { font-family: var(--mono); font-size: clamp(44px, 6vw, 110px); line-height: 1; color: var(--text); letter-spacing: -.03em; }
.big-stat small { font-size: .35em; color: var(--accent); margin-left: .2em; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text-2); font-size: 15px; text-decoration: none;
}
.btn:hover { border-color: var(--accent-3); color: var(--text); }
.btn[aria-pressed="true"] { background: var(--accent-3); border-color: var(--accent); color: #fff; }
.btn.primary { background: linear-gradient(135deg, #7b5ac7, #5a3fa0); border-color: transparent; color: #fff; font-weight: 600; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* Agenda */
.agenda { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.agenda button { text-align: left; cursor: pointer; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 8px; transition: border-color .2s, transform .2s; }
.agenda button:hover { border-color: var(--accent-3); transform: translateY(-2px); }
.agenda .n { font-family: var(--mono); color: var(--num); font-size: 28px; }
.agenda .t { font-size: 17px; color: var(--text); line-height: 1.25; }

/* ---------- Quiz ---------- */
.quiz { max-width: 980px; width: 100%; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; color: var(--muted); font-size: 14px; font-family: var(--mono); }
.quiz-bar { flex: 1; height: 6px; background: var(--card); border-radius: 99px; overflow: hidden; }
.quiz-bar i { display: block; height: 100%; background: var(--accent-2); transition: width .4s; }
.quiz-q { font-size: calc(var(--fs-body) * 1.2); color: var(--text); line-height: 1.35; margin: 0 0 18px; font-weight: 500; }
.quiz-opts { display: grid; gap: 10px; }
.quiz-opts button {
  text-align: left; cursor: pointer; padding: 14px 18px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); color: var(--text-2); font-size: calc(var(--fs-body) * .9); line-height: 1.35;
  display: flex; gap: 12px; align-items: flex-start; transition: border-color .2s, background .2s;
}
.quiz-opts button:hover:not(:disabled) { border-color: var(--accent-3); }
.quiz-opts button .l { font-family: var(--mono); color: var(--accent); }
.quiz-opts button.ok { border-color: var(--ok); background: rgba(61,220,132,.1); color: var(--text); }
.quiz-opts button.bad { border-color: var(--red); background: rgba(255,93,108,.1); }
.quiz-opts button:disabled { cursor: default; }
.quiz-fb { margin-top: 16px; min-height: 3em; font-size: calc(var(--fs-body) * .88); color: var(--text-2); }
.quiz-fb b.ok { color: var(--ok); } .quiz-fb b.bad { color: var(--red); }
.quiz-actions { margin-top: 12px; display: flex; gap: 10px; }
.quiz-score { text-align: center; padding: 30px 0; }

/* ---------- Flashcards ---------- */
.fc-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; }
.fc { width: min(720px, 100%); aspect-ratio: 16 / 9; perspective: 1400px; cursor: pointer; background: none; border: 0; padding: 0; }
.fc-in { position: relative; width: 100%; height: 100%; transition: transform .6s cubic-bezier(.2,.7,.2,1); transform-style: preserve-3d; }
.fc.flipped .fc-in { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; border: 1px solid var(--line); }
.fc-front { background: var(--hero); font-size: clamp(22px, 2.6vw, 42px); color: var(--text); font-weight: 500; }
.fc-back { background: var(--card); transform: rotateY(180deg); font-size: clamp(15px, 1.4vw, 22px); color: var(--text-2); line-height: 1.5; }
.fc-face .hint { position: absolute; bottom: 14px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.fc-ctrl { display: flex; align-items: center; gap: 14px; font-family: var(--mono); color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4, .agenda { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .g2, .g3, .g4, .split, .split.even { grid-template-columns: minmax(0, 1fr); }
  .agenda { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deck-top .crumb { display: none; }
  .slide > .inner { margin: 0 auto; }
  .deck-nav { right: 16px; bottom: 12px; }
}

/* ---------- Impresión / PDF: una diapositiva por página ---------- */
@media print {
  @page { size: 1920px 1080px; margin: 0; }
  body { overflow: visible; }
  .deck-top, .deck-nav, .deck-progress, .deck-toc, .deck-scrim, .deck-fade, .no-print { display: none !important; }
  .slide .foot-logo { display: block; position: absolute; left: var(--pad-x); bottom: 22px; height: 22px; opacity: .45; }
  .deck { position: static; }
  .slide { position: relative; opacity: 1 !important; visibility: visible !important; transform: none !important; transition: none !important; width: 1920px; height: 1080px; overflow: hidden; page-break-after: always; break-after: page; }
  .slide [data-in] { opacity: 1 !important; transform: none !important; animation: none !important; }
}

/* ---------- Capa técnica desplegable ---------- */
.deep { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(35, 37, 50, .6); }
.deep summary { cursor: pointer; list-style: none; padding: 12px 18px; font-size: 15px; font-weight: 600; color: var(--accent); display: flex; align-items: center; gap: 10px; }
.deep summary::-webkit-details-marker { display: none; }
.deep summary::before { content: "+"; font-family: var(--mono); font-size: 18px; width: 18px; }
.deep[open] summary::before { content: "−"; }
.deep-body { padding: 0 18px 16px 46px; }
.deep-body ul { margin: 0; padding-left: 1.1em; color: var(--text-2); font-size: calc(var(--fs-body) * .8); line-height: 1.5; display: grid; gap: 6px; }
.deep-body .src, .src { margin: 10px 0 0; font-size: 12px; color: var(--muted); letter-spacing: .02em; }

/* ---------- Pasos de procedimiento ---------- */
.steps { margin: 0; padding: 0; list-style: none; counter-reset: st; display: grid; gap: 8px; }
.steps li { counter-increment: st; position: relative; padding: 12px 14px 12px 52px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: calc(var(--fs-body) * .78); line-height: 1.45; transition: color .25s, border-color .25s, opacity .25s; }
.steps li::before { content: counter(st); position: absolute; left: 14px; top: 11px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-family: var(--mono); font-size: 13px; background: var(--card-2); color: var(--muted); }
.steps li b { color: var(--text-2); }
.steps li.done { opacity: .55; }
.steps li.done::before { content: "✓"; color: var(--ok); }
.steps li.now { color: var(--text-2); border-color: var(--accent); }
.steps li.now::before { background: var(--accent-3); color: #fff; }
.steps li.now b { color: var(--text); }
.steps li.next { display: none; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { padding-left: 26px; position: relative; color: var(--text-2); font-size: calc(var(--fs-body) * .82); }
.checks li::before { content: ""; position: absolute; left: 0; top: .35em; width: 12px; height: 12px; border: 2px solid var(--accent-2); border-radius: 3px; }

/* ---------- Siglas con explicación al pasar el cursor ---------- */
abbr.gl { text-decoration: none; cursor: help; border-radius: 3px; }
abbr.gl.first { text-decoration: underline dotted var(--accent-2); text-underline-offset: 3px; }
abbr.gl:hover, abbr.gl:focus-visible { background: rgba(181, 171, 252, .16); outline: none; }
.gl-tip { position: fixed; left: 0; top: 0; z-index: 60; max-width: min(340px, calc(100vw - 16px)); padding: 10px 14px; border-radius: 10px; background: #0e0f18; border: 1px solid var(--accent-3); color: var(--text-2); font-size: 14px; line-height: 1.45; box-shadow: 0 10px 30px rgba(0,0,0,.45); pointer-events: none; opacity: 0; transition: opacity .12s; }
.gl-tip.on { opacity: 1; }
.gl-tip b { display: block; color: var(--accent); font-family: var(--mono); font-size: 13px; margin-bottom: 2px; }

/* Visor de imagen ampliada */
.zoom { position: fixed; inset: 0; z-index: 70; background: rgba(8, 9, 16, .92); display: flex; align-items: center; justify-content: center; padding: 24px; }
.zoom[hidden] { display: none; }
.zoom img { max-width: 100%; max-height: 100%; border-radius: 10px; background: #fff; }
.zoom-close { position: absolute; top: 16px; right: 16px; }
[data-pane][hidden] { display: none !important; }
