/* ==========================================================================================
   HEADER LAYOUT
   ========================================================================================== */
.ve_header {
  background: linear-gradient(var(--vp--color--surface), #fff);
}

.ve_header__content {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "logo consultation phones"
    "nav nav nav";
  align-items: center;
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 20px;
  column-gap: 8px;
}

.ve_header__brand {
  grid-area: logo;
}

.ve_header__consultation {
  grid-area: consultation;
  justify-self: center;
}

.ve_header__phones {
  grid-area: phones;
}

.ve_header__nav {
  grid-area: nav;
  width: 100%;
}

/* --- Scrolled Header Styles --- */
.ve_header.scrolled {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  width: 100%;
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transform: translateY(0);
  /* Start visible when scrolled */
}

.ve_header.scrolled .ve_header__content {
  grid-template-columns: auto 1fr auto auto;
  grid-template-rows: auto;
  grid-template-areas: "logo nav consultation phones";
  max-width: 100%;
}

.ve_header.scrolled .ve_header__nav {
  justify-self: start;
}


.ve_header.scrolled .ve_header__ul {
  width: fit-content;
  height: auto;
  justify-content: flex-start;
  transition: all 0s;
}

.ve_header.scrolled .ve_header__li {
  width: auto;
  height: auto;
  display: block;
  container-type: unset;
  flex: unset;
}

.ve_header.scrolled .nav-menu__item {
  padding: 8px 12px;
  border: 1px solid transparent;
  background: none;
  box-shadow: none;
  border-radius: 8px;
}

.ve_header.scrolled .nav-menu__item svg {
  display: none;
  /* Hide the icon */
}

.ve_header.scrolled .nav_menu__text {
  display: block;
  /* Show the text */
  font-size: 16px;
}

/* ==========================================================================================
   BRAND-LOGO BLOCK
   ========================================================================================== */
.ve_header__brand {
  display: flex;
  align-items: stretch;
  width: 320px;
  height: 80px;
}

.ve_header.scrolled .ve_header__brand {
  height: fit-content;
  width: fit-content;
}

.ve_header__brand>.custom-logo-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.custom-logo {
  width: 320px;
  height: auto;
  display: block;
  margin: 0 auto;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Мобільний логотип для iPhone - CSS content підхід */
@media (max-width: 600px) {
  .custom-logo {
    content: url('/wp-content/themes/veles-energy-parent/assets/images/Veles_Energy__logo_with_text_below_100x73.png') !important;
    width: 100px !important;
    height: auto;
  }
  
  .ve_footer__brand .custom-logo {
    content: url('/wp-content/themes/veles-energy-parent/assets/images/veles-energo_logo_text.png') !important;
    width: 360px !important;
  }
}

/* Additional iOS WebKit compatibility */
@media screen and (-webkit-min-device-pixel-ratio: 1) {
  .custom-logo {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
  }
}

.ve_header.scrolled .custom-logo {
  width: 280px;
}

/* Mobile-first: default mobile styles */
.ve_header__brand {
  width: 100px !important;
}

.ve_header__brand>.custom-logo-link {
  width: 100px;
}

/* Desktop styles */
@media (min-width: 768px) {
  .ve_header__brand {
    width: auto !important;
  }
  
  .ve_header__brand>.custom-logo-link {
    width: auto;
  }
}

/* ==========================================================================================
   CONSULTATION BUTTON BLOCK
   ========================================================================================== */
.ve_header__consultation {
  display: flex;
  flex-direction: row;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 8px 0;
}

@media (max-width: 960px) {
  .ve_header__consultation {
    justify-content: flex-end;
  }

  .ve_header.scrolled .ve_header__consultation {
    padding: 4px 0;
  }
}

.ve_header.scrolled .ve_header__consultation {
  padding: 0;
  justify-content: flex-end;
}

@media (max-width: 960px) {
  .ve_header.scrolled .ve_header__consultation {
    padding: 4px 0;
  }
}

.ve_header__consultation-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  background-color: transparent;
  color: var(--vp--color--primary);
  font-size: 24px;
  font-weight: 500;
  text-align: center;
}

@media (max-width: 960px) {
  .ve_header__consultation-btn {
    max-width: 140px;
    border-radius: 10px;
    background-color: var(--vp--color--primary);
    color: var(--vp--color--on-primary);
    font-size: 16px;
    font-weight: 500;
    text-align: center;
  }
}

.ve_header__consultation-btn i {
  display: none;
}

@media (max-width: 960px) {

  .ve_header__consultation-btn i {
    display: inline-block;
  }
}

.ve_header__consultation-btn:hover {
  background-color: white;
  color: var(--vp--color--secondary);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
  transition: all 0.5s ease-out;
}

.ve_header.scrolled .ve_header__consultation-btn {
  max-width: 140px;
  border-radius: 10px;
  background-color: var(--vp--color--primary);
  color: var(--vp--color--on-primary);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
}

.ve_header.scrolled .ve_header__consultation-btn i {
  display: inline-block;
}

.ve_header.scrolled .ve_header__consultation-btn:hover {
  background-color: white;
  color: var(--vp--color--secondary);
  border: none;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
  transition: all 0.5s ease-out;
}

/* ==========================================================================================
   PHONES BLOCK
   ========================================================================================== */
.ve_header__phones {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  height: 100%;
  padding: 4px 0;
  gap: 0;
}

@media (max-width: 660px) {
  .ve_header__phones {
    gap: 4px
  }
}


.ve_header.scrolled .ve_header__phones {
  padding: 0;
}

.ve_header__phone {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 4px;
  gap: 8px;
  color: var(--vp--color--primary);
  font-size: 28px;
  line-height: 40px;
  letter-spacing: -2px;
  text-wrap: nowrap;
  text-decoration: none;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.ve_header__phone:hover {
  color: var(--vp--color--secondary);
  transition: all 0.75s ease-out;
}

@media (max-width: 960px) {
  .ve_header__phone {
    font-size: 24px;
    line-height: 32px;
  }
}

@media (max-width: 660px) {
  .ve_header__phone {
    font-size: 20px;
    line-height: 24px;
  }
}

.ve_header.scrolled .ve_header__phone {
  font-size: 24px;
  line-height: 32px;
}

@media (max-width: 660px) {
  .ve_header.scrolled .ve_header__phone {
    font-size: 20px;
    line-height: 24px;
  }
}

.ve_header__phone i {
  font-size: 20px;
  opacity: 0;
}

.ve_header__phone:hover i {
  opacity: 1;
  transition: all 0.75s ease-out;
}

@media (max-width: 740px) {
  .ve_header__phone i {
    display: none;
  }
}

/* ==========================================================================================
   NAVIGATION BLOCK
   ========================================================================================== */

/* Main list container */
.ve_header__ul {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 0;
  gap: 16px;
  list-style: none;
}

/* List item - This is the container we track */
.ve_header__li {
  position: relative;
  width: 0;
  /* Allow flexbox to control the width completely */
  height: 112px;
  margin: 0;
  /*  transition: all 0.5s ease-out; */
  container-type: inline-size;
  flex: 1;
}

/* Link - Stretches to fill the LI */
.ve_header__ul .menu-item a {
  color: var(--vp--color--primary);
  text-decoration: none;
  height: 100%;
  white-space: nowrap;
  /* Prevent text wrapping */
}

/* Content block inside the link */
.nav-menu__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  /* Push content to the bottom */
  width: 100%;
  height: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 16px;
  transition: background-color 0.3s ease-out, border-color 0.3s ease-out, box-shadow 0.3s ease-out;
}

/* User's hover style - preserved */
.nav-menu__item:hover {
  background-color: white;
  border: 1px solid lightgray;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Icon */
.nav-menu__item svg {
  width: 50px;
  height: 50px;
  margin-bottom: 10px;
}

/* Text */
.nav_menu__text {
  font-size: 14px;
  text-align: center;
}

/* Container Query for adaptive behavior */
@container (max-width: 136px) {
  .nav_menu__text {
    display: none;
  }

  .nav-menu__item {
    justify-content: center;
    /* Center icon vertically when text is gone */
  }

  .nav-menu__item svg {
    margin-bottom: 0;
  }
}

/* Media Queries for screen size adjustments */
@media (max-width: 768px) {
  .ve_header__ul {
    gap: 0;
  }
}

@media (max-width: 648px) {
  .ve_header__li {
    height: 64px;
  }

  .nav-menu__item svg {
    width: 36px;
    margin-bottom: 4px;
  }
}

@media (max-width: 1420px) {

  .ve_header.scrolled .ve_header__content {
    padding: 0;
  }

  .ve_header.scrolled .ve_header__content {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    grid-template-areas:
      "logo consultation phones"
      "nav nav nav";
    row-gap: 8px;
  }

  .ve_header.scrolled .ve_header__ul {
    width: 100%;
  }

  .ve_header.scrolled .ve_header__li {
    flex: 1;
    width: 0;
    display: list-item;
    container-type: inline-size;
  }

  .ve_header.scrolled .nav-menu__item {
    padding: 12px;
    height: fit-content;
    border-radius: 16px;
  }

  .ve_header.scrolled .nav-menu__item svg {
    display: block;
  }

  .ve_header.scrolled .nav_menu__text {
    font-size: 14px;
    display: none;
  }
}

@media (max-width: 600px) {
  .ve_header.scrolled .nav-menu__item {
    padding: 0;
  }
}


/* --- Phone shake animation --- */
@keyframes shake-phone {

  0%,
  25%,
  100% {
    transform: rotate(0);
  }

  2.5%,
  7.5%,
  12.5%,
  17.5%,
  22.5% {
    transform: rotate(-8deg);
  }

  5%,
  10%,
  15%,
  20% {
    transform: rotate(8deg);
  }
}

.ve_header__li.icon--contact:hover svg {
  animation: shake-phone 2.5s linear infinite;
}

/* ==========================================================================================
   MOBILE HAMBURGER BUTTON
   ========================================================================================== */
.ve_header__hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 10;
  transition: transform 0.3s ease;
}

.ve_header__hamburger:hover {
  transform: scale(1.1);
}

.ve_header__hamburger-line {
  width: 100%;
  height: 3px;
  background-color: var(--vp--color--primary);
  border-radius: 2px;
  transition: all 0.3s ease;
  transform-origin: center;
}

/* Hamburger active state (when menu is open) - animated to X */
.ve_header__hamburger.active .ve_header__hamburger-line:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}

.ve_header__hamburger.active .ve_header__hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scale(0);
}

.ve_header__hamburger.active .ve_header__hamburger-line:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}

/* Show hamburger on mobile screens */
@media (max-width: 991px) {
  .ve_header__hamburger {
    display: flex;
  }
}

/* ==========================================================================================
   MOBILE MENU ADAPTATIONS (Hide/Show elements)
   ========================================================================================== */
@media (max-width: 991px) {

  /* Hide desktop navigation */
  .ve_header__nav--desktop {
    display: none;
  }

  /* Hide phones from header on mobile */
  .ve_header__phones {
    display: none;
  }

  /* Adjust header grid for mobile */
  .ve_header__content {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto;
    grid-template-areas: "logo consultation hamburger";
    padding: 12px 20px;
    gap: 20px;
  }

  .ve_header__brand {
    grid-area: logo;
  }

  .ve_header__consultation {
    grid-area: consultation;
  }

  .ve_header__hamburger {
    grid-area: hamburger;
  }

  /* Scrolled header on mobile */
  .ve_header.scrolled .ve_header__content {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto;
    grid-template-areas: "logo consultation hamburger";
    padding: 8px 20px;
  }
}

/* ==========================================================================================
   MOBILE OFFCANVAS MENU STYLES
   ========================================================================================== */
.ve_mobile-menu {
  --bs-offcanvas-width: 280px;
}

.ve_mobile-menu__header {
  background: linear-gradient(var(--vp--color--surface), #fff);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding: 20px;
}

.ve_mobile-menu__header .offcanvas-title {
  color: #b5b5b5;
  font-size: 24px;
  font-weight: 600;
}

.ve_mobile-menu__body {
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 24px;
}

/* Mobile Navigation Menu */
.ve_mobile-menu__nav {
  flex: 1;
}

.ve_mobile-menu__ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ve_mobile-menu__ul .ve_header__li {
  width: 100%;
  height: auto;
  margin: 0;
  container-type: normal;
  flex: none;
}

.ve_mobile-menu__ul .menu-item a {
  display: block;
  width: 100%;
  color: var(--vp--color--primary);
  text-decoration: none;
}

.ve_mobile-menu__ul .nav-menu__item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  height: auto;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: all 0.3s ease;
  gap: 12px;
}

.ve_mobile-menu__ul .nav-menu__item:hover,
.ve_mobile-menu__ul .nav-menu__item:active {
  background-color: var(--vp--color--surface);
  border-color: var(--vp--color--primary);
}

.ve_mobile-menu__ul .nav-menu__item svg {
  width: 32px;
  height: 32px;
  margin: 0;
  flex-shrink: 0;
}

.ve_mobile-menu__ul .nav_menu__text {
  display: block;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
}

/* Mobile Consultation Button */
.ve_mobile-menu__consultation {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 16px;
}

.ve_mobile-menu__consultation-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  background-color: var(--vp--color--primary);
  color: var(--vp--color--on-primary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.ve_mobile-menu__consultation-btn:hover {
  background-color: var(--vp--color--secondary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.ve_mobile-menu__consultation-btn i {
  font-size: 32px;
}

/* Mobile Phones */
.ve_mobile-menu__phones {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 16px;
}

.ve_mobile-menu__phone {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.02);
  color: var(--vp--color--primary);
  font-size: 18px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.3s ease;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.ve_mobile-menu__phone:hover {
  background-color: var(--vp--color--surface);
  color: var(--vp--color--secondary);
  transform: translateX(4px);
}

.ve_mobile-menu__phone i {
  font-size: 20px;
  opacity: 0.8;
}
