/**
 * Mega menu: panel shell + backdrop + the four layout grids
 * (Products / Services / Resources / Blog) + shared promo card.
 *
 * Desktop (>1024px): panels are `position: fixed`, centered on the
 * viewport, `top` driven by --mega-top (set by assets/js/mega-menu.js from
 * the header's own bottom edge, so it tracks the sticky header's collapsed
 * state without any layout thrash). Visibility is class-driven
 * (`.mega_open` on the trigger <li>, added by JS) with a plain :hover /
 * :focus-within fallback so the panel still works with JS disabled.
 *
 * ≤1024px: folded back into the existing mobile drawer flow — see the
 * breakpoint block near the bottom, which mirrors assets/css/public.css's
 * own `header nav .sub-menu` mobile rules.
 *
 * Sizing is tuned ~15% larger than the original px scale so the panel
 * reads at a comfortable size at 100% browser zoom (matching how it
 * looked at +15% zoom before).
 */

header nav .menu>li.has_mega {
  position: relative;
}
header nav .menu>li.has_mega>a {
  display: flex;
  align-items: center;
  gap: 4px;
}
header nav .menu>li.has_mega>a::after {
  content: '';
  position: relative;
  right: -3px;
  width: 9px;
  height: 6px;
  flex-shrink: 0;
  background: url(../img/icon-select.svg) no-repeat center / contain;
  transition: transform 0.25s ease;
  opacity: 0.7;
}
header nav .menu>li.has_mega.mega_open>a::after,
header nav .menu>li.has_mega:hover>a::after {
  transform: rotate(180deg);
}

/* Hover bridge. `header .main .grid`'s last row is 76px tall (set by
   `header .rt`) while a menu link is only ~49px, so `align-items: center`
   leaves ~14px of header below the link before the panel's top edge — a
   dead zone that dropped :hover mid-travel and snapped the panel shut.
   This invisible band spans exactly that gap (height measured in
   mega-menu.js as --mega-bridge, so it stays correct in every collapsed
   header state) and is only interactive while the panel is actually open,
   so it can never swallow clicks on the header when closed. */
header nav .menu>li.has_mega>a::before {
  content: '';
  position: absolute;
  top: 100%;
  left: -18px;
  right: -18px;
  height: var(--mega-bridge, 16px);
  pointer-events: none;
}
header nav .menu>li.has_mega:hover>a::before,
header nav .menu>li.has_mega:focus-within>a::before,
header nav .menu>li.has_mega.mega_open>a::before {
  pointer-events: auto;
}

.mega_backdrop {
  position: fixed;
  inset: 0;
  z-index: 995;
  background: rgba(10, 14, 16, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.mega_backdrop.is-active {
  opacity: 1;
}

.mega_panel {
  position: fixed;
  left: 50%;
  top: var(--mega-top, 150px);
  z-index: 997;
  width: min(1380px, calc(100vw - 40px));
  max-height: calc(100vh - var(--mega-top, 150px) - 20px);
  overflow: auto;
  transform: translate(-50%, -8px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  background-color: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(10, 20, 20, 0.16), 0 4px 10px rgba(10, 20, 20, 0.08);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  /* Everything in here is sized in px rather than rem on purpose, matching
     the header's own `font-size: 18px` nav links: html's
     `font-size: clamp(7.5px, 0.520834vw, 10px)` drops 1rem to 7.5px below
     ~1920px, which shrank the whole panel to ~75% on a 1440px screen. This
     base size covers anything that inherits instead. */
  font-size: 16px;
}
header nav .menu>li.has_mega:hover>.mega_panel,
header nav .menu>li.has_mega:focus-within>.mega_panel,
header nav .menu>li.has_mega.mega_open>.mega_panel {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translate(-50%, 0);
}
.mega_panel.is-morphing {
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s, width 0.32s cubic-bezier(0.4, 0, 0.2, 1), height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.mega_inner {
  padding: 36px 36px 32px;
}

/* Shared bits reused across layouts ------------------------------------ */

.mega_eyebrow {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 7px;
}
.mega_viewall {
  display: flex !important;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--secondary);
  margin-top: 12px;
}
.mega_viewall::after {
  content: '';
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}
.mega_viewall:hover::after {
  transform: rotate(-45deg) translate(2px, -2px);
}

.mega_promos {
  grid-column: 1 / -1;
  display: flex;
  gap: 14px;
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.mega_promo {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  background-color: var(--bg);
  transition: background-color 0.2s ease, transform 0.2s ease;
}
.mega_promo:hover {
  background-color: #eef4f3;
  transform: translateY(-2px);
}
.mega_promo .img {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 9px;
  background: no-repeat center / cover, var(--secondary);
}
.mega_promo .body {
  min-width: 0;
}
.mega_promo .eyebrow {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
}
.mega_promo .title {
  display: block;
  font-size: 17px;
  font-weight: 600;
  color: var(--title);
  line-height: 1.3;
}
.mega_promo .text {
  display: block;
  font-size: 15px;
  color: var(--text);
  margin-top: 2px;
}
.mega_promo .link {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--secondary);
  margin-top: 5px;
}


/* ==================== Products: two-pane catalog browser ============== */

.mega_panel[data-layout="products"] {
  width: min(1400px, calc(100vw - 40px));
}

.mega_products {
  display: grid;
  grid-template-columns: 288px 1fr;
  grid-template-areas: "rail stage" "popular popular";
  gap: 0;
}
.mega_products_rail {
  grid-area: rail;
  border-right: 1px solid var(--border);
  padding-right: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 390px;
  overflow: auto;
}
.mega_rail_item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 17px;
  font-weight: 600;
  color: var(--title);
  transition: background-color 0.18s ease, color 0.18s ease;
}
.mega_rail_item .count {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  flex-shrink: 0;
}
.mega_rail_item:hover,
.mega_rail_item:focus-visible,
.mega_rail_item.is-active {
  background-color: var(--bg);
  color: var(--primary);
}
.mega_rail_item.is-active {
  background-color: #fdf1e6;
}

.mega_products_stage {
  grid-area: stage;
  padding-left: 32px;
  position: relative;
  min-height: 230px;
}
.mega_stage_pane {
  display: none;
  animation: mega_fade 0.2s ease;
}
.mega_stage_pane.is-active {
  display: block;
}
.mega_stage_grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px 18px;
}
.mega_stage_card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  color: var(--text);
  transition: color 0.18s ease, padding-left 0.18s ease;
}
.mega_stage_card:hover {
  color: var(--primary);
  padding-left: 5px;
}
.mega_stage_card .count {
  font-size: 13px;
  color: var(--text);
  opacity: 0.7;
  flex-shrink: 0;
}

.mega_products_popular {
  grid-area: popular;
  margin-top: 28px;
  padding-top: 23px;
  border-top: 1px solid var(--border);
}
.mega_popular_label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 14px;
}
.mega_popular_strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.mega_popular_item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px;
  border-radius: 12px;
  transition: background-color 0.18s ease;
}
.mega_popular_item:hover {
  background-color: var(--bg);
}
.mega_popular_item .icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 8px;
  background-color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.mega_popular_item .icon img {
  width: 70%;
  height: 70%;
  object-fit: contain;
}
.mega_popular_item .body {
  min-width: 0;
}
.mega_popular_item .title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--title);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mega_popular_item .price {
  display: block;
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
}


/* ==================== Services: numbered workflow columns ============= */

.mega_panel[data-layout="services"] {
  width: min(1240px, calc(100vw - 40px));
}

.mega_services_columns {
  display: flex;
  gap: 28px;
}
.mega_service_col {
  flex: 1;
  min-width: 0;
  position: relative;
  padding-top: 5px;
}
.mega_service_num {
  position: absolute;
  top: -0.6rem;
  right: 0;
  font-size: 37px;
  font-weight: 700;
  color: var(--bg);
  line-height: 1;
  z-index: 0;
}
.mega_service_icon {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background-color: #fdf1e6;
  color: var(--primary);
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}
.mega_service_icon svg {
  width: 24px;
  height: 24px;
}
.mega_service_title {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--title);
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}
.mega_service_title:hover {
  color: var(--primary);
}
.mega_service_links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mega_service_links a {
  font-size: 15.5px;
  color: var(--text);
  transition: color 0.18s ease, padding-left 0.18s ease;
  display: inline-block;
}
.mega_service_links a:hover {
  color: var(--primary);
  padding-left: 3px;
}

.mega_services_cta {
  margin-top: 30px;
  padding: 21px 25px;
  border-radius: 14px;
  background: linear-gradient(120deg, var(--secondary), #0e6f64);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}
.mega_cta_text strong {
  display: block;
  font-size: 18px;
  margin-bottom: 3px;
}
.mega_cta_text p {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
}
.mega_cta_stats {
  display: flex;
  gap: 23px;
  flex-shrink: 0;
}
.mega_cta_stats span {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
}
.mega_cta_stats strong {
  font-size: 23px;
  color: #fff;
}
.mega_cta_btn {
  margin-left: auto;
  flex-shrink: 0;
  background-color: #fff;
  color: var(--secondary);
  padding: 13px 23px;
  border: none;
  border-radius: 9px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease;
}
.mega_cta_btn:hover {
  transform: translateY(-2px);
}


/* ==================== Resources: asymmetric bento mosaic =============== */

.mega_panel[data-layout="resources"] {
  width: min(1265px, calc(100vw - 40px));
}

.mega_resources {
  display: grid;
  grid-template-columns: 276px 1fr 253px;
  gap: 28px;
  align-items: start;
}

.mega_resource_feature {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  border-radius: 14px;
  overflow: hidden;
  background-color: var(--bg);
  min-height: 322px;
  padding: 0;
}
.mega_resource_feature .img {
  height: 150px;
  background: no-repeat center / cover, linear-gradient(135deg, var(--secondary), #0b6058);
}
.mega_resource_feature .body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.mega_resource_feature .badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--primary);
  background-color: #fdf1e6;
  padding: 3px 9px;
  border-radius: 6px;
  margin-bottom: 9px;
}
.mega_resource_feature .title {
  font-size: 18px;
  font-weight: 700;
  color: var(--title);
  line-height: 1.35;
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mega_resource_feature .excerpt {
  font-size: 15px;
  color: var(--text);
  margin-top: 7px;
  flex: 1;
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mega_resource_feature .format {
  font-size: 14px;
  color: var(--secondary);
  font-weight: 600;
  margin-top: 14px;
}
.mega_resource_feature:hover .title {
  color: var(--primary);
}

.mega_resource_tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 14px;
}
.mega_resource_tile {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 18px;
  border-radius: 13px;
  border: 1px solid var(--border);
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.mega_resource_tile:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.mega_resource_tile .icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background-color: var(--bg);
  color: var(--secondary);
}
.mega_resource_tile .icon svg {
  width: 22px;
  height: 22px;
}
.mega_resource_tile .title {
  font-size: 16px;
  font-weight: 700;
  color: var(--title);
}
.mega_resource_tile .count {
  font-size: 13px;
  color: var(--text);
}

.mega_resource_latest {
  border-left: 1px solid var(--border);
  padding-left: 25px;
}
.mega_latest_label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 14px;
}
.mega_resource_latest ul {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mega_resource_latest a,
.mega_resource_latest button {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  font-size: 15.5px;
  color: var(--title);
  line-height: 1.4;
  transition: color 0.18s ease;
}
.mega_resource_latest a:hover,
.mega_resource_latest button:hover {
  color: var(--primary);
}


/* ==================== Blog: magazine spread ============================ */

.mega_panel[data-layout="blog"] {
  width: min(1310px, calc(100vw - 40px));
}

.mega_blog {
  display: grid;
  grid-template-columns: 1fr 1fr 253px;
  gap: 28px;
}

.mega_blog_hero {
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  background-color: var(--bg);
}
.mega_blog_hero .img {
  height: 172px;
  background: no-repeat center / cover, linear-gradient(135deg, #edad4b, #0b6058);
}
.mega_blog_hero .body {
  padding: 18px;
}
.mega_blog_hero .cat {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 7px;
}
.mega_blog_hero .title {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--title);
  line-height: 1.35;
}
.mega_blog_hero:hover .title {
  color: var(--primary);
}
.mega_blog_hero .excerpt {
  display: block;
  font-size: 15px;
  color: var(--text);
  margin-top: 7px;
}
.mega_blog_hero .date {
  display: block;
  font-size: 13px;
  color: var(--text);
  opacity: 0.7;
  margin-top: 12px;
}

.mega_blog_stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mega_blog_card {
  display: flex;
  gap: 14px;
  align-items: center;
}
.mega_blog_card .img {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 10px;
  background: no-repeat center / cover, var(--bg);
}
.mega_blog_card .meta {
  display: flex;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text);
  margin-bottom: 3px;
}
.mega_blog_card .meta .cat {
  color: var(--primary);
  font-weight: 700;
}
.mega_blog_card .title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--title);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.mega_blog_card:hover .title {
  color: var(--primary);
}

.mega_blog_categories {
  border-left: 1px solid var(--border);
  padding-left: 25px;
}
.mega_cat_label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 14px;
}
.mega_blog_categories ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mega_blog_categories a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  font-size: 15.5px;
  color: var(--title);
  transition: color 0.18s ease;
}
.mega_blog_categories a .count {
  font-size: 12.5px;
  color: var(--text);
  opacity: 0.7;
}
.mega_blog_categories a:hover {
  color: var(--primary);
}

@keyframes mega_fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ==================== ≤1024px: fold into the mobile drawer ============= */

@media screen and (max-width: 1024px) {
  .mega_backdrop {
    display: none;
  }
  header nav .menu>li.has_mega>a::after,
  header nav .menu>li.has_mega>a::before {
    display: none;
  }
  /* Mirrors public.css's `.menu-item-has-children::before/::after` chevron
     so a "childless" mega item (a layout assigned with no real nav
     children) still gets the same collapse affordance on mobile. */
  header nav .menu>li.has_mega {
    position: relative;
  }
  header nav .menu>li.has_mega>a {
    margin-right: 46px;
  }
  header nav .menu>li.has_mega::before,
  header nav .menu>li.has_mega::after {
    content: '';
    display: block;
    position: absolute;
    top: 5px;
    right: 0;
    width: 36px;
    height: 36px;
    transition: all 0.3s;
    border-radius: var(--radius);
  }
  header nav .menu>li.has_mega::after {
    background: url(../img/icon-select.svg) no-repeat center / 10px 6px;
  }
  header nav .menu>li.has_mega.active::before {
    background-color: rgba(0, 0, 0, 0.05);
  }
  header nav .menu>li.has_mega.active::after {
    transform: rotate(180deg);
  }
  .mega_panel {
    position: static;
    display: none;
    width: auto;
    max-height: none;
    overflow: visible;
    top: auto;
    left: auto;
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    margin: 12px 0;
    padding: 0;
    border-radius: var(--radius);
    box-shadow: none;
    background-color: rgba(0, 0, 0, 0.02);
    transition: none;
    font-size: 14px;
  }
  header nav .menu>li.has_mega:hover>.mega_panel,
  header nav .menu>li.has_mega:focus-within>.mega_panel,
  header nav .menu>li.has_mega.mega_open>.mega_panel {
    transform: none;
  }
  .mega_inner {
    padding: 10px;
  }
  .mega_products,
  .mega_services_columns,
  .mega_resources,
  .mega_blog {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  .mega_products_rail {
    border-right: none;
    padding-right: 0;
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
    gap: 6px;
  }
  .mega_rail_item {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .mega_products_stage {
    padding-left: 0;
  }
  .mega_stage_grid {
    grid-template-columns: 1fr;
  }
  .mega_popular_strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .mega_resource_tiles {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
  .mega_resource_latest,
  .mega_blog_categories {
    border-left: none;
    padding-left: 0;
  }
  .mega_blog_hero .img {
    height: 120px;
  }
  .mega_services_cta {
    flex-direction: column;
    align-items: flex-start;
  }
  .mega_cta_btn {
    margin-left: 0;
  }
  .mega_promos {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mega_panel,
  .mega_backdrop,
  .mega_stage_pane,
  header nav .menu>li.has_mega>a::after {
    transition: none !important;
    animation: none !important;
  }
}