/* ============================================================
   Digital Planet — Modern Dropdown Mega-Menu Styling
   ============================================================ */

/* Dim Backdrop Veil */
.catalog-veil {
  position: fixed;
  inset: var(--catalog-top, 95px) 0 0 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 54;
  transition: opacity 0.2s ease;
}

.catalog-veil[hidden],
.mega-menu[hidden] {
  display: none !important;
}

/* Mega-Menu Container */
.mega-menu {
  position: fixed;
  top: var(--catalog-top, 95px);
  left: 50%;
  transform: translateX(-50%);
  width: min(1320px, calc(100% - 32px));
  max-height: calc(100dvh - var(--catalog-top, 95px) - 24px);
  background: #ffffff;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18), 0 4px 16px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
  border-top: none;
  z-index: 55;
  overflow: hidden;
  animation: megaMenuReveal 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes megaMenuReveal {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Catalog open locks body scroll */
body.catalog-open {
  overflow: hidden;
}

/* Desktop Grid Layout */
.mega-desktop {
  display: grid;
  grid-template-columns: 295px minmax(0, 1fr);
  min-height: 480px;
  max-height: calc(100dvh - var(--catalog-top, 95px) - 30px);
}

/* Left Roots Sidebar */
.mega-roots {
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  padding: 14px 10px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.mega-roots::-webkit-scrollbar {
  width: 5px;
}
.mega-roots::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.mega-root {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 2px;
  color: #334155;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.mega-root:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.mega-root.is-active {
  background: #eff6ff;
  color: var(--accent);
  font-weight: 750;
  box-shadow: inset 3px 0 0 var(--accent);
}

.mega-root-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  mix-blend-mode: multiply;
  flex-shrink: 0;
}

.mega-root-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mega-root-arrow {
  color: #94a3b8;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
}

.mega-root.is-active .mega-root-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

/* Right Content Area */
.mega-groups {
  padding: 24px 36px 36px;
  overflow-y: auto;
  max-height: calc(100dvh - var(--catalog-top, 95px) - 30px);
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.mega-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 22px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
  gap: 12px;
}

.mega-panel-root-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #0f172a;
  font-size: 16px;
  text-decoration: none;
  transition: color 0.15s ease;
}

.mega-panel-root-link:hover {
  color: var(--accent);
}

.mega-panel-root-link strong {
  color: var(--accent);
  font-weight: 800;
}

.mega-head-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.mega-arrow-right {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.mega-all-catalog-link {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 650;
  color: #475569;
  background: #f1f5f9;
  padding: 6px 14px;
  border-radius: 20px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.mega-all-catalog-link:hover {
  background: var(--accent);
  color: #ffffff;
}

/* Subcategory Columns Grid */
.mega-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px 32px;
}

.mega-column {
  min-width: 0;
}

.mega-group {
  margin-bottom: 22px;
  break-inside: avoid;
}

.mega-group-title {
  display: block;
  font-size: 14.5px;
  font-weight: 750;
  color: #0f172a;
  margin-bottom: 8px;
  text-decoration: none;
  letter-spacing: -0.2px;
  transition: color 0.15s ease;
}

.mega-group-title:hover {
  color: var(--accent);
}

.mega-deep {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: 2px;
}

.mega-deep a {
  font-size: 12.5px;
  color: #64748b;
  text-decoration: none;
  line-height: 1.45;
  transition: color 0.15s ease;
}

.mega-deep a:hover {
  color: var(--accent);
}

.mega-deep .mega-more {
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  margin-top: 2px;
}

.mega-no-children {
  padding: 40px 20px;
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

.mega-no-children p {
  margin-bottom: 16px;
}

/* Mobile Header & Accordion */
.mega-menu-head {
  display: none;
}

.mega-mobile {
  display: none;
}

/* Mobile & Tablet Adaptation */
@media (max-width: 960px) {
  .mega-desktop {
    grid-template-columns: 240px minmax(0, 1fr);
  }
  .mega-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
  .mega-groups {
    padding: 20px;
  }
}

@media (max-width: 768px) {
  .mega-menu {
    top: var(--catalog-top, 60px);
    left: 0;
    transform: none;
    width: 100%;
    height: calc(100dvh - var(--catalog-top, 60px));
    max-height: none;
    border-radius: 0;
    overflow-y: auto;
    animation: megaMenuMobile 0.2s ease-out;
  }

  @keyframes megaMenuMobile {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .mega-desktop {
    display: none;
  }

  .mega-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 2;
  }

  .mega-menu-head strong {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
  }

  .mega-menu-head button {
    border: 0;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: #64748b;
    padding: 4px 8px;
    cursor: pointer;
  }

  .mega-mobile {
    display: block;
    padding: 14px 20px 60px;
  }

  .mobile-tree-head {
    margin-bottom: 16px;
  }

  .full-w {
    width: 100%;
    text-align: center;
  }

  .mobile-category-branch,
  .mobile-category-link {
    border-bottom: 1px solid #f1f5f9;
  }

  .mobile-category-branch summary,
  .mobile-category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    font-size: 14px;
    font-weight: 650;
    color: #1e293b;
    cursor: pointer;
    list-style: none;
    text-decoration: none;
  }

  .mobile-category-branch summary::-webkit-details-marker {
    display: none;
  }

  .mobile-chevron {
    font-size: 18px;
    color: #94a3b8;
    transition: transform 0.2s ease;
  }

  .mobile-cat-info {
    display: inline-flex;
    align-items: center;
    gap: 10px;
  }

  .mobile-root-icon {
    width: 26px;
    height: 26px;
    object-fit: contain;
    mix-blend-mode: multiply;
    flex-shrink: 0;
    border-radius: 4px;
  }

  .mobile-category-branch[open] > summary .mobile-chevron {
    transform: rotate(180deg);
    color: var(--accent);
  }

  .mobile-category-children {
    padding-left: 14px;
    border-left: 2px solid #dbeafe;
    margin: 4px 0 12px 6px;
  }

  .mobile-category-all {
    display: block;
    padding: 8px 0;
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
  }

  .mobile-arr {
    color: #94a3b8;
    font-size: 16px;
  }
}
