/* ==========================================
   BASES OFICIALES — usa las variables de ../styles.css
   ========================================== */

.site-header nav a.nav-active { color: var(--green); }
.site-header nav a.nav-active::after { left: 0; right: 0; background: var(--green); }

/* Barra de lectura */
.b-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 200;
  pointer-events: none;
}
.b-progress i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--cyan), var(--green));
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.7);
}

/* Portada */
.b-hero {
  position: relative;
  overflow: hidden;
  padding: 90px clamp(24px, 6vw, 100px) 70px;
  border-bottom: 1px solid rgba(118, 145, 182, 0.14);
  background:
    radial-gradient(circle at 50% 0%, rgba(0, 229, 255, 0.10), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(154, 108, 255, 0.08), transparent 35%);
}
.b-hero-grid {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.05) 1px, transparent 1px);
  background-size: 38px 38px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%);
}
.b-hero-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 229, 255, 0.8), transparent);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.6);
  animation: bScan 6s linear infinite;
}
@keyframes bScan { 0% { top: 0; opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { top: 100%; opacity: 0; } }

.b-hero-inner { position: relative; z-index: 1; max-width: 1040px; margin: 0 auto; text-align: center; }
.b-hero .terminal-kicker { justify-content: center; }
.b-title { margin: 6px 0 0; }
.b-title .b-glitch {
  position: relative;
  display: inline-block;
  font: 700 clamp(3rem, 9vw, 7rem)/0.9 var(--font-title);
  letter-spacing: -0.03em;
  color: var(--text);
  text-shadow: 0 0 28px rgba(0, 229, 255, 0.25);
}
.b-title .b-glitch::before,
.b-title .b-glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.b-title .b-glitch::before { color: var(--cyan); transform: translate(2px, 0); clip-path: inset(0 0 62% 0); opacity: 0.55; animation: bGlitch 3.2s steps(1) infinite; }
.b-title .b-glitch::after { color: var(--red); transform: translate(-2px, 0); clip-path: inset(58% 0 0 0); opacity: 0.45; animation: bGlitch 2.7s steps(1) infinite reverse; }
@keyframes bGlitch {
  0%, 86%, 100% { transform: translate(0, 0); }
  88% { transform: translate(4px, -1px); }
  90% { transform: translate(-3px, 1px); }
  92% { transform: translate(2px, 0); }
}
.b-title em {
  display: block;
  margin-top: 14px;
  color: var(--green);
  font: 600 clamp(1rem, 2.2vw, 1.45rem)/1.2 var(--font-mono);
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.b-lema {
  margin: 22px auto 0;
  color: #c2cedf;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-style: italic;
}
.b-meta { max-width: 820px; margin: 30px auto 0; text-align: left; }
.b-meta b { color: var(--cyan); font-weight: 600; }
.b-colab {
  margin: 26px auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 10px;
}
.b-colab > * {
  padding: 6px 12px;
  border: 1px solid rgba(118, 145, 182, 0.22);
  border-radius: 999px;
  color: #b9c7d9;
  font-size: 0.82rem;
  text-decoration: none;
}
.b-colab a:hover { border-color: var(--cyan); color: var(--text); }
.b-colab .b-colab-label { border: 0; color: #7c9dbd; font: 600 0.72rem/1.9 var(--font-mono); }
.b-actions { margin-top: 30px; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* Distribución con índice lateral */
.b-layout {
  max-width: 1360px;
  margin: 0 auto;
  padding: 50px clamp(18px, 4vw, 60px) 80px;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: clamp(28px, 4vw, 60px);
  align-items: start;
}

.b-toc { position: sticky; top: 96px; }
.b-toc-box {
  max-height: calc(100vh - 120px);
  overflow: auto;
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: 8px;
  background: rgba(3, 8, 14, 0.92);
  box-shadow: var(--shadow);
  font-family: var(--font-mono);
}
.b-toc-head {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 229, 255, 0.14);
  color: #86a7b9;
  font-size: 0.74rem;
}
.b-toc-head span { color: var(--green); }
.b-toc ol { list-style: none; margin: 0; padding: 10px 8px; }
.b-toc ol ol { padding: 2px 0 4px 26px; border-left: 1px dashed rgba(118, 145, 182, 0.25); margin-left: 22px; }
.b-toc a {
  display: block;
  padding: 6px 8px;
  border-radius: 4px;
  color: #9aa9bf;
  font-size: 0.76rem;
  line-height: 1.35;
  text-decoration: none;
  transition: color 0.18s ease, background 0.18s ease;
}
.b-toc a b { color: #5d7590; margin-right: 6px; font-weight: 700; }
.b-toc ol ol a { font-size: 0.72rem; padding: 4px 8px; }
.b-toc a:hover { color: var(--text); background: rgba(0, 229, 255, 0.06); }
.b-toc a.on { color: var(--green); background: rgba(182, 255, 59, 0.07); }
.b-toc a.on b { color: var(--green); }
.b-toc a.on::before { content: "> "; }
.b-toc-pdf {
  display: block;
  margin: 0 16px 14px;
  padding: 9px 10px;
  border: 1px dashed rgba(182, 255, 59, 0.4);
  border-radius: 4px;
  color: var(--green);
  font-size: 0.74rem;
  text-align: center;
  text-decoration: none;
}
.b-toc-pdf:hover { background: rgba(182, 255, 59, 0.08); }

/* Documento */
.b-doc { min-width: 0; }
.b-sec {
  position: relative;
  padding: 38px clamp(20px, 3vw, 40px) 34px;
  margin-bottom: 28px;
  border: 1px solid rgba(118, 145, 182, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(10, 16, 28, 0.82), rgba(5, 9, 16, 0.82));
  scroll-margin-top: 96px;
}
.b-sec::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 24px;
  width: 90px;
  height: 2px;
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.7);
}
.b-sec-head { margin-bottom: 22px; }
.b-sec-head .section-number { color: var(--cyan); }
.b-sec h2 {
  margin: 0;
  font: 700 clamp(1.7rem, 3vw, 2.6rem)/1 var(--font-title);
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
.b-sec p, .b-sec li, .b-sec dd { color: #c1ccda; line-height: 1.7; }
.b-sec p { margin: 0 0 14px; }
.b-sec strong { color: var(--text); }
.b-sec a { color: var(--cyan); text-decoration: none; border-bottom: 1px dashed rgba(0, 229, 255, 0.45); }
.b-sec a:hover { color: var(--green); border-bottom-color: var(--green); }
.b-sec a.button { border-bottom: 1px solid transparent; color: inherit; }
.b-sec a.button-primary { color: #07100b; }
.b-sec code {
  padding: 2px 6px;
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.06);
  color: var(--cyan);
  font: 500 0.86em var(--font-mono);
}

.b-sub {
  margin: 36px 0 14px;
  padding-top: 22px;
  border-top: 1px dashed rgba(118, 145, 182, 0.22);
  font: 700 clamp(1.25rem, 2vw, 1.6rem)/1.15 var(--font-title);
  scroll-margin-top: 96px;
}
.b-sub span { margin-right: 10px; color: var(--green); font-family: var(--font-mono); font-size: 0.8em; }
.b-sub2 { margin: 24px 0 10px; color: var(--cyan); font: 600 0.86rem/1.3 var(--font-mono); letter-spacing: 0.03em; }
.b-sub2::before { content: "## "; color: #5d7590; }

.b-note {
  padding: 12px 16px;
  border-left: 2px solid var(--amber);
  background: rgba(255, 189, 106, 0.06);
  color: #e9cfa8 !important;
  font: 500 0.86rem/1.6 var(--font-mono);
}

/* Listas */
.b-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.b-list li { position: relative; padding-left: 28px; }
.b-list li::before { content: "▸"; position: absolute; left: 4px; top: 0; color: var(--cyan); font-family: var(--font-mono); }
.b-list b { color: var(--text); }
.b-list.b-ok li::before { content: "✓"; color: var(--green); }
.b-list.b-bad li::before { content: "✗"; color: var(--red); }

/* Pasos */
.b-steps { list-style: none; counter-reset: paso; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; }
.b-steps li {
  counter-increment: paso;
  position: relative;
  padding: 14px 16px 14px 62px;
  border: 1px solid rgba(118, 145, 182, 0.18);
  border-radius: 6px;
  background: rgba(3, 9, 16, 0.6);
}
.b-steps li::before {
  content: "0" counter(paso);
  position: absolute;
  left: 14px;
  top: 13px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(182, 255, 59, 0.45);
  border-radius: 4px;
  color: var(--green);
  font: 700 0.8rem/1 var(--font-mono);
}
.b-steps b { color: var(--text); }

/* Tarjetas */
.b-grid { display: grid; gap: 14px; margin: 6px 0 16px; }
.b-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.b-grid-cat { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.b-card, .b-cat {
  position: relative;
  padding: 18px 18px 16px;
  border: 1px solid rgba(118, 145, 182, 0.2);
  border-radius: 6px;
  background: rgba(3, 9, 16, 0.65);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}
.b-card:hover, .b-cat:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 229, 255, 0.5);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3), 0 0 22px rgba(0, 229, 255, 0.06);
}
.b-card h3, .b-cat h3 { margin: 8px 0 8px; font: 700 1.15rem/1.15 var(--font-title); }
.b-card p, .b-cat p { margin: 0; font-size: 0.92rem; line-height: 1.6; }
.b-tag {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: 3px;
  color: var(--cyan);
  font: 600 0.68rem/1.3 var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.b-deny { border-color: rgba(255, 95, 122, 0.28); }
.b-deny .b-tag { border-color: rgba(255, 95, 122, 0.45); color: var(--red); }
.b-deny:hover { border-color: rgba(255, 95, 122, 0.6); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3), 0 0 22px rgba(255, 95, 122, 0.08); }
.b-allow { border-color: rgba(182, 255, 59, 0.28); }
.b-allow .b-tag { border-color: rgba(182, 255, 59, 0.45); color: var(--green); }
.b-cat span { color: var(--green); font: 600 0.78rem/1 var(--font-mono); }
.b-cat span::before { content: "drwxr-x  "; color: #5d7590; }

/* Tablas */
.b-table-wrap { margin: 8px 0 18px; overflow-x: auto; border: 1px solid rgba(0, 229, 255, 0.2); border-radius: 6px; }
.b-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 0.9rem; }
.b-table th {
  padding: 11px 14px;
  background: rgba(0, 229, 255, 0.07);
  color: var(--cyan);
  font: 600 0.72rem/1.3 var(--font-mono);
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}
.b-table td { padding: 12px 14px; border-top: 1px solid rgba(118, 145, 182, 0.15); color: #c1ccda; line-height: 1.55; vertical-align: top; }
.b-table td:first-child { color: var(--text); font-weight: 600; }
.b-table tbody tr:hover td { background: rgba(0, 229, 255, 0.03); }
.b-table .b-yes { color: #d4f5a6; }
.b-table .b-no { color: #f2b5c0; }
.b-table .b-none { color: #6f7f95; font-family: var(--font-mono); }

/* Alertas */
.b-alert { margin: 20px 0; padding: 18px 20px; border-radius: 6px; border: 1px solid; }
.b-alert p { margin: 0; }
.b-alert .b-alert-head { margin-bottom: 8px; font: 700 0.86rem/1.3 var(--font-mono); letter-spacing: 0.06em; }
.b-alert-amber { border-color: rgba(255, 189, 106, 0.45); background: rgba(255, 189, 106, 0.06); }
.b-alert-amber .b-alert-head { color: var(--amber); }
.b-alert-red { border-color: rgba(255, 95, 122, 0.5); background: rgba(255, 95, 122, 0.07); box-shadow: 0 0 30px rgba(255, 95, 122, 0.06) inset; }
.b-alert-red .b-alert-head { color: var(--red); }

/* Identidad CTFd == Discord */
.b-identity { margin: 6px 0 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-family: var(--font-mono); }
.b-id-box { display: grid; gap: 4px; padding: 10px 14px; border: 1px solid rgba(0, 229, 255, 0.3); border-radius: 5px; color: #7c9dbd; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; }
.b-id-box b { color: var(--text); font-size: 0.86rem; text-transform: none; letter-spacing: 0; }
.b-id-eq { color: var(--cyan); font-size: 1.2rem; font-weight: 700; }
.b-id-ok { color: var(--green); font-size: 0.8rem; }

/* Definiciones (datos personales) */
.b-defs { margin: 6px 0 0; display: grid; gap: 4px; }
.b-defs dt { margin-top: 12px; color: var(--cyan); font: 600 0.8rem/1.3 var(--font-mono); }
.b-defs dt::before { content: "$ "; color: var(--green); }
.b-defs dd { margin: 0; padding-left: 16px; border-left: 1px solid rgba(118, 145, 182, 0.22); }

/* Fases */
.b-phases { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 10px 0 8px; position: relative; }
.b-phase {
  position: relative;
  padding: 18px 16px;
  border: 1px solid rgba(0, 229, 255, 0.22);
  border-radius: 6px;
  background: rgba(3, 9, 16, 0.7);
}
.b-phase:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -12px;
  top: 22px;
  z-index: 2;
  color: var(--cyan);
  font-family: var(--font-mono);
}
.b-phase-id { margin: 0 0 6px !important; color: var(--cyan) !important; font: 700 1.4rem/1 var(--font-mono); }
.b-phase-id span { display: block; margin-top: 6px; color: #7c9dbd; font-size: 0.68rem; font-weight: 500; }
.b-phase h3 { margin: 0 0 10px; font: 700 1.25rem/1.1 var(--font-title); text-transform: uppercase; }
.b-phase p { font-size: 0.84rem; line-height: 1.55; margin-bottom: 8px; }
.b-phase b { color: var(--text); }
.b-phase-infra { color: var(--green) !important; font-family: var(--font-mono); font-size: 0.74rem !important; }
.b-phase-final { border-color: rgba(182, 255, 59, 0.5); box-shadow: 0 0 28px rgba(182, 255, 59, 0.07); }
.b-phase-final .b-phase-id { color: var(--green) !important; }

.b-reset { margin: 6px 0 16px; }
.b-reset b { color: var(--green); }

/* Herramientas permitidas */
.b-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.b-tools span {
  padding: 5px 10px;
  border: 1px solid rgba(182, 255, 59, 0.3);
  border-radius: 3px;
  background: rgba(182, 255, 59, 0.05);
  color: #d4f5a6;
  font: 500 0.76rem/1.3 var(--font-mono);
}

/* Escala de sanciones */
.b-severity { list-style: none; margin: 6px 0 16px; padding: 0; display: grid; gap: 10px; }
.b-severity li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid rgba(118, 145, 182, 0.18);
  border-radius: 6px;
  background: rgba(3, 9, 16, 0.6);
}
.b-severity h3 { margin: 0 0 4px; font: 700 1.1rem/1.2 var(--font-title); }
.b-severity p { margin: 0; font-size: 0.92rem; }
.b-sev { padding: 6px 0; border-radius: 3px; text-align: center; font: 700 0.72rem/1 var(--font-mono); letter-spacing: 0.1em; }
.b-severity li:nth-child(1) .b-sev { color: #7fd7ff; border: 1px solid rgba(127, 215, 255, 0.45); }
.b-severity li:nth-child(2) .b-sev { color: var(--amber); border: 1px solid rgba(255, 189, 106, 0.5); }
.b-severity li:nth-child(3) .b-sev { color: #ff8a5f; border: 1px solid rgba(255, 138, 95, 0.55); }
.b-severity li:nth-child(4) .b-sev { color: #07100b; background: var(--red); }
.b-severity li:nth-child(4) { border-color: rgba(255, 95, 122, 0.4); }

/* Podio */
.b-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; margin: 14px 0 14px; }
.b-place {
  padding: 20px 16px;
  border: 1px solid rgba(118, 145, 182, 0.25);
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, rgba(10, 16, 28, 0.9), rgba(3, 9, 16, 0.9));
  text-align: center;
}
.b-place span { display: block; font: 700 2.4rem/1 var(--font-mono); }
.b-place h3 { margin: 10px 0 6px; font: 700 1.1rem/1.15 var(--font-title); text-transform: uppercase; }
.b-place p { margin: 0 !important; color: #7c9dbd !important; font-family: var(--font-mono); font-size: 0.8rem; }
.b-p1 { min-height: 210px; border-color: rgba(182, 255, 59, 0.55); box-shadow: 0 0 34px rgba(182, 255, 59, 0.1); }
.b-p1 span { color: var(--green); text-shadow: 0 0 18px rgba(182, 255, 59, 0.5); }
.b-p2 { min-height: 170px; }
.b-p2 span { color: var(--cyan); }
.b-p3 { min-height: 140px; }
.b-p3 span { color: var(--purple); }
.b-honor { margin-bottom: 18px; border-color: rgba(154, 108, 255, 0.35); }
.b-honor .b-tag { border-color: rgba(154, 108, 255, 0.5); color: var(--purple); }

.b-check { grid-template-columns: 1fr; margin: 6px 0 16px; }
.b-check span { color: #c8e9a0; }

/* Cierre */
.b-end { margin-top: 30px; padding-top: 26px; border-top: 1px solid rgba(118, 145, 182, 0.18); text-align: center; }
.b-end-sig { margin: 0 !important; color: var(--cyan) !important; font: 600 0.82rem/1.4 var(--font-mono); letter-spacing: 0.06em; }

.b-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-radius: 6px;
  background: rgba(5, 7, 13, 0.9);
  color: var(--cyan);
  font: 700 1rem/1 var(--font-mono);
  text-decoration: none;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.b-top.show { opacity: 1; transform: none; pointer-events: auto; }
.b-top:hover { border-color: var(--green); color: var(--green); }

/* Responsivo */
@media (max-width: 1180px) {
  .b-phases { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .b-phase:nth-child(2)::after { display: none; }
}
@media (max-width: 980px) {
  .b-layout { grid-template-columns: 1fr; padding-top: 28px; }
  .b-toc { position: static; }
  .b-toc-box { max-height: none; }
  .b-toc > .b-toc-box > ol { columns: 2; column-gap: 12px; }
  .b-toc > .b-toc-box > ol > li { break-inside: avoid; }
}
@media (max-width: 720px) {
  .b-hero { padding: 56px 16px 48px; }
  .b-layout { padding-inline: 16px; }
  .b-toc > .b-toc-box > ol { columns: 1; }
  .b-grid-2, .b-phases, .b-podium { grid-template-columns: 1fr; }
  .b-phase::after { display: none; }
  .b-podium .b-p1 { order: -1; }
  .b-place { min-height: 0; border-radius: 6px; }
  .b-severity li { grid-template-columns: 1fr; gap: 10px; }
  .b-sev { justify-self: start; padding: 6px 10px; }
  .b-sec { padding: 28px 16px 24px; }

  /* Tablas como tarjetas apiladas: sin desplazamiento lateral */
  .b-table { min-width: 0; }
  .b-table thead { display: none; }
  .b-table tr { display: block; border-top: 1px solid rgba(0, 229, 255, 0.18); }
  .b-table tr:first-child { border-top: 0; }
  .b-table td { display: block; border-top: 0; padding: 4px 14px; }
  .b-table td:first-child { padding-top: 14px; color: var(--cyan); font-family: var(--font-mono); font-size: 0.82rem; }
  .b-table td:last-child { padding-bottom: 14px; }
  .b-table td:not(:first-child)::before { display: block; color: #6f7f95; font: 600 0.66rem/1.6 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
  .b-table-infra td:nth-child(2)::before { content: "función"; }
  .b-table-infra td:nth-child(3)::before { content: "ubicación"; }
  .b-table-ia td:nth-child(2)::before { content: "uso permitido"; }
  .b-table-ia td:nth-child(3)::before { content: "uso prohibido"; }
}
@media (prefers-reduced-motion: reduce) {
  .b-hero-scan, .b-title .b-glitch::before, .b-title .b-glitch::after { animation: none; }
  .b-card:hover, .b-cat:hover { transform: none; }
}
