/* ==========================================================
   Capa Gratuita - estilos de las guías (se suma a styles.css)
   ========================================================== */

:root {
  --accent-soft: #EEF9D2;
  --code-bg: #12161C;
  --code-head: #1C222B;
  --code-text: #E6E8EC;
}

/* ---------- Cabecera de la guía ---------- */
.guide-head { padding-top: 40px; }
.guide-title {
  margin: 20px 0 16px; max-width: 900px;
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.1rem, 5vw, 3.5rem); line-height: 1.05; letter-spacing: -0.035em;
}
.guide-meta {
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  font-family: var(--font-mono); font-size: 13px; color: var(--muted);
}
.guide-meta li { display: flex; align-items: center; gap: 8px; }
.guide-meta li::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); border: 1px solid var(--ink);
}

.status-bar {
  margin-top: 28px; background: var(--card); border: 1px solid var(--ink);
  border-radius: 16px; padding: 20px 24px;
  display: flex; flex-wrap: wrap; gap: 16px 40px; align-items: center; justify-content: space-between;
}
.status-items { display: flex; flex-wrap: wrap; gap: 12px 32px; font-size: 15px; }
.status-items > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.status-items dt { color: var(--muted); }
.status-items dt::after { content: ":"; }
.status-items dd { margin: 0; }
.status-link { font-weight: 600; font-size: 15px; border-bottom: 2px solid var(--accent); }
.status-link:hover { opacity: .8; }

/* ---------- Distribución ---------- */
.guide-layout {
  display: flex; flex-wrap: wrap; gap: 48px; align-items: flex-start;
  padding-top: 40px; padding-bottom: 64px;
}

/* ---------- Índice lateral ---------- */
.toc {
  flex: 1 1 220px; max-width: 280px; min-width: 220px;
  position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px; font-size: 15px;
}
.toc-details summary { cursor: pointer; padding: 4px 0 12px; list-style: none; }
.toc-details summary::-webkit-details-marker { display: none; }
.toc-details.is-static summary { cursor: default; pointer-events: none; }
/* Indicador de plegado solo cuando el índice se puede abrir y cerrar (móvil) */
.toc-details:not(.is-static) summary { display: flex; align-items: center; justify-content: space-between; }
.toc-details:not(.is-static) summary::after {
  content: ""; width: 10px; height: 10px; margin-right: 4px;
  border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  transform: rotate(45deg); transition: transform .15s ease;
}
.toc-details[open]:not(.is-static) summary::after { transform: rotate(-135deg); }
.toc ol { display: flex; flex-direction: column; gap: 2px; list-style: none; padding: 0; }
.toc nav a {
  display: flex; align-items: center; min-height: 40px; padding: 4px 12px;
  border-left: 3px solid var(--line); line-height: 1.3;
}
.toc nav a:hover { background: rgba(18, 22, 28, .04); }
.toc nav a[aria-current="true"] { border-left-color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.toc-cta { flex-shrink: 0; }

/* ---------- Artículo ---------- */
.guide-article {
  flex: 3 1 560px; min-width: 0; max-width: 760px;
  font-size: 18px; line-height: 1.65; color: #262C35;
}
.guide-article > * + * { margin-top: 18px; }
.guide-article h2 {
  margin-top: 64px; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.7rem, 3vw, 2.1rem); line-height: 1.12; letter-spacing: -0.025em;
  color: var(--ink); scroll-margin-top: 24px;
}
.guide-article h2:first-child { margin-top: 0; }
.guide-article h3 {
  margin-top: 44px; font-family: var(--font-display); font-weight: 700;
  font-size: 1.5rem; letter-spacing: -0.02em; color: var(--ink); scroll-margin-top: 24px;
}
.guide-article strong { color: var(--ink); font-weight: 600; }
.guide-article a { text-decoration: underline; text-underline-offset: 3px; }

.phase {
  display: block; width: fit-content; margin-bottom: 10px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: .08em;
  background: var(--accent); border: 1px solid var(--ink); border-radius: 999px; padding: 3px 12px;
}

/* Listas */
.guide-article ul, .guide-article ol { padding-left: 24px; }
.guide-article ul { list-style: disc; }
.guide-article ol { list-style: decimal; }
.guide-article li { margin-bottom: 8px; padding-left: 4px; }
.guide-article li::marker { color: var(--ink); font-weight: 700; }

/* Pasos con número en círculo */
.guide-article ol.steps {
  list-style: none; padding: 0; counter-reset: step;
  display: flex; flex-direction: column; gap: 14px;
}
.guide-article ol.steps > li {
  counter-increment: step; position: relative; margin: 0; padding: 4px 0 0 52px; min-height: 36px;
}
.guide-article ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); border: 1px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 16px; color: var(--ink);
}
.guide-article ol.steps ul { margin: 8px 0 0; }

/* Checklist */
.guide-article ul.checklist { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.guide-article ul.checklist li { position: relative; padding-left: 34px; margin: 0; }
.guide-article ul.checklist li::before {
  content: ""; position: absolute; left: 0; top: 5px; width: 20px; height: 20px;
  border: 2px solid var(--ink); border-radius: 5px; background: var(--card);
}

/* Código en línea */
.guide-article code {
  font-family: var(--font-mono); font-size: .88em; background: #E4E0D2;
  border-radius: 5px; padding: 2px 6px; color: var(--ink); overflow-wrap: anywhere;
}

/* Citas destacadas */
.pull {
  margin: 28px 0; padding: 24px 28px; background: var(--card);
  border: 1px solid var(--ink); border-radius: var(--radius); box-shadow: 5px 5px 0 var(--ink);
  font-family: var(--font-display); font-weight: 600; font-size: 1.45rem; line-height: 1.3;
  letter-spacing: -0.015em; color: var(--ink);
}
.pull-dark {
  background: var(--ink); color: var(--bg); box-shadow: 5px 5px 0 var(--accent);
  display: flex; flex-direction: column; gap: 10px;
}
.pull-dark strong { color: var(--accent); font-size: 1.7rem; line-height: 1.15; }
.pull-dark span { font-family: var(--font-body); font-weight: 400; font-size: 1.05rem; color: #C9CDD4; letter-spacing: 0; }

/* Avisos */
.note {
  background: var(--card); border: 1px solid var(--ink); border-radius: 14px;
  padding: 18px 22px; font-size: 16px; line-height: 1.55;
  display: flex; flex-direction: column; gap: 6px;
}
.guide-article .note > * + * { margin-top: 0; }
.note .mono-label { color: var(--ink); }
.note-warn { background: var(--warn-bg); }
.note-info { background: #E2ECFF; }

/* Gates */
.gate {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: var(--accent-soft); border: 1px solid var(--ink); border-radius: var(--radius-sm);
  font-size: 15px; line-height: 1.5; margin-top: 24px;
}
.gate svg { flex-shrink: 0; color: var(--ink); }
.gate strong { font-family: var(--font-mono); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }

/* Flujo completo */
.guide-article ol.flow-list {
  list-style: none; padding: 0; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.guide-article ol.flow-list li { margin: 0; padding: 0; }
.flow-list a {
  display: flex; align-items: center; gap: 12px; height: 100%;
  padding: 12px 16px; background: var(--card); border: 1px solid var(--ink);
  border-radius: 12px; text-decoration: none; font-size: 16px; line-height: 1.3;
}
.flow-list a:hover { background: var(--accent-soft); }
.flow-n {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px; background: var(--ink); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 14px;
}

/* Bloques de código y prompts */
.codebox { background: var(--code-bg); border-radius: 12px; overflow: hidden; margin: 22px 0; }
.codebox-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 8px 6px 16px; background: var(--code-head); border-bottom: 1px solid #2A313B;
  font-family: var(--font-mono); font-size: 12px; color: #8A919C; letter-spacing: .04em;
}
.codebox-tag { margin-left: 10px; color: var(--accent); font-weight: 700; }
.codebox pre {
  margin: 0; padding: 18px 20px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 14px; line-height: 1.65; color: var(--code-text);
}
.codebox-prompt pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Prompts largos: sin JavaScript se ven completos; con JavaScript se pliegan a ~10 líneas y se abren con un botón */
.codebox-toggle { display: none; }
.js .codebox-toggle {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; padding: 0 14px;
  background: var(--code-head); color: var(--bg); border: 0; border-top: 1px solid #2A313B;
  font-family: var(--font-mono); font-size: 12px; cursor: pointer;
}
.js .codebox-toggle:hover { color: var(--accent); }
.js .codebox-prompt.is-collapsible:not(.is-open) pre {
  max-height: 16.5em; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent);
}

.copy-btn {
  display: none; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  background: transparent; color: var(--bg); border: 1px solid #3C434D; border-radius: 8px;
  font-family: var(--font-mono); font-size: 12px; cursor: pointer;
}
.js .copy-btn { display: inline-flex; }
.copy-btn:hover { border-color: var(--accent); }
.copy-btn.is-done { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.codebox :focus-visible { outline-color: var(--accent); }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--ink); border-radius: 14px; background: var(--card); margin: 22px 0; }
.guide-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 15px; line-height: 1.5; text-align: left; }
.guide-table th, .guide-table td { padding: 12px 16px; vertical-align: top; }
.guide-table thead th {
  background: var(--ink); color: var(--bg); font-family: var(--font-mono);
  font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase;
}
.guide-table tbody tr + tr td { border-top: 1px solid #E4E0D2; }

/* Cierre */
.guide-cta {
  margin-top: 64px; background: var(--ink); color: var(--bg); border-radius: var(--radius);
  padding: 36px 32px; display: flex; flex-direction: column; gap: 16px;
}
.guide-article .guide-cta h2 { margin: 0; color: var(--bg); font-size: 2rem; }
.guide-cta p { color: #B8BDC6; font-size: 17px; max-width: 560px; }
.guide-cta :focus-visible { outline-color: var(--accent); }
.guide-article .guide-cta a { text-decoration: none; }

/* Imágenes con pie de foto (![texto](/ruta.png "pie") en el Markdown) */
.guide-figure { margin: 28px 0; }
.guide-figure img {
  width: 100%; height: auto; border: 1px solid var(--ink); border-radius: 14px; background: var(--card);
}
.guide-figure figcaption, .video figcaption {
  margin-top: 10px; font-family: var(--font-mono); font-size: 13px; line-height: 1.5; color: var(--muted);
}

/* Videos de YouTube: miniatura con botón; el reproductor se carga al dar clic (ver guide.js) */
.video { margin: 28px 0; }
.video-frame {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  border: 1px solid var(--ink); border-radius: 14px; background: var(--code-bg);
}
.video-frame iframe, .video-frame .video-link {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.guide-article .video-link { display: block; text-decoration: none; }
.video-link img { width: 100%; height: 100%; object-fit: cover; opacity: .92; }
.video-play {
  position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--ink); transition: transform .12s ease;
}
.video-play::after {
  content: ""; position: absolute; left: 27px; top: 19px;
  border-style: solid; border-width: 16px 0 16px 26px; border-color: transparent transparent transparent var(--ink);
}
.video-link:hover .video-play { transform: scale(1.06); }
/* Video de la cabecera (campo "video" de los metadatos).
   En pantallas pequeñas va debajo de la ficha de estado; en escritorio, a su izquierda (ver más abajo). */
.guide-head .guide-video { max-width: 760px; margin: 28px 0 0; }

/* Pie: frase de vigencia */
.footer-note {
  padding: 0 32px 20px; text-align: center; font-family: var(--font-mono);
  font-size: 12px; color: #8A919C;
}

/* ---------- Cabecera en dos columnas (solo con video, en escritorio) ---------- */
@media (min-width: 981px) {
  .guide-hero.has-video {
    display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
    grid-template-areas: "video info"; gap: 32px; align-items: start; margin-top: 12px;
  }
  .guide-head .guide-hero.has-video .guide-video { grid-area: video; max-width: none; margin: 0; }
  .guide-hero.has-video .guide-info { grid-area: info; }
  /* La ficha pasa a ser una columna junto al video */
  .guide-hero.has-video .guide-meta { flex-direction: column; gap: 8px; }
  .guide-hero.has-video .status-bar {
    margin-top: 20px; padding: 20px; flex-direction: column; align-items: flex-start; gap: 16px;
  }
  .guide-hero.has-video .status-items { flex-direction: column; gap: 12px; }
}

/* ---------- Pantallas pequeñas ---------- */
@media (max-width: 980px) {
  .guide-layout { gap: 28px; padding-top: 24px; }
  .toc { flex-basis: 100%; max-width: none; position: static; max-height: none; }
  .toc-details { border: 1px solid var(--ink); border-radius: 14px; background: var(--card); padding: 0 16px; }
  .toc-details summary { padding: 14px 0; }
  .toc-details[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
  .toc nav a { min-height: 44px; }
  .toc .toc-cta { display: none; }
}
@media (max-width: 640px) {
  .guide-article { font-size: 17px; }
  .guide-head { padding-top: 24px; }
  .status-bar { padding: 16px; }
  .guide-article h2 { margin-top: 48px; }
  .pull { padding: 20px; font-size: 1.25rem; }
  .guide-cta { padding: 28px 20px; }
  .footer-note { padding: 0 16px 20px; }
}