/**
 * KidWind Mobile Navigation
 *
 * Styles for the mobile sub-menu disclosure panels built by mobile-nav.js, plus
 * the off-canvas panel rules moved out of Cornerstone's Global CSS.
 *
 * Selectors are prefixed with `body` so they outrank the originals on specificity
 * alone. If the old rules are still sitting in Cornerstone's Global CSS, these win
 * regardless of stylesheet order.
 *
 * @package Nubbernaut_Kidwind
 * @since 1.9.2
 */

/* -----------------------------------------------------------------------------
 * Off-canvas panel (moved from Cornerstone Global CSS)
 * -------------------------------------------------------------------------- */

body #mobile-menu-trigger,
body #mobile-menu-close {
  cursor: pointer;
}

/**
 * `transform` alone leaves the closed panel focusable and exposed to screen
 * readers, so keyboard users could tab into an invisible off-screen menu.
 * `visibility` fixes both, and delaying its transition until the slide finishes
 * keeps the close animation intact.
 */
body #mobile-menu-container {
  visibility: hidden;
  transform: translateX(100%);
  transition: transform 0.3s ease-out, visibility 0s linear 0.3s;
}

body #mobile-menu-container.active {
  visibility: visible;
  transform: translateX(0%);
  transition: transform 0.3s ease-out, visibility 0s linear 0s;
}

/* Focus must stay visible now that the panel is keyboard operable. */
body #mobile-menu-trigger:focus-visible,
body #mobile-menu-close:focus-visible,
body .nk-tile-toggle:focus-visible,
body .nk-subnav__head:focus-visible,
body .nk-subnav__link:focus-visible {
  outline: 2px solid var(--lightpurple, #6c59ff);
  outline-offset: 2px;
  border-radius: 4px;
}

/* -----------------------------------------------------------------------------
 * Icon tiles promoted to disclosure toggles
 * -------------------------------------------------------------------------- */

body .nk-tile-toggle {
  cursor: pointer;
  position: relative;
  border-radius: 0.5rem;
  transition: background-color 0.2s ease-out;
}

/* Expanded tile stays visually tied to the list that opened below it. */
body .nk-tile-toggle[aria-expanded='true'] {
  background: var(--offwhite, #f9f9f9);
}

/* -----------------------------------------------------------------------------
 * Sub-menu disclosure panels
 * -------------------------------------------------------------------------- */

/**
 * Collapsed panels are `display: none` rather than zero-height: as a grid child a
 * zero-height row would still contribute the grid's row gap, leaving a visible
 * gutter under the tiles. It also keeps the collapsed links out of the tab order
 * and the accessibility tree for free.
 */
body .nk-subnav {
  display: none;
  grid-column: 1 / -1;
}

body .nk-subnav.is-open {
  display: block;
  animation: nk-subnav-reveal 0.2s ease-out;
}

@keyframes nk-subnav-reveal {
  from {
    opacity: 0;
    transform: translateY(-0.35rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/**
 * Full-width collapse bar. The panel can open well below the tile that triggered
 * it, so this names the section AND gives an unmissable way to close it — the
 * whole bar is the target, not just the chevron.
 */
body .nk-subnav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 2.75rem;
  margin: 0;
  padding: 0.5rem 1.25rem;
  border: 0;
  /* Matches the tile radius so the panel reads as part of the same set. */
  border-radius: 0.5rem 0.5rem 0 0;
  background: var(--darkpurple, #4d40b2);
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

body .nk-subnav__title {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

body .nk-subnav__collapse {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

body .nk-subnav__collapse svg {
  display: block;
  width: 0.7rem;
  height: auto;
  fill: currentColor;
  /* Points up: this bar only ever closes. */
  transform: rotate(180deg);
}

body .nk-subnav__list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--lightgray, rgb(240, 240, 240));
  background: var(--offwhite, #f9f9f9);
}

body .nk-subnav__list li {
  margin: 0;
  padding: 0;
}

body .nk-subnav__link {
  /* 44px minimum tap target. */
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  color: var(--darkpurple, #4d40b2);
  font-weight: 600;
  text-decoration: none;
  line-height: 1.3;
}

body .nk-subnav__link:hover,
body .nk-subnav__link:focus {
  color: var(--lightpurple, #6c59ff);
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  body #mobile-menu-container,
  body #mobile-menu-container.active,
  body .nk-tile-toggle {
    transition: none;
  }

  body .nk-subnav.is-open {
    animation: none;
  }
}
