/* ---------- Variables ---------- */
/* Los nombres indican función, no tono: --black es siempre el fondo
   y --white siempre el texto, también en el modo claro. */
:root {
  color-scheme: dark;

  /* Modo oscuro: Coral */
  --black: #140c0c;
  --dark: #1e1312;
  --dark2: #2b1c1a;
  --white: #fdf1ee;
  --white2: #ecd8d3;
  --gray: #ab928c;
  --gray2: #553f3a;
  --accent: #ff7a59;
  --accent2: #ff5a33;
  --ink-rgb: 253, 241, 238; /* Bordes y fondos translúcidos */
  --bg-rgb: 20, 12, 12;
  --accent-rgb: 255, 122, 89;
  --sky-sun: #f5b94a;
  --sky-moon: #e8e4d8;
  --sky-opacity: 0.09;

  --font-title: 'Fraunces', serif;
  --font-text: 'Source Serif 4', serif;
  --font-accent: 'Fraunces', serif;

  --radius: 12px;
  --radius-lg: 20px;
  --transition: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Modo claro: Crema */
:root[data-theme="light"] {
  color-scheme: light;

  --black: #faf5ec;
  --dark: #f1e9db;
  --dark2: #e6dbc8;
  --white: #2a2320;
  --white2: #4a403a;
  --gray: #75675d;
  --gray2: #c9bcab;
  --accent: #c2410c;
  --accent2: #9a3412;
  --ink-rgb: 42, 35, 32;
  --bg-rgb: 250, 245, 236;
  --accent-rgb: 194, 65, 12;
  --sky-sun: #f5b94a;
  --sky-moon: #c3cbe0;
  --sky-opacity: 0.11;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

[hidden] {
  display: none !important;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--black);
  color: var(--white);
  font-family: var(--font-text);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

main {
  flex: 1;
  padding-top: 6rem; /* Reserva el espacio de la navbar fija */
}

/* ---------- Navbar ---------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2.5rem;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}

.navbar.scrolled {
  background: rgba(var(--bg-rgb), 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom-color: rgba(var(--ink-rgb), 0.06);
}

.logo {
  display: flex;
  margin-right: auto;
  font-family: var(--font-title);
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.1rem;
}

.moon-icon {
  display: inline-block;
  height: 1.1rem;
  vertical-align: -0.2em;
  color: var(--accent);
  animation: moon-beat 1.6s ease-in-out infinite;
}

@keyframes moon-beat {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.25);
  }
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-socials {
  display: flex;
  gap: 0.5rem;
}

.social-pill {
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(var(--ink-rgb), 0.15);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--white2);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.social-pill:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--black);
}

/* ---------- Interruptor de tema ---------- */
.theme-switch {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  height: 32px;
  background: rgba(var(--ink-rgb), 0.08);
  border: 1px solid rgba(var(--ink-rgb), 0.15);
  border-radius: 100px;
}

.theme-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--black);
  /* Con nombre propio, la transición lo desliza en vez de fundirlo en dos sitios */
  view-transition-name: theme-switch-thumb;
}

:root:not([data-theme="light"]) .theme-switch-thumb {
  transform: translateX(24px);
}

.theme-icon {
  grid-area: 1 / 1;
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

/* Fundido entre temas */
::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) {
  animation-duration: 0.5s;
  animation-timing-function: ease-in-out;
}

.lang-switch {
  flex-shrink: 0;
}

/* ---------- Tres rayitas ---------- */
.hamburger {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin-left: -8px; /* Alinea las rayitas, no la zona de clic, con el margen */
}

.hamburger span {
  position: absolute;
  left: 8px;
  width: 24px;
  height: 2px;
  border-radius: 2px;
  background: var(--white);
  transition: transform var(--transition), opacity var(--transition);
}

.hamburger span:nth-child(1) {
  top: 11px;
}

.hamburger span:nth-child(2) {
  top: 19px;
}

.hamburger span:nth-child(3) {
  top: 27px;
}

.hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* ---------- Menú de pestañas ---------- */
/* Base: pantalla completa en móvil y tableta */
.site-menu {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: safe center;
  justify-content: center;
  padding: 5rem 0 1.5rem; /* Deja libre la barra superior */
  overflow-y: auto; /* Por si no cabe, como en un móvil apaisado */
  background: var(--black);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform var(--transition), visibility var(--transition);
}

.site-menu.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform var(--transition), visibility 0s; /* Visible ya para poder recibir el foco */
}

.site-menu nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

.site-menu a {
  font-size: 1.9rem;
  font-weight: 800;
  transition: background var(--transition), color var(--transition);
}

.site-menu a[aria-current="page"] {
  color: var(--accent2);
}

.site-menu a:hover {
  color: var(--accent);
}

.site-submenu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  margin-top: -0.5rem;
}

.site-menu .site-submenu a {
  font-size: 1rem;
  font-weight: 500;
  color: var(--white2);
}

@media (max-width: 1000px) {
  .nav-socials {
    display: none;
  }

  /* A pantalla completa, las pestañas son grandes como títulos */
  .site-menu nav > a {
    font-family: var(--font-title);
  }

  /* En móvil las rayitas van a la derecha */
  .hamburger {
    order: 1;
    margin: 0 -8px 0 0.75rem;
  }

  body.menu-open {
    overflow: hidden;
  }
}

/* Ordenador: panel lateral izquierdo con pestañas en forma de píldora */
@media (min-width: 1001px) {
  .site-menu {
    right: auto;
    width: 240px;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 5.5rem 1.5rem 2rem;
    background: var(--dark);
    border-right: 1px solid rgba(var(--ink-rgb), 0.08);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.25);
    transform: translateX(-100%);
  }

  .site-menu nav {
    align-items: stretch;
    width: 100%;
    gap: 0.25rem;
    padding: 0.3rem;
    background: rgba(var(--ink-rgb), 0.04);
    border: 1px solid rgba(var(--ink-rgb), 0.08);
    border-radius: var(--radius-lg);
  }

  .site-menu a {
    display: block;
    padding: 0.45rem 1.1rem;
    border-radius: 100px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--white2);
  }

  .site-menu a[aria-current="page"] {
    background: rgba(var(--ink-rgb), 0.08);
    color: var(--accent2);
  }

  .site-menu a:hover {
    background: rgba(var(--ink-rgb), 0.08);
    color: var(--white);
  }

  .site-submenu {
    align-items: stretch;
    gap: 0;
    margin: 0 0 0.25rem;
  }

  .site-menu .site-submenu a {
    padding: 0.2rem 1.1rem 0.2rem 1.8rem;
    font-size: 0.8rem;
    font-weight: 400;
  }

  .site-menu .site-submenu a:hover {
    background: none;
    color: var(--accent2);
  }
}

/* ---------- Pestañas visibles en la barra (ordenador) ---------- */
.nav-inline {
  display: none;
}

@media (min-width: 1001px) {
  .hamburger {
    display: none;
  }

  .nav-inline {
    display: flex;
    gap: 1.6rem;
    margin-right: 2rem;
    font-size: 0.9rem;
  }

  .nav-inline a {
    color: var(--white2);
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 0.4em;
    transition: color var(--transition), text-decoration-color var(--transition);
  }

  .nav-inline a:hover,
  .nav-inline a[aria-current="page"] {
    color: var(--white);
    text-decoration-color: var(--accent);
  }
}

/* ---------- Fondo: sol o luna ---------- */
/* La opacidad máxima de cada tema (--sky-opacity) mantiene el contraste del texto */
.sky {
  position: fixed;
  top: 14vh;
  right: -6vw;
  z-index: -1;
  width: clamp(220px, 38vw, 520px);
  aspect-ratio: 1;
  opacity: calc(var(--sky-progress, 0) * var(--sky-opacity));
  transform: translateY(calc((1 - var(--sky-progress, 0)) * 3rem));
  pointer-events: none;
}

.sky-sun {
  color: var(--sky-sun);
}

.sky-moon {
  color: var(--sky-moon);
}

.sky svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Presentación ---------- */
.page-intro {
  padding-bottom: 1rem;
}

.hero-title {
  font-family: var(--font-title);
  margin-bottom: 1.25rem;
  font-size: clamp(2.4rem, 6.5vw, 4.25rem);
  font-weight: 800;
  line-height: 1.1;
  text-wrap: balance; /* Evita palabras sueltas en la última línea */
}

.hero-highlight {
  display: block;
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 700;
  color: var(--accent);
}

.hero-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--white2);
}

.hero-roles li {
  position: relative;
}

.hero-roles li + li::before {
  content: '';
  position: absolute;
  top: 0.35em;
  bottom: 0.35em;
  left: -0.65rem;
  width: 1px;
  background: var(--accent);
}

/* ---------- Secciones de página ---------- */
.page-section:empty {
  display: none;
}

.page-section {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 3rem 2.5rem;
  scroll-margin-top: 2rem;
}

.section-title {
  font-family: var(--font-title);
  margin-bottom: 1rem;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
}

.section-text {
  max-width: 65ch;
  margin-bottom: 1rem;
  color: var(--white2);
}

/* ---------- Tarjetas de proyecto ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.card-grid-wide {
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
  background: var(--dark);
  border: 1px solid rgba(var(--ink-rgb), 0.08);
  border-radius: var(--radius);
}

.card-title {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 700;
}

.card-text {
  flex: 1;
  color: var(--white2);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  padding: 0.15rem 0.6rem;
  background: var(--dark2);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--white2);
}

/* Tarjeta entera clicable, como la de un juego */
.game-card {
  transition: border-color var(--transition), transform var(--transition);
}

.game-card:hover,
.game-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.game-icon {
  width: 3rem;
  height: 3rem;
  fill: var(--accent);
}

/* Tecnologías que sigue explorando */
.tag-learning {
  background: none;
  outline: 1px dashed rgba(var(--ink-rgb), 0.45);
  outline-offset: -1px;
}

/* Ocupa el hueco libre al final de la cuadrícula */
.skills-legend {
  align-self: end;
}

.card-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent2);
}

/* ---------- Botones ---------- */
.button-link {
  display: inline-block;
  padding: 0.55rem 1.2rem;
  border: 1px solid rgba(var(--ink-rgb), 0.15);
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--white);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.button-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--black);
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* ---------- Paneles y formularios ---------- */
.panel {
  max-width: 520px;
  padding: 1.5rem;
  background: var(--dark);
  border: 1px solid rgba(var(--ink-rgb), 0.08);
  border-radius: var(--radius-lg);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.field input {
  padding: 0.6rem 0.8rem;
  background: var(--black);
  border: 1px solid rgba(var(--ink-rgb), 0.15);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 400;
  color: var(--white);
}

.field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.form-error {
  min-height: 1.6em;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--accent2);
}

/* ---------- Mi Pet ---------- */
.stats {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
}

.stat {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  align-items: center;
  font-size: 0.875rem;
}

.stat progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}

/* ---------- Footer ---------- */
.footer {
  padding: 2.5rem 2.5rem 0;
  border-top: 1px solid rgba(var(--ink-rgb), 0.06);
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
}

.footer-name {
  font-weight: 700;
}

.footer-copy {
  color: var(--gray);
}

.footer-top {
  color: var(--white2);
  transition: color var(--transition);
}

.footer-top:hover {
  color: var(--accent);
}

.footer-deco {
  margin-top: 1.5rem;
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 900;
  font-size: clamp(2rem, calc((100vw - 5rem) / 6.1), 12rem); /* Ancho libre / ancho del nombre en em */
  line-height: 1.4;
  color: transparent;
  -webkit-text-stroke: 1px rgba(var(--ink-rgb), 0.04);
  -webkit-user-select: none;
  user-select: none;
}

/* En los móviles más estrechos la barra superior va justa */
@media (max-width: 380px) {
  .nav-actions {
    gap: 0.4rem;
  }

  .hamburger {
    margin-left: 0.4rem;
  }

  .lang-switch {
    padding-inline: 0.55rem;
  }
}

@media (max-width: 600px) {
  .hero-roles {
    flex-direction: column;
  }

  .hero-roles li + li::before {
    display: none;
  }

  .navbar {
    padding-inline: 1.25rem;
  }

  .page-section {
    padding-inline: 1.25rem;
  }

  .footer-row {
    flex-direction: column;
    text-align: center;
  }
}

/* ---------- Cursor personalizado ---------- */
.cursor-dot,
.cursor-ring {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

html.has-custom-cursor,
html.has-custom-cursor * {
  cursor: none !important;
}

html.has-custom-cursor .cursor-dot,
html.has-custom-cursor .cursor-ring {
  display: block;
}

html.cursor-visible .cursor-dot,
html.cursor-visible .cursor-ring {
  opacity: 1;
}

.cursor-dot {
  width: 15px;
  height: 15px;
  border-radius: 0;
  background:
    linear-gradient(var(--accent), var(--accent)) center / 100% 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) center / 2px 100% no-repeat;
  transition: width 0.2s ease, height 0.2s ease, opacity 0.2s ease;
}

.cursor-ring {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  transition: width 0.2s ease, height 0.2s ease, opacity 0.2s ease;
}

html.cursor-hover .cursor-dot {
  width: 21px;
  height: 21px;
}

html.cursor-hover .cursor-ring {
  width: 56px;
  height: 56px;
}

@media (pointer: coarse) {
  html.has-custom-cursor,
  html.has-custom-cursor * {
    cursor: auto !important;
  }

  html.has-custom-cursor .cursor-dot,
  html.has-custom-cursor .cursor-ring {
    display: none;
  }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .sky {
    transform: none;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
