/* ─────────────────────────────────────────────
   FARM — CSS limpo
   Coordenadas virtuais do mapa: 1000 x 700.
───────────────────────────────────────────── */

.screen--farm {
  min-height: calc(100vh - var(--topbar-h));
  padding: 16px clamp(12px, 2vw, 28px) 28px;
}

.farm-layout {
  width: min(1180px, calc(100vw - 48px));
  margin: 0 auto;
}

.farm-stage {
  position: relative;
  width: 100%;
  height: min(78vh, 790px);
  min-height: 560px;
  border: 5px solid var(--wood-900);
  outline: 3px solid rgba(240, 200, 64, .32);
  outline-offset: -11px;
  background:
    linear-gradient(rgba(0,0,0,.035), rgba(0,0,0,.035)),
    url("../assets/backgrounds/farm_house.png") center center / cover no-repeat,
    url("../assets/backgrounds/farm_bg.png") center center / cover no-repeat,
    #2d7b36;
  box-shadow:
    0 0 0 4px rgba(0,0,0,.35),
    8px 8px 0 rgba(0,0,0,.34);
  overflow: hidden;
  cursor: crosshair;
}

.farm-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 55%, rgba(0,0,0,.18));
  pointer-events: none;
  z-index: 20;
}

.farm-objective-chip {
  position: absolute;
  z-index: 30;
  left: 16px;
  top: 14px;
  max-width: min(570px, calc(100% - 32px));
  padding: 9px 14px;
  border: 4px solid var(--wood-900);
  background: rgba(58, 38, 16, .88);
  color: var(--gold-300);
  font-size: clamp(19px, 1.75vw, 26px);
  line-height: 1.05;
  text-shadow: 2px 2px 0 var(--shadow-hard);
  box-shadow: 4px 4px 0 rgba(0,0,0,.28);
}

.farm-sprite {
  position: absolute;
  z-index: 12;
  left: calc(var(--x, 500) / 1000 * 100%);
  top: calc(var(--y, 500) / 700 * 100%);
  width: var(--w, 62px);
  height: var(--h, 82px);
  transform: translate(-50%, -100%);
  image-rendering: pixelated;
  filter: drop-shadow(3px 5px 0 rgba(0,0,0,.32));
  transition: left .12s linear, top .12s linear;
  pointer-events: none;
  will-change: left, top, transform, filter;
}

.farm-sprite img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  transform-origin: 50% 92%;
}

.farm-sprite--melissa {
  --w: 60px;
  --h: 84px;
  z-index: 14;
  transition: left .10s linear, top .10s linear;
}

.farm-sprite--diego {
  --w: 64px;
  --h: 90px;
  z-index: 13;
  transition: left .25s ease-out, top .25s ease-out;
}

.farm-sprite--abigail {
  --w: 66px;
  --h: 86px;
  z-index: 11;
  animation: spriteIdle 2.6s ease-in-out infinite;
}

.farm-sprite.is-walking {
  filter:
    drop-shadow(3px 5px 0 rgba(0,0,0,.32))
    brightness(1.15);
}

.farm-sprite.is-walking img {
  animation: farmerWalkBounce .20s steps(2, end) infinite;
}

.farm-sprite.is-moving-left img {
  transform: scaleX(-1);
}

.farm-sprite.is-moving-right img {
  transform: scaleX(1);
}

.farm-sprite.is-moving-up img {
  filter: brightness(.88);
}

.farm-sprite.is-moving-down img {
  filter: brightness(1.14);
}

.farm-name {
  position: absolute;
  left: 50%;
  bottom: -20px;
  transform: translateX(-50%);
  color: var(--gold-300);
  font-size: 21px;
  text-shadow: 2px 2px 0 var(--shadow-hard);
  white-space: nowrap;
}

.farm-hotspot {
  position: absolute;
  z-index: 10;
  left: calc(var(--x, 500) / 1000 * 100%);
  top: calc(var(--y, 300) / 700 * 100%);
  width: var(--size, 54px);
  height: var(--size, 54px);
  border: 0;
  background: transparent;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  cursor: pointer;
  image-rendering: pixelated;
  filter:
    drop-shadow(0 0 7px rgba(255, 224, 96, .75))
    drop-shadow(3px 4px 0 rgba(0,0,0,.34));
  animation: hotspotFloat 1.7s ease-in-out infinite;
}

.farm-hotspot img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.farm-hotspot.is-locked {
  cursor: not-allowed;
  opacity: .48;
  filter: grayscale(.65) drop-shadow(3px 4px 0 rgba(0,0,0,.34));
  animation: none;
}

/* Coordenadas calibradas em grade 1000x700 */
.hotspot-mailbox { --x: 764; --y: 252; --size: 51px; }
.hotspot-chest { --x: 533; --y: 308; --size: 54px; }
.hotspot-crops { --x: 600; --y: 467; --size: 48px; }
.hotspot-pond { --x: 335; --y: 468; --size: 50px; }
.hotspot-star { --x: 520; --y: 294; --size: 44px; }

.farm-dialogue-strip {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(780px, calc(100% - 52px));
  padding: 13px 18px;
  border: 4px solid var(--gold-500);
  background: rgba(18, 8, 6, .82);
  color: var(--cream-100);
  font-size: clamp(21px, 2.05vw, 30px);
  line-height: 1.05;
  text-align: center;
  text-shadow: 2px 2px 0 var(--shadow-hard);
  pointer-events: none;
}

.walk-dust {
  position: absolute;
  z-index: 9;
  left: calc(var(--x) / 1000 * 100%);
  top: calc(var(--y) / 700 * 100%);
  width: 24px;
  height: 12px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(244, 220, 169, .62);
  box-shadow:
    0 0 0 3px rgba(91, 64, 37, .18),
    10px 2px 0 rgba(244, 220, 169, .22),
    -9px 1px 0 rgba(244, 220, 169, .20);
  pointer-events: none;
  animation: dustPoof .46s ease-out forwards;
}

.farm-controls {
  width: min(1180px, calc(100vw - 48px));
  margin: 10px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.dpad {
  display: grid;
  grid-template-columns: 48px 48px 48px;
  grid-template-rows: 48px 48px;
  gap: 5px;
}

.dpad button,
.farm-main-actions button {
  border: 4px solid var(--wood-900);
  background: rgba(91, 64, 37, .96);
  color: var(--gold-300);
  box-shadow: 4px 4px 0 rgba(0,0,0,.32);
  cursor: pointer;
  font-size: 27px;
  line-height: 1;
  text-shadow: 2px 2px 0 var(--shadow-hard);
}

.dpad button:hover,
.dpad button:focus-visible,
.farm-main-actions button:hover,
.farm-main-actions button:focus-visible {
  outline: none;
  background: var(--gold-500);
  color: var(--wood-900);
  text-shadow: none;
}

.dpad-up { grid-column: 2; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }

.farm-main-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.farm-main-actions button {
  min-height: 54px;
  padding: 0 16px;
  font-size: clamp(23px, 2.2vw, 32px);
}

#challenge-abigail.is-distance-locked,
#open-letter.is-distance-locked {
  opacity: .48;
  filter: grayscale(.45);
}

#challenge-abigail.is-available {
  opacity: 1;
  filter: none;
  animation: challengePulse .86s ease-in-out infinite;
}

.inventory-bar {
  position: static;
  transform: none;
  width: fit-content;
  max-width: calc(100vw - 48px);
  margin: 12px auto 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 5px solid var(--wood-900);
  background: rgba(58, 38, 16, .96);
  box-shadow: 6px 6px 0 rgba(0,0,0,.34);
  flex-wrap: wrap;
  justify-content: center;
}

.inventory-slot {
  width: 45px;
  height: 45px;
  border: 3px solid var(--wood-900);
  background: rgba(91, 64, 37, .92);
  display: grid;
  place-items: center;
  position: relative;
}

.inventory-slot img {
  max-width: 32px;
  max-height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
}

.inventory-slot.is-locked {
  opacity: .45;
  filter: grayscale(.8);
}

.inventory-slot span {
  position: absolute;
  left: 3px;
  top: -2px;
  color: var(--cream-200);
  font-size: 14px;
  text-shadow: 1px 1px 0 var(--shadow-hard);
}

/* Modal base, usado por carta e batalha */
.game-modal {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(8, 3, 1, .52);
}

.game-modal__card {
  width: min(760px, calc(100vw - 42px));
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  border: 5px solid var(--wood-900);
  outline: 3px solid rgba(240, 200, 64, .38);
  outline-offset: -10px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.025), transparent 18%, rgba(0,0,0,0.04) 52%, transparent),
    rgba(58, 38, 16, .98);
  box-shadow:
    0 0 0 4px rgba(0,0,0,.38),
    10px 10px 0 rgba(0,0,0,.44);
  color: var(--cream-100);
}

.letter-paper {
  background:
    linear-gradient(rgba(255, 247, 207, .94), rgba(255, 231, 174, .94)),
    url("../assets/backgrounds/letter_bg.png") center / cover no-repeat;
  color: #2b1508;
  padding: 28px clamp(24px, 5vw, 52px);
  border: 5px solid var(--wood-900);
  box-shadow: inset 4px 4px 0 rgba(255,255,255,.30);
}

.letter-paper h2 {
  margin: 0 0 12px;
  color: #8f3b25;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1;
}

.letter-paper p {
  font-size: clamp(22px, 2.4vw, 31px);
  line-height: 1.22;
  margin: 0 0 14px;
}

.menu-panel {
  width: min(880px, calc(100vw - 190px));
  max-height: calc(100vh - var(--topbar-h) - 34px);
  overflow-y: auto;
  border: 5px solid var(--wood-900);
  outline: 3px solid rgba(240, 200, 64, .35);
  outline-offset: -11px;
  background: rgba(91, 64, 37, .94);
  box-shadow:
    0 0 0 4px rgba(0,0,0,.35),
    10px 10px 0 rgba(0,0,0,.36);
  padding: 24px;
}

.menu-title {
  text-align: center;
  margin: 0 0 18px;
  color: var(--title-brown);
  font-family: var(--font-title);
  font-size: clamp(44px, 5.4vw, 72px);
  line-height: .9;
  text-shadow:
    1px 0 0 var(--title-stroke),
    -1px 0 0 var(--title-stroke),
    0 1px 0 var(--title-stroke),
    0 -1px 0 var(--title-stroke),
    2px 2px 0 var(--gold-600),
    4px 4px 0 var(--shadow-hard);
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.menu-option {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 4px solid var(--wood-900);
  background: rgba(58, 38, 16, .82);
  padding: 12px;
  color: var(--cream-100);
}

.menu-option img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  image-rendering: pixelated;
}

.menu-option strong {
  display: block;
  color: var(--gold-300);
  font-size: clamp(22px, 2.2vw, 30px);
  line-height: 1;
  text-shadow: 2px 2px 0 var(--shadow-hard);
}

.menu-option span {
  display: block;
  margin-top: 4px;
  color: var(--cream-300);
  font-size: clamp(18px, 1.75vw, 24px);
  line-height: 1;
  text-shadow: 2px 2px 0 var(--shadow-hard);
}

@keyframes farmerWalkBounce {
  0% { transform: translateY(0) rotate(-2deg) scaleY(1.00); }
  50% { transform: translateY(-4px) rotate(2deg) scaleY(1.02); }
  100% { transform: translateY(0) rotate(-2deg) scaleY(1.00); }
}

@keyframes dustPoof {
  0% { transform: translate(-50%, -50%) scale(.45); opacity: 0; }
  25% { opacity: .74; }
  100% { transform: translate(-50%, -50%) scale(1.9); opacity: 0; }
}

@keyframes challengePulse {
  0%, 100% {
    box-shadow: 4px 4px 0 rgba(0,0,0,.32), 0 0 0 rgba(255, 218, 88, 0);
  }
  50% {
    box-shadow: 4px 4px 0 rgba(0,0,0,.32), 0 0 18px rgba(255, 218, 88, .62);
  }
}

@keyframes spriteIdle {
  0%, 100% { transform: translate(-50%, -100%) translateY(0); }
  50% { transform: translate(-50%, -100%) translateY(-1px); }
}

@keyframes hotspotFloat {
  0%, 100% { transform: translate(-50%, -50%) translateY(0) scale(1); }
  50% { transform: translate(-50%, -50%) translateY(-4px) scale(1.05); }
}

@media (max-width: 980px) {
  .screen--farm {
    padding-left: 12px;
    padding-right: 12px;
  }

  .farm-layout,
  .farm-controls {
    width: min(940px, calc(100vw - 24px));
  }

  .farm-stage {
    height: 74vh;
    min-height: 520px;
  }
}

@media (max-width: 760px) {
  .farm-stage {
    min-height: 460px;
  }

  .farm-objective-chip {
    font-size: 19px;
  }

  .farm-controls {
    flex-direction: column;
    align-items: center;
  }

  .farm-main-actions {
    justify-content: center;
  }

  .inventory-slot {
    width: 39px;
    height: 39px;
  }

  .inventory-slot img {
    max-width: 28px;
    max-height: 28px;
  }

  .menu-grid {
    grid-template-columns: 1fr;
  }
}


.hotspot-crops.is-ready {
  opacity: 1;
  filter:
    drop-shadow(0 0 12px rgba(255, 55, 116, .80))
    drop-shadow(0 0 18px rgba(255, 218, 88, .45))
    drop-shadow(3px 4px 0 rgba(0,0,0,.34));
  animation: cropHotspotReady 1.05s ease-in-out infinite;
}

.hotspot-crops.is-ready::after {
  content: "plantação";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 4px;
  color: var(--gold-300);
  font-size: 17px;
  line-height: 1;
  text-shadow: 2px 2px 0 var(--shadow-hard);
  white-space: nowrap;
}

@keyframes cropHotspotReady {
  0%, 100% { transform: translate(-50%, -50%) translateY(0) scale(1); }
  50% { transform: translate(-50%, -50%) translateY(-5px) scale(1.12); }
}
