/* site.css (T-227): web legal de Magnetoons. CSS propio, sin fuentes ni recursos externos.
   Contrastes comprobados (WCAG 2.2 AA): texto >= 4,5:1; bordes y foco >= 3:1 sobre el fondo y la superficie. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #f3f1ec;
  --text: #1b1d21;
  --muted: #4b515b;
  --link: #0a4fb8;
  --visited: #5b2f9e;
  --on-link: #ffffff;
  --border: #7d838d;
  --focus: #0a4fb8;
  --ph-bg: #ffe27a;
  --ph-text: #1b1d21;
  --code-bg: #ecebe6;
  --measure: 46rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --surface: #1c1e23;
    --text: #ececf1;
    --muted: #b6bbc5;
    --link: #8fb8ff;
    --visited: #c3a6f5;
    --on-link: #121316;
    --border: #7f8691;
    --focus: #8fb8ff;
    --ph-bg: #6b5400;
    --ph-text: #fff4c9;
    --code-bg: #23262c;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

/* Enlaces: siempre subrayados (no dependen solo del color) */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:visited {
  color: var(--visited);
}

a:hover {
  text-decoration-thickness: 0.16em;
}

/* Foco visible: contorno de 3 px (>= 2 px) con contraste >= 3:1 */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

main:focus {
  outline: none;
}

/* Saltar al contenido */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--link);
  color: var(--on-link);
  font-weight: 600;
  transform: translateY(-300%);
}

.skip-link:visited {
  color: var(--on-link);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
}

/* Estructura */
.wrap,
.bar {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right));
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding-block: 0.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 800;
  text-decoration: none;
}

.brand:visited {
  color: var(--text);
}

.lang-switch {
  margin: 0;
}

.lang-switch a,
.doc-nav a,
.footer-block a,
.toc a,
.lang-choice a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.25rem 0.5rem;
}

.doc-nav {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: max(0.5rem, env(safe-area-inset-left)) max(0.5rem, env(safe-area-inset-right));
  padding-bottom: 0.25rem;
}

.doc-nav ul,
.footer-block ul,
.toc ul,
.lang-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-nav a[aria-current="page"] {
  font-weight: 700;
  text-decoration-thickness: 0.2em;
}

main {
  display: block;
  padding-block: 1.5rem 3rem;
}

.doc > :first-child {
  margin-top: 0;
}

/* Tipografía del documento */
h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 2rem 0 0.75rem;
  text-wrap: balance;
}

h1 {
  font-size: 1.9rem;
  margin-top: 0;
}

h2 {
  font-size: 1.45rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

h3 {
  font-size: 1.2rem;
}

h4 {
  font-size: 1.05rem;
}

p,
ul,
ol,
blockquote,
.table-wrap {
  margin: 0 0 1rem;
}

ul,
ol {
  padding-inline-start: 1.5rem;
}

li {
  margin-block: 0.25rem;
}

li > ul,
li > ol {
  margin: 0.25rem 0;
}

blockquote {
  padding: 0.25rem 1rem;
  border-inline-start: 4px solid var(--border);
  background: var(--surface);
}

blockquote > :last-child {
  margin-bottom: 0;
}

hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

code {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

/* Marcadores sin sustituir (solo en borradores) */
mark.ph {
  padding: 0 0.2em;
  border: 1px dashed var(--border);
  background: var(--ph-bg);
  color: var(--ph-text);
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Tablas: contenedor desplazable y enfocable (sin desbordar la página a 320 px) */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.97rem;
}

.table-wrap th,
.table-wrap td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
  min-width: 7rem;
}

.table-wrap th {
  background: var(--surface);
}

.table-wrap .ta-c {
  text-align: center;
}

.table-wrap .ta-r {
  text-align: end;
}

/* Índice de la página */
.toc {
  margin: 0 0 1.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.toc-title {
  margin: 0 0 0.25rem;
  font-weight: 700;
}

/* Listas de la portada y de los índices */
.doc-list {
  padding: 0;
  list-style: none;
}

.doc-list li {
  margin-block: 1rem;
}

.doc-list li > a {
  font-size: 1.1rem;
  font-weight: 600;
}

.doc-list li > p {
  margin: 0;
  color: var(--muted);
}

.lang-choice a {
  min-height: 3rem;
  padding-inline: 1rem;
  border: 2px solid var(--border);
  font-weight: 600;
}

/* Pie */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.95rem;
}

.footer-block {
  padding-block: 0.75rem;
}

.footer-block p {
  margin: 0;
}

@media (min-width: 40rem) {
  body {
    font-size: 1.125rem;
  }

  h1 {
    font-size: 2.2rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  mark.ph {
    border: 1px solid CanvasText;
    background: Mark;
    color: MarkText;
  }

  .skip-link {
    border: 2px solid LinkText;
  }
}

@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --text: #000;
    --muted: #000;
    --link: #000;
    --visited: #000;
    --border: #555;
    --code-bg: #fff;
  }

  body {
    font-size: 11pt;
  }

  .skip-link,
  .lang-switch,
  .doc-nav,
  .toc,
  .lang-choice {
    display: none !important;
  }

  .site-header,
  .site-footer {
    background: none;
  }

  .wrap,
  .bar {
    max-width: none;
    padding-inline: 0;
  }

  main {
    padding-block: 1rem;
  }

  a {
    text-decoration: underline;
  }

  a[href^="https:"]::after {
    content: " (" attr(href) ")";
    font-size: 0.9em;
    overflow-wrap: anywhere;
  }

  .table-wrap {
    overflow: visible;
  }

  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
  }

  tr,
  blockquote,
  li {
    break-inside: avoid;
  }

  mark.ph {
    background: none;
    color: #000;
    border: 1px solid #000;
  }
}
