/* Unified Mega Menu System (Product & Resources) */
#topNav ul li.ks-nav-mega {
  overflow: visible;
  position: relative;
}

#topNav .ks-nav-mega-trigger {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #333;
  font: inherit;
  font-weight: 400;
  line-height: inherit;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  transition: color 0.25s ease;
}

#topNav .ks-nav-mega-trigger[aria-expanded="true"],
#topNav .ks-nav-mega.s .ks-nav-mega-trigger,
#topNav .ks-nav-mega-trigger:hover {
  color: #007e7c;
}

#topNav .ks-nav-mega.s .ks-nav-mega-trigger {
  font-weight: 600;
}

#topNav .ks-nav-mega-trigger:focus-visible,
.ks-nav-mega-panel a:focus-visible {
  outline: 2px solid #00a3a1;
  outline-offset: 2px;
}

/* Mega menu container (base + popover-polyfill compatibility) */
.ks-nav-mega-panel {
  margin: 0;
  padding: 0;
  border: 0;
  background: #ffffff;
  color: #0e2233;
  line-height: 1.5;
  white-space: normal;
  text-align: start;
}

.ks-nav-mega-panel[hidden] {
  display: none;
}

@supports not selector(:popover-open) {
  .ks-nav-mega-panel[popover]:not(.\:popover-open) {
    display: none;
  }
}

/* Desktop wide mega menu layout */
@media (min-width: 1201px) {
  #topNav .ks-nav-mega-trigger::before {
    content: "";
    position: absolute;
    inset-inline: -4px;
    inset-block-end: 0;
    block-size: 3px;
    background: linear-gradient(90deg, #00a3a1, #007e7c);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.22s ease;
  }

  #topNav .ks-nav-mega-trigger[aria-expanded="true"]::before,
  #topNav .ks-nav-mega.s .ks-nav-mega-trigger::before {
    transform: scaleX(1);
  }

  .ks-nav-mega-panel[popover] {
    position: fixed;
    inset-block-start: var(--ks-mega-top, 110px);
    inset-block-end: auto;
    inset-inline: 0;
    margin-inline: auto;
    inline-size: min(95dvw, 1280px);
    max-inline-size: calc(100dvw - 24px);
    block-size: auto;
    max-block-size: calc(100dvh - var(--ks-mega-top, 110px) - 20px);
    border: 1px solid #d5e2ea;
    border-block-start: 2px solid #00a3a1;
    border-radius: 0 0 14px 14px;
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(7, 22, 36, 0.2);
    overflow: visible;
    opacity: 0;
    translate: 0 -8px;
    transition: opacity 0.2s ease, translate 0.2s ease, display 0.2s ease, overlay 0.2s ease;
    transition-behavior: allow-discrete;
  }

  .ks-nav-products-panel[popover] {
    inline-size: min(96dvw, 1380px);
  }

  /* Invisible hover bridge above the popover so pointer movement from trigger stays seamless */
  .ks-nav-mega-panel[popover]::before {
    content: "";
    position: absolute;
    inset-inline: 0;
    inset-block-end: 100%;
    block-size: 10px;
  }

  /* Also hides panel before script adds popover so there is no pre-open flash */
  .ks-nav-mega-panel:not(:is(:popover-open, .\:popover-open)) {
    display: none;
  }

  .ks-nav-mega-panel[popover]:is(:popover-open, .\:popover-open) {
    display: block;
    opacity: 1;
    translate: 0 0;
  }

  @starting-style {
    .ks-nav-mega-panel[popover]:is(:popover-open, .\:popover-open) {
      opacity: 0;
      translate: 0 -8px;
    }
  }

  /* =========================================================
     RESOURCES MEGA MENU
     ========================================================= */
  .ks-mega-inner {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
    border-radius: 0 0 14px 14px;
    overflow: hidden;
  }

  .ks-mega-feature {
    display: flex;
    flex-direction: column;
    background: #e4e9ee;
    border-inline-end: 1px solid #e3e8eb;
  }

  .ks-mega-feature-copy {
    padding: 24px 26px 20px;
    background: linear-gradient(135deg, #0e2233 0%, #143652 100%);
    color: #ffffff;
    border-block-end: 3px solid #00a3a1;
  }

  .ks-mega-feature-title {
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 8px;
    letter-spacing: 0.2px;
  }

  .ks-mega-feature-subtitle {
    font-size: 13.5px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.84);
    margin: 0;
  }

  .ks-mega-feature-media {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #e4e9ee;
    overflow: hidden;
  }

  .ks-mega-feature-media img {
    display: block;
    inline-size: 100%;
    block-size: 100%;
    max-block-size: 310px;
    object-fit: cover;
    object-position: center;
  }

  .ks-mega-col {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    padding: 32px 34px;
    background: #ffffff;
  }

  .ks-mega-col + .ks-mega-col {
    border-inline-start: 1px solid #ebf0f3;
  }

  .ks-mega-item {
    display: block;
    padding: 14px 16px;
    border-radius: 8px;
    text-decoration: none;
    transition: background-color 0.2s ease;
  }

  .ks-mega-item:hover,
  .ks-mega-item[aria-current] {
    background: #f0f8f8;
  }

  .ks-mega-item-title {
    display: block;
    font-size: 16px;
    line-height: 1.35;
    font-weight: 700;
    color: #0e2233;
    margin-block-end: 4px;
    transition: color 0.2s ease;
  }

  .ks-mega-item:hover .ks-mega-item-title,
  .ks-mega-item[aria-current] .ks-mega-item-title {
    color: #007e7c;
  }

  .ks-mega-item[aria-current] .ks-mega-item-title::after {
    content: "";
    display: inline-block;
    inline-size: 6px;
    block-size: 6px;
    margin-inline-start: 8px;
    border-radius: 50%;
    background: #007e7c;
    vertical-align: middle;
  }

  .ks-mega-item-desc {
    display: block;
    font-size: 13.5px;
    line-height: 1.55;
    color: #5b6c7a;
    font-weight: 400;
  }

  /* =========================================================
     PRODUCTS HIGH-TECH MEGA MENU
     ========================================================= */
  .ks-prod-mega-inner {
    display: grid;
    grid-template-columns: 310px minmax(0, 1.42fr) minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
    border-radius: 0 0 14px 14px;
    overflow: hidden;
    background: #ffffff;
  }

  .ks-prod-mega-feature {
    display: flex;
    flex-direction: column;
    background: #e6ebf0;
    border-inline-end: 1px solid #dce6ec;
  }

  .ks-prod-mega-feature-head {
    position: relative;
    padding: 22px 24px 18px;
    background:
      radial-gradient(circle at 92% 14%, rgba(0, 212, 208, 0.26), transparent 54%),
      linear-gradient(145deg, #071522 0%, #0d2840 62%, #0b3a4b 100%);
    color: #ffffff;
    border-block-end: 2px solid #00c4c1;
  }

  .ks-prod-mega-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    margin-block-end: 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 212, 208, 0.35);
    background: rgba(0, 212, 208, 0.12);
    color: #66f0ec;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.9px;
    text-transform: uppercase;
  }

  .ks-prod-mega-eyebrow::before {
    content: "";
    inline-size: 6px;
    block-size: 6px;
    border-radius: 50%;
    background: #00e5df;
    box-shadow: 0 0 8px #00e5df;
  }

  .ks-prod-mega-title {
    font-size: 21px;
    line-height: 1.25;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 6px;
  }

  .ks-prod-mega-subtitle {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
    margin: 0 0 14px;
  }

  .ks-prod-mega-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #00b8b5, #008b89);
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(0, 184, 181, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  }

  .ks-prod-mega-all:hover {
    color: #ffffff;
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 212, 208, 0.45);
  }

  .ks-prod-mega-media {
    flex: 1 1 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #e9eef3 0%, #dce4ec 100%);
    overflow: hidden;
  }

  .ks-prod-mega-media img {
    display: block;
    inline-size: 100%;
    block-size: 100%;
    max-block-size: 318px;
    object-fit: cover;
    object-position: center;
  }

  .ks-prod-mega-col {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 24px 22px 22px;
    background: #ffffff;
    min-width: 0;
  }

  .ks-prod-mega-col + .ks-prod-mega-col {
    border-inline-start: 1px solid #ebf0f4;
  }

  .ks-prod-group-head {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding-block-end: 14px;
    margin-block-end: 14px;
    border-block-end: 1px solid #eaf1f5;
    text-decoration: none;
  }

  .ks-prod-group-icon {
    flex: 0 0 auto;
    inline-size: 34px;
    block-size: 34px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0b2438 0%, #0f3b52 100%);
    color: #46ece8;
    border: 1px solid rgba(0, 196, 193, 0.3);
    box-shadow: 0 4px 12px rgba(11, 36, 56, 0.14);
    transition: transform 0.2s ease, border-color 0.2s ease;
  }

  .ks-prod-group-head:hover .ks-prod-group-icon {
    transform: translateY(-1px);
    border-color: #00c4c1;
  }

  .ks-prod-group-meta {
    min-width: 0;
  }

  .ks-prod-group-title {
    display: block;
    font-size: 15.5px;
    line-height: 1.3;
    font-weight: 700;
    color: #0e2233;
    transition: color 0.2s ease;
  }

  .ks-prod-group-head:hover .ks-prod-group-title {
    color: #007e7c;
  }

  .ks-prod-group-sub {
    display: block;
    font-size: 12px;
    line-height: 1.45;
    color: #556470;
    margin-block-start: 2px;
  }

  /* Column 1: Core Components 2-subcolumn compact grid */
  .ks-prod-compact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 10px;
    flex: 1 1 auto;
    align-content: start;
  }

  .ks-prod-compact-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 7px;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 500;
    color: #1f3649;
    text-decoration: none;
    transition: background-color 0.18s ease, color 0.18s ease, padding-inline-start 0.18s ease;
  }

  .ks-prod-compact-link::before {
    content: "";
    flex: 0 0 auto;
    inline-size: 5px;
    block-size: 5px;
    border-radius: 50%;
    background: #b6cbd6;
    transition: background-color 0.18s ease, box-shadow 0.18s ease;
  }

  .ks-prod-compact-link:hover,
  .ks-prod-compact-link[aria-current] {
    background: #eef8f8;
    color: #007e7c;
  }

  .ks-prod-compact-link:hover::before,
  .ks-prod-compact-link[aria-current]::before {
    background: #00a3a1;
    box-shadow: 0 0 6px rgba(0, 163, 161, 0.65);
  }

  .ks-prod-col-footer {
    margin-block-start: 12px;
    padding-block-start: 10px;
    border-block-start: 1px dashed #e2ecf1;
  }

  .ks-prod-col-more {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 700;
    color: #007e7c;
    text-decoration: none;
  }

  .ks-prod-col-more:hover {
    color: #005d5b;
  }

  /* Columns 2 & 3: Automation Modules & Integrated Solutions tech cards */
  .ks-prod-card-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 auto;
  }

  .ks-prod-tech-card {
    display: block;
    padding: 13px 14px;
    border-radius: 10px;
    border: 1px solid #e4edf2;
    border-inline-start: 3px solid #cfdce4;
    background: #f8fbfc;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  }

  .ks-prod-tech-card:hover,
  .ks-prod-tech-card[aria-current] {
    background: #eef8f8;
    border-color: #b7e3e2;
    border-inline-start-color: #00a3a1;
    transform: translateX(2px);
    box-shadow: 0 6px 16px rgba(0, 126, 124, 0.08);
  }

  .ks-prod-tech-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-block-end: 4px;
  }

  .ks-prod-tech-card-title {
    font-size: 14px;
    line-height: 1.35;
    font-weight: 700;
    color: #0e2233;
    transition: color 0.2s ease;
  }

  .ks-prod-tech-card:hover .ks-prod-tech-card-title,
  .ks-prod-tech-card[aria-current] .ks-prod-tech-card-title {
    color: #007e7c;
  }

  .ks-prod-tech-tag {
    flex: 0 0 auto;
    padding: 2px 7px;
    border-radius: 4px;
    background: #e2f3f3;
    color: #006f6d;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
  }

  .ks-prod-tech-card-desc {
    display: block;
    font-size: 12.5px;
    line-height: 1.5;
    color: #5b6c7a;
  }

  /* Custom OEM/ODM dark-tech banner card at bottom of Column 3 */
  .ks-prod-oem-cta {
    display: block;
    margin-block-start: auto;
    padding: 14px 16px;
    border-radius: 10px;
    background:
      radial-gradient(circle at 95% 15%, rgba(0, 212, 208, 0.24), transparent 55%),
      linear-gradient(135deg, #091d2f 0%, #10324d 100%);
    border: 1px solid rgba(0, 196, 193, 0.32);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  }

  .ks-prod-oem-cta:hover {
    transform: translateY(-2px);
    border-color: #00d4d0;
    box-shadow: 0 10px 24px rgba(9, 29, 47, 0.22);
  }

  .ks-prod-oem-kicker {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    color: #57ece8;
    margin-block-end: 4px;
  }

  .ks-prod-oem-title {
    display: block;
    font-size: 14px;
    line-height: 1.35;
    font-weight: 700;
    color: #ffffff;
    margin-block-end: 4px;
  }

  .ks-prod-oem-desc {
    display: block;
    font-size: 12px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.78);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ks-nav-mega-panel[popover],
  #topNav .ks-nav-mega-trigger::before,
  .ks-prod-tech-card,
  .ks-prod-oem-cta,
  .ks-prod-mega-all {
    transition: none;
  }
}

/* Narrow / mobile inline disclosure */
@media (max-width: 1200px) {
  #topNav .ks-nav-mega-trigger {
    display: flex;
    inline-size: 100%;
    justify-content: space-between;
    line-height: 48px;
  }

  .ks-nav-mega-panel {
    position: static;
    margin-block-end: 10px;
    padding: 4px 0 6px 12px;
    border-inline-start: 2px solid #dce5ea;
    background: transparent;
  }

  .ks-mega-feature,
  .ks-prod-mega-feature {
    display: none;
  }

  .ks-mega-inner,
  .ks-prod-mega-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .ks-mega-col,
  .ks-prod-mega-col,
  .ks-prod-compact-grid,
  .ks-prod-card-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .ks-prod-group-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 6px 4px;
    border-block-end: 1px solid #eef2f5;
    margin-block-end: 4px;
  }

  .ks-prod-group-icon {
    display: none;
  }

  .ks-prod-group-title {
    font-size: 14px;
    font-weight: 700;
    color: #007e7c;
  }

  .ks-prod-group-sub,
  .ks-prod-tech-tag,
  .ks-prod-col-footer {
    display: none;
  }

  .ks-mega-item,
  .ks-prod-compact-link,
  .ks-prod-tech-card,
  .ks-prod-oem-cta {
    display: block;
    padding: 7px 10px;
    border-radius: 6px;
    line-height: 1.4;
    background: transparent;
    border: 0;
  }

  .ks-mega-item:hover,
  .ks-mega-item[aria-current],
  .ks-prod-compact-link:hover,
  .ks-prod-tech-card:hover {
    background: #eef7f7;
  }

  .ks-mega-item-title,
  .ks-prod-tech-card-title,
  .ks-prod-oem-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #0e2233;
  }

  .ks-prod-compact-link {
    font-size: 13.5px;
    color: #2c4356;
  }

  .ks-mega-item[aria-current] .ks-mega-item-title,
  .ks-prod-compact-link[aria-current],
  .ks-prod-tech-card[aria-current] .ks-prod-tech-card-title {
    color: #007e7c;
  }

  .ks-mega-item-desc,
  .ks-prod-tech-card-desc,
  .ks-prod-oem-desc,
  .ks-prod-oem-kicker {
    display: block;
    font-size: 12px;
    line-height: 1.45;
    color: #556470;
    margin-block-start: 2px;
  }
}

@media (forced-colors: active) {
  #topNav .ks-nav-mega-trigger[aria-expanded="true"]::before,
  #topNav .ks-nav-mega.s .ks-nav-mega-trigger::before {
    background: Highlight;
  }
  .ks-mega-item[aria-current],
  .ks-prod-tech-card[aria-current],
  .ks-prod-compact-link[aria-current] {
    outline: 1px solid Highlight;
  }
}
