/*
 * Tooline Direct — Glass Tower child theme
 *
 * Scoping rules:
 *   .category-id-84 .*   → Hot Buys page only
 *   .td-scope .*         → only content wrapped in <div class="td-scope"> (editor content)
 *   body .*              → site-wide (used sparingly, currently only for the mega-menu fix)
 *
 * Sections:
 *   1. Editor-scoped content styles (.td-scope) — Hot Buys page
 *   2. Hot Buys page layout (sidebar, hero, description, sort bar)
 *   3. Site-wide header mega-menu fix
 */


/* =========================================================================
   1. Content-editor scoped rules (Hot Buys page description block)
   ========================================================================= */

.category-id-84 .td-scope h1,
.category-id-84 .td-scope h2,
.category-id-84 .td-scope h3,
.category-id-84 .td-scope p {
  padding-top: 10px;
  padding-bottom: 10px;
}

.category-id-84 .td-scope a {
  padding-top: 10px;
  padding-bottom: 10px;
  color: #551a8b;
  text-decoration: none;
}

.category-id-84 .td-scope a:visited {
  color: #551a8b;
}

.category-id-84 .td-scope a:hover,
.category-id-84 .td-scope a:focus {
  color: #3b1160;
  text-decoration: underline;
}

/* Flex grid for image rows — 3 across, square, scales to container width */
.category-id-84 .td-scope .td-image-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin: 1.25rem 0;
}

.category-id-84 .td-scope .td-image-row img {
  flex: 1 1 0;
  width: 100%;
  max-width: calc((100% - 2rem) / 3);
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: contain;
  max-height: none;
}

.category-id-84 .td-scope .td-image-row.td-image-row-2 img {
  max-width: calc((100% - 2rem) / 3);
}


/* =========================================================================
   2. Hot Buys page layout
   ========================================================================= */

/* Hide the left sidebar entirely on this page */
.category-id-84 #left-column {
  display: none !important;
}

/* Promote the content wrapper to full width now that the sidebar is gone */
.category-id-84 #content-wrapper {
  flex: 0 0 100%;
  max-width: 100%;
  width: 100%;
}

.category-id-84 #content-wrapper.col-md-9,
.category-id-84 #content-wrapper.col-sm-8 {
  flex: 0 0 100%;
  max-width: 100%;
}

.category-id-84 #wrapper {
  padding-top: 1rem;
}

/* Hide the auto-generated H1 — the .td-scope block already carries the intro headline */
.category-id-84 .block-category > .h1 {
  display: none;
}

/* Tidy the wrapping card so it doesn't look like a floating panel */
.category-id-84 .block-category.card.card-block {
  border: none;
  background: transparent;
  padding: 0;
  margin-bottom: 2rem;
  box-shadow: none;
}

.category-id-84 .block-category-inner {
  padding: 0;
}

/* The theme adds .text-muted to the description container — restore full-strength body text */
.category-id-84 #category-description.text-muted {
  color: #222;
}

.category-id-84 #category-description .td-scope p {
  color: #222;
  line-height: 1.6;
  font-size: 1rem;
}

.category-id-84 #category-description .td-scope h1 {
  font-size: 2.25rem;
  line-height: 1.15;
  color: #1a1a1a;
  margin: 0 0 0.5rem;
}

.category-id-84 #category-description .td-scope h2 {
  font-size: 1.5rem;
  color: #1a1a1a;
  margin: 1.5rem 0 0.5rem;
}

.category-id-84 #category-description .td-scope h3 {
  font-size: 1.15rem;
  color: #333;
  font-weight: 600;
  margin: 0.75rem 0;
}

/* Sort / count bar above the product grid */
.category-id-84 #js-product-list-top.products-selection {
  align-items: center;
  padding: 0.75rem 0;
  margin: 0 0 1.25rem;
  border-top: 1px solid #e5e5e5;
  border-bottom: 1px solid #e5e5e5;
}

.category-id-84 #js-product-list-top .total-products p {
  margin: 0;
  color: #666;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.category-id-84 #js-product-list-top .sort-by {
  color: #666;
  font-size: 0.9rem;
  align-self: center;
  padding-top: 0.35rem;
}

/* Pagination / "Showing X of Y" strip */
.category-id-84 .pagination {
  margin: 1.5rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid #e5e5e5;
  color: #666;
  font-size: 0.9rem;
}

/* Mobile tweaks */
@media (max-width: 767px) {
  .category-id-84 .td-scope .td-image-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .category-id-84 .td-scope .td-image-row img {
    max-width: calc((100% - 1rem) / 2);
  }
  .category-id-84 #category-description .td-scope h1 {
    font-size: 1.65rem;
  }
}


/* =========================================================================
   3. Site-wide header mega-menu fix
   -------------------------------------------------------------------------
   Problem: the Metabo (and Tooline) mega-menus render second-level submenus
   inline underneath the first level, breaking the layout.
   Fix:
     a) Hide nested <ul> submenus inside the top-menu popover by default;
        show them only when their parent <li> is hovered.
     b) Lay out the flat first-level items as a proper multi-column grid
        so long menus don't wrap awkwardly.
   ========================================================================= */

/* Give the popover a comfortable width and column layout */
#_desktop_top_menu .popover.sub-menu {
  min-width: 640px;
  max-width: 90vw;
  padding: 1rem 1.25rem;
  border: 1px solid #e5e5e5;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  background: #fff;
}

/* First-level list inside the popover: 4-column grid */
#_desktop_top_menu .popover.sub-menu > ul.top-menu[data-depth="1"] {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

#_desktop_top_menu .popover.sub-menu > ul.top-menu[data-depth="1"] > li {
  position: relative;
  min-width: 0;
}

#_desktop_top_menu .popover.sub-menu > ul.top-menu[data-depth="1"] > li > a {
  display: block;
  padding: 0.35rem 0;
  white-space: normal;
  line-height: 1.3;
}

/* HIDE the depth-2 submenus by default (this is the actual bug fix) */
#_desktop_top_menu .popover.sub-menu ul.top-menu[data-depth="2"] {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: #fafafa;
  border: 1px solid #e5e5e5;
  padding: 0.5rem 0.75rem;
  margin-top: 0.25rem;
  list-style: none;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Show a depth-2 submenu when its parent <li> is hovered or focused */
#_desktop_top_menu .popover.sub-menu > ul.top-menu[data-depth="1"] > li:hover > .collapse,
#_desktop_top_menu .popover.sub-menu > ul.top-menu[data-depth="1"] > li:focus-within > .collapse {
  display: block;
}

#_desktop_top_menu .popover.sub-menu > ul.top-menu[data-depth="1"] > li:hover > .collapse > ul.top-menu[data-depth="2"],
#_desktop_top_menu .popover.sub-menu > ul.top-menu[data-depth="1"] > li:focus-within > .collapse > ul.top-menu[data-depth="2"] {
  display: block;
}

/* Small visual affordance: bold parents that have children */
#_desktop_top_menu .popover.sub-menu > ul.top-menu[data-depth="1"] > li:has(.collapse ul[data-depth="2"]) > a::after {
  content: " ›";
  color: #999;
  font-weight: 400;
  margin-left: 0.25rem;
}

/* Responsive: fewer columns on narrower viewports */
@media (max-width: 1200px) {
  #_desktop_top_menu .popover.sub-menu > ul.top-menu[data-depth="1"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  #_desktop_top_menu .popover.sub-menu {
    min-width: 480px;
  }
  #_desktop_top_menu .popover.sub-menu > ul.top-menu[data-depth="1"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
