/* Páginas legales de MagicCode: estáticas, sin framework, con la paleta del sitio (grises + acento violeta). */
/* Archivo (SIL Open Font License) servida desde el propio sitio: sin esperar a Google Fonts. */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("../fonts/archivo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("../fonts/archivo-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #fafafb;
  --surface: #f1f2f4;
  --ink: #14161b;
  --text: #33373f;
  --muted: #5b606b;
  --faint: #e3e5e9;
  --accent: #5b3df5;
  --accent-light: #9d85ff;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 96px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.7 Archivo, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: #fff; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

[hidden] { display: none !important; }

/* Barra superior */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 250, 251, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--faint);
}
.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); font: 800 18px/1 Archivo, sans-serif; font-stretch: 125%; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand img { height: 34px; width: auto; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.back { color: var(--muted); font-size: 14px; white-space: nowrap; }
.back:hover { color: var(--ink); text-decoration: none; }

.lang { display: inline-flex; border: 1px solid var(--faint); border-radius: 999px; padding: 3px; }
.lang button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 700 12px/1 Archivo, sans-serif;
  letter-spacing: 0.08em;
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Encabezado */
.hero { position: relative; border-bottom: 1px solid var(--faint); overflow: hidden; }
.hero::before {
  content: "";
  position: absolute;
  inset: -40% -10% auto auto;
  width: 60%;
  height: 160%;
  background: radial-gradient(closest-side, rgba(157, 133, 255, 0.22), transparent);
  pointer-events: none;
}
.hero-inner { position: relative; max-width: 1160px; margin: 0 auto; padding: 72px 20px 56px; }
.kicker {
  display: inline-block;
  color: var(--accent);
  font: 600 13px/1 Archivo, sans-serif;
  margin-bottom: 20px;
}
h1 {
  margin: 0;
  color: var(--ink);
  font: 800 clamp(2.4rem, 6vw, 4.2rem)/1 Archivo, sans-serif;
  font-stretch: 125%;
  letter-spacing: -0.035em;
  max-width: 16ch;
}
.lead { margin: 22px 0 0; max-width: 62ch; font-size: 18px; color: var(--text); }
.meta { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 1px solid var(--faint);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
}
.bar { height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-light)); }

/* Cuerpo */
.layout {
  max-width: 1160px;
  margin: 0 auto;
  padding: 48px 20px 80px;
  display: grid;
  gap: 48px;
}
@media (min-width: 960px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); gap: 64px; }
}

.toc { font-size: 14px; }
.toc-title { color: var(--ink); font: 700 14px/1 Archivo, sans-serif; margin: 0 0 16px; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; border-top: 1px solid var(--faint); }
.toc a { display: flex; gap: 10px; padding: 9px 0; color: var(--muted); }
.toc a::before { content: counter(toc, decimal-leading-zero); color: var(--accent); font-size: 12px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.toc a:hover { color: var(--ink); text-decoration: none; }
@media (min-width: 960px) {
  .toc { position: sticky; top: 96px; align-self: start; max-height: calc(100vh - 120px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
  .toc::-webkit-scrollbar { width: 4px; }
  .toc::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 4px; }
}
@media (max-width: 959px) {
  .toc { border: 1px solid var(--faint); border-radius: 20px; padding: 20px; background: var(--surface); }
}

.doc { min-width: 0; max-width: 760px; }
.doc section { padding: 8px 0 28px; border-bottom: 1px solid var(--faint); margin-bottom: 28px; }
.doc section:last-child { border-bottom: 0; }
.doc h2 {
  color: var(--ink);
  font: 750 clamp(1.35rem, 2.6vw, 1.7rem)/1.2 Archivo, sans-serif;
  font-stretch: 115%;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}
.doc h3 { color: var(--ink); font: 700 1.05rem/1.4 Archivo, sans-serif; margin: 22px 0 8px; }
.doc p { margin: 0 0 14px; }
.doc ul, .doc ol { margin: 0 0 14px; padding-left: 22px; }
.doc li { margin: 6px 0; }
.doc li::marker { color: var(--accent); }
.doc strong { color: var(--ink); font-weight: 650; }
.doc a { overflow-wrap: anywhere; }

.card {
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: 20px;
  padding: 20px 22px;
  margin: 0 0 16px;
}
.card p:last-child, .card ul:last-child { margin-bottom: 0; }
.note { border-left: 2px solid var(--accent); padding: 4px 0 4px 16px; margin: 0 0 16px; color: var(--text); }

dl.data { margin: 0; display: grid; gap: 10px; }
dl.data div { display: grid; gap: 2px; }
dl.data dt { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
dl.data dd { margin: 0; color: var(--ink); }
@media (min-width: 640px) {
  dl.data div { grid-template-columns: 170px 1fr; gap: 16px; }
}

/* Pie */
.foot { border-top: 1px solid var(--faint); background: var(--ink); }
.foot-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 32px 20px 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  justify-content: space-between;
  font-size: 14px;
  color: #a3a8b3;
}
.foot nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.foot nav a { color: #a3a8b3; }
.foot nav a:hover, .foot nav a[aria-current="page"] { color: var(--accent-light); }

@view-transition { navigation: auto; }

@media (max-width: 520px) {
  .back { display: none; }
  .hero-inner { padding: 52px 16px 40px; }
  .layout { padding: 32px 16px 64px; }
  .topbar-inner, .foot-inner { padding-left: 16px; padding-right: 16px; }
  .lead { font-size: 16px; }
}

@media print {
  .topbar, .toc, .foot, .lang { display: none !important; }
  body { background: #fff; color: #111; }
  .hero, .doc section { border-color: #ddd; }
  h1, .doc h2, .doc h3, .doc strong, dl.data dd { color: #000; }
  .card { background: #fff; border-color: #ddd; }
  a { color: #000; }
}
