/* =============================================================================
   FARM PAGE STYLES
   ============================================================================= */

.farms-show,
.farms-edit {
  background-color: #99dfff;
  min-height: 100vh;
}

.farms-show {
  height: 100vh;
  overflow: hidden;
}

.farm-page {
  padding: 16px;
  padding-top: 80px;
  min-height: 100vh;
  box-sizing: border-box;
  max-width: 1200px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .farm-page {
    padding: 24px 32px;
    padding-top: 96px;
  }
}

/* =============================================================================
   HEADER
   ============================================================================= */
.farm-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: white;
  border-radius: 6px;
  border: 4px solid black;
  box-shadow: 4px 4px 0 0 black;
}

.farm-header__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.farm-header__title a {
  color: inherit;
  text-decoration: none;
}

.farm-header__title a:hover {
  text-decoration: underline;
}

.farm-header__harvest {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: rgba(0, 0, 0, 0.7);
}

.farm-header__actions {
  display: flex;
  gap: 8px;
}

/* =============================================================================
   MODE BANNER
   ============================================================================= */
.farm-mode-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #d2bfff, #a57fff);
  border-radius: 6px;
  border: 4px solid black;
  box-shadow: 4px 4px 0 0 black;
  color: white;
  position: fixed;
  top: 72px;
  left: 16px;
  right: 16px;
  z-index: 50;
  overflow: hidden;
}

@media (min-width: 768px) {
  .farm-mode-banner {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100% - 64px);
    max-width: 600px;
  }
}

.farm-mode-banner.is-visible {
  display: flex;
}

.farm-mode-banner__content p {
  margin: 0;
  font-size: 1rem;
}

.farm-page.is-planting .farm-mode-banner {
  background: linear-gradient(135deg, #a57fff, #8b5cf6);
}

.farm-page.is-using-item .farm-mode-banner {
  background: linear-gradient(135deg, #6ee7b7, #10b981);
}

/* Selection mode cursors - apply to whole page */
.farm-page.is-planting {
  cursor: url("/assets/misc/cursors/cursor_target-0f53cdf3.png") 22 22, pointer;
}

.farm-page.is-using-item {
  cursor: url("/assets/misc/cursors/cursor_use_item-9dc4af44.png") 22 22, pointer;
}

/* =============================================================================
   INVENTORY TOGGLE (mobile only)
   ============================================================================= */
.farm-inventory-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: white;
  border: 4px solid black;
  border-radius: 6px;
  box-shadow: 4px 4px 0 0 black;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  z-index: 80;
}

.farm-inventory-toggle i {
  font-size: 1.2rem;
}

.farm-inventory-toggle:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 0 black;
}

@media (min-width: 1024px) {
  .farm-inventory-toggle {
    display: none;
  }
}

/* =============================================================================
   MAIN CONTENT LAYOUT
   ============================================================================= */
.farm-left {
  flex: 1;
  min-width: 0;
}

@media (min-width: 1024px) {
  .farm-left {
    margin-right: 300px;
  }
}

.farm-main {
  display: flex;
  justify-content: center;
}

/* =============================================================================
   PLOT GRID
   ============================================================================= */
.farm-plots {
  display: grid;
  gap: 12px;
}

.farm-plots--size-2 {
  grid-template-columns: repeat(2, 140px);
}

.farm-plots--size-3 {
  grid-template-columns: repeat(3, 120px);
}

.farm-plots--size-4 {
  grid-template-columns: repeat(4, 100px);
}

@media (min-width: 480px) {
  .farm-plots--size-2 {
    grid-template-columns: repeat(2, 160px);
    gap: 16px;
  }

  .farm-plots--size-3 {
    grid-template-columns: repeat(3, 140px);
    gap: 16px;
  }

  .farm-plots--size-4 {
    grid-template-columns: repeat(4, 120px);
    gap: 14px;
  }
}

/* =============================================================================
   INDIVIDUAL PLOT
   ============================================================================= */
.farm-plot {
  position: relative;
  aspect-ratio: 1;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center bottom;
  animation: float 8s ease-in-out infinite;
}

/* Creature wrapper - anchored to bottom */
.farm-plot__creature-wrap {
  position: absolute;
  bottom: 7%;
  left: 50%;
  transform: translateX(-50%);
  width: 70%;
  height: 60%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.farm-plot__creature-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.farm-plot__creature-img.is-unsprouted {
  filter: grayscale(1);
  opacity: 0.8;
  max-height: 50%;
  align-self: flex-end;
}

.farm-plot:hover .farm-plot__creature-img {
  transform: scale(1.05);
}

/* Footer with name and sprout button */
.farm-plot__footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-bottom: 2px;
}

.farm-plot__name {
  background: black;
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
  max-width: 95%;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.farm-plot:hover .farm-plot__name {
  opacity: 1;
}

/* Sprout button - shown on hover (desktop) or always (mobile) */
.farm-plot__sprout-form {
  opacity: 1;
}

.farm-plot__sprout-btn {
  font-size: 0.7rem;
  padding: 4px 12px;
}

/* Sprout countdown timer */
.farm-plot__sprout-timer {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.farm-plot__sprout-timer i {
  font-size: 0.7rem;
}

@media (min-width: 768px) {
  .farm-plot__sprout-form,
  .farm-plot__sprout-timer {
    opacity: 0;
    transition: opacity 0.15s ease;
  }

  .farm-plot:hover .farm-plot__sprout-form,
  .farm-plot:hover .farm-plot__sprout-timer {
    opacity: 1;
  }
}

/* Action overlay forms (for plant/use modes) */
.farm-plot__action-form {
  position: absolute;
  inset: 0;
  z-index: 10;
}


.farm-plot__action-btn {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0;
  color: transparent;
  animation: target-pulse 1.2s ease-in-out infinite;
}

.farm-plot__action-btn:hover {
  animation: none;
  background: rgba(165, 127, 255, 0.3);
}

@keyframes target-pulse {
  0%, 100% {
    transform: scale(1);
    background: rgba(165, 127, 255, 0.15);
  }
  50% {
    transform: scale(1.08);
    background: rgba(165, 127, 255, 0.35);
  }
}

/* Mode-specific plot styling */
.farm-page.is-planting .farm-plot:not(:has([data-plant-target])),
.farm-page.is-using-item .farm-plot:not(:has([data-use-target])) {
  opacity: 0.5;
  pointer-events: none;
}

.farm-page.is-planting .farm-plot__action-btn {
  cursor: url("/assets/misc/cursors/cursor_target-0f53cdf3.png") 22 22, pointer;
}

.farm-page.is-using-item .farm-plot__action-btn {
  cursor: url("/assets/misc/cursors/cursor_use_item-9dc4af44.png") 22 22, pointer;
}

/* Hide hover actions (sprout button, name) when in selection mode */
.farm-page.is-planting .farm-plot__footer,
.farm-page.is-using-item .farm-plot__footer {
  display: none;
}

/* =============================================================================
   PLANTED OOZE TOOLTIP
   ============================================================================= */
.farm-plot__name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
}

.farm-plot__helper {
  cursor: help;
  z-index: 6;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 100%;
  color: black;
  font-weight: 900;
  text-align: center;
  line-height: 1.2rem;
  width: 1.2rem;
  height: 1.2rem;
  font-size: 0.65rem;
  transition: all 0.15s ease;
  flex-shrink: 0;
  opacity: 0;
}

.farm-plot:hover .farm-plot__helper {
  opacity: 1;
}

.farm-plot__helper:hover,
.farm-plot__helper:focus,
.farm-plot__helper:active {
  background-color: white;
  transform: scale(1.2);
}

.farm-plot__effect-text {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  min-width: 180px;
  max-width: 240px;
  background-color: black;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.farm-plot__effect-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: black;
}

.farm-plot__effect-text p {
  margin: 0;
  padding: 10px 12px;
  font-family: "Baloo", -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.95);
  text-align: center;
}

.farm-plot__helper:hover + .farm-plot__effect-text,
.farm-plot__helper:focus + .farm-plot__effect-text,
.farm-plot__helper:active + .farm-plot__effect-text {
  opacity: 1;
}

/* =============================================================================
   SIDEBAR
   ============================================================================= */
.farm-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

.farm-sidebar-overlay.is-visible {
  display: block;
}

@media (min-width: 1024px) {
  .farm-sidebar-overlay {
    display: none !important;
  }
}

.farm-sidebar {
  display: flex;
  flex-direction: column;
  background: white;
  border: 4px solid black;
  border-radius: 6px;
  box-shadow: 4px 4px 0 0 black;
  overflow: hidden;
  z-index: 100;
}

/* Mobile: slide-in drawer */
@media (max-width: 1023px) {
  .farm-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 360px;
    border-radius: 0;
    border-right: none;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .farm-sidebar.is-open {
    transform: translateX(0);
  }
}

/* Desktop: fixed right sidebar */
@media (min-width: 1024px) {
  .farm-sidebar {
    position: fixed;
    top: 80px;
    right: 24px;
    bottom: 24px;
    width: 280px;
    max-height: none;
    overflow: hidden;
    border-radius: 6px;
  }
}

.farm-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 4px solid black;
  flex-shrink: 0;
  gap: 8px;
}

.farm-sidebar__title {
  font-family: "Baloo", -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", monospace;
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.farm-sidebar__header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.farm-sidebar__icon-wrap {
  position: relative;
}

.farm-sidebar__icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 2px solid black;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s ease;
}

.farm-sidebar__icon-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.farm-sidebar__icon-btn--harvest {
  cursor: default;
  border-color: rgba(0, 0, 0, 0.3);
}

.farm-sidebar__harvest-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  white-space: nowrap;
  padding: 8px 12px;
  background: black;
  color: white;
  font-size: 0.75rem;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.farm-sidebar__harvest-tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  right: 8px;
  border: 6px solid transparent;
  border-bottom-color: black;
}

.farm-sidebar__icon-wrap:hover .farm-sidebar__harvest-tooltip {
  opacity: 1;
}

.farm-sidebar__close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 2px solid black;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.farm-sidebar__close:hover {
  background: rgba(0, 0, 0, 0.1);
}

@media (min-width: 1024px) {
  .farm-sidebar__close {
    display: none;
  }
}

.farm-sidebar__scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.farm-sidebar__section {
  padding: 16px;
  border-bottom: 3px solid rgba(0, 0, 0, 0.1);
}

.farm-sidebar__section:last-child {
  border-bottom: none;
}

.farm-sidebar__empty {
  text-align: center;
  color: rgba(0, 0, 0, 0.4);
  font-size: 0.8rem;
  font-style: italic;
  padding: 12px 0;
  margin: 0;
}

/* Entity card grid - 2 columns */
.farm-sidebar__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* =============================================================================
   ENTITY CARDS
   ============================================================================= */
.farm-entity-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px 8px;
  background: #f8f5ff;
  border: 3px solid black;
  border-radius: 8px;
  box-shadow: 3px 3px 0 0 black;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.farm-entity-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 0 black;
  background: #efe8ff;
}

.farm-entity-card:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 0 black;
}

.farm-entity-card__img {
  width: 52px;
  height: 52px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.farm-entity-card.is-item .farm-entity-card__img {
  width: 44px;
  height: 44px;
}

.farm-entity-card__name {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.farm-entity-card__count {
  position: absolute;
  bottom: -8px;
  right: -8px;
  min-width: 24px;
  height: 24px;
  line-height: 18px;
  font-size: 0.65rem;
  font-weight: 700;
  background-color: #fff17f;
  border-radius: 100%;
  border: 3px solid black;
  text-align: center;
  color: black;
  padding: 0 4px;
  z-index: 10;
}

/* Mojo cost badge (top-left purple circle) */
.farm-entity-card__mojo {
  position: absolute;
  top: -8px;
  left: -8px;
  min-width: 22px;
  height: 22px;
  line-height: 16px;
  font-size: 0.65rem;
  font-weight: 700;
  background-color: #a57fff;
  border-radius: 100%;
  border: 3px solid black;
  text-align: center;
  color: white;
  z-index: 10;
}

/* Help button (question mark) - positioned bottom-left to match shed cards */
.farm-entity-card__helper {
  cursor: help;
  opacity: 0;
  z-index: 6;
  position: absolute;
  left: 4px;
  bottom: 4px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 100%;
  color: white;
  font-weight: 900;
  text-align: center;
  line-height: 1.3rem;
  width: 1.3rem;
  height: 1.3rem;
  font-size: 0.7rem;
  transition: all 0.15s ease;
}

.farm-entity-card__helper:hover,
.farm-entity-card__helper:focus,
.farm-entity-card__helper:active {
  background-color: black;
  opacity: 0 !important;
  transform: scale(1.5);
}

.farm-entity-card:hover .farm-entity-card__helper {
  opacity: 1;
}

/* Effect text overlay (shown on hover - covers the card) */
.farm-entity-card__effect-text {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-color: black;
  border-radius: 5px;
  opacity: 0;
  transition: opacity 0.1s ease-in-out;
  pointer-events: none;
}

.farm-entity-card__effect-text p {
  margin: 0;
  padding: 8px;
  font-family: "Baloo", -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", monospace;
  font-size: 0.8rem;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.95);
  text-align: left;
}

.farm-entity-card__helper:hover + .farm-entity-card__effect-text,
.farm-entity-card__helper:focus + .farm-entity-card__effect-text,
.farm-entity-card__helper:active + .farm-entity-card__effect-text {
  opacity: 1;
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* =============================================================================
   FARM LOG & SETTINGS (preserve)
   ============================================================================= */
.farms-log,
.farms-farm_log {
  background-color: #99dfff;
  min-height: 100vh;
}

.farms-farm_log .events {
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.farms input.farm-name {
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  width: 100%;
  padding: 6px;
}

.form-inputs .form-group {
  padding: 6px 0;
  margin-bottom: 6px;
}

.form-inputs label {
  font-weight: bold;
  padding-bottom: 6px;
  display: block;
}

.form-inputs input[type=text],
.form-inputs input[type=number] {
  font-size: 1.2rem;
  width: 100%;
  padding: 12px;
  border-radius: 3px;
  border: 2px solid rgba(0, 0, 0, 0.1);
}

.form-inputs input:focus {
  border-color: black;
}

/* =============================================================================
   DEAD OOZE CARDS
   ============================================================================= */
.farm-entity-card.is-dead {
  opacity: 0.45;
}

.farm-entity-card.is-dead:hover {
  opacity: 0.7;
}

/* =============================================================================
   BUSY STATE (planting / using / sprouting in progress)
   ============================================================================= */
.farm-page.is-busy .farm-inventory-toggle,
.farm-page.is-busy .farm-sidebar__scroll {
  pointer-events: none;
  opacity: 0.5;
}

.farm-page.is-busy .farm-mode-banner {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.farm-page.is-busy .farm-plot {
  opacity: 0.35;
  transition: opacity 0.3s ease;
}

.farm-page.is-busy .farm-plot.is-busy-target {
  opacity: 1;
  animation: busy-glow 1.5s ease-in-out infinite;
}

@keyframes busy-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15) drop-shadow(0 0 8px rgba(251, 191, 36, 0.5)); }
}

/* Progress meter bar (fills across banner bottom) */
.farm-mode-banner__meter {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 0 2px 2px 0;
  animation: meter-fill var(--meter-duration, 4s) linear forwards;
}

@keyframes meter-fill {
  from { width: 0%; }
  to { width: 100%; }
}

/* Animated dots */
.farm-mode-banner__dots {
  display: inline;
  margin-left: 1px;
}

.farm-mode-banner__dots span {
  display: inline-block;
  animation: dot-bounce 1.4s ease-in-out infinite;
}

.farm-mode-banner__dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.farm-mode-banner__dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dot-bounce {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}
