/* ===== Tokens base (tema claro) ===== */
:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #ecebe6;
  --code-bg: #edece7;
  --text: #22251f;
  --text-soft: #565a52;
  --text-mute: #8c8e85;
  --border: #e3e1d9;
  --shadow: 0 1px 2px rgba(28, 30, 26, .06), 0 8px 24px rgba(28, 30, 26, .08);
  --shadow-lg: 0 10px 30px rgba(28, 30, 26, .16);
  --on-primary: #ffffff;
  --radius: 16px;
  --maxw: 980px;
}

[data-theme="dark"] {
  --bg: #191b18;
  --surface: #212420;
  --surface-2: #2b2e29;
  --code-bg: #282b26;
  --text: #e9e8e2;
  --text-soft: #abaca3;
  --text-mute: #7f817a;
  --border: #33352f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .55);
  /* En oscuro el primary es claro, así que el texto encima va oscuro. */
  --on-primary: #11201c;
}

/* Acotadas a html porque [data-palette] casaría también con los botones swatch
   y les redefiniría las variables sobre ellos mismos. */
html[data-palette="teal"]       { --primary: #136b5e; --primary-strong: #0e564c; --primary-soft: #e4efec; --hero: #114a43; --hero-accent: #9ae9d9; }
html[data-palette="indigo"]     { --primary: #37548f; --primary-strong: #2b4373; --primary-soft: #e7eaf3; --hero: #283c6e; --hero-accent: #b4c9ff; }
html[data-palette="burgundy"]   { --primary: #8a3144; --primary-strong: #6f2737; --primary-soft: #f3e6e9; --hero: #5e2330; --hero-accent: #ffb8c5; }
html[data-palette="forest"]     { --primary: #356b3f; --primary-strong: #2a5532; --primary-soft: #e6efe5; --hero: #274a2c; --hero-accent: #a3e9ae; }
html[data-palette="terracotta"] { --primary: #a85534; --primary-strong: #8a4429; --primary-soft: #f5e9e2; --hero: #7a3d24; --hero-accent: #ffc4ab; }

/* ===== Paletas de acento (oscuro) ===== */
html[data-theme="dark"][data-palette="teal"]       { --primary: #58b4a4; --primary-strong: #74c4b6; --primary-soft: #17302c; }
html[data-theme="dark"][data-palette="indigo"]     { --primary: #90a1d6; --primary-strong: #aab6df; --primary-soft: #1f2438; }
html[data-theme="dark"][data-palette="burgundy"]   { --primary: #cf7b8b; --primary-strong: #dc97a4; --primary-soft: #321c21; }
html[data-theme="dark"][data-palette="forest"]     { --primary: #6fb277; --primary-strong: #8bc391; --primary-soft: #1b2c1d; }
html[data-theme="dark"][data-palette="terracotta"] { --primary: #d68f6b; --primary-strong: #e0a484; --primary-soft: #2e2018; }

/* ===== Accesibilidad: alto contraste ===== */
html.a11y-contrast {
  --bg: #ffffff; --surface: #ffffff; --surface-2: #ffffff; --code-bg: #ffffff;
  --text: #000000; --text-soft: #1a1a1a; --text-mute: #333333; --border: #000000;
  --primary: #00564a; --primary-strong: #003d34; --primary-soft: #ffffff;
  --on-primary: #ffffff; --hero: #003d34; --hero-accent: #ffffff; --shadow: none; --shadow-lg: none;
}
html.a11y-contrast[data-theme="dark"] {
  --bg: #000000; --surface: #000000; --surface-2: #000000; --code-bg: #000000;
  --text: #ffffff; --text-soft: #ffffff; --text-mute: #dddddd; --border: #ffffff;
  --primary: #6ee7d4; --primary-strong: #9af0e2; --primary-soft: #000000;
  --on-primary: #000000; --hero: #000000; --hero-accent: #6ee7d4;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 22px; }
a { color: var(--primary-strong); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ===== Cabecera ===== */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); /* fallback si no hay color-mix */
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
/* Sin soporte de backdrop-filter, fondo sólido para que sea legible al hacer scroll. */
@supports not (backdrop-filter: blur(1px)) {
  .site-header { background: var(--surface); }
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; }

.brand { display: flex; align-items: center; gap: 12px; user-select: none; }
.brand-logo {
  display: block;
  width: 40px; height: 40px;
  border-radius: 10px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.18rem; font-weight: 700; letter-spacing: -.01em; }
.brand-text small { color: var(--text-soft); font-size: .78rem; }

.header-tools { display: flex; align-items: center; gap: 8px; }
.tool-wrap { position: relative; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary-strong); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-expanded="true"] { border-color: var(--primary); background: var(--primary-soft); }

.ic-sun { display: none; }
[data-theme="dark"] .ic-sun { display: block; }
[data-theme="dark"] .ic-moon { display: none; }

/* ===== Popovers (paleta y accesibilidad) ===== */
.popover {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 10px;
  z-index: 30;
  min-width: 190px;
}
.popover-wide { display: flex; flex-direction: column; gap: 6px; }
/* El atributo [hidden] debe ganar al display:flex de .popover-wide. */
.popover[hidden] { display: none; }
.popover-title { margin: 2px 4px 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-mute); }

.swatch {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text);
  padding: 8px 10px; font: inherit; font-size: .9rem; cursor: pointer; text-align: left;
}
.swatch:hover { background: var(--surface-2); }
.swatch[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.swatch .dot { width: 18px; height: 18px; border-radius: 50%; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.swatch .check { margin-left: auto; opacity: 0; }
.swatch[aria-checked="true"] .check { opacity: 1; color: var(--primary-strong); }

.chip-toggle {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font: inherit; font-size: .88rem;
  cursor: pointer; text-align: left;
}
.chip-toggle:hover { border-color: var(--primary); }
.chip-toggle[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }

/* ===== Héroe: banda a color de la paleta ===== */
.hero {
  background: var(--hero);
  color: #fff;
  padding-block: 64px 58px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero .eyebrow {
  margin: 0 0 12px; text-transform: uppercase; letter-spacing: .16em;
  font-size: .74rem; font-weight: 700; color: var(--hero-accent);
}
.hero h1 { margin: 0 0 14px; font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; letter-spacing: -.025em; line-height: 1.08; color: #fff; }
.hero-sub { margin: 0 auto; max-width: 640px; color: rgba(255, 255, 255, .85); font-size: 1.1rem; }
.hero-sub strong { color: #fff; }

.latest-badge {
  display: inline-flex; align-items: baseline; gap: 10px;
  margin-top: 26px; padding: 10px 20px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .26);
}
.latest-badge .tag { font-weight: 800; font-size: 1.08rem; color: var(--hero-accent); }
.latest-badge .date { color: rgba(255, 255, 255, .78); font-size: .85rem; }

/* ===== Secciones ===== */
.section { padding-block: 38px; }
.section h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.015em; margin: 0 0 20px; }
.loading { color: var(--text-soft); }
.error-box { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: 18px; color: var(--text-soft); }

/* ===== Tarjetas de descarga ===== */
.cards { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 16px;
}
.card.recommended { border-color: var(--primary); box-shadow: var(--shadow-lg); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-arch { font-size: 1.15rem; font-weight: 700; margin: 0; }
.card-pill {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-soft); white-space: nowrap;
}
.card-pill.is-rec { background: var(--primary); color: var(--on-primary); }

.card-note { font-size: .85rem; color: var(--text-soft); margin: -4px 0 0; }
.card-size { font-size: .82rem; color: var(--text-mute); margin: 0; }

.btn-download {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 13px 16px; border-radius: 12px;
  background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 1rem;
  text-decoration: none; border: 1px solid transparent; transition: background .15s ease;
}
.btn-download:hover { background: var(--primary-strong); }
.btn-download svg { width: 19px; height: 19px; }

/* Bloque de código numérico */
.code-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1px dashed var(--primary); border-radius: 12px; background: var(--primary-soft);
}
.code-row .code-label { font-size: .78rem; color: var(--text-soft); }
.code-row .code-value {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 1.2rem; font-weight: 700; letter-spacing: .08em; margin-left: auto; color: var(--primary-strong);
}

/* Sumas de verificación (sha256 / md5) */
.hashes { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.hash {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px 10px;
}
.hash .hash-label { font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: var(--text-mute); }
.hash .hash-value {
  font-family: ui-monospace, Consolas, monospace; font-size: .76rem;
  color: var(--text-soft); word-break: break-all; background: var(--code-bg);
  padding: 6px 8px; border-radius: 8px;
}

.btn-copy {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 9px; padding: 6px 9px; font: inherit; font-size: .78rem; cursor: pointer; white-space: nowrap;
}
.btn-copy:hover { border-color: var(--primary); color: var(--primary-strong); }
.btn-copy svg { width: 15px; height: 15px; }

/* ===== Cómo instalar ===== */
.howto-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.howto-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.howto-card h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 1.08rem; }
.howto-card h3 svg { width: 22px; height: 22px; color: var(--primary-strong); flex: 0 0 auto; }
.howto-card ol { margin: 0; padding-left: 1.2em; }
.howto-card li { margin-bottom: 7px; }

/* ===== Guía por dispositivo ===== */
.guide-intro { margin: -6px 0 18px; color: var(--text-soft); max-width: 720px; }
.guide { display: block; }
.guide-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.guide-item > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 16px 20px; font-weight: 600; }
.guide-item > summary::-webkit-details-marker { display: none; }
.guide-item > summary svg { width: 22px; height: 22px; color: var(--primary-strong); flex: 0 0 auto; }
.guide-item > summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--text-mute); border-bottom: 2px solid var(--text-mute); transform: rotate(-45deg); transition: transform .15s ease; }
.guide-item[open] > summary::after { transform: rotate(45deg); }
.guide-body { padding: 0 20px 20px; color: var(--text); }
.guide-body p { margin: 0 0 10px; }
.guide-body ol, .guide-body ul { margin: 0 0 10px; padding-left: 1.25em; }
.guide-body li { margin-bottom: 6px; }
.guide-body p:last-child, .guide-body ol:last-child, .guide-body ul:last-child { margin-bottom: 0; }
.guide-warn { border-left: 3px solid var(--primary); background: var(--primary-soft); padding: 10px 14px; border-radius: 8px; color: var(--text); }

/* ===== Historial ===== */
.history { display: flex; flex-direction: column; gap: 12px; }
.release { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.release > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 17px 22px; }
.release > summary::-webkit-details-marker { display: none; }
.release > summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--text-mute); border-bottom: 2px solid var(--text-mute); transform: rotate(-45deg); transition: transform .15s ease; }
.release[open] > summary::after { transform: rotate(45deg); }
.release .rel-tag { font-weight: 800; font-size: 1.08rem; }
.release .rel-date { color: var(--text-soft); font-size: .82rem; }
.release .rel-latest { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 9px; border-radius: 999px; background: var(--primary); color: var(--on-primary); }

.rel-body { padding: 0 22px 22px; }
.rel-notes { color: var(--text); }
.rel-notes ul { padding-left: 1.2em; margin: 0 0 14px; }
.rel-notes li { margin-bottom: 6px; }
.rel-notes h3, .rel-notes h4 { margin: 14px 0 8px; font-size: 1rem; }
.rel-notes p { margin: 0 0 10px; }
.rel-notes a { word-break: break-word; }
.rel-notes h4 { margin: 28px 0 4px; font-size: 1.1rem; text-align: center; }

/* Hueco amplio por arriba para despegar la captura del párrafo anterior, salvo cuando
   viene justo detrás de su encabezado, que entonces va pegada a él. aspect-ratio en vez
   de altura fija para que la caja encoja con la columna en móvil. */
.rel-shot { display: block; width: 100%; max-width: 760px; aspect-ratio: 2 / 1; margin: 24px auto 10px; background: var(--surface-2); border-radius: 8px; }
.rel-notes h3 + p .rel-shot, .rel-notes h4 + p .rel-shot { margin-top: 4px; }

/* Caja fija: las capturas vienen con recortes de alturas muy distintas y sin esto
   cada una entra con un tamaño. contain evita cortar texto de los menús. */
.rel-notes img { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }

/* Solo con ratón: en táctil el hover se queda pegado tras el toque y taparía el texto.
   El aumento va en position fixed porque la tarjeta de versión recorta con overflow hidden
   y un scale se quedaría cortado; pointer-events none evita que la imagen ampliada se robe
   el hover a sí misma y entre en un parpadeo. */
@media (hover: hover) {
  .rel-shot { cursor: zoom-in; }
  .rel-shot:hover img {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: auto; height: 92vh; max-width: 94vw;
    z-index: 60; pointer-events: none; box-shadow: var(--shadow-lg);
  }
}

.rel-notes-box { margin-top: 18px; border-top: 1px solid var(--border); }
.rel-notes-box > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 0 12px; font-weight: 600; color: var(--text-soft); }
.rel-notes-box > summary::-webkit-details-marker { display: none; }
.rel-notes-box > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--text-mute); border-bottom: 2px solid var(--text-mute); transform: rotate(-45deg); transition: transform .15s ease; }
.rel-notes-box[open] > summary::after { transform: rotate(45deg); }

.rel-assets { display: flex; flex-direction: column; gap: 16px; border-top: 1px solid var(--border); padding-top: 18px; }
.rel-asset { display: flex; flex-direction: column; gap: 10px; }
.rel-asset-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.rel-asset .asset-name { font-weight: 600; font-size: .92rem; word-break: break-all; }
.rel-asset .asset-size { color: var(--text-soft); font-size: .8rem; }
.rel-asset .spacer { flex: 1; }
.rel-asset .code-chip {
  font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: .85rem;
  color: var(--primary-strong); background: var(--primary-soft); border: 1px solid var(--primary);
  border-radius: 999px; padding: 3px 10px; letter-spacing: .05em;
}
.rel-asset .btn-download { width: auto; padding: 9px 16px; font-size: .9rem; }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding-block: 30px; margin-top: 40px; color: var(--text-soft); font-size: .88rem; text-align: center; }
.site-footer p { margin: 0; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px);
  background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 999px;
  font-size: .86rem; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .2s ease, transform .2s ease; pointer-events: none; z-index: 40;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Accesibilidad: texto =====
   Las clases van en <html>. 'large' escala el font-size raíz (afecta a todo lo
   que esté en rem) y 'bold'/'upper' heredan a toda la página. */
html.a11y-large { font-size: 118.75%; }
html.a11y-bold, html.a11y-bold body { font-weight: 600; }
html.a11y-bold .hero h1, html.a11y-bold .release .rel-tag, html.a11y-bold .card-arch,
html.a11y-bold .section h2 { font-weight: 900; }
html.a11y-upper body { text-transform: uppercase; }
/* Algunos controles de formulario no heredan text-transform por defecto. */
html.a11y-upper button, html.a11y-upper a, html.a11y-upper input, html.a11y-upper summary { text-transform: uppercase; }

/* ===== Foco visible para teclado ===== */
a:focus-visible, button:focus-visible, summary:focus-visible, .swatch:focus-visible, details > summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 8px;
}
.hero a:focus-visible, .hero button:focus-visible { outline-color: var(--hero-accent); }

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

@media (max-width: 560px) {
  .hero { padding-top: 38px; }
  .brand-text small { display: none; }
  .rel-asset-head .btn-download { width: 100%; }
  .rel-asset-head .spacer { display: none; }
  .hash { grid-template-columns: 1fr auto; }
  .hash .hash-label { grid-column: 1 / -1; }
}
