/* =================================================================
   JR Projects · Estantería de cajas de PC "big box"
   =================================================================

   ÍNDICE
     1. Variables (colores, fuentes, medidas de la caja)
     2. Base
     3. Efecto de pantalla CRT
     4. Cabecera
     5. Filtros por categoría
     6. Estantería: mueble 3D
     7. Estantería: flechas de navegación
     8. Caja 3D
     9. Carátula
    10. Lomo
    11. Panel de información
    12. Pie de página
    13. Ventana de proyecto (caja abierta)
    14. Contraportada
    15. Adaptación a pantallas pequeñas
    16. Accesibilidad

   NOTA SOBRE EL 3D
   Las cajas y el mueble usan transformaciones 3D de CSS.
     - translateZ(n)   acerca (+) o aleja (-) un elemento del usuario.
     - rotateX/rotateY giran un elemento en horizontal o vertical.
     - perspective     define la "cámara": cuanto menor, más exagerado el 3D.
   Para que el mueble y las cajas encajen, ambos usan la misma
   perspectiva (sección 6).
   ================================================================= */


/* =================================================================
   1. Variables
   ================================================================= */
:root {
  /* Colores generales */
  --color-background: #14110f;
  --color-wall: #1e1a17;
  --color-wall-dots: #2b2622;
  --color-panel: #0c0a09;
  --color-text: #f3e9d2;
  --color-text-dim: #b8ab90;
  --color-highlight: #ffb000;   /* ámbar: títulos y elemento activo */
  --color-action: #e0322b;      /* rojo: botón principal y pegatinas */
  --color-ai: #b6ff3b;          /* verde lima: sello "Hecho con IA" */

  /* Fuentes (se cargan desde Google Fonts en index.html) */
  --font-pixel: "Press Start 2P", monospace;  /* botones y etiquetas */
  --font-screen: "VT323", monospace;          /* texto general, estilo monitor */
  --font-title: "Bungee", Impact, sans-serif; /* títulos de las cajas */

  /* Medidas de la caja. El JavaScript también las lee de aquí. */
  --box-width: 230px;
  --box-height: 310px;
  --box-depth: 60px;
}


/* =================================================================
   2. Base
   ================================================================= */
* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  color: var(--color-text);
  font-family: var(--font-screen);
  font-size: 22px;
  /* Pared de tienda: puntos de panel perforado + degradado oscuro */
  background-color: var(--color-background);
  background-image:
    radial-gradient(circle, var(--color-wall-dots) 2px, transparent 2.5px),
    linear-gradient(180deg, #221d19 0%, var(--color-wall) 55%, #0d0b0a 100%);
  background-size: 26px 26px, 100% 100%;
}

a { color: inherit; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Todos los botones de la web usan la fuente pixel */
button,
.box-contents__link {
  font-family: var(--font-pixel);
  cursor: pointer;
}


/* =================================================================
   3. Efecto de pantalla CRT
   Capa fija por encima de todo con líneas horizontales y
   bordes oscurecidos. No recibe clics (pointer-events: none).
   Sin mix-blend-mode a propósito: con negro semitransparente el
   resultado es el mismo y el móvil no tiene que recalcular la mezcla
   en cada fotograma al hacer scroll.
   ================================================================= */
.crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  transform: translateZ(0); /* capa propia en la GPU: no se redibuja al hacer scroll */
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%);
}


/* =================================================================
   4. Cabecera
   ================================================================= */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  background: var(--color-panel);
  border-bottom: 4px solid #000;
  box-shadow: 0 4px 0 #2a241f;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.logo__mark {
  padding: 10px 8px;
  background: var(--color-action);
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 4px 4px 0 #000;
  font-family: var(--font-pixel);
  font-size: 18px;
}

.logo__text {
  display: flex;
  flex-direction: column;
}

.logo__title {
  font-family: var(--font-title);
  font-size: 24px;
  letter-spacing: 2px;
  color: var(--color-highlight);
  text-shadow: 3px 3px 0 #000;
}

.logo__subtitle {
  font-size: 18px;
  color: var(--color-text-dim);
}

.sound-button {
  padding: 10px 12px;
  background: #000;
  color: var(--color-text-dim);
  border: 2px solid #3a332d;
  font-size: 10px;
  white-space: nowrap;
}

.sound-button[aria-pressed="true"] {
  color: #5dff7a;
  border-color: #5dff7a;
}


/* =================================================================
   5. Filtros por categoría
   ================================================================= */
.category-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 22px 16px 0;
}

.filter-button {
  padding: 10px 14px;
  background: #2a241f;
  color: var(--color-text);
  border: 3px solid #000;
  box-shadow: 0 4px 0 #000;
  font-size: 10px;
  text-transform: uppercase;
  transition: transform .1s, background .2s;
}

.filter-button:hover { background: #3a322b; }

/* Al pulsar, el botón "se hunde" */
.filter-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #000;
}

.filter-button.is-active {
  background: var(--color-highlight);
  color: #000;
}


/* =================================================================
   6. Estantería: mueble 3D

   Estructura (ver index.html):
     .shelf
       .shelf-furniture   ← el mueble (detrás)
         .shelf-origin    ← punto de apoyo de las cajas
           .shelf-back-panel, .shelf-top-board, .shelf-board…
       .shelf-boxes       ← las cajas (delante), las crea shelf.js

   .shelf-origin está justo donde se apoya la base de las cajas.
   Todas las piezas del mueble se colocan respecto a ese punto.
   ================================================================= */
.shelf {
  position: relative;
  height: calc(var(--box-height) + 190px);
  margin-top: 4px;
  overflow: hidden;
  user-select: none;
  touch-action: pan-y; /* permite hacer scroll vertical en móvil */
}

/* El mueble y las cajas comparten la misma "cámara" */
.shelf-furniture,
.shelf-boxes {
  position: absolute;
  inset: 0;
  perspective: 1400px;
  perspective-origin: 50% 12%; /* cámara un poco por encima: se ve la balda */
}

.shelf-boxes { z-index: 1; }

/* Medidas del mueble */
.shelf-furniture {
  --shelf-depth: 260px;          /* fondo de la balda */
  --shelf-center-z: 35px;        /* centro de la balda (de delante a atrás) */
  --shelf-space-above: 50px;     /* hueco entre la caja y la balda de arriba */
  --shelf-length: 3600px;        /* ancho, mayor que cualquier pantalla */
  --shelf-edge-height: 34px;     /* grosor visible de cada balda */
  --shelf-inner-height: calc(var(--box-height) + var(--shelf-space-above));
}

.shelf-origin {
  position: absolute;
  left: 50%;
  top: calc(50% + var(--box-height) / 2 + 10px);
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}

/* Todas las piezas son igual de anchas y centradas */
.shelf-origin > div {
  position: absolute;
  left: calc(var(--shelf-length) / -2);
  width: var(--shelf-length);
}

/* Balda donde se apoyan las cajas (tumbada con rotateX) */
.shelf-board {
  top: calc(var(--shelf-depth) / -2);
  height: var(--shelf-depth);
  transform: translateZ(var(--shelf-center-z)) rotateX(90deg);
  background:
    linear-gradient(0deg, rgba(0, 0, 0, .55), transparent 35%),                       /* sombra al fondo */
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .07) 0 3px, transparent 3px 140px), /* vetas */
    linear-gradient(0deg, #9a6638, #7a4c28);                                          /* madera */
}

/* Canto delantero de la balda, con la etiqueta */
.shelf-board-edge {
  top: 0;
  height: var(--shelf-edge-height);
  transform: translateZ(calc(var(--shelf-center-z) + var(--shelf-depth) / 2));
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(180deg, #b07a45 0 3px, #6b4426 3px 100%);
  border-bottom: 3px solid #2b1a0d;
}

.shelf-label {
  padding: 5px 10px;
  background: var(--color-text);
  color: #1a1612;
  border: 2px solid #000;
  font-family: var(--font-pixel);
  font-size: 9px;
}

/* Fondo del mueble, más claro arriba (luz del techo) */
.shelf-back-panel {
  top: calc(var(--shelf-inner-height) * -1);
  height: var(--shelf-inner-height);
  transform: translateZ(calc(var(--shelf-center-z) - var(--shelf-depth) / 2));
  background:
    radial-gradient(circle, rgba(0, 0, 0, .35) 2px, transparent 2.5px) 0 0 / 22px 22px,
    linear-gradient(180deg, #5a3a20 0%, #3b2614 45%, #24170c 100%);
}

/* Balda superior, vista desde abajo */
.shelf-top-board {
  top: calc(var(--shelf-inner-height) * -1 - var(--shelf-depth) / 2);
  height: var(--shelf-depth);
  transform: translateZ(var(--shelf-center-z)) rotateX(90deg);
  background: linear-gradient(0deg, #1a0f07, #2e1d0f);
}

/* Canto de la balda superior, con una tira de luz debajo */
.shelf-top-board-edge {
  top: calc(var(--shelf-inner-height) * -1 - var(--shelf-edge-height));
  height: var(--shelf-edge-height);
  transform: translateZ(calc(var(--shelf-center-z) + var(--shelf-depth) / 2));
  background: linear-gradient(180deg, #6b4426 0 calc(100% - 6px), #ffe9a8 calc(100% - 6px));
}


/* =================================================================
   7. Estantería: flechas de navegación
   ================================================================= */
.shelf-arrow {
  position: absolute;
  top: 50%;
  z-index: 30;
  width: 48px;
  height: 48px;
  transform: translateY(-50%);
  background: #000;
  color: var(--color-highlight);
  border: 3px solid var(--color-highlight);
  box-shadow: 4px 4px 0 #000;
  font-size: 16px;
}

.shelf-arrow:hover {
  background: var(--color-highlight);
  color: #000;
}

.shelf-arrow--previous { left: 16px; }
.shelf-arrow--next { right: 16px; }


/* =================================================================
   8. Caja 3D

   .shelf-slot  hueco de la caja en la estantería. shelf.js le pone
                un transform para moverlo a su sitio.
   .box         la caja en sí. Solo se anima cuando está seleccionada.
   .box__face   cada una de las caras. Todas parten del centro de la
                caja y se giran/desplazan hasta su posición:

                         top
                   ┌───────────┐
              left │   front   │ right      (back queda detrás)
                   └───────────┘
                        bottom
   ================================================================= */
.shelf-slot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--box-width);
  height: var(--box-height);
  margin-left: calc(var(--box-width) / -2);
  margin-top: calc(var(--box-height) / -2 + 10px);
  transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.2, .8, .2, 1), opacity .4s;
  cursor: pointer;
}

.box {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.2, .8, .2, 1);
}

/* La caja seleccionada gira despacio sobre su base (sin despegarse de la balda) */
.shelf-slot.is-selected .box {
  animation: box-idle 7s ease-in-out infinite;
}

.shelf-slot.is-selected:hover .box {
  animation-play-state: paused;
  transform: rotateY(-30deg);
}

/* Ahorro de batería: el giro se para cuando la estantería no se ve
   (clase is-offscreen, la pone shelf.js) o hay una caja abierta encima
   (clase viewer-open en <body>, la pone project-viewer.js). */
.shelf.is-offscreen .shelf-slot.is-selected .box,
.viewer-open .shelf-slot.is-selected .box {
  animation-play-state: paused;
}

@keyframes box-idle {
  0%, 100% { transform: rotateY(-20deg); }
  50%      { transform: rotateY(-8deg); }
}

.box__face {
  position: absolute;
  overflow: hidden;
  backface-visibility: hidden; /* no se ve una cara cuando está de espaldas */
}

/* Delante y detrás: tamaño de la carátula */
.box__face--front,
.box__face--back {
  width: var(--box-width);
  height: var(--box-height);
}
.box__face--front { transform: translateZ(calc(var(--box-depth) / 2)); }
.box__face--back  { transform: rotateY(180deg) translateZ(calc(var(--box-depth) / 2)); }

/* Laterales: tan anchos como el grosor de la caja */
.box__face--left,
.box__face--right {
  left: calc((var(--box-width) - var(--box-depth)) / 2);
  width: var(--box-depth);
  height: var(--box-height);
}
.box__face--left  { transform: rotateY(-90deg) translateZ(calc(var(--box-width) / 2)); }
.box__face--right { transform: rotateY(90deg)  translateZ(calc(var(--box-width) / 2)); }

/* Arriba y abajo */
.box__face--top,
.box__face--bottom {
  top: calc((var(--box-height) - var(--box-depth)) / 2);
  width: var(--box-width);
  height: var(--box-depth);
}
.box__face--top    { transform: rotateX(90deg)  translateZ(calc(var(--box-height) / 2)); }
.box__face--bottom { transform: rotateX(-90deg) translateZ(calc(var(--box-height) / 2)); background: #000; }

/* Sombra sobre la balda: un plano tumbado justo bajo la caja */
.box__face--shadow {
  left: -20px;
  top: calc((var(--box-height) - var(--box-depth)) / 2 - 20px);
  width: calc(var(--box-width) + 40px);
  height: calc(var(--box-depth) + 40px);
  transform: rotateX(90deg) translateZ(calc(var(--box-height) / -2 - 1px));
  background: radial-gradient(closest-side, rgba(0, 0, 0, .75), rgba(0, 0, 0, .35) 60%, transparent);
  backface-visibility: visible;
}

/* Caras lisas (tapa superior y trasera), del color de la caja */
.box__plain {
  width: 100%;
  height: 100%;
  background: var(--cover-color);
}
.box__plain--light { filter: brightness(1.25); border: 2px solid rgba(0, 0, 0, .5); }
.box__plain--dark  { filter: brightness(.6); }


/* =================================================================
   9. Carátula

   Los colores llegan desde el JSON como variables en el atributo
   style (ver coverColorStyle en js/utils.js):
     --cover-color   fondo de la caja
     --cover-accent  color del título
   ================================================================= */
.cover {
  container-type: inline-size; /* permite medir textos con "cqw" (% del ancho de la carátula) */
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--cover-color);
  border: 2px solid rgba(0, 0, 0, .6);
}

/* Brillo de plástico/cartón por encima de la carátula y el lomo */
.cover::after,
.spine::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .22) 0%, transparent 28%, transparent 70%, rgba(0, 0, 0, .25) 100%);
}

/* Franja superior: categoría y "PC CD-ROM" */
.cover__header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2.2cqw 3.5cqw;
  background: #000;
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 3.5cqw;
  white-space: nowrap;
}

.cover__platform {
  padding: .9cqw 1.7cqw;
  background: #fff;
  color: #000;
}

/* Imagen propia (cuando el proyecto tiene cover.image) */
.cover__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Patrón de fondo generado (cuando no hay imagen) */
.cover__art {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.cover__title {
  position: relative;
  z-index: 2;
  margin: auto 0;              /* centrado vertical */
  padding: 0 5.2cqw;
  font-family: var(--font-title);
  /* El tamaño se ajusta a la palabra más larga para que no se corte.
     --title-longest-word lo calcula templates.js. */
  font-size: min(13cqw, calc(86cqw / (var(--title-longest-word, 8) * 0.74)));
  line-height: .95;
  text-align: center;
  color: var(--cover-accent);
  text-shadow: 2px 2px 0 #000, 4px 4px 0 #000, 6px 6px 0 rgba(0, 0, 0, .5);
}

.cover__subtitle {
  display: block;
  margin-top: 3.5cqw;
  font-family: var(--font-screen);
  font-size: 7.8cqw;
  line-height: 1;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

/* Franja inferior: editor y sello de categoría */
.cover__footer {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2.6cqw 3.5cqw;
  background: rgba(0, 0, 0, .75);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 3cqw;
}

/* Con imagen propia no hay título en medio que empuje el pie hacia abajo */
.cover--has-image .cover__footer { margin-top: auto; }

/* Pegatina roja ("¡NUEVO!") */
.cover__sticker {
  position: absolute;
  z-index: 3;
  top: 13cqw;
  right: -2.6cqw;
  transform: rotate(12deg);
  padding: 3.5cqw 4.3cqw;
  background: var(--color-action);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 2px 2px 0 #000;
  font-family: var(--font-pixel);
  font-size: 3.9cqw;
}

/* Sello "HECHO CON IA" (proyectos con "madeWithAI": true).
   En la carátula va abajo a la izquierda; con --inline se usa
   en la contraportada y en el panel de información. */
.ai-stamp {
  position: absolute;
  z-index: 3;
  left: 3.5cqw;
  bottom: 16.5cqw;
  transform: rotate(-5deg);
  padding: 2.2cqw 3cqw;
  background: var(--color-ai);
  color: #000;
  border: 2px dashed #000;
  outline: 2px solid var(--color-ai);
  font-family: var(--font-pixel);
  font-size: 3cqw;
  white-space: nowrap;
}

.ai-stamp--inline {
  position: static;
  display: inline-block;
  margin-top: 12px;
  padding: 5px 7px;
  font-size: 10px;
}

/* Sello con la letra de la categoría (también en la contraportada) */
.rating-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 26px;
  background: #fff;
  color: #000;
  border: 2px solid #000;
  font-family: var(--font-pixel);
  font-size: 10px;
}

/* Dentro de la carátula el sello escala con la caja */
.cover .rating-seal {
  width: 9.6cqw;
  height: 11.3cqw;
  font-size: 4.3cqw;
}

/* --- Patrones de fondo ("cover.style" en el JSON) --- */
.cover__art--rays {
  background: repeating-conic-gradient(from 0deg at 50% 60%, rgba(255, 255, 255, .14) 0 8deg, transparent 8deg 18deg);
}

.cover__art--stripes {
  background: repeating-linear-gradient(135deg, rgba(0, 0, 0, .25) 0 14px, transparent 14px 34px);
}

.cover__art--checker {
  background: conic-gradient(rgba(0, 0, 0, .22) 25%, transparent 0 50%, rgba(0, 0, 0, .22) 0 75%, transparent 0) 0 0 / 34px 34px;
}

.cover__art--stars {
  background:
    radial-gradient(circle at 20% 30%, #fff 1.5px, transparent 2px),
    radial-gradient(circle at 70% 20%, #fff 1px, transparent 1.5px),
    radial-gradient(circle at 80% 70%, #fff 1.5px, transparent 2px),
    radial-gradient(circle at 35% 80%, #fff 1px, transparent 1.5px),
    radial-gradient(circle at 55% 50%, rgba(255, 255, 255, .7) 1px, transparent 1.5px);
  background-size: 90px 90px;
}

.cover__art--grid {
  background:
    linear-gradient(transparent 60%, rgba(0, 0, 0, .25) 60%),
    linear-gradient(90deg, rgba(255, 255, 255, .15) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(rgba(255, 255, 255, .15) 1px, transparent 1px) 0 0 / 22px 22px;
}

/* Órbitas / surcos de vinilo concéntricos */
.cover__art--orbits {
  background:
    radial-gradient(circle at 50% 50%, var(--cover-accent) 0 3cqw, transparent 3.2cqw),
    repeating-radial-gradient(circle at 50% 50%, transparent 0 6cqw, rgba(255, 255, 255, .16) 6cqw 6.6cqw),
    radial-gradient(1px 1px at 15% 20%, #fff, transparent),
    radial-gradient(1px 1px at 80% 15%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 85% 85%, #fff, transparent),
    radial-gradient(1px 1px at 10% 75%, #fff, transparent);
}

/* Sol a rayas, estilo retro */
.cover__art--sun::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 52%;
  width: 65cqw;
  height: 65cqw;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: repeating-linear-gradient(180deg, var(--cover-accent) 0 10px, transparent 10px 14px);
  opacity: .85;
}


/* =================================================================
   10. Lomo
   ================================================================= */
.spine {
  container-type: size; /* permite medir con "cqw" y "cqh" */
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  background: var(--cover-color);
  border: 2px solid rgba(0, 0, 0, .6);
}

.spine__logo {
  padding: 4px 3px;
  background: #000;
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 9px;
}

/* Marca "IA" en el lomo de los proyectos hechos con IA */
.spine__ai {
  padding: 3px 2px;
  background: var(--color-ai);
  color: #000;
  font-family: var(--font-pixel);
  font-size: 7px;
}

.spine__title {
  writing-mode: vertical-rl; /* texto en vertical */
  max-height: 70%;
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--font-title);
  /* Se reduce según la longitud del título (--spine-title-length, de templates.js) */
  font-size: min(30cqw, calc(66cqh / (var(--spine-title-length, 10) * 0.74)));
  line-height: 1;
  color: var(--cover-accent);
  text-shadow: 2px 2px 0 #000;
}

.spine__year {
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 7px;
}


/* =================================================================
   11. Panel de información (bajo la estantería)
   ================================================================= */
.project-info {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 20px 24px;
  text-align: center;
}

.project-info__tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 20px;
  color: var(--color-text-dim);
}

.project-info__tags span:not(:empty) {
  padding: 0 8px;
  border: 2px solid #3a332d;
}

/* Etiqueta de categoría: el color de fondo lo pone main.js */
.project-info__tags .project-info__category:not(:empty) {
  color: #000;
  border-color: #000;
}

.project-info__tags .project-info__ai:not(:empty) {
  background: var(--color-ai);
  color: #000;
  border: 2px dashed #000;
}

.project-info__title {
  margin: 12px 0 6px;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(26px, 4vw, 42px);
  color: var(--color-highlight);
  text-shadow: 3px 3px 0 var(--color-action), 6px 6px 0 #000;
}

.project-info__tagline {
  margin: 0 0 18px;
  font-size: 24px;
}

.open-button {
  padding: 14px 22px;
  background: var(--color-action);
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 5px 5px 0 #000;
  font-size: 12px;
  text-transform: uppercase;
  animation: border-blink 1.2s steps(2) infinite;
}

.open-button:hover { background: #ff4a40; }

.open-button:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 #000;
}

@keyframes border-blink {
  50% { border-color: var(--color-highlight); }
}

.keyboard-hint {
  margin: 16px 0 0;
  font-size: 18px;
  color: var(--color-text-dim);
}


/* =================================================================
   12. Pie de página
   ================================================================= */
.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 28px;
  background: var(--color-panel);
  border-top: 4px solid #000;
  font-size: 18px;
  color: var(--color-text-dim);
}


/* =================================================================
   13. Ventana de proyecto (caja abierta)

   Contiene dos caras: la carátula (.viewer__front) y la
   contraportada (.viewer__back). Al añadir la clase "is-flipped"
   (desde project-viewer.js) las dos giran 180° y se intercambian.
   ================================================================= */
.project-viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.project-viewer[hidden] { display: none; }

.project-viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 4, 3, .88);
}

.project-viewer__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  width: 44px;
  height: 44px;
  background: #000;
  color: #fff;
  border: 3px solid #fff;
  font-size: 14px;
}

.project-viewer__close:hover { background: var(--color-action); }

.viewer__card {
  position: relative;
  z-index: 2;
  width: min(880px, 100%);
  height: min(86vh, 900px);
  height: min(86dvh, 900px); /* dvh descuenta las barras del navegador; si no lo entiende, usa la línea anterior */
  perspective: 2000px;
  transform-style: preserve-3d;
}

.viewer__front,
.viewer__back {
  position: absolute;
  inset: 0;
  transition: transform .9s cubic-bezier(.3, .7, .2, 1);
}

/* Ocultar cada cara cuando está de espaldas (también su contenido) */
.viewer__front, .viewer__front > *,
.viewer__back,  .viewer__back > * {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Estado inicial: carátula de frente, contraportada de espaldas */
.viewer__front { transform: rotateY(0deg); display: flex; justify-content: center; }
.viewer__back  { transform: rotateY(-180deg); }

/* Estado girado */
.project-viewer.is-flipped .viewer__front { transform: rotateY(180deg); }
.project-viewer.is-flipped .viewer__back  { transform: rotateY(0deg); }

/* La carátula grande mantiene la proporción de la caja */
.viewer__front .cover {
  width: auto;
  height: 100%;
  aspect-ratio: 230 / 310;
}
/* Los textos de la carátula usan "cqw" (% del ancho de la carátula),
   así que crecen solos al mostrarla en grande: no hace falta ajustarlos aquí. */


/* =================================================================
   14. Contraportada
   ================================================================= */
.back-cover {
  height: 100%;
  overflow-y: auto;
  background: var(--cover-color);
  color: #fff;
  border: 4px solid #000;
  box-shadow: 10px 10px 0 #000;
  scrollbar-color: var(--cover-accent) #000;
}

/* Capa oscura sobre el color de la caja para que el texto se lea bien */
.back-cover__content {
  min-height: 100%;
  padding: 26px 30px 20px;
  background: rgba(0, 0, 0, .55);
}

.back-cover__header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--cover-accent);
}

.back-cover__title {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1;
  color: var(--cover-accent);
  text-shadow: 3px 3px 0 #000;
}

.back-cover__tagline {
  margin: 8px 0 0;
  font-size: 26px;
  font-style: italic;
}

/* Dos columnas: capturas y texto | requisitos y enlaces */
.back-cover__columns {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 24px;
}

.back-cover__heading {
  margin: 0 0 10px;
  font-family: var(--font-pixel);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 1px;
  color: var(--cover-accent);
}

.back-cover__description {
  margin: 0 0 16px;
  font-size: 23px;
  line-height: 1.25;
}

/* Capturas: la primera grande, las otras dos debajo */
.screenshots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.screenshot {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #000;
  border: 3px solid #fff;
  box-shadow: 4px 4px 0 #000;
}

.screenshot:first-child {
  grid-column: span 2;
  aspect-ratio: 16 / 9;
}

.screenshot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Hueco vacío cuando el proyecto aún no tiene capturas */
.screenshot--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--cover-accent);
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 4px),
    #111;
}

.feature-list {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  font-size: 22px;
}

.feature-list li {
  position: relative;
  margin-bottom: 4px;
  padding-left: 26px;
}

.feature-list li::before {
  content: "★";
  position: absolute;
  left: 0;
  color: var(--cover-accent);
}

/* Recuadro crema: "Requisitos del sistema" y "Ficha" */
.info-box {
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--color-text);
  color: #1a1612;
  border: 3px solid #000;
  box-shadow: 4px 4px 0 #000;
}

.info-box .back-cover__heading { color: #1a1612; }

.info-box dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 0;
  font-size: 20px;
}

.info-box dt { font-weight: bold; }
.info-box dd { margin: 0; }

/* Enlaces: "Contenido de la caja" */
.box-contents {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.box-contents__link {
  display: block;
  padding: 12px;
  background: var(--cover-accent);
  color: #000;
  border: 3px solid #000;
  box-shadow: 4px 4px 0 #000;
  font-size: 10px;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
}

.box-contents__link:hover { background: #fff; }

/* Pie: sello, texto legal y código de barras */
.back-cover__footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 2px dashed rgba(255, 255, 255, .4);
  font-size: 16px;
  color: rgba(255, 255, 255, .75);
}

.back-cover__footer .rating-seal {
  width: 34px;
  height: 40px;
  font-size: 16px;
}

.back-cover__legal {
  max-width: 60%;
  line-height: 1.1;
}

.barcode {
  flex-shrink: 0;
  width: 120px;
  height: 50px;
  border: 4px solid #fff;
  background:
    repeating-linear-gradient(90deg, #000 0 2px, #fff 2px 3px, #000 3px 4px, #fff 4px 7px, #000 7px 10px, #fff 10px 11px),
    #fff;
}


/* =================================================================
   15. Adaptación a pantallas pequeñas
   ================================================================= */

/* Portátiles con poca altura: cajas algo más pequeñas para que quepa el mueble
   (los móviles en horizontal tienen sus propias reglas más abajo) */
@media (max-height: 820px) and (min-width: 721px) {
  :root {
    --box-width: 200px;
    --box-height: 270px;
    --box-depth: 54px;
  }

  .site-header { padding: 12px 28px; }
  .category-filters { padding-top: 14px; }
}

/* --- Móviles y tablets pequeñas (vertical u horizontal) ---------
   Reglas comunes: botones de al menos 44 px (tamaño cómodo para
   el dedo) y filtros en una sola fila que se desliza de lado. */
@media (max-width: 720px), (max-height: 500px) and (orientation: landscape) {
  body { font-size: 20px; }

  /* Cabecera compacta */
  .site-header { padding: 10px 16px; }
  .logo__mark { padding: 8px 6px; font-size: 13px; }
  .logo__title { font-size: 18px; }
  .logo__subtitle { font-size: 15px; }
  .sound-button { min-height: 44px; padding: 8px 10px; font-size: 8px; }

  /* Filtros: una fila con scroll horizontal. El degradado del borde
     derecho indica que hay más botones si se desliza. */
  .category-filters {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 8px;
    padding: 12px 16px 10px;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
    mask-image: linear-gradient(90deg, #000 85%, transparent);
  }
  .category-filters::-webkit-scrollbar { display: none; }

  .filter-button {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 9px;
    scroll-snap-align: start;
  }

  /* Estantería: menos hueco por encima de las cajas */
  .shelf { height: calc(var(--box-height) + 130px); }
  .shelf-furniture { --shelf-space-above: 30px; }
  .shelf-arrow { width: 44px; height: 44px; font-size: 12px; }
  .shelf-arrow--previous { left: 6px; }
  .shelf-arrow--next { right: 6px; }

  /* Panel de información y pie */
  .project-info { padding: 4px 16px 20px; }
  .project-info__title { margin-top: 8px; }
  .project-info__tagline { font-size: 20px; margin-bottom: 14px; }
  .open-button { min-height: 48px; }
  .keyboard-hint { display: none; }
  .site-footer { padding: 12px 16px; font-size: 16px; }

  /* Ventana de proyecto. "dvh" descuenta las barras del navegador del móvil
     (con "vh" la parte de abajo podía quedar tapada); "vh" queda de respaldo. */
  .project-viewer { padding: 10px; }
  .project-viewer__close { top: 8px; right: 8px; }
  .viewer__card { height: 92vh; height: 92dvh; }
  .back-cover__content { padding: 18px 16px; }
  .back-cover__description { font-size: 21px; }
  .back-cover__legal { max-width: 100%; }
}

/* --- Móvil en vertical ------------------------------------------ */
@media (max-width: 720px) {
  :root {
    --box-width: 170px;
    --box-height: 230px;
    --box-depth: 46px;
  }

  /* Contraportada en una sola columna */
  .back-cover__columns { grid-template-columns: 1fr; gap: 0; }
}

/* Móviles pequeños o bajos (ej. 320×640): cajas algo menores para que
   el botón "Abrir caja" se vea sin hacer scroll */
@media (max-width: 720px) and (max-height: 740px) {
  :root {
    --box-width: 150px;
    --box-height: 203px;
    --box-depth: 40px;
  }

  .logo__subtitle { display: none; }
}

/* --- Móvil en horizontal ----------------------------------------
   La pantalla es muy baja: la estantería va a la izquierda y la
   información del proyecto a la derecha, para que todo quepa sin scroll. */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --box-width: 120px;
    --box-height: 162px;
    --box-depth: 34px;
  }

  .site-header { padding: 6px 16px; }
  .logo__subtitle { display: none; }
  .category-filters { padding: 8px 16px 6px; }

  main {
    flex-direction: row;
    align-items: center;
  }

  .shelf {
    flex: 1 1 58%;
    min-width: 0;
    height: calc(var(--box-height) + 110px);
  }

  .project-info {
    flex: 1 1 42%;
    max-width: none;
    padding: 0 16px 0 8px;
    text-align: left;
  }
  .project-info__tags { justify-content: flex-start; font-size: 17px; gap: 6px; }
  .project-info__title { font-size: 24px; }
  .project-info__tagline { font-size: 18px; }

  .viewer__card { height: calc(100vh - 20px); height: calc(100dvh - 20px); }
  .back-cover__columns { gap: 16px; }
}


/* =================================================================
   16. Accesibilidad
   ================================================================= */

/* Oculta un elemento a la vista pero no a los lectores de pantalla */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Sin animaciones si el usuario lo ha pedido en su sistema */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: .01ms !important;
  }
}
