/* =============================================
   Variables
   ============================================= */

:root {
  --gutter: 1.5rem;
  --font: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-heading: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Light mode */
  --body-bg: #d2ebfe;
  --body-bg1: #040404;
  --body-color: #333333;
  --secondary-color: #666666;
  --link-color: #111111;
  --link-color-hover: #000000;
  --link-border-color: rgba(0, 0, 0, 0.25);
  --link-border-color-hover: rgba(0, 0, 0, 0.5);
  --heading-color: #111111;
  --hr-color: rgba(0, 0, 0, 0.1);
  --border: #e5e5e5;
  --card-bg: #f9f9f9;
  --accent: #0066ff;
  --control-h: 2.125rem;
}

[data-theme="dark"] {
  --body-bg: #202844;
  --body-bg1: #1e1e1e;
  --body-color: #e0e0e0;
  --secondary-color: #aaaaaa;
  --link-color: #ffffff;
  --link-color-hover: #4d9fff;
  --link-border-color: rgba(255, 255, 255, 0.25);
  --link-border-color-hover: rgba(255, 255, 255, 0.5);
  --heading-color: #ffffff;
  --hr-color: rgba(255, 255, 255, 0.12);
  --border: #333333;
  --card-bg: #1e1e1e;
  --accent: #4d9fff;
}

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

html {
  font-family: var(--font);
  font-size: 14.4px;
}

body {
  padding: 2rem var(--gutter);
  margin: 0;
  line-height: 1.6;
  color: var(--body-color);
  background-color: var(--body-bg);
  opacity: 0;
  transition: opacity 0.25s ease, background-color 0.35s ease, color 0.35s ease;
}

body.loaded {
  opacity: 1;
}

.container {
  max-width: 62rem;
  margin-inline: auto;
}

/* =============================================
   Typography
   ============================================= */
h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.1;
  color: var(--heading-color);
  letter-spacing: -0.025rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

p {
  margin-top: 0;
  margin-bottom: 1.6rem;
}

p + h1,
p + h2,
p + h3,
ul + h1,
ul + h2,
ul + h3,
ol + h1,
ol + h2,
ol + h3 {
  margin-top: 1.6rem;
}

strong {
  font-weight: 700;
  color: var(--heading-color);
}

ul, ol {
  margin-top: 0;
  margin-bottom: 1rem;
  padding-left: 1.5em;
}

.small { font-size: 85%; }
.muted { color: var(--secondary-color); }
.fw-400 { font-weight: 400; }
.fw-600 { font-weight: 600; }
.fs-3 { font-size: 1.5rem; }
.fs-4 { font-size: 1.25rem; }

@media (max-width: 768px) {
  .fs-4 { font-size: 1rem; }
}

/* =============================================
   Links
   ============================================= */
a {
  font-weight: inherit;
  line-height: inherit;
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
  text-decoration-skip-ink: auto;
  text-underline-offset: 0.25rem;
}

a:hover {
  color: var(--link-color-hover);
}

.page a {
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--link-border-color);
}

.page a:hover {
  text-decoration-color: var(--link-color-hover);
}

.page h2 a {
  text-decoration: none;
}

/* =============================================
   Layout utilities
   ============================================= */
.list-unstyled {
  padding-left: 0;
}

.list-unstyled li {
  padding-inline: 0;
  list-style-type: none;
}

.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.align-items-center { align-items: center; }
.align-content-center { align-content: center; }
.gap { gap: 0.25rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-5 { margin-bottom: 3rem; }
.mr-1 { margin-right: 0.25rem; }
.mt-1 { margin-top: 0.25rem; }

.circle { border-radius: 50%; }
.img-full { max-width: auto !important; height: auto; }

.col-1-2 { grid-column: 1 / span 2; }
.col-2-2 { grid-column: 2 / span 2; }

@media (min-width: 768px) {
  .cols-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-gap: 1.75rem;
  }

  .cols-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 1.75rem;
  }
}

.cols-3 > div {
  margin-bottom: 3rem;
}

.cols-2 > div {
  margin-bottom: 1.5rem;
}

h4 {
  color: var(--secondary-color);
}

/* =============================================
   Header / Nav
   ============================================= */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  padding-bottom: 0.5rem;
  margin-bottom: 3rem;
  border-bottom: 0.125rem solid var(--hr-color);
  gap: 1rem;
}

@media (min-width: 34em) {
  .masthead {
    padding-top: 1rem;
  }
}

.masthead h3 {
  margin-bottom: 0;
  margin-left: 0;
}

.nav-wrapper {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav {
  padding-left: 0;
  margin: 0;
  list-style: none;
  display: flex;
  gap: 1rem;
}

.nav li {
  display: inline-block;
}

.nav a {
  padding: 0.25rem;
}

.nav a.active {
  font-weight: 600;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

@media (max-width: 820px) {
  .masthead {
    flex-wrap: wrap;
    row-gap: 0.75rem;
  }

  .nav-wrapper {
    order: 3;
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 0.75rem;
  }

  .nav {
    flex-wrap: wrap;
    row-gap: 0.5rem;
    gap: 0.25rem 0.6rem;
  }

  .nav a {
    padding: 0.25rem 0;
    font-size: 0.9rem;
  }
}

@media (max-width: 360px) {
  :root {
    --control-h: 1.875rem;
  }

  .lang-switcher {
    padding: 1px;
  }

  .lang-btn {
    padding: 0.2rem 0.45rem;
    font-size: 0.7rem;
  }
}

/* =============================================
   Hero
   ============================================= */
.hero img {
  width: 11.25rem;
  height: 11.25rem;
  object-fit: cover;
}

@media (max-width: 768px) {
  .hero img {
    width: 8rem;
    height: 8rem;
  }

  .social {
    display: inline-flex;
    gap: 2rem;
  }
}

.social {
  gap: 1.5rem;
}

/* =============================================
   Icons
   ============================================= */
.bi {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  fill: currentColor;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.x-flip {
  transform: scaleX(-1);
}

/* =============================================
   Language switcher (ES / EN)
   ============================================= */
.lang-switcher {
  display: inline-flex;
  align-items: stretch;
  height: var(--control-h);
  box-sizing: border-box;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 0 0.6rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  color: var(--body-color);
  opacity: 0.5;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  pointer-events: none;
}

.lang-btn.active {
  opacity: 1;
  background-color: var(--toggle-hover-bg, rgba(128,128,128,0.15));
}

@media (hover: hover) and (pointer: fine) {
  .lang-btn:hover {
    opacity: 1;
  }
}

/* =============================================
   Light/Dark mode button
   ============================================= */
#theme-toggle {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: var(--control-h);
  height: var(--control-h);
  box-sizing: border-box;
  padding: 0;
  cursor: pointer;
  color: var(--body-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

@media (hover: hover) and (pointer: fine) {
  #theme-toggle:hover {
    border-color: none;
    background-color: var(--toggle-hover-bg, rgba(128,128,128,0.15));
    transform: scale(1.05);
  }
}

#theme-toggle:active {
  transform: scale(0.96);
}

#theme-toggle:focus-visible,
.lang-switcher:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Mostrar / ocultar iconos */
[data-theme="dark"] .icon-sun {
  display: none;
}

[data-theme="light"] .icon-moon,
:root:not([data-theme="dark"]) .icon-moon {
  display: none;
}

/* =============================================
   Transición suave
   ============================================= */
a,
.masthead,
footer,
#theme-toggle,
.lang-switcher {
  transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease;
}

/* =============================================
   Footer
   ============================================= */
footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  font-size: 0.875rem;
  border-top: 0.125rem solid var(--hr-color);
}