/**
 * Hero Fixed Positioning System
 * Ensures consistent positioning regardless of viewport size on desktop
 */

/* ===========================
   DESKTOP FIXED CONTAINER
   =========================== */
@media (min-width: 769px) {
  /* Hero container with fixed maximum width */
  .hero-banner-modern {
    position: relative;
    height: 600px !important;
    min-height: 600px !important;
    max-height: 600px !important;
    overflow: hidden;
    display: block !important;
  }

  /* Inner container for consistent positioning */
  .hero-banner-modern::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1920px; /* Maximum reference width */
    height: 100%;
    pointer-events: none;
    z-index: 1;
  }

  /* Hero background fixed */
  .hero-background {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
  }

  /* Hero overlay */
  .hero-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 2;
  }

  /* All hero elements - absolute positioning relative to container */
  .hero-element {
    position: absolute !important;
    z-index: 3;
    transition: none !important; /* Remove transitions for instant updates */
  }

  /* Fix transform origin for proper centering */
  .hero-title-element,
  .hero-highlight-element,
  .hero-description-element,
  .hero-btn1-element,
  .hero-btn2-element {
    position: absolute !important;
    transform-origin: center center !important;
    transform: translate(-50%, -50%) !important;
  }

  /* Ensure description has proper width */
  .hero-description-element {
    width: 60% !important;
    max-width: 800px !important;
  }

  /* Buttons should not stretch */
  .hero-btn1-element,
  .hero-btn2-element {
    width: auto !important;
    white-space: nowrap !important;
  }

  /* Prevent responsive system from overriding in desktop */
  body:not(.is-mobile) .hero-element {
    position: absolute !important;
    transform: translate(-50%, -50%) !important;
  }

  /* Override any flex layouts on desktop */
  body:not(.is-mobile) .hero-banner-modern {
    display: block !important;
    flex-direction: unset !important;
    justify-content: unset !important;
    align-items: unset !important;
    padding: 0 !important;
  }
}

/* ===========================
   CUSTOMIZER SPECIFIC STYLES
   =========================== */
.customize-preview .hero-banner-modern {
  position: relative !important;
}

.customize-preview .hero-element {
  position: absolute !important;
  transition: left 0.1s ease, top 0.1s ease !important; /* Smooth dragging */
}

/* Dragging states */
.hero-element.dragging-title,
.hero-element.dragging-highlight,
.hero-element.dragging-description,
.hero-element.dragging-btn1,
.hero-element.dragging-btn2 {
  z-index: 100 !important;
  opacity: 0.9;
  transition: none !important; /* No transition while dragging */
}

/* Drag indicators in customizer */
.customize-preview .hero-drag-indicator-title,
.customize-preview .hero-drag-indicator-highlight,
.customize-preview .hero-drag-indicator-description,
.customize-preview .hero-drag-indicator-btn1,
.customize-preview .hero-drag-indicator-btn2 {
  display: flex !important;
  opacity: 1 !important;
}

/* Hide drag indicators on frontend */
body:not(.customize-preview) [class*="hero-drag-indicator"] {
  display: none !important;
}

/* ===========================
   LARGE DESKTOP SCREENS
   =========================== */
@media (min-width: 1920px) {
  .hero-banner-modern {
    position: relative;
  }

  /* Create a virtual container for positioning */
  .hero-element {
    position: absolute !important;
    /* Calculate position based on 1920px reference */
    left: calc(50% + ((var(--pos-x, 50) - 50) * 9.6px)) !important;
    top: calc(var(--pos-y, 50) * 6px) !important;
    transform: translate(-50%, -50%) !important;
  }
}

/* ===========================
   TABLET OVERRIDE
   =========================== */
@media (min-width: 769px) and (max-width: 1024px) {
  /* Keep same system as desktop for tablets */
  .hero-banner-modern {
    height: 500px !important;
    min-height: 500px !important;
  }

  .hero-element {
    position: absolute !important;
    transform: translate(-50%, -50%) !important;
  }
}

/* ===========================
   POSITION CALCULATION HELPERS
   =========================== */
.hero-element[data-desktop-x][data-desktop-y] {
  /* Use data attributes for positioning */
  left: attr(data-desktop-x %) !important;
  top: attr(data-desktop-y %) !important;
}

/* ===========================
   FIX FOR CENTERED CONTAINER
   =========================== */
@media (min-width: 769px) {
  /* Ensure hero content is properly contained */
  .hero-banner-modern {
    margin: 0 auto;
    position: relative;
    width: 100%;
  }

  /* Create reference container */
  .hero-positioning-container {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1920px;
    height: 100%;
    pointer-events: none;
  }

  /* Position elements relative to this container */
  .hero-positioning-container .hero-element {
    pointer-events: all;
  }
}

/* ===========================
   DEBUG MODE (optional)
   =========================== */
.debug-hero-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  opacity: 0.3;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,0,0,0.1) 0px, transparent 1px, transparent 59px, rgba(255,0,0,0.1) 60px),
    repeating-linear-gradient(90deg, rgba(255,0,0,0.1) 0px, transparent 1px, transparent 59px, rgba(255,0,0,0.1) 60px);
}