/* Shared app navigation. */

:root {
  --app-sidebar-width-expanded: 11.5rem;
  --app-sidebar-inner-margin-x: 0.4rem;
  --app-sidebar-inner-margin-x-start: 0.4rem;
  /* Extra end margin + inset: collapse tab sits on the glass edge (left: 100%). */
  --app-sidebar-inner-margin-x-end: 0.75rem;
  --app-sidebar-collapsed-inset-end: 0.12rem;
  --app-sidebar-collapsed-pad: 0.1rem;
  /* Collapsed rail width (rem @ 16px root):
     start 0.4 + end 0.75 + icon 2.15 + pads 0.2 + end-pads 0.44 = 3.94rem */
  --app-sidebar-width-collapsed: calc(
    var(--app-sidebar-inner-margin-x-start)
    + var(--app-sidebar-inner-margin-x-end)
    + var(--app-sidebar-row-height)
    + (var(--app-sidebar-collapsed-pad) * 2)
    + ((var(--app-sidebar-collapsed-pad) + var(--app-sidebar-collapsed-inset-end)) * 2)
  );
  --app-sidebar-rail-width: var(--app-sidebar-width-collapsed);
  /* ── THE MOBILE TOGGLE'S FOOTPRINT, AS A NUMBER THE LAYOUT CAN READ ─────
   *
   * The control is `position: fixed` at the bottom-left and below 1024px the
   * content column is full-bleed, so it sat ON the page. Measured on
   * /ticker/NVDA against the live payload: at 758px the button covered the
   * hero paragraph; at 375px it covered FOR REFERENCE ONLY and the 55-day low
   * beside it; at 320px it covered content at 31 of 31 sampled scroll
   * positions. It is not a defect at one breakpoint -- it is every width from
   * 1px to 1023px, which is exactly the range where the control is displayed
   * and nothing reserves room for it.
   *
   * A viewport-fixed control cannot avoid a full-bleed scrolling column by
   * moving; wherever it sits, the column scrolls underneath it. The only fix
   * that holds at every width and every scroll offset is to RESERVE its
   * footprint, so these three are one source of truth: the size and the inset
   * position the button, and the gutter -- their sum -- is what the content
   * column gives up. Change one and the other two follow.
   *
   * The narrow step is not a smaller button for its own sake: 2.75rem is 44px,
   * the minimum touch target, and spending 80px of a 320px screen on a control
   * this occasional is its own kind of wrong. */
  --app-sidebar-toggle-size: 2.75rem;
  --app-sidebar-toggle-inset: 0.5rem;
  --app-sidebar-toggle-gutter: calc(
    var(--app-sidebar-toggle-inset) + var(--app-sidebar-toggle-size)
  );
  --app-sidebar-z: 140;
  --app-sidebar-row-height: 1.95rem;
  --app-sidebar-icon-glyph: 1rem;
  /* Centers a tight icon box inside the collapsed row-height tile. */
  --app-sidebar-icon-inset: calc((var(--app-sidebar-row-height) - var(--app-sidebar-icon-glyph)) / 2);
  --app-sidebar-label-gap: 0.55rem;
  /* Shared ancestor left paddings so the link's left edge — and thus the icon —
     sits at the same x whether collapsed or expanded. */
  --app-sidebar-section-pad: 0.45rem;
  --app-sidebar-nav-pad: 0.12rem;
  --app-sidebar-font: var(--banana-font-body);
  --app-sidebar-text: var(--banana-on-surface-variant);
  --app-sidebar-text-muted: var(--banana-text-muted);
  --app-sidebar-text-active: var(--banana-primary-fixed);
  --app-sidebar-border: #262626;
  --app-sidebar-surface: var(--banana-surface-container);
}

.app-sidebar .material-symbols-outlined,
.app-sidebar__mobile-toggle .material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

html:not(.app-sidebar-icons-ready) .app-sidebar .material-symbols-outlined,
html:not(.app-sidebar-icons-ready) .app-sidebar__mobile-toggle .material-symbols-outlined {
  visibility: hidden;
}

html:has(.app-shell),
html:has(.app-shell) body {
  background-color: var(--banana-background, #0e0e0e);
}

.app-shell {
  --app-sidebar-current-width: var(--app-sidebar-width-expanded);
  display: flex;
  min-height: 100vh;
  width: 100%;
  box-sizing: border-box;
  background-color: var(--banana-background, #0e0e0e);
}

.app-shell.is-collapsed {
  --app-sidebar-current-width: var(--app-sidebar-width-collapsed);
}

.app-shell__main {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  width: 100%;
  margin-left: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background-color: var(--banana-background, #0e0e0e);
}

@media (min-width: 1024px) {
  /* The sidebar is permanent on desktop: it reserves its full width, so it
     sits beside the page instead of over it, and it has no collapse control. */
  :root {
    --app-sidebar-rail-width: var(--app-sidebar-width-expanded);
  }

  .app-shell__main {
    margin-left: var(--app-sidebar-width-expanded);
  }

  .app-shell .app-sidebar__collapse-btn {
    display: none;
  }
}

/* BELOW 1024px THE MOBILE TOGGLE RESERVES SPACE THE SAME WAY THE RAIL DOES.
 * Same principle, same place in the file: a control that is always on screen
 * is part of the layout, and the collapsed rail above has reserved its own
 * width since the shell was written. The toggle never did, so it spent every
 * width under 1024px painted over whatever the page had put in its corner.
 *
 * The gutter goes on the shell rather than on any page, because the control
 * belongs to the shell and every page inside it is equally covered. Pages keep
 * their own horizontal padding, which lands inside this and supplies the gap
 * between the button and the first character of text. */
@media (max-width: 1023px) {
  .app-shell__main {
    padding-left: var(--app-sidebar-toggle-gutter);
  }
}

/* Where a 320px screen is not the constraint, the control goes back to its
 * designed size. 600px is the width at which 5rem of gutter stops being a
 * fifth of the viewport. */
@media (min-width: 600px) and (max-width: 1023px) {
  :root {
    --app-sidebar-toggle-size: 3.75rem;
    --app-sidebar-toggle-inset: 1.25rem;
  }
}

/* Fixed rail and mobile drawer. */

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--app-sidebar-current-width);
  z-index: var(--app-sidebar-z);
  box-sizing: border-box;
  pointer-events: none;
  transition: width 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar__inner,
.app-sidebar__mobile-toggle {
  pointer-events: auto;
}

.app-sidebar__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  border-inline-end: 1px solid var(--app-sidebar-border);
  background: #000;
  font-family: var(--app-sidebar-font);
}

/* ---- Brand hero ---- */

.app-sidebar__head {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0.7rem 0.55rem 0.55rem;
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  text-decoration: none;
  padding: 0.25rem 0.35rem;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  transition: color 0.15s ease;
}

.app-sidebar__brand:hover {
  background: none;
}

.app-sidebar__brand:hover .app-sidebar__brand-text {
  color: var(--app-sidebar-text-active);
}

.app-sidebar__brand-logo {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  object-fit: contain;
}

.app-sidebar__brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  transition: opacity 0.15s ease, width 0.15s ease;
}

.app-sidebar__brand-text {
  font-family: var(--banana-font-heading);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--banana-on-surface, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-shell.is-collapsed .app-sidebar__brand-copy {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

.app-shell.is-collapsed .app-sidebar__group-label {
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  pointer-events: none;
}

.app-shell.is-collapsed .app-sidebar__brand {
  justify-content: center;
  align-self: stretch;
  width: 100%;
  padding-left: 0;
  padding-right: 0;
  gap: 0;
}

.app-shell.is-collapsed .app-sidebar__brand:hover .app-sidebar__brand-text {
  color: var(--banana-on-surface, #fff);
}

.app-shell.is-collapsed .app-sidebar__head {
  align-items: stretch;
  padding-left: calc(var(--app-sidebar-collapsed-pad) * 2);
  padding-right: calc(
    (var(--app-sidebar-collapsed-pad) * 2)
    + (var(--app-sidebar-collapsed-inset-end) * 2)
  );
}

.app-shell.is-collapsed .app-sidebar__foot {
  align-items: center;
  padding-left: calc(var(--app-sidebar-collapsed-pad) * 2);
  padding-right: calc(
    (var(--app-sidebar-collapsed-pad) * 2)
    + (var(--app-sidebar-collapsed-inset-end) * 2)
  );
}

.app-shell.is-collapsed .app-sidebar__inner {
  margin: 0.45rem var(--app-sidebar-inner-margin-x-end) 0.45rem var(--app-sidebar-inner-margin-x-start);
  width: calc(100% - var(--app-sidebar-inner-margin-x-start) - var(--app-sidebar-inner-margin-x-end));
  max-width: none;
}

.app-shell.is-collapsed .app-sidebar__section {
  padding-left: var(--app-sidebar-collapsed-pad);
  padding-right: calc(var(--app-sidebar-collapsed-pad) + var(--app-sidebar-collapsed-inset-end));
}

.app-shell.is-collapsed .app-sidebar__nav {
  padding-top: var(--app-sidebar-collapsed-pad);
  padding-bottom: var(--app-sidebar-collapsed-pad);
  padding-left: var(--app-sidebar-collapsed-pad);
  padding-right: calc(var(--app-sidebar-collapsed-pad) + var(--app-sidebar-collapsed-inset-end));
}

.app-shell.is-collapsed .app-sidebar__link + .app-sidebar__link {
  margin-top: 0;
}

.app-shell.is-collapsed .app-sidebar__link,
.app-shell.is-collapsed .app-sidebar__auth-link {
  position: relative;
  justify-content: center;
  align-items: center;
  width: var(--app-sidebar-row-height);
  min-width: var(--app-sidebar-row-height);
  padding: 0;
  gap: 0;
  flex-shrink: 0;
  letter-spacing: 0;
}

.app-shell.is-collapsed .app-sidebar__link .app-sidebar__label,
.app-shell.is-collapsed .app-sidebar__auth-link .app-sidebar__label {
  display: none;
}

/* ---- Nav card ---- */

.app-sidebar__section {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 var(--app-sidebar-section-pad);
  overflow: hidden;
  border-radius: 0 0 calc(var(--banana-radius, 12px) - 2px) calc(var(--banana-radius, 12px) - 2px);
}

.app-sidebar__group-label {
  margin: 0 0 0.2rem;
  padding-inline: var(--app-sidebar-icon-inset);
  font: 500 0.66rem/1.3 var(--banana-font-mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--app-sidebar-text-muted);
}

.app-sidebar__nav-card {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border: none;
  border-radius: 0;
  background: none;
}

.app-sidebar__nav {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: var(--app-sidebar-nav-pad);
  gap: 0.65rem;
}

.app-sidebar__link,
.app-sidebar__auth-link {
  display: flex;
  align-items: center;
  gap: var(--app-sidebar-label-gap);
  height: var(--app-sidebar-row-height);
  min-height: var(--app-sidebar-row-height);
  padding: 0 0.48rem 0 var(--app-sidebar-icon-inset);
  border-radius: 0.4rem;
  text-decoration: none;
  color: var(--app-sidebar-text);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  transition: color 0.15s ease, background-color 0.15s ease;
  box-sizing: border-box;
}

.app-sidebar__link:hover,
.app-sidebar__auth-link:hover {
  color: #fff;
  background-color: var(--app-sidebar-surface);
}

.app-sidebar__link--active,
.app-sidebar__link--active:hover {
  color: var(--app-sidebar-text-active);
  background-color: color-mix(in srgb, var(--app-sidebar-text-active) 11%, #000);
}

.app-sidebar :is(a, button):focus-visible,
.app-sidebar__mobile-toggle:focus-visible {
  outline: 2px solid var(--app-sidebar-text-active);
  outline-offset: -2px;
}

.app-sidebar__icon {
  flex: 0 0 auto;
  box-sizing: border-box;
}

.app-sidebar__icon.material-symbols-outlined {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  font-family: 'Material Symbols Outlined';
  font-size: var(--app-sidebar-icon-glyph);
  line-height: 1;
  overflow: visible;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.app-sidebar__icon--svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--app-sidebar-icon-glyph);
  height: var(--app-sidebar-icon-glyph);
}

.app-sidebar__icon--svg svg {
  width: 100%;
  height: 100%;
  display: block;
}

.app-sidebar__label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
  transition: opacity 0.15s ease, width 0.15s ease;
}

.app-shell.is-collapsed .app-sidebar__collapse-btn .app-sidebar__collapse-icon--collapsed {
  display: inline-flex;
}

.app-shell:not(.is-collapsed) .app-sidebar__collapse-btn .app-sidebar__collapse-icon--expanded {
  display: inline-flex;
}

.app-shell:not(.is-collapsed) .app-sidebar__collapse-btn .app-sidebar__collapse-icon--collapsed {
  display: none;
}

.app-shell.is-collapsed .app-sidebar__collapse-btn .app-sidebar__collapse-icon--expanded {
  display: none;
}

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

.app-sidebar__foot {
  flex: 0 0 auto;
  padding: 0.45rem 0.5rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.app-sidebar__collapse-btn {
  position: absolute;
  inset: 0.5rem 0.45rem auto auto;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 0.4rem;
  background: transparent;
  color: var(--app-sidebar-text);
  cursor: pointer;
}

.app-sidebar__collapse-btn:hover {
  color: var(--app-sidebar-text-active);
  background: var(--app-sidebar-surface);
}

.app-sidebar__collapse-btn .app-sidebar__label {
  display: none;
}

/* User menu in sidebar layout */
.app-sidebar .site-nav__user-menu--sidebar {
  width: 100%;
}

.app-sidebar .site-nav__user-menu--sidebar .site-nav__user-menu-trigger {
  width: 100%;
  max-width: none;
  justify-content: flex-start;
  align-items: center;
  gap: 0.55rem;
  height: var(--app-sidebar-row-height);
  min-height: var(--app-sidebar-row-height);
  padding: 0 0.48rem;
  border-radius: 0.4rem;
  background: var(--app-sidebar-surface);
  border: 1px solid var(--app-sidebar-border);
  color: var(--app-sidebar-text);
}

.app-sidebar .site-nav__user-menu--sidebar .site-nav__user-menu-trigger:hover,
.app-sidebar .site-nav__user-menu--sidebar .site-nav__user-menu-trigger:focus-visible {
  color: var(--banana-on-surface, #fff);
  background: #202020;
  border-color: #343434;
}

.app-shell.is-collapsed .site-nav__user-menu--sidebar .site-nav__user-menu-trigger {
  justify-content: center;
  align-items: center;
  width: var(--app-sidebar-row-height);
  max-width: var(--app-sidebar-row-height);
  height: var(--app-sidebar-row-height);
  min-height: var(--app-sidebar-row-height);
  padding: 0;
  margin-inline: 0;
  letter-spacing: 0;
}

.app-shell.is-collapsed .site-nav__user-menu--sidebar .site-nav__user-menu-trigger:hover,
.app-shell.is-collapsed .site-nav__user-menu--sidebar .site-nav__user-menu-trigger:focus-visible {
  padding: 0;
}

.app-shell.is-collapsed .site-nav__user-menu--sidebar .site-nav__user-avatar {
  width: 1.35rem;
  height: 1.35rem;
}

.app-shell.is-collapsed .site-nav__user-menu--sidebar .site-nav__user-text,
.app-shell.is-collapsed .site-nav__user-menu--sidebar .site-nav__user-menu-chevron {
  display: none;
}

.app-sidebar .site-nav__user-menu--sidebar .site-nav__user-menu-chevron {
  display: block;
}

.app-shell--user-menu-open .site-nav__user-menu--sidebar .site-nav__user-menu-trigger {
  border-color: color-mix(in srgb, var(--app-sidebar-text-active) 28%, transparent);
  background: color-mix(in srgb, var(--app-sidebar-text-active) 8%, transparent);
}

.app-shell--user-menu-open .site-nav__user-menu--sidebar .site-nav__user-menu-chevron {
  transform: rotate(180deg);
  color: var(--banana-on-surface);
}

.site-nav__user-menu-panel.site-nav__user-menu-panel--sidebar {
  min-width: 13rem;
  border: 1px solid var(--app-sidebar-border);
  border-radius: 0.6rem;
  background: var(--app-sidebar-surface);
}

.app-sidebar .site-nav__user-name,
.site-nav__user-menu-panel--sidebar :is(.site-nav__user-menu-header-name, .site-nav__user-menu-item) {
  font-family: var(--app-sidebar-font);
  font-weight: 500;
}

.app-sidebar .site-nav__user-menu--sidebar .site-nav__user-name {
  display: block;
}

.app-sidebar__avatar-fallback {
  display: inline-grid;
  place-items: center;
  background: color-mix(in srgb, var(--app-sidebar-text-active) 12%, #000);
  color: var(--app-sidebar-text-active);
  font: 600 0.75rem/1 var(--app-sidebar-font);
}

/* Mobile toggle */
.app-sidebar__mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  position: fixed;
  /* READ FROM THE TOKENS, not repeated here. These four values and the gutter
   * the content column gives up have to be the same measurement, and they were
   * two measurements until 2026-07-30 -- one written here and one that did not
   * exist. */
  bottom: var(--app-sidebar-toggle-inset);
  left: var(--app-sidebar-toggle-inset);
  z-index: calc(var(--app-sidebar-z) + 2);
  width: var(--app-sidebar-toggle-size);
  height: var(--app-sidebar-toggle-size);
  border: 1px solid var(--app-sidebar-border);
  border-radius: 0.55rem;
  background: var(--app-sidebar-surface);
  color: var(--app-sidebar-text-active);
  cursor: pointer;
}

.app-sidebar__mobile-toggle:hover {
  border-color: var(--app-sidebar-text-active);
}

.app-sidebar__mobile-toggle .material-symbols-outlined {
  /* Scaled off the button rather than fixed at 1.65rem, which was sized for a
   * 3.75rem button and overflowed the 2.75rem one. */
  font-size: calc(var(--app-sidebar-toggle-size) * 0.44);
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.app-sidebar__backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: calc(var(--app-sidebar-z) - 1);
  background: rgb(0 0 0 / 55%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.app-shell.is-mobile-open .app-sidebar__backdrop {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ---- Mobile drawer (<1024px) ---- */

@media (max-width: 1023px) {
  .app-shell__main {
    margin-left: 0;
  }

  .app-sidebar {
    --app-sidebar-row-height: 2.75rem;
    width: min(14rem, 100vw);
    visibility: hidden;
    transform: translateX(-100%);
    pointer-events: none;
  }

  .app-shell.is-mobile-open .app-sidebar {
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
  }

  .app-sidebar__head {
    padding-inline-end: 3.2rem;
  }

  .app-sidebar__mobile-toggle {
    display: flex;
  }

  .app-shell.is-mobile-open .app-sidebar__mobile-toggle {
    display: none;
  }

  .app-shell.is-mobile-open .site-nav__user-menu--sidebar .site-nav__user-text,
  .app-shell.is-mobile-open .site-nav__user-menu--sidebar .site-nav__user-menu-chevron {
    opacity: 1;
    width: auto;
    display: flex;
    pointer-events: auto;
  }

  .app-shell.is-mobile-open .app-sidebar__link,
  .app-shell.is-mobile-open .app-sidebar__auth-link {
    display: flex;
    align-items: center;
    gap: var(--app-sidebar-label-gap);
    width: auto;
    height: var(--app-sidebar-row-height);
    min-height: var(--app-sidebar-row-height);
    padding: 0 0.48rem 0 var(--app-sidebar-icon-inset);
  }

  .app-shell.is-mobile-open .app-sidebar__link .app-sidebar__icon,
  .app-shell.is-mobile-open .app-sidebar__auth-link .app-sidebar__icon {
    translate: 0;
  }

  .app-shell.is-mobile-open .app-sidebar__collapse-btn .app-sidebar__collapse-icon--expanded {
    display: inline-flex;
  }

  .app-shell.is-mobile-open .app-sidebar__collapse-btn .app-sidebar__collapse-icon--collapsed {
    display: none;
  }
}

@media (min-width: 1024px) {
  .app-sidebar__mobile-toggle {
    display: none !important;
  }
}

/* Legend app inside shell */
.app-shell__main > .legend-app {
  flex: 1 1 auto;
  padding-top: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
}

.app-shell__main > .legend-app > .site-nav {
  display: none;
}

/* Tailwind preflight loads on Fundamentals+ pages; keep sidebar metrics stable. */
html:has(.app-shell) .app-sidebar,
html:has(.app-shell) .app-sidebar *,
html:has(.app-shell) .app-sidebar__mobile-toggle {
  box-sizing: border-box;
}

html:has(.app-shell) .app-sidebar__brand-logo {
  width: 1.75rem;
  height: 1.75rem;
  max-width: none;
}

html:has(.app-shell) .app-sidebar__icon--svg,
html:has(.app-shell) .app-sidebar__icon--svg svg {
  display: inline-flex;
  flex-shrink: 0;
}

html:has(.app-shell) .app-sidebar button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
}

html:has(.app-shell) .app-sidebar a {
  text-decoration: none;
}
