/* ----------  Fuentes  ---------- */
@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&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;
  --bittersweet: #FE675D;
  --afwhite: #EFF1F3;
  --night: #151414;
}

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

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

html[data-theme="light"] {
  --background: var(--afwhite);
  --text: var(--night);
}

html[data-theme="dark"] {
  --background: var(--night);
  --text: var(--afwhite);
}

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

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

body.loaded { opacity: 1; }

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

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

/* ----------  Tipografía  ---------- */
h1 { font-size: 1.5rem; margin: 0 0 .6em; text-align: left; }
h2 { font-size: 1.3rem; margin: 1.2em 0 .5em; text-align: left; }
h3 { font-size: 1.2rem; margin: 1em 0 1em; 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 1em 1.2em;
  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(--bittersweet);
  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  ---------- */
a {
  color: var(--bittersweet);
  text-decoration: none;
  position: relative;
  transition: color .3s ease;
}

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

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

a:hover::after { transform: scaleX(1); max-width: 100%; }
a:not(:hover)::after { transform-origin: right; }
a:active { color: var(--text); }

a:active::before {
  border: 6px solid var(--text);
  border-radius: 40%;
}

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

#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') repeat-x;
  -webkit-mask-repeat: repeat-x;
  -webkit-mask-size: auto 100%;
  mask: url('../svg/divider-h.svg') repeat-x;
  mask-repeat: repeat-x;
  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') repeat-y;
  -webkit-mask-repeat: repeat-y;
  -webkit-mask-size: 100% auto;
  mask: url('../svg/divider-v.svg') repeat-y;
  mask-repeat: repeat-y;
  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(--bittersweet);
}

.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  ---------- */
.logo-link {
  color: var(--logo-color, currentColor);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: color .25s ease;
}

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

.logo-link::after {
  height: 2px;
  bottom: 0px;
  transform-origin: right;
}

.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);
}

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

/* ----------  Theme toggle  ---------- */
.theme-toggle {
  position: relative;
  will-change: opacity;
  text-decoration: none;
  color: var(--text);
}

@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;
}

.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 5em;
  text-align: center;
}

/* ----------  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; }
.footer-icons a::after,
.about-icons a::after { height: 0px; }

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

.icon-link::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--text);
  border-radius: 50%;
  transition: all .2s ease;
  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(--bittersweet);
  transition: border-color .05s ease, color .05s ease;
}

.icon-link:active::before {
  border: 6px solid var(--bittersweet);
  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(--bittersweet);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

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

.summary p { margin: 0; }

/* ----------  Blog — Tags  ---------- */
.tags {
  display: flex;
  margin-right: .5em;
  flex-wrap: wrap;
  position: relative;
  z-index: 30;
}

.tags a {
  font-size: .85rem;
  color: var(--bittersweet);
  text-decoration: none;
}

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

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

.card-link::after { display: none; }

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

.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); }

.post-card .headline h2 a::after { transform: scaleX(0); transform-origin: left; }
.post-card:hover .headline h2 a::after { transform: scaleX(1); }
.post-card:not(:hover) .headline h2 a::after { transform-origin: right; }
.post-card:has(.tags:hover) .headline h2 a::after { transform: scaleX(0); transform-origin: right; }

/* ----------  Paginación  ---------- */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 3em 0;
  font-size: 0.9rem;
}

.page-link-l,
.page-link-r {
  color: var(--bittersweet);
  text-decoration: none;
  position: relative;
}

.page-link-l::after,
.page-link-r::after {
  content: '';
  position: absolute;
  bottom: 2px;
  height: 1px;
  width: 100%;
  background: var(--bittersweet);
  transform: scaleX(0);
  transition: transform .3s ease;
}

.page-link-l:hover::after { transform: scaleX(1); transform-origin: right; }
.page-link-r:hover::after { transform: scaleX(1); transform-origin: left; }
.page-link-l:not(:hover)::after { transform-origin: right; }
.page-link-r:not(:hover)::after { transform-origin: left; }

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

.page-info { opacity: 0.7; }

/* ----------  Notas al pie  ---------- */
.footnote-ref { font-size: 0.75em; }

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

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

.footnote-ref::after,
.footnotes a::after { background: transparent; }

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

/* ----------  Breadcrumbs  ---------- */
.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(--bittersweet); text-decoration: none; position: relative; }
.breadcrumbs a:hover::after { transform: scaleX(1); }
.breadcrumbs .sep { opacity: .5; user-select: none; }
.breadcrumbs .current { font-weight: 600; opacity: 1; color: var(--text); }


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

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

@media screen and (max-width: 800px) {
  .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%; }
}

@media screen and (max-width: 650px) {
  html[data-fontsize="large"] .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--background);
    max-width: 800px;
    margin-inline: auto;
  }

  html[data-fontsize="large"] .hamburger {
    display: flex;
    align-items: center;
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3em 0 0 0.5em;
  }

  html[data-fontsize="large"] #nav-utils {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    display: flex;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-end;
    z-index: 100;
    gap: 0.5em;
    background: var(--background);
    width: 100%;
    transform: translateY(-10px);
    transition: opacity .3s ease, visibility .3s ease, transform .3s ease, background .6s ease;
    padding-right: 1.5em;
  }

  html[data-fontsize="large"] #fade-wrapper { padding-top: 3.5em; }

  html[data-fontsize="large"] #nav-utils.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  html[data-fontsize="large"] #back-to-top,
  html[data-fontsize="large"] #back-to-top.visible,
  html[data-fontsize="large"] #back-to-top:hover,
  html[data-fontsize="large"] #back-to-top:active {
    border: none;
    border-color: transparent;
  }

  html[data-fontsize="large"] .page-content { padding: 1.5em 1.5em; }
  html[data-fontsize="large"] .headline { display: unset; }
}

@media screen and (max-width: 580px) {
  .page-content { padding: 1.5em 1.5em; }

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

  .hamburger {
    display: flex;
    align-items: center;
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3em 0 0 0.5em;
  }

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

  #fade-wrapper { padding-top: 3.5em; }

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

  #back-to-top,
  #back-to-top.visible,
  #back-to-top:hover,
  #back-to-top:active {
    border: none;
    border-color: transparent;
  }
}

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

@media screen and (max-width: 420px) {
  html[data-fontsize="large"] .header {
    padding: 0.5em 0.8em;
  }

  html[data-fontsize="large"] .navbar {
    padding: 0em;
  }

  html[data-fontsize="large"] .navbar a {
    display: inline-block;
    padding: 2px 0 6px 0;
  }

  html[data-fontsize="large"] .navbar a:first-child {
    padding-top: 16px;
  }

  html[data-fontsize="large"] .logo-link svg {
    height: 1.2cm;
  }

  html[data-fontsize="large"] .page-content {
    padding: 0.8em 0.8em;
  }

  html[data-fontsize="large"] .footer-icons,
  html[data-fontsize="large"] .about-icons {
    gap: .4rem;
  }
}

@media screen and (max-width: 380px) {
  .header,
  .page-content {
    padding: 0.8em 0.8em;
  }
}

/* ----------  Barra de progreso  ---------- */
#read-progress {
  position: fixed;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--bittersweet);
  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(--bittersweet);
  border-color: var(--bittersweet);
  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;
}

.pill-link::after { display: none; }

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

.pill-link:active {
  background: var(--bittersweet);
  border-color: var(--bittersweet);
  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;
}

.font-size-toggle::after { display: 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;
}

.font-size-toggle:hover .font-size-active { opacity: 0.3; }
.font-size-toggle:hover .font-size-inactive { opacity: 1; }