/* TD-10 (L8-04): user-select: none ESCOPADO a los elementos interactivos
   de HUD/lienzo (antes se aplicaba a TODO vía `*`, bloqueando la selección
   de texto legible; ahora solo las superficies de interacción). */
button,
header,
aside,
footer,
#babylon-panama-canvas,
#projected-labels-layer,
#projected-micro-landmarks,
.province-marker-wrapper,
.micro-landmark-tag {
  user-select: none;
  -webkit-user-select: none;
}

body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #0284C7;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.font-display {
  font-family: 'Fredoka', sans-serif;
}

/* ===================================================================== */
/* LETRERO DE GRANJA RÚSTICO CON VETA DE MADERA REAL, CLAVOS Y HERRAJES  */
/* ===================================================================== */
.farm-wood-board {
  position: relative;
  background-color: #8B5A2B;
  background-image:
    repeating-linear-gradient(
      3deg,
      rgba(62, 36, 13, 0.22) 0px,
      rgba(62, 36, 13, 0.22) 2px,
      transparent 2px,
      transparent 9px,
      rgba(255, 215, 165, 0.12) 9px,
      rgba(255, 215, 165, 0.12) 12px
    ),
    linear-gradient(
      180deg,
      #B87B42 0%,
      #965E2B 31%,
      #3E2108 32%,
      #A86B34 34%,
      #875222 65%,
      #3E2108 66%,
      #9B622E 68%,
      #734218 100%
    );
  border: 5px solid #3B200B;
  border-radius: 18px;
  box-shadow:
    inset 0 4px 0 rgba(255, 232, 195, 0.45),
    inset 0 -6px 0 rgba(35, 18, 5, 0.8),
    0 18px 32px -6px rgba(10, 25, 47, 0.55),
    0 4px 10px rgba(0, 0, 0, 0.4);
}

.iron-bracket {
  position: absolute;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, #475569 0%, #1E293B 100%);
  border: 2px solid #0F172A;
  border-radius: 4px;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.35), 0 2px 4px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.iron-bracket::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #CBD5E1, #334155);
  box-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.farm-rope {
  width: 10px;
  height: 28px;
  background: repeating-linear-gradient(
    45deg,
    #D97706,
    #D97706 4px,
    #92400E 4px,
    #92400E 8px
  );
  border-left: 2px solid #451A03;
  border-right: 2px solid #451A03;
  box-shadow: 2px 4px 6px rgba(0,0,0,0.4);
}

.carved-farm-text {
  color: #FFFBEB;
  text-shadow:
    0 3px 0 #3B200B,
    0 5px 0 #231204,
    0 -1px 0 rgba(255, 255, 255, 0.4),
    0 8px 14px rgba(0, 0, 0, 0.55);
  letter-spacing: 0.04em;
}

.wood-panel {
  background: linear-gradient(180deg, #8F5C2E 0%, #7A4B21 100%); /* cream text >= 4.5:1 along the whole gradient (WCAG AA) */
  border: 3px solid #4A2C11;
  box-shadow:
    inset 0 2px 0 rgba(255, 225, 185, 0.35),
    inset 0 -4px 0 rgba(45, 24, 8, 0.65),
    0 12px 24px -5px rgba(15, 23, 42, 0.45);
  color: #FFFDF9;
  text-shadow: 0 2px 0 #3E240D;
}

.airbrush-chassis {
  background: linear-gradient(135deg, #002366 0%, #0369A1 48%, #BE185D 100%); /* white text >= 4.5:1 along the whole gradient (WCAG AA) */
  border: 3px solid #FFFFFF;
  box-shadow:
    inset 0 3px 6px rgba(255, 255, 255, 0.65),
    0 12px 25px -4px rgba(2, 132, 199, 0.5);
}

@keyframes signSwing {
  0%, 100% { transform: rotate(-0.7deg) translateY(0px); }
  50% { transform: rotate(0.7deg) translateY(2px); }
}

.swinging-farm-sign {
  transform-origin: top center;
  animation: signSwing 5s ease-in-out infinite;
}

.swinging-farm-sign:hover {
  animation-play-state: paused;
  transform: scale(1.02) rotate(0deg);
}

/* TD-10 (L8-04): accesibilidad — respeta prefers-reduced-motion
   (deshabilita el vaivén del letrero para usuarios con sensibilidad
   al movimiento). */
@media (prefers-reduced-motion: reduce) {
  .swinging-farm-sign {
    animation: none;
  }
}

/* ===================================================================== */
/* ETIQUETAS LIMPIAS DE LA v0.0.1 + LETRERO EMERGENTE SOLO EN MOUSE OVER */
/* ===================================================================== */
.province-marker-wrapper {
  /* S-07: posicionado via transform: translate3d() (inline, compositor-friendly);
     base top:0;left:0 para que el static-position del absolute no desplace el pin */
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  z-index: 15;
}

/* TD-10 (L8-04): z-index 50 → 25 — el hover de los pins queda BAJO los
   modales (z-50) para que un pin hover no tape el diálogo. */
.province-marker-wrapper.is-hovered {
  z-index: 25;
}

.v1-province-text {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  pointer-events: auto;
}

.v2-hover-card {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%) translateY(8px) scale(0.92);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

/* Label LOD (far camera): the province name is hidden; the 3D hover card still works via .is-hovered. */
.province-marker-wrapper.lod-far {
  pointer-events: none;
}
.province-marker-wrapper.lod-far .v1-province-text {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.province-marker-wrapper:hover .v2-hover-card,
.province-marker-wrapper.is-hovered .v2-hover-card {
  opacity: 1;
  transform: translateX(-50%) translateY(0px) scale(1);
  pointer-events: auto;
}

.province-marker-wrapper:hover .v1-province-text,
.province-marker-wrapper.is-hovered .v1-province-text {
  transform: scale(1.08);
}

/* LB-11: country names = LOD 1 of the HUD (visible when the province labels are not). Name only. */
.country-label {
  position: absolute;
  top: 0;
  left: 0;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #0F172A; /* slate-900: >= 7:1 (WCAG AAA) sobre cada gris claro de los países "bloqueados" y sobre el halo blanco */
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.95), 0 0 8px rgba(255, 255, 255, 0.7);
  pointer-events: none;
  will-change: transform;
}

.country-label.country-label-home {
  /* Panamá = el único país activo del MVP: letras con los colores de la bandera. */
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.12em;
}
/* Contorno de DOS anillos por letra: el interior contrasta con la letra (>= 4.5:1, WCAG AA) y el exterior
   con el interior (>= 3:1), así la letra se lee sobre tierra clara, mar o diorama. Probado en tests/label-contrast.test.js. */
.country-label-home span {
  text-shadow:
    1.20px 0px 0 var(--ring-in), -1.20px 0px 0 var(--ring-in), 0px 1.20px 0 var(--ring-in), 0px -1.20px 0 var(--ring-in), 0.85px 0.85px 0 var(--ring-in), -0.85px 0.85px 0 var(--ring-in), 0.85px -0.85px 0 var(--ring-in), -0.85px -0.85px 0 var(--ring-in),
    2.60px 0px 0 var(--ring-out), -2.60px 0px 0 var(--ring-out), 0px 2.60px 0 var(--ring-out), 0px -2.60px 0 var(--ring-out), 1.84px 1.84px 0 var(--ring-out), -1.84px 1.84px 0 var(--ring-out), 1.84px -1.84px 0 var(--ring-out), -1.84px -1.84px 0 var(--ring-out);
}
/* Colores oficiales de la bandera: Decreto Ejecutivo 337 de 2017 (Gaceta Oficial, 22-dic-2017). */
.country-label-home .flag-red { color: #DA121A; --ring-in: #FFFFFF; --ring-out: #000000; }
.country-label-home .flag-white { color: #FFFFFF; --ring-in: #000000; --ring-out: #FFFFFF; }
.country-label-home .flag-blue { color: #072357; --ring-in: #FFFFFF; --ring-out: #000000; }

.planet-label {
  /* Nombres del sistema solar (zoom lejano): blanco sobre el negro del espacio, con halo negro (WCAG AAA). */
  position: absolute;
  top: 0;
  left: 0;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #FFFFFF;
  text-shadow: 0 0 3px #000000, 0 0 6px #000000;
  pointer-events: none;
  will-change: transform;
}

.micro-landmark-tag {
  /* S-07: base top:0;left:0 — el frame lo posiciona con transform: translate3d() inline */
  top: 0;
  left: 0;
  transform: translate(-50%, -100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.micro-landmark-tag:hover,
.micro-landmark-tag.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.15); border-radius: 8px; }
::-webkit-scrollbar-thumb { background: #D97706; border-radius: 8px; }

/* ===================================================================== */
/* BOOT ERROR BOUNDARY (S-03) — FALLBACK VISIBLE SI WEBGL/CDN FALLA      */
/* Oculto por defecto; main.js añade .is-visible en el catch. El UI Lit   */
/* (HUD, park guide, bottom dock) sigue funcional — solo se sustituye el  */
/* lienzo 3D.                                                             */
/* ===================================================================== */
.lt-webgl-fallback {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.82);
  pointer-events: none;
}

.lt-webgl-fallback.is-visible {
  display: flex;
}

.lt-webgl-fallback-card {
  max-width: 520px;
  margin: 0 24px;
  padding: 28px 36px;
  background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
  border: 3px solid #F59E0B;
  border-radius: 18px;
  box-shadow:
    inset 0 2px 0 rgba(255, 235, 195, 0.25),
    0 18px 32px -6px rgba(0, 0, 0, 0.6);
  text-align: center;
  color: #FFFBEB;
}

.lt-webgl-fallback-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  font-family: 'Fredoka', sans-serif;
}

.lt-webgl-fallback-cause {
  margin: 10px 0 0;
  font-size: 14px;
  color: #FCD34D;
  word-break: break-word;
}