/**handles:kk-nav**/
/* ==========================================================================
   1. DESKTOP BASE NAVIGATION (MIN-WIDTH: 992PX)
   ========================================================================== */

.fse-custom-megamenu-nav {
  position: static !important;
}

.fse-mobile-toggle {
  display: none; /* Hidden on Desktop */
}

@media (min-width: 992px) {
  .fse-nav-level-1 {
    display: flex !important;
    align-items: center !important;
    gap: 1.5rem !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .fse-nav-item-l1 {
    position: static !important;
  }

  .fse-nav-link-l1 {
    color: #ffffff !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    font-size: 1rem !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.3rem !important;
    cursor: pointer !important;
  }

  /* Desktop Megamenu Panel */
  .fse-megamenu-panel {
    display: none;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    background-color: #1a1a1a !important;
    padding: 3rem 0 !important;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4) !important;
    z-index: 999999 !important;
  }

  .fse-nav-item-l1.is-open .fse-megamenu-panel {
    display: block !important;
  }

  .fse-megamenu-inner {
    width: min(90%, var(--wp--style--global--wide-size, 1200px)) !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
  }

  .fse-megamenu-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 2.5rem 2rem !important;
  }

  .fse-megamenu-column {
    display: flex !important;
    flex-direction: column !important;
  }

  .fse-megamenu-title-link {
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 1.15rem !important;
    text-decoration: none !important;
    padding-bottom: 0.5rem !important;
    margin-bottom: 0.75rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
  }

  .fse-nav-level-3 {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  .fse-nav-level-3 a {
    color: #cccccc !important;
    font-size: 0.95rem !important;
    text-decoration: none !important;
  }

  .fse-nav-item-l1 .fse-nav-link-l1 .fse-caret {
    transition: transform 0.3s ease !important;
  }

  .fse-nav-item-l1.is-open .fse-nav-link-l1 .fse-caret {
    transform: rotate(180deg) !important;
  }
}

/* ==========================================================================
   2. FULL-WIDTH MEGAMENU PANEL (CLICK-ONLY TRIGGER)
   ========================================================================== */

.fse-megamenu-panel {
  display: none;
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  right: 0 !important;
  width: 100vw !important;
  background-color: #1a1a1a !important; /* Dark panel background */
  padding: 3rem 0 !important;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4) !important;
  z-index: 999999 !important;
}

/* Open Panel ONLY when .is-open class is present via JS Click */
.fse-nav-item-l1.is-open .fse-megamenu-panel {
  display: block !important;
}

/* Inner Container - Matches alignwide container width */
.fse-megamenu-inner {
  width: min(90%, var(--wp--style--global--wide-size, 1200px)) !important;
  margin: 0 auto !important;
  box-sizing: border-box !important;
}

/* ==========================================================================
   3. GRID COLUMNS & STACKED LINKS (LEVEL 2 & 3)
   ========================================================================== */

.fse-megamenu-grid {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important; /* 3 Column layout */
  gap: 2.5rem 2rem !important;
}

.fse-megamenu-column {
  display: flex !important;
  flex-direction: column !important;
}

/* Level 2 Submenu Heading Link */
.fse-megamenu-title-link {
  color: #ffffff !important;
  font-weight: 700 !important;
  font-size: 1.15rem !important;
  text-decoration: none !important;
  padding-bottom: 0.5rem !important;
  margin-bottom: 0.75rem !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
  display: block !important;
}

.fse-megamenu-title-link:hover {
  text-decoration: underline !important;
}

/* Level 3 Link List */
.fse-nav-level-3 {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.5rem !important;
}

.fse-nav-level-3 a {
  color: #cccccc !important;
  font-size: 0.95rem !important;
  text-decoration: none !important;
  font-weight: 400 !important;
  display: inline-block !important;
}

.fse-nav-level-3 a:hover {
  color: #ffffff !important;
  text-decoration: underline !important;
}

@media screen and (max-width: 991px) {
  .fse-custom-megamenu-nav {
    display: flex !important;
    justify-content: flex-end !important;
  }

  /* Hamburger Button */
  .fse-mobile-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 4px !important;
    padding: 1rem 0.75rem !important;
    cursor: pointer !important;
  }

  .fse-hamburger-icon,
  .fse-hamburger-icon::before,
  .fse-hamburger-icon::after {
    display: block !important;
    width: 22px !important;
    height: 2px !important;
    background-color: #ffffff !important;
    position: relative !important;
    transition: all 0.3s ease !important;
  }

  .fse-hamburger-icon::before,
  .fse-hamburger-icon::after {
    content: "" !important;
    position: absolute !important;
    left: 0 !important;
  }

  .fse-hamburger-icon::before {
    top: -6px !important;
  }
  .fse-hamburger-icon::after {
    top: 6px !important;
  }

  /* Mobile Drawer List */
  .fse-nav-level-1 {
    display: none !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    background-color: #121212 !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5) !important;
    z-index: 999999 !important;
    flex-direction: column !important;
  }

  .fse-custom-megamenu-nav.mobile-menu-open .fse-nav-level-1 {
    display: flex !important;
  }

  /* Level 1 Item Wrappers */
  .fse-nav-item-l1 {
    width: 100% !important;
    position: relative !important;
    box-sizing: border-box !important;
  }

  .fse-nav-link-l1 {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0.85rem 1.25rem !important;
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 1.05rem !important;
    font-weight: 500 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-sizing: border-box !important;
  }

  /* Blue Border Highlight for Active Mobile Accordion (from reference) */
  .fse-nav-item-l1.is-open > .fse-nav-link-l1 {
    outline: 2px solid #0056b3 !important;
    outline-offset: -2px !important;
    background-color: #1a1a1a !important;
  }

  /* --- INLINE SUBMENU PANEL (PUSHES DOWN LOWER ITEMS) --- */
  .fse-megamenu-panel {
    display: none !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    background-color: #181818 !important;
    padding: 0 !important;
    box-shadow: none !important;
    transform: none !important;
  }

  .fse-nav-item-l1.is-open .fse-megamenu-panel {
    display: block !important;
  }

  .fse-megamenu-inner {
    width: 100% !important;
    padding: 0.5rem 1.25rem 1rem 1.25rem !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  /* Stack Level 2 Links vertically */
  .fse-megamenu-grid {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    gap: 0 !important;
    width: 100% !important;
  }

  .fse-megamenu-column {
    display: block !important;
    width: 100% !important;
  }

  /* Display ONLY Level 2 links */
  .fse-megamenu-title-link {
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    text-decoration: none !important;
    padding: 0.6rem 0 0.6rem 0.5rem !important;
    margin: 0 !important;
    border: none !important;
    display: block !important;
  }

  .fse-megamenu-title-link:hover {
    color: #cccccc !important;
  }

  /* HIDE LEVEL 3 CONTENT COMPLETELY ON MOBILE */
  .fse-nav-level-3 {
    display: none !important;
  }
}

/* Nav responsiveness tweaks */
@media screen and (max-width: 1400px) {
  .site-header__actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* body lock while a mega-menu submenu or a panel dialog is open */
body.has-open-panel,
html.has-open-submenu,
body.has-open-submenu {
  overflow: hidden;
  padding-right: 0;
}

/* Third-level horizontal nav used by page_secondary-nav.php (unchanged, not Bootstrap-based) */
#primary-third-level > ul {
  margin-bottom: 0 !important;
  list-style-type: none;
  padding: 0;
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#primary-third-level > ul > li {
  margin-right: 2em;
  padding: 0.75em 0;
  white-space: nowrap;
}

#primary-third-level a {
  text-decoration: none;
  color: #fff;
}

#primary-third-level a:hover,
#primary-third-level a:active {
  color: #e4f4f7;
}

/* Language switcher */
.lang-switcher {
  color: #fff;
  font-size: 14px;
  text-decoration: none;
}

.lang-switcher:hover {
  color: rgba(255, 255, 255, 0.75);
}

/* Notice banner */
.notice-banner {
  padding: 0.5em 0;
  text-align: center;
}

/* Panels (search / oma konsa) */
.site-header {
  position: relative;
  z-index: 1020;
}

.site-header__bar {
  padding: 0.5em 0;
}

.site-header__actions {
  align-items: center;
  gap: 0.5rem;
}

.panel__close {
  align-self: flex-end;
}

.panel__body {
  padding: 2rem 1rem;
}

.omakonsa-toggle {
  top: 14%;
  transform-origin: bottom right;
  transform: rotate(-90deg);
  z-index: 999;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  color: #000;
  background-color: #f9fafb;
  border-color: #f9fafb;
  box-shadow: none;
  padding: 0.5rem;
  font-family: var(--wp--preset--font-family--montserrat);
  font-size: 16px;
  font-weight: 500;
  border-radius: 0.25rem 0.25rem 0 0;
  transition: box-shadow 0.2s ease;
}

.omakonsa-toggle:hover {
  background-color: #f9fafb;
  border-color: #f9fafb;
  box-shadow: 0 0 0 0.25rem rgba(211, 212, 213, 0.5);
}

.omakonsa-toggle::after {
  content: "";
  display: inline-block;
}

#omakonsa-panel .panel__close {
  background-color: transparent !important;
}

/* "Oma konsa" panel menu, replaces the old widget-area list look */
#omakonsa-sidebar .wp-block-navigation__container {
  flex-direction: column;
  align-items: flex-start;
}

#omakonsa-sidebar .wp-block-navigation-item {
  line-height: 2.5em;
}

#omakonsa-sidebar .wp-block-navigation-item__content {
  padding-left: 0.5em;
  font-weight: 600;
  color: #171717;
}

/* Search panel */
#kk-search-panel .panel__close {
  background: transparent !important;
  color: var(--wp--preset--color--valkoinen);
}

#kk-search-panel .panel__close > i {
  color: var(--wp--preset--color--valkoinen) !important;
}

#kk-search-panel .panel__body {
  padding: var(--wp--preset--spacing--60) 0 var(--wp--preset--spacing--90);
}

#kk-search-panel .search-form {
  max-width: 500px;
  margin: 0 auto;
}

#kk-search-panel .search-submit {
  border-top-left-radius: 0;
  border-top-right-radius: 4px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 4px;
}

@media (max-width: 768px) {
  #kk-search-panel .panel__body {
    padding-right: var(--wp--style--root--padding-right);
    padding-left: var(--wp--style--root--padding-left);
  }
}