/* =============================================================================
 * mobile-hud.css — Restyling fase 2 «Huerto Royale» (2026-07-07).
 *
 * Feedback Daniel: «en la finca ahora se ve todo súper atomizado al jugar
 * en móvil». El HUD de La Finca mostraba 7 botones de acción + 3 de cámara
 * + chips, todos sueltos flotando sobre el juego en un iPhone.
 *
 * Solución (patrón Clash Royale: pocas acciones visibles, el resto en un
 * menú contextual): en pantallas ≤ 820px la barra inferior queda reducida
 * a [⏭️ Día] [🌾 Finca] [☰ Más]; las 5 acciones secundarias (Codex,
 * Personalizar, Bailar, Guardar, Cargar) viven en un cajón desplegable.
 * Los botones de cámara pasan a solo-icono (el texto va a aria-label).
 *
 * Este fichero se carga DESPUÉS del CSS del bundle (assets/index-*.css),
 * por lo que gana en cascada con la misma especificidad. El bundle del
 * juego NO se toca (ver COMO_ACTUALIZAR.md) — si se regenera, este
 * fichero y mobile-hud.js siguen funcionando porque operan sobre los IDs
 * estables del index.html.
 * ============================================================================= */

@media (max-width: 820px) {
  /* Barra inferior: una sola fila compacta, sin wrap caótico. */
  #hud-bottom {
    position: fixed;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 6px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }
  #hud-bottom > .action-btn {
    margin-bottom: 0;
    padding: 12px 14px;
    font-size: 13px;
    white-space: nowrap;
  }

  /* Cajón «Más»: panel anclado sobre la barra, estética del juego
     (fondo oscuro translúcido + borde dorado suave). */
  #hud-more-drawer {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255, 248, 241, 0.97);
    border: 0;
    box-shadow: 0 4px 0 #f5cbdf, 0 10px 24px rgba(58, 31, 42, 0.3);
    border-radius: 18px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
  #hud-more-drawer.hidden {
    display: none;
  }
  #hud-more-drawer .action-btn {
    margin-bottom: 0;
    width: 100%;
    text-align: left;
  }

  /* Botones de cámara: solo icono (mobile-hud.js mueve el texto a
     aria-label), tamaño táctil correcto y pegados al borde. */
  #hud-camera-switch {
    gap: 6px;
    right: 8px;
  }
  #hud-camera-switch .cam-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 10px;
    font-size: 18px;
  }

  /* ---------------------------------------------------------------------
   * HUD superior — Restyling fase 3 «Huerto Royale» (2026-07-08).
   *
   * Feedback Daniel: los chips Día/Clima/€/⭐ también se veían atomizados
   * en móvil y el chip del dinero chocaba con la ✕ de salida que pinta
   * cultivo/page.tsx (Next) arriba-derecha (right:12px, 40px de ancho).
   *
   * Solución: marca reducida a solo el título compacto, chips en UNA fila
   * estrecha (patrón CR: recursos legibles de un vistazo, cero ruido) y
   * padding-right reservando el hueco de la ✕. El bundle ya oculta
   * .hud-brand-sub a ≤768px; aquí lo extendemos hasta 820px para que
   * toda la capa móvil comparta el mismo breakpoint. */
  #hud-top {
    align-items: flex-start;
    gap: 8px;
    /* 52px de la ✕ (12px margen + 40px botón) + 4px de aire. */
    padding: max(8px, env(safe-area-inset-top)) 56px 8px 10px;
  }
  #hud-top .hud-brand-title {
    font-size: 15px;
    line-height: 1.2;
  }
  #hud-top .hud-brand-sub {
    display: none;
  }
  #hud-top .hud-status {
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
  }
  #hud-top .hud-chip {
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 11px;
    line-height: 1.3;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Móviles muy estrechos (~iPhone SE): los 4 chips no caben ni
     compactados junto al título → la marca sobra dentro del juego
     (ya hay branding en toda la app) y los chips ganan la fila. */
  @media (max-width: 430px) {
    #hud-top .hud-brand {
      display: none;
    }
    #hud-top .hud-status {
      flex: 1;
    }
  }
}

/* =============================================================================
 * Guía reactiva de la primera siembra + autoguardado (finca-guide.js, 2026-09-10)
 * ============================================================================= */
#finca-guide {
  position: fixed;
  left: 50%;
  top: calc(128px + env(safe-area-inset-top));
  transform: translateX(-50%);
  width: min(92vw, 460px);
  z-index: 35;
  background: rgba(255, 248, 241, 0.97);
  border: 0;
  border-radius: 18px;
  padding: 12px 14px 12px;
  color: #3a1f2a;
  font-family: 'Work Sans', system-ui, sans-serif;
  box-shadow: 0 4px 0 #f5cbdf, 0 12px 30px rgba(58, 31, 42, 0.3);
  pointer-events: auto;
  transition: transform .2s ease, opacity .2s ease;
}
#finca-guide.hidden { display: none !important; }
#finca-guide.minimized {
  width: auto;
  padding: 8px 14px;
  opacity: .92;
}
#finca-guide.minimized .fg-text,
#finca-guide.minimized .fg-next,
#finca-guide.minimized .fg-skip { display: none; }
#finca-guide.minimized .fg-progress { margin: 0; }
/* Con un panel del juego abierto: tarjeta compacta pegada arriba, sin botón,
   sin tapar la ✕ del panel (los side-panel en móvil ocupan la parte baja). */
#finca-guide.docked {
  top: calc(52px + env(safe-area-inset-top));
  width: min(92vw, 460px);
  padding: 8px 12px;
  background: rgba(255, 248, 241, 0.94);
}
#finca-guide.docked .fg-next { display: none; }
#finca-guide.docked .fg-text { font-size: 13px; }
#finca-guide.docked .fg-head { margin-bottom: 3px; }
#finca-guide .fg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
#finca-guide .fg-step { font-family: 'Saira Semi Condensed', system-ui, sans-serif; font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: #d8547c; }
#finca-guide .fg-skip { background: none; border: 0; color: rgba(58, 31, 42, .55); font-size: 12px; font-weight: 700; padding: 4px 6px; cursor: pointer; }
#finca-guide .fg-text { font-size: 14.5px; line-height: 1.4; }
#finca-guide .fg-text b { color: #d8547c; }
#finca-guide .fg-progress { font-size: 12px; font-weight: 700; color: #2b7f9a; margin-top: 6px; min-height: 0; }
#finca-guide .fg-progress:empty { display: none; }
#finca-guide .fg-next {
  margin-top: 10px;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #f5a02c, #e27c01);
  color: #fff;
  font-family: 'Saira Semi Condensed', system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 4px 0 #a85a00, 0 8px 16px rgba(226,124,1,.3);
  cursor: pointer;
}
#finca-guide .fg-next:active { transform: translateY(3px); box-shadow: 0 1px 0 #a85a00; }
#finca-guide-arrow {
  position: fixed;
  z-index: 41;
  font-size: 30px;
  transform: translateX(-50%);
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.6));
  animation: fg-bounce 1s ease-in-out infinite;
}
#finca-guide-arrow.hidden { display: none !important; }
@keyframes fg-bounce { 0%,100% { margin-top: 0 } 50% { margin-top: -8px } }

/* Aviso de autoguardado */
#finca-autosave {
  position: fixed;
  right: 12px;
  top: calc(64px + env(safe-area-inset-top));
  z-index: 39;
  background: rgba(255, 248, 241, 0.97);
  border: 0;
  box-shadow: 0 2px 0 #f5cbdf;
  color: #3a1f2a;
  border-radius: 999px;
  padding: 5px 12px;
  font: 700 12px 'Work Sans', system-ui, sans-serif;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
#finca-autosave.show { opacity: 1; transform: translateY(0); }

/* Menú inicial: botón Continuar con resumen de la partida */
#btn-continue-game.has-save { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
#btn-continue-game.has-save small { font-size: 11px; font-weight: 600; opacity: .75; }
#btn-continue-game.hidden { display: none !important; }

/* En móvil, el botón de la mano gana presencia cuando hay algo con lo que
   interactuar (el juego lo muestra siempre; nosotros lo resaltamos si el
   prompt está visible). */
@media (max-width: 820px) {
  body.touch-device #interaction-prompt:not(.hidden) ~ #mobile-controls #btn-mobile-interact,
  body.touch-device #btn-mobile-interact.fg-hot {
    background: linear-gradient(180deg, #f5a02c, #e27c01);
    color: #fff;
    box-shadow: 0 4px 0 #a85a00, 0 0 0 4px rgba(226, 124, 1, .3), 0 8px 16px rgba(0,0,0,.4);
  }
}

/* Pico ganado al cerrar temporada (finca-guide.js → /api/finca/campaign-complete) */
#finca-pick-toast {
  position: fixed; left: 50%; top: 14%; transform: translate(-50%, -20px); z-index: 10001;
  background: #fff1e0; color: #3a1f2a; font-family: "Baloo 2", "Work Sans", system-ui, sans-serif; font-weight: 800; font-size: 20px;
  padding: 12px 22px; border-radius: 999px; box-shadow: 0 4px 0 #f5cbdf, 0 12px 30px rgba(58,31,42,.35);
  opacity: 0; transition: opacity .3s, transform .4s cubic-bezier(.2,1.4,.4,1); pointer-events: none;
}
#finca-pick-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* La guía se retira mientras hay decisiones importantes en pantalla */
#finca-guide.suppressed, #finca-guide-arrow.suppressed { display: none !important; }

/* Salir al Tour (finca-guide.js) */
#btn-exit-tour-menu { margin-top: 6px; }
#btn-exit-tour { background: rgba(255,248,241,.95); }
#hud-more-drawer #btn-exit-tour { border-top: 1px solid rgba(58,31,42,.1); margin-top: 4px; }
