/* mascotas.css — zona Juego de mascotas (bloque D): tarjeta de la portada, /mascotas, ranking, previa del nombre
 * y Gestión → Mascotas (las tarjetas de Gestión reutilizan .proposal, .persona y .queue de gestion.css, que se
 * carga después: por eso los selectores de aquí llevan dos clases). */

/* ---- Fotos y fichas ---- */
.mascota-ficha { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--e-4); align-items: start; }
.mascota-foto { width: 120px; height: auto; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--radio-m); background: var(--soft); display: block; }
.mascota-foto.mini { width: 56px; height: 56px; flex: none; }
.mascota-datos { min-width: 0; }
.mascota-datos h3 { margin: 0 0 var(--e-1); overflow-wrap: anywhere; }
.mascota-datos p { margin: 0 0 var(--e-2); }
.mascota-frase { color: var(--ink); overflow-wrap: anywhere; }
.mascota-titulo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e-1) var(--e-3); margin-bottom: var(--e-1); }
.mascota-titulo h3 { margin: 0; }
.mascota-titulo .tag { margin: 0; }
.filtro-lista[hidden], .filtro-etiqueta[hidden] { display: none; }

/* ---- Tarjeta «La mascota del día» (portada) ----
 * Móvil: foto pequeña + nombre y edad en una fila, la frase y el juego debajo a todo el ancho.
 * Escritorio: dos columnas, la foto a la izquierda y nombre, frase y juego a la derecha. */
.mascota-dia-grid { display: grid; grid-template-columns: 96px minmax(0, 1fr); grid-template-areas: "foto datos" "frase frase" "juego juego"; gap: var(--e-4); align-items: start; }
.mascota-dia-grid > .mascota-foto { grid-area: foto; width: 96px; }
.mascota-dia-grid > .mascota-datos { grid-area: datos; align-self: center; }
.mascota-dia-grid > .mascota-frase { grid-area: frase; }
.mascota-dia-grid > .mascota-juego-caja { grid-area: juego; min-width: 0; }
.mascota-dia .mascota-datos h3 { font-size: var(--t-l); line-height: 1.2; }
.mascota-dia .mascota-datos p { margin: 0; }
.mascota-dia .mascota-frase { margin: 0; padding: var(--e-3) var(--e-4); background: var(--tint); border-radius: var(--radio-l); font-size: var(--t-m); line-height: 1.4; }
.mascota-pregunta { font-size: var(--t-l); line-height: 1.25; margin: 0; }
.mascota-pregunta label { font: inherit; letter-spacing: inherit; }
.mascota-juego { max-width: 480px; }
.mascota-juego .field { margin-bottom: var(--e-3); }
.mascota-juego .btn { width: 100%; min-height: 48px; }
.mascota-aviso-intento { margin: var(--e-2) 0 0; text-align: center; }

.mascota-resultado { padding: var(--e-4) var(--e-5); border-radius: var(--radio-l); background: var(--tint); color: var(--ink); max-width: 480px; }
.mascota-resultado p { margin: 0; }
.mascota-resultado .resultado-titulo { font-size: var(--t-l); font-weight: 700; line-height: 1.25; margin-bottom: var(--e-1); }
.mascota-resultado a { font-weight: 600; white-space: nowrap; }
.mascota-resultado.acierto { background: var(--yellow); border: 1px solid var(--tan); color: var(--accent-ink); }
.mascota-resultado.acierto a { color: var(--accent-ink); }
.mascota-resultado.fallo { background: var(--tint); }
.mascota-resultado.acierto .resultado-titulo { animation: aparece .2s ease-out; }
@keyframes aparece { from { transform: scale(.96); opacity: .5; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .mascota-resultado.acierto .resultado-titulo { animation: none; } }

.mascota-ayer { display: flex; align-items: center; gap: var(--e-3); margin-top: var(--e-5); padding-top: var(--e-4); border-top: 1px solid var(--line); }
.mascota-ayer p { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.mascota-ayer .muted { display: block; font-size: var(--t-s); }

@media (min-width: 641px) {
  .mascota-dia-grid { grid-template-columns: 280px minmax(0, 1fr); grid-template-areas: "foto datos" "foto frase" "foto juego"; grid-template-rows: auto auto 1fr; gap: var(--e-4) var(--e-7); }
  .mascota-dia-grid > .mascota-foto { width: 280px; grid-row: 1 / span 3; }
  .mascota-dia-grid > .mascota-datos { align-self: end; }
  .mascota-dia .mascota-datos h3 { font-size: var(--t-xl); }
  .mascota-dia-grid > .mascota-frase { align-self: start; max-width: 480px; }
  .mascota-juego .btn { width: auto; min-width: 200px; }
  .mascota-aviso-intento { text-align: left; }
}

/* ---- /mascotas y ranking ---- */
.mascotas-col { max-width: 680px; }
.mascotas-col .welcome .btn { flex: none; }
.mascotas-col .empty .acciones { justify-content: center; margin-top: var(--e-3); }
.ranking-regla { margin: 0 0 var(--e-3); }

.pasos { list-style: none; margin: 0 0 var(--e-6); padding: 0; display: grid; gap: var(--e-3); font-size: var(--t-base); }
.pasos li { display: flex; align-items: center; gap: var(--e-3); }
.paso-num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--tint); color: var(--accent-ink); font-size: var(--t-s); font-weight: 700; }
@media (min-width: 641px) {
  .pasos { grid-auto-flow: column; grid-auto-columns: 1fr; align-items: start; gap: var(--e-5); }
  .pasos li { align-items: flex-start; }
}

/* Perfil plegado en una línea cuando ya existe */
.perfil-resumen { padding: var(--e-3) var(--e-5); margin: 0; }
.perfil-resumen > summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: var(--e-3); cursor: pointer; font-weight: 600; overflow-wrap: anywhere; }
.perfil-resumen > summary .perfil-editar { flex: none; color: var(--accent-ink); font-size: var(--t-s); text-decoration: underline; text-underline-offset: 4px; }
.perfil-resumen[open] > summary { margin-bottom: var(--e-4); }
.perfil-resumen[open] > summary .perfil-editar { display: none; }
.confirmar.perfil-borrar { margin-top: var(--e-4); }
.perfil-resumen > .confirmar.perfil-borrar { display: block; padding-top: var(--e-4); border-top: 1px solid var(--line); }

/* Emojis y especie: botones de radio visibles (el <input> va oculto pero sigue siendo enfocable) */
.campo-opciones { border: 0; margin: 0 0 var(--e-5); padding: 0; min-width: 0; display: grid; gap: var(--e-2); }
.campo-opciones legend { padding: 0; margin-bottom: var(--e-2); font-size: var(--t-s); font-weight: 600; }
.campo-opciones small { font-size: var(--t-s); color: var(--muted); }
.opciones { display: grid; gap: var(--e-2); }
.opciones.emojis { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
.opciones.especies { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 360px; }
.opcion { position: relative; display: block; }
.opcion span { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: var(--e-2); border: 1px solid var(--control); border-radius: var(--radio-m); background: var(--surface); font-size: var(--t-m); cursor: pointer; }
.opcion .sr + span:hover { background: var(--soft); }
.opcion input:checked + span { background: var(--yellow); border: 2px solid var(--accent); font-weight: 600; }
.opcion input:focus-visible + span { outline: var(--foco); outline-offset: 2px; }
.opciones.emojis .opcion span { font-size: var(--t-l); }

/* Formulario de la mascota */
.mascota-form { max-width: 560px; }
.mascota-form .field textarea { min-height: 72px; }
.mascota-form input[type="file"]::file-selector-button { margin-right: var(--e-3); padding: var(--e-2) var(--e-4); border: 1px solid var(--control); border-radius: var(--radio-m); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--t-s); font-weight: 600; cursor: pointer; }
.ayuda-foto summary { cursor: pointer; font-size: var(--t-s); color: var(--accent-ink); min-height: 44px; display: flex; align-items: center; }
.ayuda-foto p { margin: 0; }

/* ---- Encuadre de la foto (publico/encuadre.js) ----
 * Sin JavaScript no hay nada de esto: el input de fichero se ve como siempre y los botones y el editor quedan ocultos.
 * encuadre.js pone .encuadre-js en el campo cuando el navegador puede con el editor. */
.encuadre { position: relative; }
.encuadre-acciones { display: none; }
.encuadre-js .encuadre-acciones { display: flex; flex-wrap: wrap; gap: var(--e-3); }
/* «Hacer una foto» solo en táctiles: en PC capture se ignora y abriría el mismo selector de archivos. */
.encuadre-acciones .encuadre-camara { display: none; }
@media (pointer: coarse) { .encuadre-js .encuadre-acciones .encuadre-camara { display: inline-flex; } }
/* El input nativo sigue en la página (guarda el fichero y valida «obligatorio»), pero solo lo ven los lectores de pantalla. */
.encuadre-js input[type="file"] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; min-height: 0; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; white-space: nowrap; }
.encuadre-previa { display: flex; align-items: center; gap: var(--e-4); }
.encuadre-previa canvas { width: 96px; height: 96px; flex: none; border-radius: var(--radio-m); background: var(--soft); }
.encuadre-previa-botones { display: flex; flex-wrap: wrap; gap: var(--e-1) var(--e-3); }

.encuadre-dialogo { padding: var(--e-5); border: 0; border-radius: var(--radio-l); width: min(480px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px #34373c55; }
.encuadre-dialogo[open] { display: flex; flex-direction: column; gap: var(--e-3); }
.encuadre-dialogo::backdrop { background: #34373c99; }
.encuadre-dialogo h2 { margin: 0; }
.encuadre-dialogo p { margin: 0; }
.encuadre-lienzo { width: min(86vw, 420px); height: auto; aspect-ratio: 1 / 1; align-self: center; border-radius: var(--radio-m); background: var(--soft); touch-action: none; cursor: grab; }
.encuadre-lienzo:active { cursor: grabbing; }
.encuadre-lienzo:focus-visible { outline: var(--foco); outline-offset: 3px; }
.encuadre-controles { display: flex; align-items: center; gap: var(--e-2); }
.encuadre-controles .btn { min-width: 44px; }
.encuadre-controles input[type="range"] { flex: 1 1 auto; min-width: 0; min-height: 44px; accent-color: var(--accent); }
.encuadre-pie { margin: var(--e-2) 0 0; }
@media (max-width: 640px) {
  .encuadre-dialogo { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .encuadre-pie { margin-top: auto; padding-top: var(--e-3); }
}

/* Mis mascotas */
.mascotas-lista { display: grid; gap: var(--e-4); margin: 0 0 var(--e-6); }
.mascota-mia { display: grid; gap: var(--e-3); }
.mascota-acciones { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--e-3); }
.mascota-acciones > details { margin: 0; }
.mascota-acciones > .mascota-editar[open] { flex: 1 1 100%; }
.mascota-editar > summary { margin-bottom: var(--e-3); }
.mascota-editar:not([open]) > summary { margin-bottom: 0; }

.previa-nombre { font-size: var(--t-xl); font-weight: 700; margin: 0 0 var(--e-2); overflow-wrap: anywhere; }

/* Ranking */
.ranking { list-style: none; margin: 0 0 var(--e-4); padding: 0; display: grid; gap: var(--e-2); }
.ranking-fila { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: var(--e-3); align-items: center; padding: var(--e-2) var(--e-4); min-height: 48px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio-m); }
.ranking-fila.yo { border-color: var(--tan); background: var(--yellow); }
.ranking-pos { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.ranking-fila.podio .ranking-pos { background: var(--tint); color: var(--accent-ink); }
.ranking-fila.p1 .ranking-pos { background: var(--accent); color: #fff; }
.ranking-nombre { overflow-wrap: anywhere; }
.ranking-nombre .tag { margin: 0 0 0 var(--e-1); }
.ranking-puntos { color: var(--muted); font-size: var(--t-s); text-align: right; }
.ranking-puntos strong { font-size: var(--t-m); font-weight: 700; color: var(--ink); }

/* ---- Gestión → Mascotas ---- */
.mascota-gestion.proposal { display: block; padding: var(--e-4); }
.mascota-gestion .mascota-ficha { grid-template-columns: 72px minmax(0, 1fr); }
.mascota-gestion .mascota-foto { width: 72px; }
.mascota-gestion .mascota-datos p { color: var(--ink); margin-bottom: var(--e-1); }
.mascota-gestion .mascota-datos p.muted, .mascota-gestion .mascota-datos p.cuenta { color: var(--muted); overflow-wrap: anywhere; }
.mascota-gestion .actions { margin-top: var(--e-3); }
.mascota-gestion.pendiente { background: var(--yellow); border-color: var(--tan); }
.mascota-gestion.pendiente .mascota-ficha { grid-template-columns: 96px minmax(0, 1fr); }
.mascota-gestion.pendiente .mascota-foto { width: 96px; }
.participante .persona-cabecera { align-items: center; }
