:root {
  --bg: #101012;
  --bar: #17171a;
  --fg: #e8e8ea;
  --dim: #8a8a92;
  --accent: #fff;
  --red: #e40a26;
  --red-bright: #ff2d47;
  --gap: 10px;
  --barh: 64px;
  --page-content-offset: 25px;
  --page-top-space: calc(var(--barh) + var(--gap) + var(--page-content-offset));
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  scrollbar-gutter: stable;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family:
    "Space Grotesk",
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

/* ---------- top bar ---------- */
header {
  position: fixed;
  inset: 0 0 auto;
  height: var(--barh);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bar) 88%, transparent);
  backdrop-filter: blur(10px);
  z-index: 10;
}

header .logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.5px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}
header .logo span {
  color: #e40a26;
}

.logo-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

nav a {
  color: var(--dim);
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 6px;
  white-space: nowrap;
  transition:
    color 0.15s,
    background 0.15s;
}
nav a:hover {
  color: var(--fg);
}
nav a.active {
  color: var(--accent);
  background: #ffffff14;
}

/* Botón hamburguesa: oculto en escritorio, donde el nav ya cabe en la barra. */
.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 100px;
  background: #ffffff0a;
  border: 1px solid #ffffff0f;
  color: var(--fg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s;
}

.menu-toggle:hover {
  background: #ffffff14;
  border-color: #ffffff1f;
}

.menu-toggle:focus-visible {
  outline: 2px solid var(--red-bright);
  outline-offset: 2px;
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentcolor;
  transition:
    transform 0.2s ease,
    opacity 0.15s ease;
}

/* Las tres barras se convierten en una X mientras el menú está desplegado. */
.menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---------- page layout ---------- */
main {
  padding: 0 var(--gap) var(--gap);
}

/* Todas las vistas comienzan a la misma distancia del header fijo. */
.view {
  display: none;
  padding-top: var(--page-top-space);
}

/* La versión base es utilizable sin JavaScript. main.js cambia body de
   .no-js a .js-ready solo cuando el módulo ya ha arrancado; entonces entra el
   router por hash y se ocultan los respaldos HTML estáticos. */
.no-js .view,
.js-ready .view.active {
  display: block;
}

.js-ready .static-fallback {
  display: none !important;
}

.no-js .gallery-tabs,
.no-js .projects-rail-wrap,
.no-js .projects-stage,
.no-js .stats-status {
  display: none;
}

.no-js .gallery-content[hidden] {
  display: block !important;
}

.no-js #grid-unity .card-body,
.no-js #grid-godot .card-body {
  position: static;
  padding: 24px;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.no-js .projects-browser {
  display: block;
}

.no-script-notice {
  max-width: 1100px;
  margin: calc(var(--barh) + 18px) auto 0;
  padding: 16px 24px;
  border: 1px solid #ffffff18;
  border-radius: 12px;
  background: #ffffff08;
  color: var(--dim);
  line-height: 1.55;
}

.no-script-notice strong {
  color: var(--fg);
}

.no-script-notice nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.no-script-notice a {
  color: var(--fg);
  font-size: 13px;
  font-weight: 700;
}

.nojs-project-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.nojs-project-item {
  padding: 22px;
  border: 1px solid #ffffff0f;
  border-radius: 12px;
  background: #ffffff06;
}

.nojs-project-item h3 {
  font-size: 20px;
}

.nojs-project-item p {
  margin-top: 8px;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.55;
}

.nojs-project-item a {
  display: inline-block;
  margin-top: 16px;
  color: var(--fg);
  font-size: 13px;
  font-weight: 700;
}

/* ---------- shared section header ---------- */
.section-header {
  text-align: center;
  margin-bottom: 64px;
}

.section-header .tag {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: clamp(36px, 5.5vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -3px;
  margin: 0;
}

.section-header h2 em {
  font-style: italic;
  color: #e40a26;
}

/* ---------- gallery tabs ---------- */
.gallery-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 40px;
}

.gallery-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid #ffffff0a;
  color: var(--dim);
  padding: 10px 24px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    color 0.2s,
    background 0.2s,
    border-color 0.2s;
  font-family: inherit;
}

.tab-glyph {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  background-color: currentcolor;
  -webkit-mask: var(--i) center / contain no-repeat;
  mask: var(--i) center / contain no-repeat;
}

/* Godot keeps its real black-and-white details instead of being flattened
   into a CSS mask, so its face remains visible. */
.tab-logo {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.gallery-tab:hover {
  color: var(--fg);
  border-color: #ffffff20;
}

.gallery-tab.active {
  color: #fff;
  background: #e40a26;
  border-color: #e40a26;
}

.gallery-tab .tab-count {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 100px;
  background: #ffffff14;
  font-size: 11px;
  font-weight: 700;
}

.gallery-tab.active .tab-count {
  /* Overlay oscuro (no claro) sobre el rojo de la pestaña activa: el blanco
     sobre #ffffff2b quedaba en ~4.2:1, por debajo del mínimo AA de 4.5:1. */
  background: #00000026;
}

.section-lead {
  margin: 18px auto 40px;
  max-width: 620px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--dim);
}

/* ---------- shared cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.card {
  position: relative;
  background: #ffffff06;
  border: 1px solid #ffffff0a;
  border-radius: 12px;
  overflow: hidden;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.2s;
  cursor: pointer;
}

.card:hover {
  background: #ffffff0c;
  border-color: #ffffff18;
  transform: translateY(-2px);
}

.media-frame {
  position: relative;
  overflow: hidden;
  background: #ffffff06;
}

.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

/* Estados visuales de los medios (js/utils.js setMediaState): pendiente
   muestra spinner sobre el medio atenuado; error deja un aviso legible.
   `.media-frame` envuelve cada imagen o vídeo de tarjeta y reserva el
   hueco; el poster del vídeo cubre la espera en cuanto se asigna. */
/* Reservamos el espacio de la imagen/vídeo y mostramos un indicador mientras
   llega. Así una red lenta no deja tarjetas aparentemente rotas o vacías. */
.media-pending {
  position: relative;
}

.media-pending > img,
.media-pending > video {
  opacity: 0.38;
}

.media-pending::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid #ffffff38;
  border-top-color: var(--red-bright);
  border-radius: 50%;
  animation: media-spinner 0.8s linear infinite;
}

.media-error {
  position: relative;
  display: grid;
  min-height: 130px;
  place-items: center;
  background: #ffffff08;
}

.media-error > img,
.media-error > video {
  opacity: 0.3;
}

.media-error::before {
  content: attr(data-media-error);
  position: relative;
  z-index: 4;
  max-width: 26ch;
  padding: 12px 16px;
  color: var(--fg);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

@keyframes media-spinner {
  to {
    transform: rotate(360deg);
  }
}

#grid-unity .card:hover .card-thumb,
#grid-godot .card:hover .card-thumb,
#grid-environments .card:hover .card-thumb {
  transform: scale(1.04);
}

.thumb-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 100px;
  background: #000000a8;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

/* Unity screenshots share this ratio, so keep the complete frame visible. */
#grid-unity {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 1200px;
}

#grid-unity .card {
  position: relative;
}

#grid-unity .card-thumb {
  aspect-ratio: 1920 / 1032;
  height: auto;
  object-fit: cover;
}

/* Show each title and description over the image on hover. */
#grid-unity .card-body {
  position: absolute;
  inset: auto 0 0;
  padding: 56px 24px 22px;
  background: linear-gradient(transparent, rgb(0 0 0 / 90%));
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
}

#grid-unity .card:hover .card-body,
#grid-unity .card:focus-within .card-body {
  opacity: 1;
  transform: translateY(0);
}

/* Godot cards match Unity: a clean screenshot grid with information
   revealed over the image, rather than a text block underneath. */
#grid-godot {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 1200px;
}

#grid-godot .card {
  position: relative;
}

#grid-godot .card-thumb {
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
}

#grid-godot .card-body {
  position: absolute;
  inset: auto 0 0;
  padding: 56px 24px 22px;
  background: linear-gradient(transparent, rgb(0 0 0 / 90%));
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
}

#grid-godot .card:hover .card-body,
#grid-godot .card:focus-within .card-body {
  opacity: 1;
  transform: translateY(0);
}

#grid-environments {
  grid-template-columns: 1fr;
  max-width: 1200px;
}

#grid-environments .card-thumb {
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: cover;
}

#grid-environments .card-body {
  padding: 24px 28px;
}

#grid-environments .card-title {
  font-size: 22px;
}

#grid-environments .card-desc {
  font-size: 15px;
}

.card-body {
  padding: 24px;
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 12px;
}

.card-label::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--red);
  margin-right: 9px;
  vertical-align: 1px;
}

.card-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.25;
}

.card-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--dim);
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.2s;
}

.card-link:hover {
  color: #e40a26;
}

.card-link .arrow {
  transition: transform 0.2s;
}

.card-link:hover .arrow {
  transform: translate(2px, -2px);
}

/* ---------- projects browser ---------- */
#view-projects {
  padding-bottom: 120px;
}

.projects-browser {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.projects-rail-wrap {
  min-width: 0;
}

.projects-rail-label {
  margin: 0 0 12px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.projects-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 530px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ffffff25 transparent;
}

.project-rail-item {
  width: 100%;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--dim);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s,
    transform 0.2s;
}

.project-rail-item:hover {
  color: var(--fg);
  background: #ffffff08;
}

.project-rail-item[aria-selected="true"] {
  background: #ffffff0a;
  border-color: #ffffff16;
  color: var(--fg);
}

.project-rail-item[aria-selected="true"] .project-rail-index {
  color: var(--red-bright);
}
.project-rail-item:active {
  transform: translateY(1px);
}

.project-rail-index {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  /* var(--dim) (#8a8a92) cumple el contraste mínimo AA (5.5:1); el gris
     anterior (#707078) se quedaba en 3.87:1 (lo detecta axe en CI). */
  color: var(--dim);
}

.project-rail-copy {
  min-width: 0;
}

.project-rail-title,
.project-rail-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-rail-title {
  font-size: 14px;
  font-weight: 700;
}

.project-rail-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--dim);
}
.projects-stage {
  min-width: 0;
}

.project-panel {
  overflow: hidden;
  border: 1px solid #ffffff0f;
  border-radius: 12px;
  background: #ffffff06;
  animation: project-panel-in 0.24s ease both;
}
.project-panel[hidden] {
  display: none;
}

@keyframes project-panel-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.project-visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 300px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #0a0a0c;
}

.project-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 62%, #0000003d);
}

.project-visual img.project-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

/* Screenshots retain their original dimensions instead of being cropped
   into the shared 16:9 calculator frame. */
.project-visual--image {
  display: block;
  min-height: 0;
  aspect-ratio: auto;
}

.project-visual--image img.project-image {
  height: auto;
  object-fit: contain;
}
.project-panel:hover .project-image {
  transform: scale(1.025);
}
.project-panel:hover .project-visual--image .project-image {
  transform: none;
}

.project-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 45%, #ffffff14, transparent 42%), #0a0a0c;
}

.project-fallback img {
  width: clamp(64px, 15vw, 112px);
  height: clamp(64px, 15vw, 112px);
  opacity: 0.7;
}

.project-details {
  position: relative;
  padding: 28px;
}

.project-status {
  position: absolute;
  top: 28px;
  right: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid #ffffff14;
  border-radius: 100px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red-bright);
}

.project-kind {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.project-kind::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 9px;
  border-radius: 2px;
  background: var(--red);
  vertical-align: 1px;
}

.project-title {
  margin: 0;
  padding-right: 112px;
  color: var(--fg);
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
  letter-spacing: -1.5px;
}

.project-description {
  max-width: 660px;
  margin: 14px 0 0;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.65;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.project-tag {
  padding: 5px 10px;
  border: 1px solid #ffffff0a;
  border-radius: 100px;
  background: #ffffff08;
  color: var(--dim);
  font-size: 11px;
  font-weight: 600;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 22px;
  color: var(--fg);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: color 0.2s;
}
.project-link:hover {
  color: var(--red-bright);
}
.project-link .arrow {
  transition: transform 0.2s;
}
.project-link:hover .arrow {
  transform: translate(3px, -3px);
}

/* ---------- about cards ---------- */
.about-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 120px;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.about-card {
  background: #ffffff06;
  border: 1px solid #ffffff0a;
  border-radius: 12px;
  padding: 32px;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.2s;
}

.about-card:hover {
  background: #ffffff0c;
  border-color: #ffffff18;
  transform: translateY(-2px);
}

.about-card .card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 16px;
}

.about-card .card-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.about-card .card-text {
  font-size: 14px;
  color: var(--dim);
  line-height: 1.7;
}

.about-card .card-text strong {
  color: var(--fg);
  font-weight: 600;
}

/* Párrafos encadenados dentro de una about-card: separa cada bloque
   del anterior (sustituye al antiguo style="margin-top: 8px" inline). */
.card-text--spaced {
  margin-top: 8px;
}

.about-full {
  grid-column: 1 / -1;
}

.skills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.skill-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #ffffff08;
  border: 1px solid #ffffff0a;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  transition:
    background 0.2s,
    border-color 0.2s;
}

.skill-pill:hover {
  background: #ffffff14;
  border-color: #ffffff20;
}

.skill-pill .skill-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.language-flag {
  display: inline-block;
  width: 1.4em;
  height: 1em;
  margin-right: 5px;
  vertical-align: -0.13em;
  object-fit: contain;
}

.about-hero {
  padding: 36px 36px 32px;
}

.about-lead {
  margin: 0 0 14px;
  font-size: 19px;
  line-height: 1.65;
  color: #d6d6db;
}
.about-lead strong {
  color: var(--fg);
  font-weight: 700;
}

.about-card .card-label::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--red);
  margin-right: 9px;
  vertical-align: 1px;
}

.about-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin: 24px 0;
}

.stat-tile {
  background: #ffffff06;
  border: 1px solid #ffffff0a;
  border-radius: 12px;
  padding: 22px 18px;
  text-align: center;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.2s;
}

.stat-tile:hover {
  background: #ffffff0c;
  border-color: #ffffff18;
  transform: translateY(-2px);
}

.stat-num {
  margin: 0;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--red-bright);
}

.stat-cap {
  margin: 6px 0 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

/* Estado de stats: el número sigue mostrando el respaldo guardado mientras
   llega stats.json, y este renglón deja claro su frescura o cualquier error. */
.stats-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 24px;
  margin: -8px 0 28px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.stats-status time {
  color: var(--fg);
  font-weight: 700;
}

.stats-spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid #ffffff2b;
  border-top-color: var(--red-bright);
  border-radius: 50%;
  animation: media-spinner 0.8s linear infinite;
}

.stats-status[data-state="error"] {
  color: #ff9ca9;
}

.stats-status[data-state="stale"] {
  color: #e4bf7b;
}

/* ---------- contact ---------- */
#contact {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 120px;
}

.contact-header {
  text-align: center;
  margin-bottom: 64px;
}

.contact-header .tag {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 20px;
}

.contact-header h2 {
  font-size: clamp(36px, 5.5vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -3px;
  margin: 0;
}

.contact-header h2 em {
  font-style: italic;
  color: #e40a26;
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.contact-card {
  background: #ffffff06;
  border: 1px solid #ffffff0a;
  border-radius: 12px;
  padding: 32px;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.2s;
}

.contact-card:hover {
  background: #ffffff0c;
  border-color: #ffffff18;
  transform: translateY(-2px);
}

.contact-card .card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 16px;
}

.contact-card .card-label::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--red);
  margin-right: 9px;
  vertical-align: 1px;
}

.contact-lead {
  margin: 18px auto 0;
  max-width: 560px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--dim);
}

.contact-card .card-link {
  display: block;
  font-size: clamp(18px, 2.5vw, 28px);
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -1px;
  transition: color 0.2s;
  word-break: break-all;
}

.contact-card .card-link:hover,
.contact-card:hover .card-link {
  color: #e40a26;
}

.contact-card .card-link .arrow {
  display: inline-block;
  margin-left: 8px;
  transition: transform 0.2s;
}

.contact-card:hover .card-link .arrow {
  transform: translate(4px, -4px);
}

.contact-card .card-desc {
  font-size: 13px;
  color: var(--dim);
  margin-top: 12px;
  line-height: 1.5;
}

.social-card {
  grid-column: 1 / -1;
}

.social-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.social-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #ffffff08;
  border: 1px solid #ffffff0a;
  border-radius: 100px;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s;
}

.social-pill:hover {
  background: #ffffff14;
  border-color: #ffffff20;
  color: #e40a26;
}

.social-pill .pill-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Icono de pill coloreable: mask + currentColor para que el glifo
   siga el color del texto (también en hover). */
.pill-glyph {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background-color: currentcolor;
  -webkit-mask: var(--i) center / contain no-repeat;
  mask: var(--i) center / contain no-repeat;
}

/* Variantes de glifo (tab-glyph / pill-glyph): la ruta del icono vive aquí
   y no en atributos style inline, que están prohibidos en index.html. */
.glyph-unity {
  --i: url("img/unity.svg");
}
.glyph-gumtree {
  --i: url("img/gumtree.svg");
}
.glyph-nexusmods {
  --i: url("img/nexusmods.svg?v=3");
}
.glyph-github {
  --i: url("img/github.svg?v=2");
}
.glyph-itchio {
  --i: url("img/itchio.svg?v=3");
}
.glyph-discord {
  --i: url("img/discord.svg?v=2");
}

/* ---------- mods ---------- */

/* Mismo estilo que las cards de Projects: imagen arriba y cuerpo
   siempre visible debajo, en una sola columna. El marco adopta la
   proporción real de cada imagen en cuanto carga (cover == encaje
   exacto, sin recortes ni bandas); 16:9 es solo el marco inicial. */
#mods-grid {
  grid-template-columns: 1fr;
}

/* La tarjeta de un mod es un artículo; las acciones explícitas tienen el foco. */
#mods-grid .card {
  cursor: default;
}

#mods-grid .card-thumb {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #ffffff06;
}

.mod-statline {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--red-bright);
}
.mod-statline[hidden] {
  display: none;
}

.mod-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 14px;
}
#view-mods {
  padding-bottom: 120px;
}

.mods-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 40px;
}

/* Total del perfil (GraphQL v2): una sola pill bajo el header. */
.mods-profile {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 900px;
  margin: -14px auto 40px;
  padding: 0 24px;
}
.mods-profile[hidden] {
  display: none;
}
.card:hover .card-thumb {
  opacity: 0.92;
}

.mod-stat {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  background: #ffffff08;
  border: 1px solid #ffffff0f;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg);
  white-space: nowrap;
}

/* Mensaje de red para Discord/Fandom. Se mantiene visible sin bloquear la
   pestaña externa que el visitante decidió abrir. */
.external-service-status {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 16px;
  border: 1px solid #ff829433;
  border-radius: 10px;
  background: #28151a;
  box-shadow: 0 12px 34px #00000066;
  color: #ffd7dc;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.external-service-status[hidden] {
  display: none;
}

/* ---------- lightbox ---------- */
#lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: inherit;
  z-index: 20;
  cursor: zoom-out;
}
#lightbox::backdrop {
  background: #000000e0;
}
#lightbox.open {
  display: flex;
}

.lightbox-media {
  position: relative;
  display: flex;
  max-width: 100%;
  max-height: 100%;
  align-items: center;
  justify-content: center;
  min-width: 40vw;
  min-height: 40vh;
}

/* Spinner del lightbox: reutiliza el estado media-pending de las tarjetas
   (watchImage/watchVideo lo activan sobre .lightbox-media). */

#lightbox img,
#lightbox video {
  max-width: 94vw;
  max-height: 94vh;
  border-radius: 6px;
  cursor: default;
}

.lightbox-close {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #ffffff4d;
  border-radius: 50%;
  background: #111111e6;
  color: #fff;
  font: 400 32px/1 sans-serif;
  cursor: pointer;
  z-index: 1;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.2s;
}

.lightbox-close:hover {
  background: var(--red);
  border-color: var(--red);
  transform: scale(1.05);
}
.lightbox-close:active {
  transform: scale(0.96);
}

/* ---------- back to top ---------- */
#back-top {
  width: 36px;
  height: 36px;
  border-radius: 100px;
  background: #ffffff0a;
  border: 1px solid #ffffff0f;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
  padding: 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  opacity: 0;
  pointer-events: none;
  /* visibility lo saca del orden de tabulación mientras está oculto:
     opacity:0 por sí solo dejaría un botón invisible enfocable con teclado. */
  visibility: hidden;
  transform: translateY(6px);
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s,
    transform 0.2s,
    opacity 0.2s,
    visibility 0.2s;
}

#back-top.visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(0);
}

#back-top.visible:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  transform: translateY(-1px);
}

#back-top:active {
  transform: translateY(0) !important;
}

#back-top svg {
  display: block;
}

/* Texto disponible para lectores de pantalla sin alterar la composición visual. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.discord-copy {
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

/* ---------- a11y: focus-visible ---------- */
:focus-visible {
  outline: 2px solid var(--red-bright);
  outline-offset: 3px;
}

.gallery-tab:focus-visible,
.social-pill:focus-visible,
.card-link:focus-visible,
.contact-card .card-link:focus-visible,
#back-top:focus-visible {
  outline: 2px solid var(--red-bright);
  outline-offset: 3px;
}

.card:focus-visible {
  outline: 2px solid var(--red-bright);
  outline-offset: 2px;
  border-color: #ffffff30;
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .card:hover,
  .about-card:hover,
  .contact-card:hover,
  .stat-tile:hover {
    transform: none !important;
  }

  .card-thumb {
    transition: none !important;
  }

  #grid-unity .card:hover .card-thumb,
  #grid-godot .card:hover .card-thumb,
  #grid-environments .card:hover .card-thumb {
    transform: none !important;
  }
}

/* ---------- responsive ---------- */
@media (width <= 700px) {
  header {
    padding: 0 16px;
    gap: 16px;
  }

  /* El toggle aparece y empuja al extremo derecho; back-top cede su
     `margin-left:auto` para que el hueco no se reparta entre los dos. */
  .menu-toggle {
    display: flex;
    margin-left: auto;
  }
  #back-top {
    margin-left: 0;
  }

  /* El nav deja de ser una fila en la barra y pasa a ser un panel
     desplegable que el botón hamburguesa muestra u oculta. */
  nav {
    display: none;
    position: absolute;
    top: calc(var(--barh) - 6px);
    right: 16px;
    flex-direction: column;
    gap: 2px;
    min-width: 190px;
    padding: 8px;
    background: color-mix(in srgb, var(--bar) 97%, transparent);
    border: 1px solid #ffffff14;
    border-radius: 10px;
    box-shadow: 0 18px 40px #00000073;
    overflow: visible;
  }
  nav.open {
    display: flex;
  }
  nav a {
    font-size: 13px;
    padding: 10px 14px;
  }

  .no-script-notice {
    margin: calc(var(--barh) + 12px) 16px 0;
    padding: 14px 16px;
  }

  .external-service-status {
    right: 16px;
    bottom: 16px;
    max-width: calc(100vw - 32px);
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .about-stats {
    grid-template-columns: 1fr;
  }
  .about-hero {
    padding: 28px 22px 24px;
  }

  .contact-header h2,
  .section-header h2 {
    letter-spacing: -1.5px;
  }
  #contact {
    padding: 0 16px 80px;
  }
  .about-section {
    padding: 0 16px 80px;
  }
  .card-grid {
    padding: 0 16px;
  }
  #mods-grid {
    grid-template-columns: 1fr;
  }
  .mods-profile {
    padding: 0 16px;
  }

  .projects-browser {
    display: block;
    padding: 0 16px;
  }
  .projects-rail-wrap {
    margin-bottom: 16px;
  }
  .projects-rail-label {
    margin-left: 2px;
  }

  .projects-rail {
    flex-direction: row;
    max-height: none;
    overflow: auto hidden;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .project-rail-item {
    flex: 0 0 min(190px, 58vw);
    scroll-snap-align: start;
  }
  .project-visual {
    min-height: 270px;
  }
  .project-visual--image {
    min-height: 0;
  }
  .project-details {
    padding: 22px;
  }
  .project-status {
    top: 22px;
    right: 22px;
  }
  .project-title {
    padding-right: 92px;
  }

  #grid-unity,
  #grid-godot {
    grid-template-columns: 1fr;
  }

  #grid-unity .card-body,
  #grid-godot .card-body {
    opacity: 1;
    transform: none;
  }
}
