/* ----------  Fuentes  ---------- */
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&family=Merriweather:ital,opsz,wght@0,18..144,300..900;1,18..144,300..900&family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&display=swap');

@font-face {
  font-family: "Bernardo Moda";
  src: url("../fonts/BernardoModa.woff2") format("woff2"),
       url("../fonts/BernardoModa.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
}

/* ----------  Variables  ---------- */
:root {
  --font-body: 'Nunito Sans', sans-serif;
  --font-display: 'Bernardo Moda', serif;

  /* Paleta de acento */
  --vibrant-coral: #FE675D;
  --vibrant-coral-dark: #FE675D;
  --lavender-purple: #8B5FBF;
  --lavender-purple-dark: #8B5FBF;
  --golden-pollen: #FFD23F;
  --golden-pollen-dark: #F5BC00;
  --moss-green: #7BC950;
  --moss-green-dark: #569C30;

  --accent-light:var(--vibrant-coral);
  --accent-dark: var(--vibrant-coral-dark);

  --platinum: #EFF1F3;
  --onyx: #151414;
}

/* ----------  Base  ---------- */
* { box-sizing: border-box; }
body { font-family: var(--font-body); }

html {
  font-size: 100%;
  --background: var(--onyx);
  --text: var(--platinum);
  --accent: var(--accent-light);
  background: var(--background);
  color: var(--text);
  transition: background .6s ease, color .6s ease;
  scroll-behavior: smooth;
}

html[data-theme="light"] {
  --background: var(--platinum);
  --text: var(--onyx);
  --accent: var(--accent-dark);
}

html[data-theme="dark"] {
  --background: var(--onyx);
  --text: var(--platinum);
  --accent: var(--accent-light);
}

/* Wiki */
html[data-section="wiki"] {
  --accent: var(--moss-green);
}
html[data-section="wiki"][data-theme="light"] {
  --accent: var(--moss-green-dark);
}

/* Now */
html[data-section="now"] {
  --accent: var(--golden-pollen);
}
html[data-section="now"][data-theme="light"] {
  --accent: var(--golden-pollen-dark);
  .now-content a {
    font-weight: 700;
  }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

body {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transition: opacity .6s ease;
  margin: 0;
  max-width: 800px;
  margin-inline: auto;
  background: transparent;
  color: inherit;
  position: relative;
}

/* Solo si hay JS se oculta para hacer el fade-in controlado */
html.js body { opacity: 0; }
html.js body.loaded { opacity: 1; }

body.loaded { opacity: 1; }

/* Clase de "pausa" */
body.no-transition *,
body.no-transition img {
  transition: none !important;
}

/* ----------  Selección  ---------- */
::selection { background: var(--accent); color: var(--background); }
::-moz-selection { background: var(--accent); color: var(--background); }

/* ----------  Tipografía  ---------- */
h1 { font-size: 1.5rem; margin: 0 0 .6em; text-align: left; }
h2 { font-size: 1.3rem; text-align: left; }
h3 { font-size: 1.2rem; text-align: left; }

p {
  font-size: 1.0rem;
  line-height: 1.6;
  margin: 0 0 1em;
  text-align: justify;
}

ul, ol {
  font-size: 1.0rem;
  line-height: 1.6;
  margin: 0 0 0 0;
  padding: 0 0 0 1em;
  text-align: justify;
}

li { margin: 0 0 .25em; }

img {
  margin: 0 0;
  border-radius: 4px;
  width: 100%;
  user-select: none;
}

code {
  font-size: .90rem;
  padding: .1em .3em;
  font-family: consolas;
}
pre code {
  display: block;
  padding: .75em 1em;
  overflow-x: auto;
}

blockquote {
  font-size: 1rem;
  line-height: 1.6;
  margin: 1em 0;
  padding: 1.5em 2.5em;
  position: relative;
  text-align: justify;
  transition: transform .2s ease, background .3s ease;
}

blockquote::before {
  content: "\201C";
  position: absolute;
  top: -0.2em;
  left: 0.4em;
  font-size: 3rem;
  color: var(--accent);
  opacity: 0.33;
  font-family: serif;
}

blockquote p {
  margin: 0;
  padding: 0;
  font-family: "Merriweather", Georgia, serif;
}

blockquote footer {
  display: block;
  text-align: right;
  padding: 0 1em 0 0;
}



/* ----------  Enlaces  ---------- */
/* Base: color y estado activo. El subrayado animado NO se aplica aquí por
   defecto; se enciende por contexto (ver "Subrayado de contenido"). */
a {
  color: var(--accent);
  text-decoration: none;
  position: relative;
  transition: color .3s ease;
}

a.no-click {
  pointer-events: none;
  cursor: default;
}

a:active { color: var(--text); }

/* ----------  Subrayado de contenido (barrido vía background-size)  ----------
   Se enciende SOLO en enlaces de prosa/contenido. Entra por la izquierda y
   sale por la derecha, replicando el transform-origin original. El color sale
   de currentColor; el contenido de wiki/now vive dentro de .page-content, así
   que hereda el barrido sin regla propia (y currentColor ya es el --accent de
   la sección). */
.page-content a,
.summary a,
.breadcrumbs a,
.section-relatos a,
.tags a {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;       /* ancla izquierda → entra por la izquierda */
  background-size: 0% 1px;
  padding-bottom: 1px;
  transition: color .3s ease, background-size .3s ease;
}

.page-content a:hover,
.summary a:hover,
.breadcrumbs a:hover,
.section-relatos a:hover,
.tags a:hover {
  background-size: 100% 1px;
}

.page-content a:not(:hover),
.summary a:not(:hover),
.breadcrumbs a:not(:hover),
.section-relatos a:not(:hover),
.tags a:not(:hover) {
  background-position: 100% 100%;    /* sale por la derecha */
}

/* ----------  Enlaces externos: icono en ::after  ----------
   Anclado a contexto: solo enlaces externos dentro de prosa (.page-content
   cubre blog, relatos, wiki y now; .summary cubre los extractos). Así tree,
   footer-icons y about-icons quedan fuera sin necesidad de exclusiones :not().
   El barrido lo da el sistema de contenido; aquí solo el icono, en flujo. */
.page-content a[href^="http"]:not([href*="lalucira.com"])::after,
.summary a[href^="http"]:not([href*="lalucira.com"])::after {
  content: '';
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-left: 0.15em;
  vertical-align: baseline;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath fill='black' d='M5.5 1v1.5H7.44L3.47 6.47l1.06 1.06L8.5 3.56V5.5H10V1H5.5zM1 2.5v6.53h6.5V6H6v2H2.5V4H5V2.5H1z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath fill='black' d='M5.5 1v1.5H7.44L3.47 6.47l1.06 1.06L8.5 3.56V5.5H10V1H5.5zM1 2.5v6.53h6.5V6H6v2H2.5V4H5V2.5H1z'/%3E%3C/svg%3E") no-repeat center / contain;
  transition: background-color .3s ease;
}

.page-content a[href^="http"]:not([href*="lalucira.com"]):active::after,
.summary a[href^="http"]:not([href*="lalucira.com"]):active::after {
  background: var(--text);
}

/* Excepciones: enlaces de interfaz que caen dentro de contextos de contenido
   (.page-content, .summary) pero no deben llevar barrido.
   - footer-icons / about-icons: iconos redondos, su efecto va en .icon-link.
   - card-link: <a> que cubre toda la card; el subrayado debe ir solo en el
     título (.post-card .headline h2 a), no en la caja completa.
   Nota: se anclan a su contexto para superar la especificidad de
   `.page-content a` (0,1,1), que de otro modo gana y reactiva el barrido. */
.page-content .footer-icons a,
.page-content .about-icons a,
.footer-icons a,
.about-icons a,
.page-content .card-link,
.post-card .card-link {
  background-image: none;
  padding-bottom: 0;
}

/* ----------  Estructura  ---------- */
#fade-wrapper {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transition: opacity .5s ease;
}

html.js #fade-wrapper { opacity: 0; }

#content-wrapper {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#footer-placeholder { flex-shrink: 0; }

.vertical {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}

.divider {
  width: 100%;
  height: 10px;
  display: block;
  margin: 2rem 0;
}

.divider-hor {
  display: block;
  width: 100%;
  height: 10px;
  background-color: var(--text);
  -webkit-mask: url('../svg/divider-h.svg');
  -webkit-mask-size: auto 100%;
  mask: url('../svg/divider-h.svg');
  mask-size: auto 100%;
  margin: 1.5em 0em;
}

.divider-ver {
  display: block;
  width: 50px;
  height: 280px;
  background-color: var(--text);
  -webkit-mask: url('../svg/divider-v.svg');
  -webkit-mask-size: 100% auto;
  mask: url('../svg/divider-v.svg');
  mask-size: 100% auto;
  margin: 0 1.5em;
}

/* ----------  Animaciones  ---------- */
@keyframes fadeIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes logoLoading {
  0%,100% { opacity: 1; }
  50%     { opacity: .35; }
}

@keyframes pulseLine {
  0%,100% { opacity: 1; }
  50%     { opacity: .35; }
}

.cascade > * {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeIn 0.8s ease forwards;
}

/* ----------  Header / Navegación  ---------- */
.header {
  position: relative;
  background: transparent;
  padding: .8em 1.5em;
  display: flex;
  justify-content: flex-start;
  min-height: 2em;
  width: 100%;
  transition: background .6s ease, margin-bottom .3s ease;
}

.nav-container {
  display: flex;
  align-items: center;
  gap: 1.5em;
  width: 100%;
}

.navbar {
  padding-top: 0.8em;
}

.navbar a {
  position: relative;
  color: var(--text);
  text-decoration: none;
  padding-block: 8px;
  margin-inline: 12px;
  transition: color .3s ease;
}

.navbar a::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  bottom: 4px;
  height: 3px;
  background: var(--text);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s ease, max-width .3s ease;
  will-change: transform, max-width;
}

.navbar a:hover::after,
.navbar a.loading::after {
  transform: scaleX(1);
  max-width: 100%;
}

.navbar a:not(:hover)::after { transform-origin: right; }

.navbar a.active::after {
  margin: 0 auto;
  max-width: 1.5em;
  transform: scaleX(1);
  transform-origin: center;
  background: var(--accent);
}

.navbar a.active:hover::after {
  max-width: 100%;
  transform-origin: center;
  background: var(--text);
}

.navbar a.loading::after {
  animation: pulseLine 1.2s ease-in-out infinite;
}

.navbar:has(a.loading) a {
  pointer-events: none;
}

/* ----------  Logo  ----------
   Conserva su ::after propio (SVG inline ajustado a medida). No usa el
   sistema de background. */
.logo-link {
  color: var(--logo-color, currentColor);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: color .25s ease;
}

.logo-link::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  height: 2px;
  bottom: 0px;
  background: currentColor;
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .3s ease;
}

.logo-link:hover::after { transform-origin: left; }
.logo-link:not(:hover)::after { transform-origin: left; transition: transform .3s ease-out; }

.logo-link:hover::after,
.logo-link.active::after,
.logo-link.loading::after,
.logo-link.loading:hover::after {
  transform: scaleX(1);
}

.logo-link:hover { color: var(--accent); }
.logo-link.active { color: var(--accent); pointer-events: none; }
.logo-link.loading { animation: logoLoading 1s ease-in-out infinite; }
.logo-link.loading:hover { color: inherit; }

/* ----------  Hamburger  ---------- */
.hamburger { display: none; }

/* ----------  Nav-utils links (menú hamburguesa)  ---------- */
.nav-utils-link { display: none; }

#nav-utils .nav-utils-link::after { display: none; }

#nav-utils .nav-utils-link:hover { color: var(--accent); }

#nav-utils .nav-utils-link.active {
  color: var(--accent);
  pointer-events: none;
  font-weight: bold;
}

#nav-utils .nav-utils-link.loading {
  animation: pulseLine 1.2s ease-in-out infinite;
  color: var(--text);
}

/* ----------  Theme toggle  ---------- */
.theme-toggle {
  position: relative;
  will-change: opacity;
  text-decoration: none;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  appearance: none;
}

@media (hover: hover) {
  .theme-toggle:hover {
    opacity: 0.5;
    transition: opacity .3s ease;
  }
}

.theme-toggle:active {
  opacity: 0.5;
  transition: opacity .1s ease;
}

.theme-toggle::after {
  transform: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
  transition: none !important;
}

/* ----------  Localización  ---------- */
.lang-toggle {
  position: relative;
  align-items: center;
  gap: 0.4em;
  font-size: 0.8em;
  transition: opacity .3s ease;
}

.lang-toggle.hidden {
  opacity: 0.5;
  pointer-events: none;
}

.lang-toggle .lang-active {
  opacity: 1;
  transition: opacity .3s ease;
}

.lang-toggle .lang-inactive {
  opacity: 0.3;
  transition: opacity .3s ease;
}

.lang-toggle.loading .lang-active,
.lang-toggle.loading .lang-inactive {
  animation: pulseLine 1.2s ease-in-out infinite;
  opacity: 1;
}

@media (hover: hover) {
  .lang-toggle:hover .lang-active { opacity: 0.3; }
  .lang-toggle:hover .lang-inactive { opacity: 1; }
}

.lang-toggle::after { display: none; }


/* ----------  Main  ---------- */
.page-content {
  background: transparent;
  color: var(--text);
  padding: 1.5em clamp(1.5rem, 5vw, 5rem);
  text-align: center;
}

.page-inner {
  max-width: 620px;
  margin-inline: auto;
}

.summary {
  text-align: justify;
}

/* ----------  Footer  ---------- */
footer {
  display: flex;
  justify-content: center;
  padding: .8em 1.5em;
  padding-top: 0em;
  background: transparent;
}

.footer-content { display: flex; flex-direction: column; align-items: center; }
.footer-icons { display: flex; gap: 1rem; }

.about-icons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin: 2em auto 0;
  width: fit-content;
}

.footer-icons a,
.about-icons a { color: var(--text); text-decoration: none; }

.icon-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
}

/* Los icon-link (footer / about / redes sociales) son enlaces externos pero
   su marca es el círculo del ::before y el SVG; nunca deben mostrar el icono
   ↗ de enlace externo que el sistema pone en el ::after. */
.icon-link::after {
  display: none !important;
}

.icon-link::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--text);
  border-radius: 50%;
  transition: border-color .6s ease, color .6s ease;
}

.icon-link:hover::before {
  border-width: 4px;
  border-radius: 40%;
}

.icon-link svg,
.icon-link::before {
  transition: all .2s ease;
}

.icon-link svg {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  color: var(--text);
}

.icon-link:active svg {
  color: var(--accent);
  transition: border-color .05s ease, color .05s ease;
}

.icon-link:active::before {
  border: 6px solid var(--accent);
  border-radius: 40%;
  transition: border-color .05s ease, color .05s ease;
}

/* ----------  Blog — Meta y cabeceras  ---------- */
.meta {
  font-size: 0.8rem;
  line-height: 1.6;
  margin: 0 0 1em;
  text-align: left;
  opacity: 0.7;
  flex-shrink: 0;
}

.headline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75em;
  margin: 0;
  min-width: 0;
}

.digest {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75em;
  margin: 0 0 .6em;
}

.vertical > section { min-width: 0; }

.ult-vertical { width: 50%; }

.ult-headline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75em;
  margin: 0;
}

.ult-headline > p:first-child {
  flex: 1;
  color: var(--accent);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ult-headline > p:last-child { flex-shrink: 0; }

.summary p { margin: 0; }

/* ----------  Blog — Tags  ----------
   Sin subrayado de contenido (no están en la lista de contextos). */
.tags {
  display: flex;
  margin-right: .5em;
  flex-wrap: wrap;
  position: relative;
  z-index: 30;
}

.tags a {
  font-size: .85rem;
  color: var(--accent);
  text-decoration: none;
  transition: color .3s ease, background-size .3s ease;
}

.tags a:active {
  color: var(--text);
  transition: color .05s ease;
}

/* ----------  Blog — Tarjetas  ---------- */
.post-card { position: relative; }

.card-link {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: auto;
}

.post-card .headline,
.post-card .post-image,
.post-card .summary {
  position: relative;
  z-index: 1;
}

/* El título de la card usa el barrido pero disparado por el hover de la card,
   no del propio enlace. Color fijo a currentColor; direccionalidad: entra
   izquierda, sale derecha; se cancela si hay hover en las tags. */
.post-card .headline h2 a {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  padding-bottom: 1px;
  transition: color .3s ease, background-size .3s ease;
}
.post-card .headline h2 a:hover { background-size: 0% 1px; }
.post-card:hover .headline h2 a { background-size: 100% 1px; }
.post-card:not(:hover) .headline h2 a { background-position: 100% 100%; }
.post-card:has(.tags:hover) .headline h2 a {
  background-size: 0% 1px;
  background-position: 100% 100%;
}

.post-image {
  width: 100%;
  aspect-ratio: 7 / 3;
  overflow: hidden;
  margin: 0 0 0.7em 0;
}

.post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
  transition: transform .3s ease;
}

.post-card:hover .post-image img { transform: scale(1.02); }

/* ----------  Paginación  ----------
   Color fijo --accent. Direccionalidad opuesta: la flecha izquierda entra por
   la derecha; la derecha entra por la izquierda. */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 3em 0;
  font-size: 0.9rem;
}

.pagination .page-link-l,
.pagination .page-link-r {
  color: var(--accent);
  text-decoration: none;
  position: relative;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-size: 0% 1px;
  padding-bottom: 1px;
  transition: background-size .3s ease, background-image .3s ease;
}

.pagination .page-link-l { background-position: 100% 100%; }  /* entra por la derecha */
.pagination .page-link-r { background-position: 0 100%; }     /* entra por la izquierda */

/* Entrada: ancla en :hover */
.pagination .page-link-l:hover { background-position: 100% 100%; background-size: 100% 1px; }
.pagination .page-link-r:hover { background-position: 0 100%;   background-size: 100% 1px; }

/* Salida: ancla opuesta en reposo (se retrae hacia el lado contrario) */
.pagination .page-link-l:not(:hover) { background-position: 100% 100%; }
.pagination .page-link-r:not(:hover) { background-position: 0 100%; }

.pagination .page-link-l.disabled,
.pagination .page-link-r.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Click: se retrae en el mismo sentido que la salida (gana a :hover) */
.pagination .page-link-l:active {
  background-position: 0 100%;
  background-size: 0% 1px;
}
.pagination .page-link-r:active {
  background-position: 100% 100%;
  background-size: 0% 1px;
}

.page-info { opacity: 0.7; }

/* ----------  Notas al pie  ----------
   Sin subrayado de contenido; solo cambio de color en hover. Se ancla a
   .page-content para superar la especificidad de `.page-content a`. */
.footnote-ref { font-size: 0.75em; }

.footnotes {
  margin-top: 2em;
  font-size: .9rem;
  opacity: .85;
}

.footnotes ol { padding-left: 1.2em; }

.page-content .footnote-ref,
.page-content .footnotes a,
.footnote-ref,
.footnotes a {
  background-image: none;
  padding-bottom: 0;
}

.footnote-ref:hover,
.footnotes a:hover { color: var(--text); }

:target {
  scroll-margin-top: 4em;
}

/* ----------  Breadcrumbs  ----------
   El subrayado lo da el sistema de contenido. .current sin enlace. */
.breadcrumbs {
  font-size: 0.9rem;
  margin-bottom: 1.2em;
  color: var(--text);
  opacity: .8;
  display: flex;
  gap: .4em;
  flex-wrap: wrap;
}

.breadcrumbs a { color: var(--accent); text-decoration: none; }
.breadcrumbs .sep { opacity: .5; user-select: none; }
.breadcrumbs .current { font-weight: 600; opacity: 1; color: var(--text); }

/* ----------  Relatos  ---------- */
.section-relatos {
  font-family: "Lora", Georgia, serif;
}

/* ----------  Now  ---------- */
.now-content h2 { text-align: center; }

/* ----------  Wiki  ---------- */
.wiki-header {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}

.wiki-index,
.wiki-article {
  font-family: "Source Serif 4", Georgia, serif;
}

.wiki-lead {
  opacity: 80%;
  padding: 0em 1em 1.2em 1em;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 0.9em;
  flex: 1;
  min-width: 0;
  display: flex;
}

.wiki-lead-container {
  flex: 1 1 0;
  min-width: 0;
}

.wiki-infobox-container {
  flex: 0 0 auto;
  width: 40%;
  max-width: 320px;
  min-width: 180px;
  font-size: .8rem;
  margin-bottom: 2em;
}

.wiki-infobox {
  width: 100%;
}

.wiki-infobox th {
  text-align: right;
  padding-right: 0.35rem;
  width: 40%;
}

.wiki-infobox td {
  width: 60%;
  text-align: left;
  padding-left: 0.35rem;
}

.wiki-vertical {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.wiki-vertical > section { min-width: 0; }

.wiki-all {
  margin-top: 2em;
}

.wiki-index a,
.wiki-content a {
  font-weight: 600;
}

/* ----------  Error 404  ---------- */
.not-found {
  background-image: url('/static/img/404.webp');
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: contain;
}

/* ----------  Header colapsado (menú hamburguesa)  ----------
   FUENTE ÚNICA de las reglas del header en modo "móvil".

   Se activa de dos formas, que comparten exactamente las mismas declaraciones
   gracias a las listas de selectores de abajo:
     1. Con JS: la clase .header.is-collapsed la togglea script.js según un
        breakpoint dinámico (nº de enlaces + tamaño de fuente).
     2. Sin JS (fallback): el @media (max-width: 550px) envuelto en
        html:not(.js), un umbral conservador que cubre casi cualquier móvil.

   Mantener SIEMPRE los mismos selectores en ambos lados de cada coma para que
   las dos vías no puedan divergir. */

.header.is-collapsed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 800;
  background: var(--background);
  max-width: 800px;
  margin-inline: auto;
  padding: 0.8em 0.8em;
}

.header.is-collapsed .logo-link {
  position: relative;
  z-index: 2;
}

.header.is-collapsed .hamburger {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 1em;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin-left: 0;
}

.header.is-collapsed .nav-container {
  position: relative;
}

.header.is-collapsed #nav-utils {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  display: flex;
  top: 100%;
  left: 0;
  right: 0;
  flex-direction: column;
  align-items: center;
  z-index: 1;
  gap: 0.5em;
  background: var(--background);
  width: 100%;
  padding-top: 0.5em;
  padding-bottom: 0.5em;
  transform: translateY(-4px);
  transition: opacity .3s ease, visibility .3s ease, transform .3s ease, background .3s ease;
}

.header.is-collapsed #nav-utils.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.header.is-collapsed .navbar:not(#nav-utils) {
  display: none;
}

.header.is-collapsed #nav-utils .nav-utils-link {
  display: inline-block;
  padding-top: 0.3em;
}

.header.is-collapsed .nav-utils-controls {
  display: flex;
  flex-direction: row;
  gap: 0.8em;
  align-items: center;
  padding-bottom: 1em;
  width: 100%;
  justify-content: center;
}

.header.is-collapsed .nav-utils-controls .font-size-toggle,
.header.is-collapsed .nav-utils-controls .lang-toggle,
.header.is-collapsed .nav-utils-controls .theme-toggle {
  padding: 0.3em 0.5em;
  margin: 0;
}

/* Empuje del contenido para dejar sitio al header fijo. Va ligado al estado del
   header, no al viewport, usando :has() (con el fallback sin-JS por media query
   más abajo, para navegadores donde el fallback estático deba aplicar igual). */
body:has(.header.is-collapsed) #fade-wrapper {
  padding-top: 3.5em;
}

/* El botón "volver arriba" pierde su borde en modo colapsado. */
.header.is-collapsed ~ * #back-to-top,
.header.is-collapsed ~ * #back-to-top.visible,
.header.is-collapsed ~ * #back-to-top:hover,
.header.is-collapsed ~ * #back-to-top:active,
html:not(.js) #back-to-top,
html:not(.js) #back-to-top.visible,
html:not(.js) #back-to-top:hover,
html:not(.js) #back-to-top:active {
  border: none;
  border-color: transparent;
}

/* ----------  Responsive  ---------- */
.content-short { display: none; }

@media screen and (max-width: 690px) {
  .vertical { flex-direction: column; }
  .divider-ver { display: none; }
  .hideauto { display: none; }
  .vertical img { order: 1; margin: 2em auto 0; align-self: center; }
  .ult-headline { justify-content: flex-start; }
  .ult-headline > p:first-child { flex: unset; }
  .ult-vertical { width: 100%; }

  .wiki-vertical { flex-direction: column; gap: 0; align-items: center; }
  .wiki-infobox-container {
    width: 100%;
    flex: auto;
    justify-content: center;
  }
  .wiki-infobox {
    width: 100%;
  }
  .wiki-infobox th,
  .wiki-infobox td {
    width: 50%;
  }
}

@media screen and (max-width: 520px) {
  .headline { display: unset; }
  .content-long { display: none; }
  .content-short { display: flex; }
}

@media screen and (max-width: 420px) {
  html[data-fontsize="large"] .footer-icons,
  html[data-fontsize="large"] .about-icons {
    gap: .4rem;
  }
}


/* ----------  NoJS  ---------- */
html:not(.js) .navbar:not(#nav-utils) { display: flex; }
html:not(.js) .hamburger { display: none; }
html:not(.js) #nav-utils { display: none; }
html:not(.js) .footer-content { margin-bottom: 6em; }
html:not(.js) .no-js-warning { display: flex; }

.no-js-warning {
  display: none;
  position: fixed;
  left: 0rem;
  right: 0rem;
  bottom: 0rem;
  z-index: 9999;
  padding: 0.9rem 1.2rem;
  border-radius: 0px;
  background: var(--background);
  color: var(--accent);
  opacity: 80%;
}

.no-js-warning p {
  font-size: 0.85rem;
  opacity: 100%;
}

/* ----------  Barra de progreso  ---------- */
#read-progress {
  position: fixed;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 300;
  transition: width .1s linear;
}

/* ----------  Botón volver arriba  ---------- */
#back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  border: 1px solid var(--text);
  background: var(--background);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease, background .2s ease, color .2s ease, border-color .2s ease, border-width .2s ease, border-radius .2s ease;
}

#back-to-top svg {
  width: 1.1rem;
  height: 1.1rem;
  transition: none;
}

#back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

#back-to-top:hover {
  background: var(--text);
  color: var(--background);
}

#back-to-top:active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--background);
  transition: background .05s ease, color .05s ease, border-color .05s ease;
}

/* ----------  Pill link  ---------- */
.pill-link {
  display: inline-block;
  padding: .45em 1.2em;
  border: 2px solid var(--text);
  border-radius: 999px;
  font-size: .9rem;
  color: var(--text);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
  margin-top: 1.5em;
}

/* Excluido del barrido: `.page-content a` (0,1,1) le inyecta background-image
   y padding-bottom: 1px, lo que rompe la simetría de la píldora. Esta regla
   anclada (0,1,1, y posterior en el archivo) los neutraliza. */
.page-content .pill-link {
  background-image: none;
  padding-bottom: .45em;
}

.pill-link:hover {
  background: var(--text);
  color: var(--background);
}

.pill-link:active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--background);
}

/* ----------  Tamaño de fuente  ---------- */
html[data-fontsize="large"] {
  font-size: 112.5%;
}

.font-size-toggle {
  position: relative;
  align-items: center;
  gap: 0.4em;
  font-size: 0.8em;
  transition: opacity .3s ease;
  display: inline-flex;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  appearance: none;
}

.font-size-toggle .font-size-active {
  opacity: 1;
  transition: opacity .3s ease;
}

.font-size-toggle .font-size-inactive {
  opacity: 0.3;
  transition: opacity .3s ease;
}

@media (hover: hover) {
  .font-size-toggle:hover .font-size-active { opacity: 0.3; }
  .font-size-toggle:hover .font-size-inactive { opacity: 1; }
}