/* Mobile/tablet off-canvas navigation. Loaded after site-shell.css. */

/* Keep the global shell sticky and the WordPress brand lockup optically centred. */
.s2w-header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
}

.s2w-brand {
  display: flex;
  height: 100%;
  align-items: center;
  align-self: stretch;
}

.s2w-brand .custom-logo-link,
.s2w-brand__logo-link {
  display: flex;
  align-items: center;
  line-height: 0;
}

.s2w-brand .custom-logo,
.s2w-brand__logo {
  display: block;
  margin: 0;
}

.s2w-nav__drawer-header,
.s2w-nav-backdrop {
  display: none;
}

@media (max-width: 1180px) {
  /*
   * The closed drawer lives one full drawer-width to the right of the viewport.
   * Some mobile browsers include that transformed fixed element in the visual
   * overflow area, which lets the whole document pan into empty space. `clip`
   * blocks that horizontal visual overflow without creating a new scroll
   * container, so the sticky header keeps working.
   */
  html,
  body {
    max-width: 100%;
    overflow-x: clip;
  }

  .s2w-header {
    z-index: 1200;
  }

  .s2w-nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    z-index: 1202;
    display: flex;
    width: min(88vw, 430px);
    max-width: 100vw;
    height: 100dvh;
    flex-direction: column;
    visibility: hidden;
    opacity: 1;
    background: var(--s2w-white);
    box-shadow: -24px 0 64px rgba(0, 0, 0, .18);
    pointer-events: none;
    transform: translateX(100%);
    transition: transform 240ms ease, visibility 240ms ease;
  }

  .admin-bar .s2w-nav {
    top: 32px;
    height: calc(100dvh - 32px);
  }

  .s2w-nav-open .s2w-nav {
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  .s2w-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1201;
    display: block;
    max-width: 100vw;
    padding: 0;
    border: 0;
    visibility: hidden;
    opacity: 0;
    background: rgba(25, 25, 25, .55);
    cursor: default;
    transition: opacity 220ms ease, visibility 220ms ease;
  }

  .s2w-nav-open .s2w-nav-backdrop {
    visibility: visible;
    opacity: 1;
  }

  .s2w-nav__drawer-header {
    display: flex;
    min-height: 78px;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--s2w-border);
    background: var(--s2w-white);
  }

  .s2w-nav__drawer-brand {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    text-decoration: none;
  }

  .s2w-nav__drawer-brand img {
    display: block;
    width: auto;
    max-width: 168px;
    max-height: 44px;
    margin: 0;
    object-fit: contain;
  }

  .s2w-nav__close {
    position: relative;
    display: inline-flex;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--s2w-border-strong);
    border-radius: 50%;
    color: var(--s2w-ink);
    background: var(--s2w-white);
    cursor: pointer;
  }

  .s2w-nav__close span,
  .s2w-nav__close span::after {
    width: 18px;
    height: 2px;
    background: currentColor;
    content: "";
  }

  .s2w-nav__close span {
    transform: rotate(45deg);
  }

  .s2w-nav__close span::after {
    display: block;
    transform: rotate(90deg);
  }

  .s2w-nav__scroll {
    width: 100%;
    height: auto;
    flex: 1 1 auto;
    padding: .85rem 1.25rem 2rem;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .s2w-nav__menu {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
    gap: 0;
  }

  .s2w-nav__menu > li {
    position: relative;
    min-width: 0;
    border-bottom: 1px solid var(--s2w-border);
  }

  .s2w-nav__menu > li > a {
    width: calc(100% - 54px);
    min-height: 58px;
    padding: .95rem .1rem;
    border-radius: 0;
    color: var(--s2w-ink);
    background: transparent;
    font-size: 1.05rem;
    font-weight: var(--s2w-weight-bold);
    line-height: 1.25;
    white-space: normal;
  }

  .s2w-nav__menu > li:not(.menu-item-has-children) > a {
    width: 100%;
  }

  .s2w-nav__menu > li > a:hover,
  .s2w-nav__menu > li > a:focus-visible,
  .s2w-nav__menu > .current-menu-item > a,
  .s2w-nav__menu > .current-menu-ancestor > a {
    color: var(--s2w-ink);
    background: transparent;
  }

  .s2w-submenu-toggle {
    position: absolute;
    top: 7px;
    right: 0;
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--s2w-border);
    border-radius: 10px;
    color: var(--s2w-ink);
    background: var(--s2w-surface);
    cursor: pointer;
    transition: transform var(--s2w-transition), border-color var(--s2w-transition), background var(--s2w-transition);
  }

  .s2w-submenu-toggle::after {
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    content: "";
    transform: translateY(-2px) rotate(45deg);
    transition: transform var(--s2w-transition);
  }

  .s2w-submenu-toggle[aria-expanded="true"] {
    border-color: var(--s2w-primary);
    background: var(--s2w-primary);
  }

  .s2w-submenu-toggle[aria-expanded="true"]::after {
    transform: translateY(2px) rotate(-135deg);
  }

  /*
   * Hard-reset desktop dropdown positioning inside the drawer. The desktop
   * :hover/:focus-within rule is more specific than a plain .sub-menu rule and
   * was translating opened mobile submenus 50% to the left.
   */
  .s2w-nav .s2w-nav__menu li > .sub-menu,
  .s2w-nav .s2w-nav__menu li:hover > .sub-menu,
  .s2w-nav .s2w-nav__menu li:focus-within > .sub-menu {
    position: static;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    display: none;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: .5rem .65rem .75rem;
    margin: 0 0 .75rem;
    border: 0;
    border-left: 4px solid var(--s2w-primary);
    border-radius: 0 var(--s2w-radius-sm) var(--s2w-radius-sm) 0;
    visibility: visible;
    opacity: 1;
    background: var(--s2w-surface);
    box-shadow: none;
    pointer-events: auto;
    transform: none;
    transition: none;
  }

  .s2w-nav .s2w-nav__menu li.s2w-submenu-open > .sub-menu {
    display: grid;
    gap: .15rem;
  }

  .s2w-nav__menu .sub-menu li {
    min-width: 0;
  }

  .s2w-nav__menu .sub-menu a {
    display: flex;
    width: 100%;
    min-height: var(--s2w-touch-target);
    align-items: center;
    padding: .65rem .7rem;
    border-radius: var(--s2w-radius-sm);
    color: var(--s2w-ink);
    font-size: .94rem;
    font-weight: var(--s2w-weight-medium);
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .s2w-nav__menu .sub-menu a:hover,
  .s2w-nav__menu .sub-menu a:focus-visible,
  .s2w-nav__menu .sub-menu .current-menu-item > a {
    background: var(--s2w-white);
    transform: none;
  }

  .s2w-nav__mobile-meta {
    display: grid;
    gap: 1.25rem;
    padding-top: 1.5rem;
  }

  .s2w-nav__mobile-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: .75rem;
  }

  .s2w-nav__account,
  .s2w-nav__mobile-actions .s2w-btn {
    width: 100%;
    min-height: 50px;
  }

  .s2w-nav__account {
    border: 1px solid var(--s2w-border-strong);
    border-radius: var(--s2w-radius-pill);
  }
}

@media (max-width: 782px) {
  .admin-bar .s2w-nav {
    top: 46px;
    height: calc(100dvh - 46px);
  }
}

@media (max-width: 640px) {
  .s2w-nav {
    width: min(92vw, 410px);
  }

  .s2w-nav__drawer-header {
    min-height: 68px;
    padding-inline: 1rem;
  }

  .s2w-nav__drawer-brand img {
    max-width: 148px;
    max-height: 40px;
  }

  .s2w-nav__scroll {
    padding: .65rem 1rem 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .s2w-nav,
  .s2w-nav-backdrop {
    transition-duration: .01ms !important;
  }
}
