/* Katadoku Detective (en pruebas). La página reutiliza las clases de Escape
   de css/style.css; aquí solo se añade lo propio de personas y objetos. */

/* Habitaciones: una persona y, opcionalmente, un objeto */
.detective-case-page .escape-game-scene:not(.is-awaiting-art) .detective-room,
.detective-case-page .detective-room{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:clamp(4px,.5vw,8px)}
.detective-marker{cursor:grab;touch-action:none;transition:transform .15s ease,box-shadow .15s ease}
.detective-marker:hover{transform:scale(1.06)}
/* Ficha colocada seleccionada o arrastrándose */
.detective-case-page .escape-game-scene .detective-room .detective-marker.is-selected,.detective-case-page .escape-game-scene .detective-room .detective-marker.is-dragging{transform:scale(1.12);box-shadow:0 0 0 3px #fff8ec,0 0 0 6px #c58a28,0 4px 12px #140a07a8}
.detective-marker.is-dragging{cursor:grabbing;opacity:.85}
.detective-marker.is-person{order:1}
.detective-marker.is-object{order:2;flex:0 0 auto;display:grid;place-items:center;width:clamp(38px,3.6vw,54px);aspect-ratio:1;border-radius:6px;background:#405044;color:#fff8ec;font:700 clamp(15px,1.8vw,25px)/1 var(--sans);box-shadow:0 3px 10px #140a07a8}

/* Fichas de la bandeja */
.detective-tray{align-items:center}
/* Iconos de objeto: anchura mínima pensada para móvil, la misma base en escritorio */
.has-icon svg{display:block;width:80%;height:80%;min-width:26px;min-height:26px;pointer-events:none}
.detective-legend-mark.has-icon svg{width:80%;height:80%;min-width:0;min-height:0}
.detective-case-page .escape-game-scene .detective-token.is-object{width:clamp(42px,3.4vw,52px);border-color:#405044;border-radius:8px;color:#405044}
.detective-case-page .escape-game-scene .detective-token.is-object:hover,.detective-case-page .escape-game-scene .detective-token.is-object:focus-visible,.detective-case-page .escape-game-scene .detective-token.is-object.is-selected{border-color:#405044;background:#405044;color:#fff8ec}
.detective-tray-divider{flex:0 0 auto;width:1px;height:28px;margin:0 4px;background:rgba(118,95,72,.45)}
.detective-tray[hidden]{display:none!important}

/* Resolución: responsable y persona objetivo; los expedientes anteriores
   conservan la clase histórica is-victim por compatibilidad. */
.detective-case-page .escape-game-scene:not(.is-awaiting-art) .detective-room.is-culprit{border:3px solid #931d30;background:rgba(147,29,48,.22)}
.detective-case-page .escape-game-scene:not(.is-awaiting-art) .detective-room.is-victim,.detective-case-page .escape-game-scene:not(.is-awaiting-art) .detective-room.is-target{border:3px dashed #fff8ec;background:rgba(20,10,7,.32)}

/* Leyenda de iniciales bajo las pistas */
.detective-legend{display:grid;gap:6px;margin-top:12px;padding-top:10px;border-top:1px solid rgba(118,95,72,.3)}
.detective-legend-row{display:flex;flex-wrap:wrap;align-items:center;gap:5px 10px;margin:0;font:12px/1.3 var(--sans)}
.detective-legend-row strong{color:#23180f}
.detective-legend-item{display:inline-flex;align-items:center;gap:4px}
.detective-legend-mark{display:inline-grid;place-items:center;width:20px;height:20px;border-radius:50%;background:#931d30;color:#fff8ec;font:700 11px/1 var(--sans)}
.detective-legend-mark.is-object{width:26px;height:26px;border-radius:5px;background:#405044}

.escape-game-rules .detective-spatial-title{margin-top:12px}

/* Móvil y tableta: las 12 fichas no caben en una fila como los 8 números de
   Escape; la bandeja pasa a dos filas sin ensanchar la pantalla. */
@media (max-width:1100px){
  .detective-case-page .escape-route-controls{width:100%}
  .detective-case-page .escape-game-scene .escape-route-tray.detective-tray{flex-wrap:wrap;justify-content:center;width:100%;max-width:100%;gap:6px 4px;padding:8px 6px;border-radius:18px}
  .detective-case-page .detective-tray .detective-token{flex:0 0 auto;width:34px}
  .detective-case-page .escape-game-scene .detective-tray .detective-token.is-object{width:44px}
  .detective-case-page .escape-game-scene:not(.is-awaiting-art) .detective-tray .escape-route-info{margin-left:3px}
  .detective-case-page .detective-tray-divider{flex-basis:100%;width:auto;height:0;margin:0}
}

/* Portada /detective/: ilustración de «Método de juego», más pequeña y
   envejecida para que parezca impresa sobre el papel. */
.detective-page.escape-page .grid-info-preview{justify-content:center}
.detective-page.escape-page .grid-info-preview img{width:min(100%,280px);filter:sepia(.25) saturate(.88) contrast(.97);mix-blend-mode:multiply}

@media (min-width:1101px){
  /* Título largo: una sola línea para no bajar sobre la primera fila. */
  .detective-case-page .escape-game-title h2{font-size:clamp(20px,2.9vw,46px);white-space:nowrap}
}
/* Escritorio: el ancho de los paneles depende solo del ancho de la ventana
   y el plano se limita en alto para que las estancias (unos 700 de los 1671
   px del plano) queden siempre a 44 px o más de cada panel. Las zonas se
   recolocan solas porque se calculan sobre esta imagen. */
@media (min-width:1101px){
  .detective-case-page .escape-game-scene{--dp-panel:clamp(218px,20vw,344px);--dp-edge:max(8px,1.2vw)}
  .detective-case-page .escape-game-scene .escape-game-objective,
  .detective-case-page .escape-game-scene .escape-game-clues{width:var(--dp-panel)}
  .detective-case-page .escape-game-scene .escape-game-objective{left:max(var(--dp-edge),env(safe-area-inset-left))}
  .detective-case-page .escape-game-scene .escape-game-clues{right:max(var(--dp-edge),env(safe-area-inset-right))}
  .detective-case-page .escape-game-scene:not(.is-awaiting-art) .escape-game-background{bottom:auto;height:min(100%,calc(1.344 * (100vw - 2 * (var(--dp-panel) + var(--dp-edge) + 44px))))}
}
/* Huella (persona responsable) y marcador de evidencia (persona afectada):
   solo señalan la casilla; no la bloquean. */
.detective-clue-mark{position:absolute;z-index:2;display:none;padding:3px;border:0;border-radius:50%;background:rgba(255,248,236,.9);cursor:help;pointer-events:auto;filter:drop-shadow(0 1px 2px rgba(20,10,7,.75))}
.detective-case-page .escape-game-scene:not(.is-awaiting-art) .detective-clue-mark{display:block}
.detective-clue-mark::before{position:absolute;inset:-6px;content:""}
.detective-clue-mark img{display:block;width:100%;height:100%;object-fit:contain;pointer-events:none}
.detective-clue-mark:focus-visible{outline:2px solid #ffd66c;outline-offset:2px;border-radius:4px}
/* Las fichas colocadas quedan siempre por encima de la huella y el marcador. */
.detective-case-page .detective-room .detective-marker{position:relative;z-index:3}
/* Mismo zumbido sutil que la «?» de Original; los dos iconos, desfasados. */
@keyframes detective-clue-mark-buzz{0%,92%,100%{transform:translateX(0) rotate(0)}93%,95%,97%{transform:translateX(-2px) rotate(-.7deg)}94%,96%,98%{transform:translateX(2px) rotate(.7deg)}99%{transform:translateX(-1px) rotate(-.3deg)}}
@media (prefers-reduced-motion:no-preference){.detective-clue-mark img{animation:detective-clue-mark-buzz 10s linear infinite}.detective-clue-mark.is-evidence img{animation-delay:-5s}}
/* Términos de las pistas con definición (mismo aspecto que en Original). Con
   propiedades separadas: Safari ignora el atajo «underline dotted <color>». */
.detective-term{display:inline;margin:0;padding:0;border:0;background:none;text-decoration-line:underline;text-decoration-style:dotted;text-decoration-color:rgba(36,52,72,.8);-webkit-text-decoration-line:underline;-webkit-text-decoration-style:dotted;-webkit-text-decoration-color:rgba(36,52,72,.8);text-decoration-thickness:2px;text-underline-offset:.22em;text-decoration-skip-ink:none;color:inherit;font:inherit;line-height:inherit;letter-spacing:inherit;text-align:inherit;cursor:help}
.detective-term:hover,.detective-term:focus-visible,.detective-term[aria-expanded="true"]{text-decoration-color:currentColor;text-decoration-style:dashed}
.detective-term:focus-visible{outline:2px solid #ffd66c;outline-offset:2px;border-radius:2px}
.detective-term-popover{position:fixed;z-index:1200;max-height:calc(100vh - 24px);overflow:auto;padding:12px 34px 12px 14px;border:1px solid #d8b48c;border-radius:8px;background:#fff9ed;box-shadow:0 8px 24px rgba(20,12,7,.28);color:#281b13;font:14px/1.45 var(--sans)}
.detective-term-title{display:block;margin:0 0 4px;color:#405044;font-weight:700}
.detective-term-popover p{margin:0}
.detective-term-close{position:absolute;top:4px;right:4px;width:30px;height:30px;padding:0;border:0;border-radius:50%;background:none;color:#765f48;font:20px/1 var(--sans);cursor:pointer}
.detective-term-close:focus-visible{outline:2px solid #ffd66c}
@media print{.detective-term{text-decoration:none!important;cursor:auto!important}.detective-term-popover{display:none!important}}
/* «Necesito ayuda»: botón bajo el título de las pistas y panel de ayudas
   progresivas (misma mecánica que en Original, con los colores de Detective). */
.detective-help-button{display:block;width:fit-content;min-height:42px;margin:0 auto 12px;white-space:nowrap;padding:10px 24px;border:1.5px solid #405044;border-radius:999px;background:#fff9ed;color:#405044;font:700 15px/1.2 var(--sans);box-shadow:0 1px 3px rgba(40,27,19,.12);cursor:pointer}
@media (max-width:559px){.detective-help-button{min-height:40px;padding:9px 20px;font-size:14px}}
.detective-help-button:hover{background:#405044;color:#fff9ed}
.detective-help-button:focus-visible{outline:3px solid #ffd66c;outline-offset:2px}
.detective-help-panel{width:min(460px,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:auto;padding:22px 22px 16px}
.detective-help-panel h2{margin:0 0 10px;color:#405044;font:400 24px/1.15 var(--serif)}
.detective-help-body p{margin:0 0 10px;font:15px/1.5 var(--sans)}
.detective-help-body strong{color:#281b13}
.detective-help-progress{margin:6px 0 10px;color:#765f48;font:13px/1.3 var(--sans);text-align:center}
.detective-help-nav{display:flex;gap:8px}
.detective-help-nav button{flex:1;min-height:44px;padding:10px 8px;border:1px solid #405044;border-radius:6px;background:transparent;color:#405044;font:600 14px/1.2 var(--sans);cursor:pointer}
.detective-help-nav .detective-help-next{background:#405044;color:#fff}
.detective-help-nav button:disabled{border-color:#c9c0b2;background:transparent;color:#a39a8c;cursor:default}
.detective-help-close{display:block;min-height:44px;margin:6px auto 0;padding:10px 12px;border:0;background:none;color:#765f48;font:500 14px/1.2 var(--sans);text-decoration:underline;text-underline-offset:3px;cursor:pointer}
.detective-help-panel button:focus-visible{outline:3px solid #ffd66c;outline-offset:2px}
@media (max-width:420px){.detective-help-panel{padding:18px 16px 12px}.detective-help-nav button{padding:10px 4px;font-size:13.5px;white-space:nowrap}}

/* En móvil, la tarjeta de expediente resuelto debe aparecer sobre el plano,
   como ya sucede en tableta y escritorio. La regla común de Escape la dejaba
   dentro de los controles, debajo de «Comprobar expediente». */
@media screen and (max-width:559px){
  body.detective-case-page.escape-game-active .escape-route-feedback[data-status="success"]{
    position:fixed;
    z-index:110;
    top:calc(var(--escape-mobile-menu-height,74px) + var(--escape-stage-height,106vw) / 2);
    left:50%;
    width:min(340px,calc(100% - 32px));
    max-width:none;
    margin:0;
    transform:translate(-50%,-50%);
  }
}
