/*
 * Mega menu rework — matches Figma "Krokus_MegaMenu" (node 293:6114).
 *
 * Design spec (1920px frame):
 *  - Full-width flush panel under the header, background #fff (the design
 *    puts the cream #FAF6EE active row on a white panel).
 *  - Left categories column: 360px wide, 48px rows, 48px left inset,
 *    16px/600 uppercase, color #1E2934, chevron at right edge (20px inset).
 *    Hover/active row: #FAF6EE (design cream) full-width fill + 12px indent.
 *  - Subcategory grid: starts at 360px, 20px gutter, 300px column pitch,
 *    48px rows flowing top-to-bottom then next column (10 rows at 1920).
 *    16px/400, color #1E2934, hover = underline.
 *  - Everything below the panel dimmed with rgba(30,41,52,.3).
 */

@media screen and (min-width: 1121px) {

  /* Anchor the panel to the fixed header instead of the <li> */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children {
    position: static;
  }

  /* Open nav item: dark text + 3px underline bar (was red) */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children.mega-open > a {
    color: #1E2934;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children > a::before {
    content: '';
    position: absolute;
    left: 0;
    right: 15px; /* exclude the caret area */
    bottom: 0;
    height: 3px;
    background: #475836; /* derives to the design's Haki via Store Design */
    opacity: 0;
    transition: opacity .2s ease-in-out;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children.mega-open > a::before {
    opacity: 1;
  }

  /* Full-width flush panel */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu {
    top: 100%;
    left: 0 !important;
    right: 0 !important;
    min-height: 492px;
    padding: 0;
    border: 0;
    border-radius: 0 !important;
    background-color: #fff;
    box-shadow: none;
  }

  /* Dim the page below the open panel */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(30, 41, 52, 0.3);
    pointer-events: none;
  }

  /* Left categories column */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories {
    width: 360px;
    padding: 0 0 24px;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li > a {
    width: 360px;
    min-height: 48px;
    padding: 0 44px 0 48px;
    font-family:"Jost", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: .03em;
    color: #1E2934;
    border-radius: 0 !important;
    transition: background-color .2s ease-in-out, padding .2s ease-in-out;
  }
  /* Chevron: keep it dark, 20px from the right edge */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li.has-children > a::after {
    right: 20px;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li:hover > a {
    background-color: #FAF6EE;
    color: #1E2934;
    padding-left: 60px;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li:hover > a::after {
    filter: none;
  }

  /* Default state while the panel is open and no category is hovered yet:
     first category shows as active with its subpanel visible (as in Figma) */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children.mega-open .dropdown-menu__categories:not(:hover) > li:first-child > a {
    background-color: #FAF6EE;
    color: #1E2934;
    padding-left: 60px;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children.mega-open .dropdown-menu__categories:not(:hover) > li:first-child > a::after {
    filter: none;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children.mega-open .dropdown-menu__categories:not(:hover) > li:first-child .submenu {
    opacity: 1;
    visibility: visible;
  }

  /* Subcategory grid — flows down each column, then to the next */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu {
    top: 0 !important;
    bottom: auto !important;
    left: 360px !important;
    right: auto !important;
    height: auto !important;
    width: auto;
    min-width: 0;
    padding: 0 20px;
    border: 0;
    border-radius: 0;
    background: transparent;
    grid-template-columns: none;
    grid-template-rows: repeat(10, 48px);
    grid-auto-flow: column;
    grid-auto-columns: 300px;
    gap: 0;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu li {
    display: flex;
    align-items: center;
    height: 48px;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu li a {
    padding: 0;
    font-family:"Jost", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.3;
    color: #1E2934;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu li a:hover {
    color: #1E2934;
    text-decoration: underline;
  }
}

/* Fewer columns fit — let each column take more rows */
@media screen and (min-width: 1350px) and (max-width: 1649px) {
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu {
    min-height: 636px;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu {
    grid-template-rows: repeat(13, 48px);
    grid-auto-columns: 280px;
  }
}
@media screen and (min-width: 1121px) and (max-width: 1349px) {
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu {
    min-height: 780px;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu {
    grid-template-rows: repeat(16, 48px);
    grid-auto-columns: 240px;
  }
}

/* ------------------------------------------------------------------ */
/* Mobile / tablet: drill-down drawer (Figma 300:9038 / 300:10348 /   */
/* 300:10499) — each level slides in as its own full panel            */
/* ------------------------------------------------------------------ */

/* Desktop never sees the drawer chrome */
@media screen and (min-width: 1121px) {
  .site-header .mobile-nav-head,
  .site-header .drill-back,
  .site-header .drill-back-row {
    display: none !important;
  }
}

@media screen and (max-width: 1120px) {

  /* Drawer: soft background; the head bar is sticky and in-flow */
  .site-header #site-navigation {
    background-color: #fff;
    padding-top: 0;
    padding-bottom: 30px;
  }
  /* While a drill panel is open, the root list behind it must not scroll */
  .site-header #site-navigation.nav-drilled {
    overflow: hidden;
  }

  /* The drawer has its own close button — hide the header X while open */
  html.mobile-nav-open .site-header .menu-toggle {
    opacity: 0;
    pointer-events: none;
  }

  /* Head bar: logo + close. Sticky at the top of the scrolling drawer. */
  .site-header .mobile-nav-head {
    position: sticky;
    top: 0;
    z-index: 60;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid #ECECEC;
  }
  .site-header .mobile-nav-head__logo img {
    height: 26px;
    width: auto;
  }
  .site-header .mobile-nav-head__close {
    position: relative;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
  }
  .site-header .mobile-nav-head__close::before,
  .site-header .mobile-nav-head__close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 1.5px;
    background: #1E2934;
  }
  .site-header .mobile-nav-head__close::before { transform: translate(-50%, -50%) rotate(45deg); }
  .site-header .mobile-nav-head__close::after  { transform: translate(-50%, -50%) rotate(-45deg); }

  /* Root list rows: uppercase, 48px, chevron on every row */
  .site-header #site-navigation #primary-menu-list {
    gap: 0;
    padding-top: 4px;
  }
  .site-header #site-navigation #primary-menu-list > li > a {
    display: flex;
    align-items: center;
    gap: 0 10px;
    width: 100%;
    min-height: 48px;
    padding: 0 44px 0 16px;
    position: relative;
    font-family:"Jost", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: .03em;
    color: #1E2934;
  }
  .site-header #site-navigation #primary-menu-list > li > a::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 16px;
    margin: auto 0;
    height: 15px;
    width: 9px;
    background: url('../images/icons/header-cat-arrow.svg') right center no-repeat;
  }
  .site-header #site-navigation #primary-menu-list > li > a:active {
    background-color: #FAF6EE;
  }
  /* Base theme places has-children chevrons at 20px — align all at 16px */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children > a::after,
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li.has-children > a::after {
    right: 16px;
    transform: none;
  }

  /* Account / wishlist rows with icons */
  .site-header #site-navigation #primary-menu-list > li.mobile-icon-item > a {
    font-weight: 400;
    letter-spacing: .05em;
    text-transform: uppercase;
    gap: 0 16px;
  }
  .site-header #site-navigation #primary-menu-list > li.mobile-icon-item > a img {
    width: 24px;
    height: 24px;
  }
  /* Pin the design color even when global link colors are customized */
  .site-header #site-navigation #primary-menu-list > li.mobile-icon-item > a,
  .site-header #site-navigation #primary-menu-list > li.mobile-icon-item > a span {
    color: #1E2934;
  }

  /* Secondary links block (Atsauksmes, Piegādes nosacījumi, …) */
  .site-header #site-navigation .mobile-view--bottom {
    margin-top: 16px;
    padding-top: 8px;
    border-top: 0;
  }
  .site-header #site-navigation .mobile-view--bottom .top-bar-links li a {
    padding: 8px 16px;
    font-family:"Jost", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    color: #1E2934;
  }

  /* Drill panels: level 2 (.dropdown-menu) and level 3 (.submenu) slide
     in over the previous level, below the head bar */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu,
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu {
    display: block;
    position: fixed;
    top: 56px;
    /* !important: the desktop mega-menu clamp writes an inline right/left, and
       it survives a resize across the breakpoint without a reload */
    left: 0 !important;
    right: 0 !important;
    bottom: 0;
    z-index: 40;
    width: auto;
    padding: 0 0 40px;
    border: 0;
    background: #fff;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 1;
    visibility: visible;
    transform: translateX(110%);
    transition: transform .3s ease-in-out;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu.drill-open,
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu.drill-open {
    transform: translateX(0);
  }
  /* The submenu's containing block is the (transformed) level-2 panel,
     which already sits below the head bar — so it anchors at 0, not 56 */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu {
    top: 0;
  }

  /* Back row (level 2): "‹ Atpakaļ" */
  .site-header #site-navigation .drill-back {
    display: flex;
    align-items: center;
    gap: 0 14px;
    width: 100%;
    min-height: 48px;
    margin: 0 0 4px;
    padding: 0 16px;
    border: 0;
    background: #FAF6EE;
    font-family:"Jost", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #1E2934;
    text-align: left;
    cursor: pointer;
  }
  .site-header #site-navigation .drill-back::before {
    content: '';
    flex-shrink: 0;
    height: 15px;
    width: 9px;
    background: url('../images/icons/header-cat-arrow.svg') center no-repeat;
    transform: rotate(180deg);
  }
  .site-header #site-navigation .drill-back-row {
    list-style: none;
    height: auto !important;
  }

  /* Title row (level 3): centered category name */
  .site-header #site-navigation .drill-back--titled {
    position: relative;
    justify-content: center;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
  }
  .site-header #site-navigation .drill-back--titled::before {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%) rotate(180deg);
  }

  /* Level 2 rows: category list, chevron on every row */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li > a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 44px 0 16px;
    position: relative;
    font-family:"Jost", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: .03em;
    color: #1E2934;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li > a::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 16px;
    margin: auto 0;
    height: 15px;
    width: 9px;
    background: url('../images/icons/header-cat-arrow.svg') right center no-repeat;
    transition: none;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li > a:active {
    background-color: #FAF6EE;
  }

  /* Level 3 rows: subcategories, regular case */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu li a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 16px;
    font-family:"Jost", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #1E2934;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu li a:hover,
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu li a:active {
    color: #1E2934;
    text-decoration: underline;
  }
}

/* ------------------------------------------------------------------ */
/* Mega menu badges (-20% / TOP / SEZONAS pills, set per menu item    */
/* in Appearance → Menus)                                             */
/* ------------------------------------------------------------------ */
.site-header #site-navigation .menu-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
  height: 20px;
  padding: 0 10px;
  border-radius: 99px;
  font-family:"Jost", "Helvetica Neue", Arial, sans-serif;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #fff;
}
/* Figma 293:6114: TOP is the Haki primary, SEZONAS the sage secondary.
   Written as red-family hexes so they derive with the Store Design colour. */
.site-header #site-navigation .menu-badge--red   { background-color: #986666; }
.site-header #site-navigation .menu-badge--olive { background-color: #475836; }
.site-header #site-navigation .menu-badge--green { background-color: #939c81; }

@media screen and (min-width: 1121px) {
  /* Badge sits at the right edge of the 300px column, 20px inset */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu li a.has-badge {
    display: flex;
    align-items: center;
    gap: 0 8px;
    width: 100%;
    padding-right: 20px;
  }
  /* Underline only the label on hover, never the badge */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu li a.has-badge:hover {
    text-decoration: none;
  }
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu li a.has-badge:hover .menu-item-label {
    text-decoration: underline;
  }
  /* Category column: badge sits before the chevron */
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li > a .menu-badge {
    margin-right: 0;
  }
}

@media screen and (max-width: 1120px) {
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li .submenu li a.has-badge,
  .site-header #site-navigation #primary-menu-list > li.menu-item-has-children .dropdown-menu__categories > li > a.has-badge {
    display: flex;
    align-items: center;
    gap: 0 8px;
  }
}
