/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

@import url("chrome://global/content/elements/moz-page-nav.tokens.css");

:host {
  margin-inline-start: var(--page-nav-margin-inline-start);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  gap: var(--page-nav-gap);

  /* (Bug 1610081) Border provides clear differentiation between side
     navigation and main content area when prefers-reduced-motion is enabled. */
  padding-inline-end: var(--space-small);
  border-inline-end: var(--border-width) solid var(--page-nav-border-color);

  @media (prefers-reduced-motion) {
    --page-nav-border-color: var(--border-color);
  }

  @media (max-width: 950px) {
    grid-template-rows: 1fr auto;
  }

  @media print {
    display: none;
  }
}

nav {
  display: flex;
  flex-direction: column;
  gap: var(--page-nav-gap);
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.page-nav-heading-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-small);
  margin-block-start: var(--page-nav-margin-block-start);

  > .logo {
    display: inline-block;
    height: var(--page-nav-heading-logo-size);
    width: var(--page-nav-heading-logo-size);
    background: image-set(url("chrome://branding/content/about-logo.png"), url("chrome://branding/content/about-logo@2x.png") 2x) no-repeat center;
    background-size: auto;
    background-size: var(--page-nav-heading-logo-size);
    /* heading logo should be centered above button icons */
    margin-inline-start: calc(var(--space-medium) - ((var(--page-nav-heading-logo-size) - var(--icon-size)) / 2));

    @media (max-width: 950px) {
      margin-inline-start: var(--space-xsmall);
    }
  }

  > .page-nav-heading {
    font-size: var(--font-size-xlarge);
    font-weight: var(--font-weight-heading);
    margin-block: 0;

    @media (max-width: 950px) {
      display: none;
    }
  }
}

.primary-nav-group,
#secondary-nav-group {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: min-content;
  gap: var(--page-nav-button-gap);

  @media (max-width: 950px) {
    justify-content: center;
  }

  &:not(:has(slot:has-slotted)) {
    display: none;
  }
}

hr {
  width: 100%;
  margin: 0;
  height: 1px;
  border: 0;
  background-color: var(--page-nav-hr-background-color);
  flex-shrink: 0;

  @media (max-width: 52rem) {
    width: var(--button-size-icon);
  }
}

:host([type="mobile"]) {
  --page-nav-heading-logo-size: var(--icon-size-xlarge);

  margin-inline-start: var(--page-nav-gap);
  margin-block-start: var(--space-small);
  padding: var(--page-nav-gap);
  box-shadow: var(--box-shadow-level-4);
  height: min-content;

  .page-nav-heading-wrapper {
    margin-block-start: unset;

    > .page-nav-heading {
      font-size: var(--font-size-xxlarge);
    }
  }

  .logo {
    margin-inline-start: unset;
  }

  nav {
    /* Temporarily hiding nav while in mobile mode until expanded state is worked on: https://bugzilla.mozilla.org/show_bug.cgi?id=1948407 */
    display: none;
  }
}
