/* Don Nadie — teclado de caja fuerte para los PIN (01-10). Lo usan la puerta (página del servidor) y «¿Quién eres?».
   Fondo: img/caja.jpg (Gemini, 1493×2000 en el original). Encima, en % de la imagen: 12 teclas, el dial (un recorte
   circular de la misma imagen que gira) y el piloto. Autónomo: no depende de estilo.css (la puerta no lo carga). */
.caja {
  position: relative; width: min(100%, 340px); max-width: 100%; aspect-ratio: 1493 / 2000; margin: 6px auto 18px;
  background: #0d0d0c url('../img/caja.jpg') center / 100% 100% no-repeat;
  border-radius: 10px; box-shadow: 0 14px 30px rgba(0, 0, 0, .55);
  container-type: inline-size;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
/* Dial: recorte circular (radio 195 de 1493 px, centro 746,557) con la misma imagen, que gira */
.caja__dial {
  position: absolute; left: 50%; top: 27.85%; width: 26.12%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.caja__dial-giro {
  width: 100%; height: 100%; border-radius: 50%;
  background: url('../img/caja.jpg') no-repeat; background-size: 382.8% 512.8%; background-position: 49.95% 22.48%;
  transition: transform 260ms cubic-bezier(.2, .7, .2, 1);
}
/* Piloto (centro 1080,548; radio 40) */
.caja__piloto {
  position: absolute; left: 72.34%; top: 27.4%; width: 5.4%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none; transition: background-color 200ms, box-shadow 200ms;
}
.caja--bien .caja__piloto { background: radial-gradient(circle at 40% 35%, #f2ffd6, #8fd14f 45%, rgba(93, 143, 42, .2) 75%); box-shadow: 0 0 14px 4px rgba(157, 207, 85, .7); }
.caja--mal .caja__piloto { background: radial-gradient(circle at 40% 35%, #ffe0d8, #e0604a 45%, rgba(165, 59, 48, .2) 75%); box-shadow: 0 0 14px 4px rgba(217, 112, 95, .75); }
.caja--mal { animation: caja-temblor 380ms cubic-bezier(.36, .07, .19, .97); }
@keyframes caja-temblor { 15%, 85% { transform: translateX(-2px); } 30%, 70% { transform: translateX(4px); } 45%, 55% { transform: translateX(-6px); } }

.caja__teclas { position: absolute; inset: 0; }
/* Teclas: columnas 517/746/975, filas 920/1127/1335/1545, diámetro ~168 (de 1493×2000).
   El botón (transparente) ocupa toda su celda de la rejilla (15,3 % × 10,35 %: unos 52×47 px con la caja a 340), para
   que el dedo acierte aunque el botón dibujado sea más pequeño; el círculo pulsado lo pinta ::before, del tamaño del dibujo. */
.caja__tecla {
  position: absolute; width: 15.2%; height: 10.3%; padding: 0; border: 0; border-radius: 0;
  transform: translate(-50%, -50%); background: transparent; cursor: pointer;
  display: grid; place-items: center;
  font: 400 7.4cqw/1 'Limelight', 'Bodoni 72', Georgia, serif; color: #e9cf86;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .9), 0 -1px 0 rgba(255, 240, 200, .25);
  -webkit-tap-highlight-color: transparent;
  transition: transform 70ms ease-out, box-shadow 70ms ease-out;
}
.caja__tecla:nth-child(3n + 1) { left: 34.63%; }
.caja__tecla:nth-child(3n + 2) { left: 49.97%; }
.caja__tecla:nth-child(3n) { left: 65.3%; }
.caja__tecla:nth-child(-n + 3) { top: 46%; }
.caja__tecla:nth-child(n + 4):nth-child(-n + 6) { top: 56.35%; }
.caja__tecla:nth-child(n + 7):nth-child(-n + 9) { top: 66.75%; }
.caja__tecla:nth-child(n + 10) { top: 77.25%; }
.caja__tecla::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 11.4cqw; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none; transition: transform 70ms ease-out, box-shadow 70ms ease-out;
}
.caja__tecla:active::before, .caja__tecla.es-pulsada::before {
  transform: translate(-50%, -50%) scale(.93);
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .28), 0 0 10px rgba(226, 192, 110, .35);
}
.caja__tecla:focus-visible { outline: none; }
.caja__tecla:focus-visible::before { outline: 2px solid #e2c06e; outline-offset: 2px; }
.caja__tecla--borrar { font: 600 5.6cqw/1 'Jost', system-ui, sans-serif; color: #d9d2bf; }
.caja__tecla--abrir { font: 600 2.55cqw/1 'Jost', system-ui, sans-serif; letter-spacing: .02em; text-transform: uppercase; color: #f0d58c; }
.caja__tecla:disabled { opacity: .5; cursor: default; }
/* El campo del PIN: sin teclado del sistema (inputmode=none) */
.caja-campo { caret-color: transparent; }

@media (prefers-reduced-motion: reduce) {
  .caja__dial-giro, .caja__tecla, .caja__tecla::before { transition: none; }
  .caja--mal { animation: none; }
}

/* La puerta (página del servidor) con el móvil en horizontal: el campo a la izquierda y la caja a la derecha, entera */
@media (orientation: landscape) and (max-height: 500px) {
  body:has(> main > #caja) { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 12px; }
  main:has(> #caja) { max-width: 760px; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 28px; align-items: start; }
  main:has(> #caja) > * { grid-column: 1; }
  main:has(> #caja) > #caja { grid-column: 2; grid-row: 1 / span 5; }
  main:has(> #caja) h1 { font-size: 44px; }
  #caja > .caja { width: min(340px, calc((100vh - 24px) * 1493 / 2000)); width: min(340px, calc((100dvh - 24px) * 1493 / 2000)); margin: 0; }
}
