/* === Mega menu system ============================================ */
@media (min-width: 992px) {
  /* Nav wrapper is the vertical positioning context */
  .nav-bar .navbar {
    position: relative;
  }

  /* Top-level mega menu items */
  .navbar-nav > li.mega-menu {
    position: static;
  }

  /* Hide any normal sub-menu for mega items on desktop */
  .navbar-nav > li.mega-menu > .sub-menu {
    display: none !important;
  }

  /* FULL-VIEWPORT-WIDTH PANEL */
  .navbar-nav > li.mega-menu .mega-panel {
    position: absolute;
    top: 100%;

    /* full browser width, centered under nav */
    left: 50%;
    right: auto;
    width: 100vw;
    max-width: 100vw;
    transform: translateX(-50%);

    z-index: 9999;

    background-color: #ffffff;
    border-top: 1px solid #c6c6c6;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);

    /* outer padding around the inner container */
    padding: 30px 0;
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%) translateY(10px);
    transition:
      opacity 360ms ease,
      transform 360ms ease,
      visibility 0ms linear 360ms;
  }

  /* Show panel on hover */
  .navbar-nav > li.mega-menu:hover .mega-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
    transition-delay: 0ms, 0ms, 0ms;
  }

  /* INNER CONTENT CONTAINER: 1170px max width, 3-column grid by default */
  .navbar-nav > li.mega-menu .mega-panel-inner {
    max-width: 1170px;
    margin: 0 auto;
    padding: 0 40px;
    box-sizing: border-box;

    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-column-gap: 30px;
    grid-row-gap: 10px;
  }

  /* Categories panel can be single-column if you prefer */
  .navbar-nav > li.mega-menu .mega-panel-inner--cats {
    grid-template-columns: 1fr;
  }

  /* In the Categories mega menu, lay out the three sections in 3 columns */
  .navbar-nav > li.mega-menu .mega-panel-inner--cats .mega-col-cats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-column-gap: 30px;
    grid-row-gap: 0;
  }

  .navbar-nav > li.mega-menu .mega-panel-inner--cats .mega-cats-section {
    /* each section becomes one column cell */
    margin: 0;
  }

  /* Slight spacing tweaks inside each section if desired */
  .navbar-nav
    > li.mega-menu
    .mega-panel-inner--cats
    .mega-cats-section--colour
    .mega-col-links--colour {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 20px;
  }

  .navbar-nav
    > li.mega-menu
    .mega-panel-inner--cats
    .mega-cats-section--colour
    .mega-col-links--colour
    li {
    margin-bottom: 4px;
  }

  /* Generic column styles */
  .navbar-nav > li.mega-menu .mega-col {
    margin: 0;
    padding: 0;
  }

  .navbar-nav > li.mega-menu .mega-col-heading {
    margin: 0 0 10px;
    font-weight: 600;
    font-size: 14px;
    text-transform: capitalize;
    letter-spacing: 0.04em;
    color: #646569;
  }

  .navbar-nav > li.mega-menu .mega-col-links {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .navbar-nav > li.mega-menu .mega-col-links li {
    margin-bottom: 6px;
  }
  .navbar-nav > li.mega-menu .mega-col-links li a {
    font-size: 14px;
    color: #646569;
  }

  .navbar-nav > li.mega-menu .mega-col-links li a:hover {
    color: #63809e;
    background: transparent;
  }

  /* Help, Inspiration & Floor Samples: image on top, text row beneath */
  .navbar-nav > li.mega-menu .mega-col-help-item a,
  .navbar-nav > li.mega-menu .mega-col-inspiration-item a,
  .navbar-nav > li.mega-menu .mega-floor-samples-tile a {
    display: block;
    padding: 14px 0;
    border-bottom: 1px solid #dddcdb;
    color: #646569;
    text-decoration: none;
    position: relative;
  }

  /*sub menu for categories*/

  .mega-col-links {
    padding: 7px 0;
  }

  .mega-col-links li {
    margin-bottom: 0px !important;
  }

  /* Image spans the full tile width */
  .navbar-nav > li.mega-menu .mega-col-help-item .mega-link-image,
  .navbar-nav > li.mega-menu .mega-col-inspiration-item .mega-link-image,
  .navbar-nav > li.mega-menu .mega-floor-samples-tile .mega-link-image {
    display: block;
    width: 100%;
    margin-bottom: 8px;
  }

  .navbar-nav > li.mega-menu .mega-col-help-item .mega-link-image img,
  .navbar-nav > li.mega-menu .mega-col-inspiration-item .mega-link-image img,
  .navbar-nav > li.mega-menu .mega-floor-samples-tile .mega-link-image img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 3px;
  }

  /* Text row sits under the image */
  .navbar-nav > li.mega-menu .mega-col-help-item .mega-link-text,
  .navbar-nav > li.mega-menu .mega-col-inspiration-item .mega-link-text,
  .navbar-nav > li.mega-menu .mega-floor-samples-tile .mega-link-text {
    display: block;
    font-size: 14px;
    color: #646569;
    padding-right: 34px; /* space for arrow on the right */
    position: relative; /* arrow positioned relative to this */
    line-height: 1.4;
  }

  /* Arrow aligned with title row for these tiles */
  .navbar-nav > li.mega-menu .mega-col-help-item .mega-link-text::after,
  .navbar-nav > li.mega-menu .mega-col-inspiration-item .mega-link-text::after,
  .navbar-nav > li.mega-menu .mega-floor-samples-tile .mega-link-text::after {
    content: "›";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 22px;
    color: #a4a3a2;
  }

  /* "More" mega menu: 3 columns, items 1–3 / 4–6 / 7–9 top to bottom */
  .navbar-nav > li.mega-menu .mega-panel-inner--more {
    max-width: 1170px;
    margin: 0 auto;
    padding: 0 40px;
    box-sizing: border-box;

    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, auto);
    column-gap: 30px;
    row-gap: 12px;
  }

  .navbar-nav > li.mega-menu .mega-panel-more .mega-more-item {
    box-sizing: border-box;
  }

  .navbar-nav > li.mega-menu .mega-panel-more .mega-more-item a {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .navbar-nav > li.mega-menu .mega-panel-more .mega-more-item--empty {
    visibility: hidden;
    pointer-events: none;
  }

  /* --- Generic row style for ALL other mega links ---------------- */

  /* Base style: block row with arrow on the right, extra padding */
  .navbar-nav > li.mega-menu .mega-panel a {
    display: block;
    position: relative;
    padding: 10px 0; /* more padding for each link */
    border-bottom: 1px solid #dddcdb;
    color: #646569;
    text-decoration: none;
  }

  .navbar-nav > li.mega-menu .mega-panel a::after {
    content: "›";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 22px;
    color: #a4a3a2;
  }

  .navbar-nav > li.mega-menu .mega-panel a:hover {
    color: #63809e;
    background: transparent;
  }

  /* Remove the generic arrow on Help/Inspiration/Floor Samples <a> so we only use the
     title-based arrow above (aligned to .mega-link-text) */
  .navbar-nav > li.mega-menu .mega-col-help-item a::after,
  .navbar-nav > li.mega-menu .mega-col-inspiration-item a::after,
  .navbar-nav > li.mega-menu .mega-floor-samples-tile a::after {
    content: none;
  }

  /* Child / secondary links: no arrow, no bottom border.
     Add class="mega-link--child" on the <a> in PHP where needed. */
  .navbar-nav > li.mega-menu .mega-panel a.mega-link--child {
    border-bottom: none;
  }

  .navbar-nav > li.mega-menu .mega-panel a.mega-link--child::after {
    content: none;
  }

  /* Splashbacks shares mega-menu / mega-menu-* with Vinyl Flooring so the
     mobile chevron is the same rule. It has no desktop mega panel — keep
     the native Kitchen splashbacks / Pattern Pieces list. */
  .navbar-nav > li.mega-menu.mega-menu-splashbacks {
    position: relative;
  }

  .navbar-nav > li.mega-menu.mega-menu-splashbacks > .sub-menu {
    display: none;
    width: max-content;
    min-width: max-content;
  }

  .navbar-nav > li.mega-menu.mega-menu-splashbacks > .sub-menu > li > a {
    white-space: nowrap;
  }

  .navbar-nav > li.mega-menu.mega-menu-splashbacks:hover > .sub-menu,
  .navbar-nav > li.mega-menu.mega-menu-splashbacks:focus-within > .sub-menu {
    display: block !important;
  }
}

/* Mobile & tablet: hide desktop mega flyout; full-width drawer + drill-down */
@media (max-width: 991px) {
  .nav-bar .container,
  .nav-bar .row {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .navbar-nav > li.mega-menu .mega-panel {
    display: none !important;
  }

  /* Mobile drawer owns navigation; disable native WP child dropdowns */
  .nav-bar .navbar .navbar-nav > li.menu-item-has-children > .sub-menu,
  .nav-bar .navbar .navbar-nav > li.menu-item-has-children:hover > .sub-menu,
  .nav-bar
    .navbar
    .navbar-nav
    > li.menu-item-has-children:focus-within
    > .sub-menu,
  .nav-bar .navbar .navbar-nav > li.menu-item-has-children:active > .sub-menu {
    display: none !important;
  }

  .nav-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.25s ease,
      visibility 0.25s;
  }

  .nav-drawer-overlay.is-visible {
    opacity: 1;
    visibility: visible;
  }

  body.nav-drawer-open {
    overflow: hidden;
  }

  /* Full-width drawer (overrides legacy 256px in style.css) */
  .nav-bar .navbar {
    width: 100%;
    max-width: 100%;
    left: 0;
    right: 0;
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
    border-right: none;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  }

  .nav-bar .navbar .toggle-button-close {
    float: none;
    display: block;
    margin-left: auto;
    margin-right: 0;
  }

  .mobile-drilldown {
    display: none;
    margin: 0;
    padding: 0 0 24px;
    --drill-n: 1;
  }

  .navbar.show-mobile-drill
    .navbar-nav
    > li.mobile-drill-active
    .mobile-drilldown {
    display: block;
  }

  .navbar.show-mobile-drill .navbar-nav > li:not(.mobile-drill-active) {
    display: none !important;
  }

  .navbar.show-mobile-drill .navbar-nav > li.mobile-drill-active {
    border-bottom: none;
    width: 100%;
  }

  .navbar.show-mobile-drill .navbar-nav > li.mobile-drill-active > a {
    display: none;
  }

  .mobile-drilldown__view {
    overflow-x: hidden;
    overflow-y: visible;
    width: 100%;
  }

  .mobile-drilldown__track {
    display: flex;
    align-items: flex-start;
    width: calc(var(--drill-n, 1) * 100%);
    transition: transform 0.28s ease;
    will-change: transform;
  }

  .mobile-drilldown__pane {
    flex: 0 0 calc(100% / var(--drill-n, 1));
    box-sizing: border-box;
    padding: 0 16px 16px;
    min-height: 120px;
    overflow: visible;
  }

  .mobile-drilldown--pages .mobile-drilldown__pane {
    max-height: none;
  }

  .mobile-drilldown__title {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.04em;
    color: #646569;
  }

  .mobile-drilldown__back {
    display: block;
    width: 100%;
    margin: 0 0 16px;
    padding: 12px 0;
    border: none;
    border-bottom: 1px solid #dddcdb;
    background: transparent;
    text-align: left;
    font-size: 15px;
    color: #63809e;
    cursor: pointer;
  }

  .mobile-drilldown__list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .mobile-drilldown__list li {
    margin: 0;
    border-bottom: 1px solid #dddcdb;
  }

  .mobile-drilldown__list a,
  .mobile-drilldown__next {
    display: block;
    width: 100%;
    padding: 16px 40px 16px 0;
    font-size: 15px;
    color: #646569;
    text-decoration: none;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
    font-family: inherit;
    text-transform: capitalize;
  }

  .navbar-nav > li.menu-item-has-children > a::after,
  .navbar-nav > li.mega-menu > a::after,
  .navbar-nav > li[class*="mega-menu-"] > a::after,
  .mobile-drilldown__next::after,
  .mobile-drilldown__list li.menu-item-has-children > a[href]::after {
    content: "›";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    color: #a4a3a2;
  }

  /* Splashbacks mobile: hide the native boxed .sub-menu so the existing
     drilldown (Kitchen splashbacks / Pattern Pieces) matches Flooring. */
  .navbar-nav > li.mega-menu-splashbacks > .sub-menu {
    display: none !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* style.css .term-splashbacks #menu-item-895 (line 492) paints this
     parent #e6e7e8 on the Kitchen Splashbacks archive. The drilldown then
     sits in a grey panel, and .navbar li { background:#fff } (line 2886)
     reads as white card rows. Neutralize current/ancestor/parent states
     so the pane matches Flooring on every route. Desktop is 992px+. */
  .term-splashbacks #menu-item-895,
  .navbar-nav > li.mega-menu-splashbacks.current-menu-item,
  .navbar-nav > li.mega-menu-splashbacks.current-menu-parent,
  .navbar-nav > li.mega-menu-splashbacks.current-menu-ancestor,
  .navbar.show-mobile-drill
    .navbar-nav
    > li.mega-menu-splashbacks.mobile-drill-active {
    background: transparent;
  }

  .navbar-nav > li.mega-menu-splashbacks .mobile-drilldown__list li {
    background: transparent;
  }

  .mobile-drilldown__list a:hover,
  .mobile-drilldown__next:hover {
    color: #63809e;
  }
}

@media (min-width: 992px) {
  .mobile-drilldown,
  .nav-drawer-overlay {
    display: none !important;
  }
}

@media (min-width: 576px) and (max-width: 671px) {
  .nav-bar .navbar {
    padding-left: 16px !important;
    padding-right: 16px !important;
    overflow-x: hidden;
  }

  .nav-bar .navbar .toggle-button-close {
    margin-right: 2px !important;
    position: relative;
    z-index: 2;
  }

  .nav-bar .navbar .navbar-nav > li > a,
  .mobile-drilldown__list a,
  .mobile-drilldown__next {
    padding-right: 48px !important;
  }

  .navbar-nav > li.menu-item-has-children > a::after,
  .navbar-nav > li.mega-menu > a::after,
  .navbar-nav > li[class*="mega-menu-"] > a::after,
  .mobile-drilldown__next::after,
  .mobile-drilldown__list li.menu-item-has-children > a[href]::after {
    right: 14px !important;
  }
}

/* Sentence-case Splashbacks child label (menu item 26239: Kitchen splashbacks). */
.navbar-nav .sub-menu > li.menu-item-26239 > a,
.mobile-drilldown#ftfam-drill-895-native .mobile-drilldown__list a[href*="/product-category/splashbacks/"] {
  text-transform: none;
}

@media (min-width: 992px) {
  .navbar-nav .sub-menu > li.menu-item-26239 > a {
    white-space: nowrap;
  }
}
