/* ============================================
   Custom Overrides — The Stone's Garden
   ============================================ */

/* === Fix 1: Sticky Header === */
.elementor-location-header,
header[data-elementor-type="header"] {
  position: sticky !important;
  top: 0;
  z-index: 9999;
  width: 100% !important;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* Override the hardcoded position:fixed and width:1440px from Elementor */
.elementor-location-header .elementor-section.elementor-sticky,
.elementor-location-header .elementor-sticky--active {
  position: relative !important;
  width: 100% !important;
  left: auto !important;
  top: auto !important;
  margin-top: 0 !important;
}

.elementor-sticky__spacer {
  display: none !important;
}

/* === Fix 3: Desktop Dropdown Flyout === */
.elementor-nav-menu--main .menu-item-has-children {
  position: relative;
}

.elementor-nav-menu--main .menu-item-has-children > .sub-menu {
  display: none !important;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10000;
  min-width: 220px;
  width: max-content;
  max-width: 360px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  border-radius: 0 0 4px 4px;
  padding: 6px 0;
  margin: 0;
  list-style: none;
}

.elementor-nav-menu--main .menu-item-has-children:hover > .sub-menu {
  display: block !important;
}

/* Sub-menu link items */
.elementor-nav-menu--main .sub-menu li {
  display: block !important;
  width: 100%;
}

.elementor-nav-menu--main .sub-menu li a {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  padding: 11px 22px !important;
  font-size: 14px;
  color: #333;
  text-decoration: none;
  white-space: normal;
  word-wrap: break-word;
  transition: background 0.2s, color 0.2s;
}

.elementor-nav-menu--main .sub-menu li a:hover {
  background: #4A6741;
  color: #fff;
}

/* Caret/arrow inline fix */
.elementor-nav-menu--main .sub-menu .menu-item-has-children > a {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.elementor-nav-menu--main .sub-menu .menu-item-has-children > a .sub-arrow {
  display: inline-flex !important;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}

.elementor-nav-menu--main .sub-menu .menu-item-has-children > a .sub-arrow i {
  transform: rotate(-90deg) !important;
}

/* Nested flyout submenu (opens to the right) */
.elementor-nav-menu--main .sub-menu .menu-item-has-children > .sub-menu {
  position: absolute !important;
  top: 0 !important;
  left: 100% !important;
  margin: 0 !important;
  background: #fff !important;
  border-radius: 0 4px 4px 0 !important;
  box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.12) !important;
  z-index: 10001 !important;
  min-width: 180px;
  width: max-content;
  max-width: 320px;
  padding: 6px 0;
}

/* === Fix 5: Mobile Nav Menu === */
@media (max-width: 1024px) {
  /* Keep header columns in a row on mobile/tablet — logo left, hamburger right */
  .elementor-location-header .elementor-container {
    display: flex !important;
    flex-wrap: nowrap !important;
    flex-direction: row !important;
    align-items: center !important;
  }

  /* Logo column */
  .elementor-location-header .elementor-element-7c80a7bd {
    flex: 1 1 0% !important;
    max-width: none !important;
  }

  /* Nav/hamburger column */
  .elementor-location-header .elementor-element-3b65737e {
    flex: 0 0 auto !important;
    max-width: none !important;
  }

  /* CTA column — ensure hidden on mobile/tablet */
  .elementor-location-header .elementor-element-1f826a86 {
    display: none !important;
  }

  /* Hamburger right-aligned */
  .elementor-element-48f6f970 .elementor-menu-toggle {
    margin: 0 !important;
    margin-left: auto !important;
  }

  /* Logo sizing */
  .elementor-location-header .site-logo img {
    max-height: 60px !important;
    width: auto !important;
    height: auto !important;
  }

  /* Nav widget positioning */
  .elementor-element-48f6f970 {
    position: static !important;
  }
  .elementor-element-48f6f970 > .elementor-widget-container {
    position: static !important;
  }

  /* Full-width mobile menu — fixed below header */
  .elementor-nav-menu--dropdown.elementor-nav-menu__container {
    position: fixed !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    min-width: 100vw !important;
    background: #fff !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12) !important;
    z-index: 10000 !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }

  /* Menu list reset */
  .elementor-nav-menu--dropdown ul {
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Menu items — centered text */
  .elementor-nav-menu--dropdown li {
    width: 100%;
    list-style: none;
  }

  .elementor-nav-menu--dropdown li > a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 14px 20px !important;
    font-size: 16px;
    color: #333 !important;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    width: 100%;
    text-align: center;
    box-sizing: border-box !important;
  }

  /* White text on green (#4A6741) background — active/highlighted items */
  .elementor-nav-menu--dropdown a.elementor-item-active,
  .elementor-nav-menu--dropdown a.highlighted,
  .elementor-nav-menu--dropdown .current-menu-item > a,
  .elementor-nav-menu--dropdown .current_page_item > a {
    color: #fff !important;
  }
  .elementor-nav-menu--dropdown a.elementor-item-active .sub-arrow,
  .elementor-nav-menu--dropdown .current-menu-item > a .sub-arrow,
  .elementor-nav-menu--dropdown .current_page_item > a .sub-arrow {
    color: #fff !important;
  }

  /* Items WITH sub-menus: center the text+caret group */
  .elementor-nav-menu--dropdown .menu-item-has-children > a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  /* Caret inline */
  .elementor-nav-menu--dropdown .menu-item-has-children > a .sub-arrow {
    display: inline-flex !important;
    align-items: center;
    flex-shrink: 0;
    font-size: 12px;
    transition: transform 0.3s;
  }

  .elementor-nav-menu--dropdown .sub-menu-open > a .sub-arrow {
    transform: rotate(180deg);
  }

  /* Sub-menus collapsed by default */
  .elementor-nav-menu--dropdown .sub-menu {
    display: none !important;
    background: #f8f8f8 !important;
    padding: 0 !important;
    width: 100% !important;
    position: static !important;
    box-shadow: none !important;
  }

  .elementor-nav-menu--dropdown .sub-menu-open > .sub-menu {
    display: block !important;
  }

  /* Sub-menu items — centered */
  .elementor-nav-menu--dropdown .sub-menu a {
    padding: 12px 20px !important;
    font-size: 14px;
    justify-content: center;
    text-align: center;
    background: #f8f8f8;
  }

  .elementor-nav-menu--dropdown .sub-menu .sub-menu a {
    background: #f2f2f2;
  }
}


/* === Mobile hero vertical centering — home, about, reviews, contact, gallery === */
@media (max-width: 767px) {
  .page-id-13 .elementor-element-55daf87 > .elementor-container,
  .page-id-14 .elementor-element-e75bf1d > .elementor-container,
  .page-id-19 .elementor-element-ede61e0 > .elementor-container,
  .page-id-20 .elementor-element-1bcc12d > .elementor-container,
  .page-id-15 .elementor-element-ba2ade8 > .elementor-container {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    align-content: center !important;
  }
}

/* === Fix 7: Gallery Grid Layout === */
.e-gallery-container.e-gallery-justified {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  position: relative !important;
  padding-bottom: 0 !important;
}

.e-gallery-container.e-gallery-justified .e-gallery-item {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  width: auto !important;
  height: auto !important;
  --item-width: auto !important;
  --item-height: auto !important;
  --item-start: auto !important;
  --item-top: auto !important;
}

.e-gallery-container.e-gallery-justified .e-gallery-image {
  width: 100%;
  aspect-ratio: 4/3;
  background-size: cover;
  background-position: center;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.e-gallery-container.e-gallery-justified .e-gallery-item:hover .e-gallery-image {
  transform: scale(1.02);
}

@media (max-width: 1024px) {
  .e-gallery-container.e-gallery-justified {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .e-gallery-container.e-gallery-justified {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Hide gallery overlay title/description */
.elementor-gallery-item__overlay {
  display: none;
}

/* === Fix 7D: Lightbox === */
#lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  align-items: center;
  justify-content: center;
}

#lightbox-overlay.active {
  display: flex;
}

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
}

.lb-img-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 88vh;
}

.lb-img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  transition: opacity 0.3s;
}

.lb-close {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 2;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  line-height: 1;
}

.lb-prev, .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 28px;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.lb-prev:hover, .lb-next:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lb-prev { left: 16px; }
.lb-next { right: 16px; }

.lb-spinner {
  display: none;
  position: absolute;
  z-index: 1;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lb-spin 0.8s linear infinite;
}

@keyframes lb-spin {
  to { transform: rotate(360deg); }
}

/* === Fix 11: Smooth Scroll === */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
}

/* === Fix 12: Image Height Matching === */
.elementor-section .elementor-row,
.elementor-section > .elementor-container {
  display: flex;
  align-items: stretch;
}

.elementor-widget-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 768px) {
  .elementor-section .elementor-row,
  .elementor-section > .elementor-container {
    flex-direction: column;
  }

  .elementor-widget-image img {
    height: auto;
    max-height: 400px;
  }
}
