/* ==========================================================================
   Component: Navbar (Browse Categories mega menu + primary links)
   Requires: common.css
   ========================================================================== */

.di-navbar {
  position: relative;
  background-color: var(--di-white);
  border-bottom: 1px solid var(--di-border);
  z-index: 20;
}

.di-navbar__inner {
  display: flex;
  align-items: center;
  gap: 30px;
  min-height: 56px;
}

/* --------------------------------------------------------------------------
   1. Browse Categories button
   -------------------------------------------------------------------------- */

.di-browse {
  position: relative;
  flex: none;
}

.di-browse__toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  min-width: 250px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--di-radius-sm);
  background-color: var(--di-green);
  color: var(--di-white);
  font-size: var(--di-fs-base);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--di-transition);
}

.di-browse__toggle:hover { background-color: var(--di-green-light); }

.di-browse__toggle-label { margin-right: auto; }

.di-browse__toggle-plus {
  transition: transform var(--di-transition);
}

.di-browse__toggle[aria-expanded="true"] .di-browse__toggle-plus {
  transform: rotate(45deg);
}

/* --------------------------------------------------------------------------
   2. Mega menu
   -------------------------------------------------------------------------- */

.di-megamenu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: min(1080px, calc(100vw - 32px));
  background-color: var(--di-white);
  border: 1px solid var(--di-border);
  border-radius: var(--di-radius);
  box-shadow: 0 18px 46px rgba(18, 53, 36, .16);
  overflow: hidden;
}

.di-megamenu[hidden] { display: none; }

/* Class / Subject / Series columns + a promo card on the right */
/* The panel itself never scrolls — each column does, so the whole menu
   always fits on one screen. */
.di-megamenu__groups {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.15fr) 210px;
  gap: 0;
  align-items: stretch;
}

.di-megamenu__col {
  padding: 20px 18px;
  border-right: 1px solid var(--di-border);
  max-height: min(58vh, 430px);
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Scrollbars hidden by design — the columns still scroll by wheel,
     touch and keyboard. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.di-megamenu__col::-webkit-scrollbar { width: 0; height: 0; }

.di-megamenu__col:last-child { border-right: 0; }

.di-megamenu__group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--di-gold);
}

.di-megamenu__group-title::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background-color: var(--di-border);
}

/* --- Class column: grouped chips -------------------------------------- */

.di-megamenu__stage + .di-megamenu__stage { margin-top: 14px; }

.di-megamenu__stage-title {
  margin: 0 0 8px;
  font-size: var(--di-fs-xs);
  font-weight: 600;
  color: var(--di-text-muted);
}

.di-megamenu__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.di-megamenu__chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--di-border);
  border-radius: var(--di-radius-pill);
  background-color: var(--di-white);
  font-size: var(--di-fs-xs);
  color: var(--di-text);
  transition: background-color var(--di-transition), border-color var(--di-transition), color var(--di-transition);
}

.di-megamenu__chip:hover,
.di-megamenu__chip:focus-visible {
  border-color: var(--di-green);
  background-color: var(--di-green);
  color: var(--di-white);
}

.di-megamenu__chip span {
  font-size: 10px;
  opacity: .6;
}

/* --- Generic link rows (subjects + series) ---------------------------- */

.di-megamenu__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.di-megamenu__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--di-radius-sm);
  font-size: var(--di-fs-sm);
  color: var(--di-text);
}

.di-megamenu__link:hover,
.di-megamenu__link:focus-visible {
  background-color: var(--di-cream);
  color: var(--di-green);
}

.di-megamenu__link-count {
  margin-left: auto;
  font-size: var(--di-fs-xs);
  color: var(--di-text-muted);
}

/* Subject initial badge */
.di-megamenu__badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--di-radius-sm);
  background-color: var(--di-cream-2);
  color: var(--di-green);
  font-size: var(--di-fs-xs);
  font-weight: 600;
}

/* Series colour dot */
.di-megamenu__dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

/* --- Promo card ------------------------------------------------------- */

.di-megamenu__promo {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 18px;
  max-height: min(58vh, 430px);
  overflow: hidden;
  background: linear-gradient(160deg, #17402b 0%, #0d2619 100%);
  color: var(--di-white);
}

.di-megamenu__promo-eyebrow {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--di-gold);
}

.di-megamenu__promo-title {
  margin: 0;
  font-size: var(--di-fs-md);
  font-weight: 600;
  line-height: 1.35;
}

.di-megamenu__promo-text {
  margin: 0;
  font-size: var(--di-fs-xs);
  line-height: 1.6;
  color: rgba(255, 255, 255, .72);
}

.di-megamenu__promo .di-btn {
  margin-top: 4px;
  padding: 9px 14px;
  font-size: var(--di-fs-xs);
}

/* --- Footer strip ----------------------------------------------------- */

.di-megamenu__footer {
  display: flex;
  align-items: center;
  gap: 22px;
  margin: 0;
  padding: 12px 18px;
  border-top: 1px solid var(--di-border);
  background-color: var(--di-cream);
}

.di-megamenu__quick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--di-fs-sm);
  color: var(--di-text);
}

.di-megamenu__quick:hover { color: var(--di-green); }

.di-megamenu__all {
  margin-left: auto;
  font-size: var(--di-fs-sm);
  font-weight: 500;
  color: var(--di-green);
}

/* --------------------------------------------------------------------------
   3. Primary links
   -------------------------------------------------------------------------- */

/* The links take the free space between the browse button and the promo
   strip, and sit centred inside it. */
.di-navbar__nav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.di-nav__list {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  /* Breathes on wide screens, tightens before it can collide with the
     browse button or the offer strip. */
  gap: clamp(14px, 1.35vw, 34px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.di-nav__link {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  padding: 6px 0;
  font-size: var(--di-fs-md);
  font-weight: 400;
  color: var(--di-text);
}

.di-nav__link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background-color: var(--di-gold);
  transition: width var(--di-transition);
}

.di-nav__link:hover::after,
.di-nav__link[aria-current="page"]::after { width: 100%; }

.di-nav__link[aria-current="page"] {
  color: var(--di-green);
  font-weight: 500;
}

/* Dropdown items (Shop by Class / Shop by Subject / Series) */
.di-nav__item {
  position: relative;
  display: flex;
}

.di-nav__toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  padding: 6px 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: var(--di-fs-md);
  font-weight: 400;
  color: var(--di-text);
  cursor: pointer;
}

.di-nav__toggle .di-icon { transition: transform var(--di-transition); }
.di-nav__toggle[aria-expanded="true"] { color: var(--di-green); }
.di-nav__toggle[aria-expanded="true"] .di-icon { transform: rotate(180deg); }

.di-nav__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: -14px;
  z-index: 40;
  min-width: 220px;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 8px;
  list-style: none;
  background-color: var(--di-white);
  border: 1px solid var(--di-border);
  border-radius: var(--di-radius);
  box-shadow: var(--di-shadow);
  scrollbar-width: thin;
  scrollbar-color: var(--di-border) transparent;
}

/* Class list is long — show it in two columns */
.di-nav__menu--wide {
  min-width: 340px;
  columns: 2;
  column-gap: 6px;
}

.di-nav__menu[hidden] { display: none; }

.di-nav__menu a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--di-radius-sm);
  font-size: var(--di-fs-sm);
  color: var(--di-text);
  break-inside: avoid;
}

.di-nav__menu a:hover,
.di-nav__menu a:focus-visible {
  background-color: var(--di-cream);
  color: var(--di-green);
}

.di-nav__menu-all {
  display: block;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--di-border);
  font-weight: 500;
  color: var(--di-green) !important;
}

/* --------------------------------------------------------------------------
   3b. School & bulk orders strip (fills the space at the end of the navbar)
   -------------------------------------------------------------------------- */

.di-navbar__promo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  padding: 6px 8px 6px 10px;
  border: 1px solid #ecdfc6;
  border-radius: var(--di-radius-sm);
  background-color: #fdf7ea;
  color: var(--di-text);
  transition: border-color var(--di-transition), background-color var(--di-transition);
}

.di-navbar__promo:hover {
  border-color: var(--di-gold);
  background-color: #fbf1de;
  color: var(--di-text);
}

.di-navbar__promo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.di-navbar__promo-title {
  font-size: var(--di-fs-sm);
  font-weight: 600;
  white-space: nowrap;
}

.di-navbar__promo-sub {
  font-size: 11px;
  color: var(--di-text-muted);
  white-space: nowrap;
}

.di-navbar__promo-btn {
  flex: none;
  padding: 8px 14px;
  border-radius: var(--di-radius-sm);
  background-color: var(--di-gold);
  color: var(--di-white);
  font-size: var(--di-fs-xs);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--di-transition);
}

.di-navbar__promo:hover .di-navbar__promo-btn { background-color: var(--di-gold-dark); }

/* --------------------------------------------------------------------------
   4. Mobile drawer
   -------------------------------------------------------------------------- */

.di-navbar__burger {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 0;
  border: 0;
  background: transparent;
  color: var(--di-text);
  font-size: var(--di-fs-base);
  font-weight: 500;
  cursor: pointer;
}

.di-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1050;
  width: min(320px, 86vw);
  display: flex;
  flex-direction: column;
  background-color: var(--di-white);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform .28s ease, visibility .28s ease;
}

.di-drawer.is-open {
  transform: none;
  visibility: visible;
}

.di-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--di-border);
}

.di-drawer__title {
  margin: 0;
  font-size: var(--di-fs-md);
  font-weight: 600;
  color: var(--di-green);
}

.di-drawer__close {
  display: inline-flex;
  padding: 6px;
  border: 0;
  border-radius: var(--di-radius-sm);
  background: transparent;
  cursor: pointer;
}

.di-drawer__body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 0 24px;
}

.di-drawer__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.di-drawer__link {
  display: block;
  padding: 12px 18px;
  font-size: var(--di-fs-base);
  color: var(--di-text);
  border-bottom: 1px solid var(--di-border);
}

.di-drawer__link:hover { background-color: var(--di-cream); }

/* Categories accordion inside the drawer */
.di-drawer__accordion-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 18px;
  border: 0;
  border-bottom: 1px solid var(--di-border);
  background: transparent;
  font-size: var(--di-fs-base);
  font-weight: 500;
  color: var(--di-green);
  text-align: left;
  cursor: pointer;
}

.di-drawer__accordion-toggle .di-icon { transition: transform var(--di-transition); }
.di-drawer__accordion-toggle[aria-expanded="true"] .di-icon { transform: rotate(180deg); }

.di-drawer__accordion-panel[hidden] { display: none; }

/* The category block is a single DOM node: navbar.js moves it between the
   mega menu and the drawer, so these are just the drawer-side overrides. */
.di-drawer .di-megamenu__groups {
  display: block;
  max-height: none;
  overflow: visible;
  background-color: var(--di-cream);
}

.di-drawer .di-megamenu__col {
  padding: 14px 18px;
  border-right: 0;
  border-bottom: 1px solid rgba(231, 225, 214, .8);
}

.di-drawer .di-megamenu__group-title { margin-bottom: 10px; }

.di-drawer .di-megamenu__link {
  padding: 9px 6px;
  border-radius: var(--di-radius-sm);
}

/* The promo card is desktop-only chrome */
.di-drawer .di-megamenu__promo { display: none; }

.di-overlay {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background-color: rgba(18, 53, 36, .45);
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility .28s ease;
}

.di-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* --------------------------------------------------------------------------
   5. Responsive
   -------------------------------------------------------------------------- */

/* The strip is shown whole or not at all — its wording never gets cut */
@media (max-width: 1559.98px) {
  .di-navbar__inner { gap: 20px; }
  .di-nav__link,
  .di-nav__toggle { font-size: var(--di-fs-base); }
  .di-navbar__promo { gap: 9px; padding: 5px 6px 5px 9px; }
  .di-navbar__promo-btn { padding: 7px 12px; }
}

@media (max-width: 1399.98px) {
  .di-navbar__inner { gap: 16px; }
  .di-browse__toggle { min-width: 0; padding: 0 14px; }
  .di-nav__link,
  .di-nav__toggle { font-size: var(--di-fs-sm); }
  .di-navbar__promo { gap: 8px; padding: 5px 5px 5px 8px; }
  .di-navbar__promo-btn { padding: 7px 11px; font-size: 11px; }
}

@media (max-width: 1199.98px) {
  /* Genuinely no room beside the links — the whole strip steps aside.
     The same offer stays in the mega menu, the footer and on its page. */
  .di-navbar__promo { display: none; }
}

@media (max-width: 1199.98px) {
  .di-navbar__inner { gap: 14px; }
  .di-browse__toggle { min-width: 0; gap: 8px; padding: 0 12px; }
  .di-nav__list { gap: 14px; }
  .di-nav__link,
  .di-nav__toggle { font-size: var(--di-fs-xs); }
  .di-nav__menu--wide { min-width: 300px; }
  .di-megamenu__list { columns: 2; }
}

@media (max-width: 991.98px) {
  /* The whole navbar row folds away — its trigger now lives on the search
     row in the header. The drawer and overlay are siblings of this row,
     so they stay in the DOM and keep working. */
  .di-navbar > .di-container { display: none; }
  .di-navbar { border-bottom: 0; }
}

@media (min-width: 992px) {
  /* Drawer markup only exists for small screens */
  .di-drawer,
  .di-overlay { display: none; }
}
