/* FarmDew physical-iPhone presentation repairs.
   Presentation only: no gameplay state or interaction ownership lives here. */

/* FarmDew now ships only the modern pixel/tilemap presentation. The document
   starts pending in static HTML, so Safari cannot paint a retired fallback while
   modules are loading. Keep the semantic world hidden until the modern scene is
   complete; a bounded generic error is the only failure presentation. */
html.farmdew-modern-pending #farmdewScene .farmdew-stage>:not(.farmdew-load-error),
html.farmdew-modern-failed #farmdewScene .farmdew-stage>:not(.farmdew-load-error){
  visibility:hidden!important;
}
html.farmdew-modern-pending #farmdewScene .farmdew-scene-message{
  visibility:visible!important;
  opacity:1!important;
}
html.farmdew-modern-failed #farmdewScene .farmdew-scene-message{
  visibility:hidden!important;
}

.farmdew-load-error{
  position:absolute;
  z-index:30;
  inset:50% auto auto 50%;
  display:flex;
  width:min(86%,300px);
  min-height:150px;
  padding:18px;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:10px;
  border:2px solid rgba(71,45,25,.7);
  border-radius:12px;
  background:#f4dfb1;
  box-shadow:0 10px 28px rgba(22,35,24,.3);
  color:#382918;
  text-align:center;
  transform:translate(-50%,-50%);
  visibility:hidden;
  opacity:0;
  pointer-events:none;
}
.farmdew-load-error strong{font-size:1rem}
.farmdew-load-error span{font-size:.82rem;line-height:1.35}
.farmdew-load-error .farmdew-button{
  min-width:120px;
  min-height:44px;
  margin-top:2px;
}

/* CSS owns the catastrophic no-module case: even if farmdew.js itself never
   executes, a static pending document becomes an actionable error after 10s. */
html.farmdew-modern-pending .farmdew-load-error{
  animation:farmdew-load-error-reveal 0s linear 10s forwards;
}
html.farmdew-modern-failed .farmdew-load-error{
  visibility:visible!important;
  opacity:1!important;
  pointer-events:auto!important;
  animation:none!important;
}
@keyframes farmdew-load-error-reveal{
  to{visibility:visible;opacity:1;pointer-events:auto}
}

/* The obsolete Phase 4A farmhouse ground mask starts at logical y=306, exactly
   where the physical iPhone screenshot cut the complete 128x112 farmhouse in
   half. The modern structure layer already owns the farmhouse presentation. */
.farmdew-phase4a.farmdew-tilemap-preview .farmdew-phase4a-ground-mask{
  display:none!important;
}

/* Keep the authored building structure layer unambiguously above Phase 4A scenery
   on Safari/WebKit. Semantic controls/farmer remain on their existing higher layers. */
.farmdew-phase4a.farmdew-tilemap-preview .farmdew-tilemap-structures{
  z-index:4!important;
}

@media(prefers-reduced-motion:reduce){
  html.farmdew-modern-pending .farmdew-load-error{animation-name:farmdew-load-error-reveal}
}
