/* =====================================================================
   portal-sidebar.css - collapse / expand for the portal navigation.

   One behaviour, defined once, loaded by every portal shell page. Like
   hairline.css this file is the single owner of its rules; do not copy
   them into a page's inline <style>.

   Two states, because the two form factors want different things:

     >= 1024px  "collapsed" hides the 280px sidebar and hands its width
                back to the content area. The header hamburger brings
                it back. The choice is remembered per browser.

     <  1024px  the sidebar is an off-canvas drawer, closed by default,
                so a phone starts with the entire viewport for content
                instead of losing 280px of ~375px to navigation.

   Loaded after portal-compiled.css so these rules win against the
   Tailwind utilities already on the <aside>. Width overrides are
   doubled (.portal-sidebar.portal-sidebar) so they beat w-[280px]
   regardless of stylesheet order.

   Versioned by query string in the <link>. Bump ?v= on every change or
   browsers will keep serving the old file.
   ===================================================================== */

:root {
  --portal-nav-width: 280px;
  --portal-nav-drawer-width: min(300px, 84vw);
  --portal-nav-ease: cubic-bezier(.22, .61, .36, 1);
  --portal-nav-duration: 260ms;
}

.portal-sidebar {
  transition:
    width var(--portal-nav-duration) var(--portal-nav-ease),
    min-width var(--portal-nav-duration) var(--portal-nav-ease),
    transform var(--portal-nav-duration) var(--portal-nav-ease),
    opacity 180ms linear;
}

/* ---------------------------------------------------------------------
   Desktop: collapse gives the width back to the content area.
   --------------------------------------------------------------------- */
@media (min-width: 1024px) {
  html[data-portal-nav="collapsed"] .portal-sidebar.portal-sidebar {
    width: 0;
    min-width: 0;
    border-right-width: 0;
    opacity: 0;
    pointer-events: none;
  }
}

/* ---------------------------------------------------------------------
   Mobile and tablet: the sidebar is a drawer over the content, not a
   column beside it. Default is closed - that is the real estate the
   small screens were asking for.
   --------------------------------------------------------------------- */
@media (max-width: 1023.98px) {
  .portal-sidebar.portal-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--portal-nav-drawer-width);
    min-width: 0;
    max-width: 84vw;
    transform: translateX(-101%);
    z-index: 60;
    box-shadow: 0 24px 60px -20px rgba(8, 14, 26, .45);
  }

  html[data-portal-drawer="open"] .portal-sidebar.portal-sidebar {
    transform: translateX(0);
  }
}

/* The dimmer behind an open drawer. Created by portal-sidebar.js so no
   page has to carry markup for it. */
.portal-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(8, 14, 26, .55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms var(--portal-nav-ease), visibility 200ms var(--portal-nav-ease);
}

html[data-portal-drawer="open"] .portal-nav-backdrop {
  opacity: 1;
  visibility: visible;
}

@media (min-width: 1024px) {
  .portal-nav-backdrop { display: none; }
}

/* Dismiss control inside the drawer. A phone user should not have to
   scroll the whole nav to find the way out. */
.portal-nav-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 11px;
  border: 1px solid #E1E6EE;
  background: rgba(255, 255, 255, .92);
  color: #67738A;
  cursor: pointer;
  transition: background 160ms var(--portal-nav-ease), color 160ms var(--portal-nav-ease);
}

.portal-nav-close:hover {
  background: #FFFFFF;
  color: #080E1A;
}

.dark .portal-nav-close {
  border-color: rgba(255, 255, 255, .12);
  background: rgba(16, 22, 35, .92);
  color: #8895AB;
}

.dark .portal-nav-close:hover {
  background: #101623;
  color: #EEF2F8;
}

.portal-nav-close svg {
  width: 16px;
  height: 16px;
}

/* Declared after the base rule above, not inside the desktop block near the
   top of the file: on equal specificity the later declaration wins, and the
   button would otherwise sit over the logo on a desktop. */
@media (min-width: 1024px) {
  .portal-nav-close { display: none; }
}

/* The dismiss chip sits over the sidebar's logo band, so give the logo
   clearance on the widths where the chip exists. object-contain keeps the
   artwork centred inside whatever box it is given. */
@media (max-width: 1023.98px) {
  .portal-sidebar #logo-light,
  .portal-sidebar #logo-dark {
    padding-right: 34px;
  }
}

/* The collapse control keeps the sidebar's own utility classes for
   colour and type; only the button reset lives here. */
.portal-nav-collapse {
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  font: inherit;
}

.portal-nav-collapse:focus-visible,
.portal-nav-close:focus-visible,
[data-portal-nav-toggle]:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 2px;
  border-radius: 11px;
}

.dark .portal-nav-collapse:focus-visible,
.dark .portal-nav-close:focus-visible,
.dark [data-portal-nav-toggle]:focus-visible {
  outline-color: #5D9DFF;
}

@media (prefers-reduced-motion: reduce) {
  .portal-sidebar,
  .portal-nav-backdrop {
    transition-duration: 1ms;
  }
}
