/* 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/. */

:host {
  border-radius: var(--border-radius-small);
  &:focus-visible {
    outline-offset: var(--page-nav-focus-outline-inset);
  }
}

a[href],
button {
  background-color: var(--page-nav-button-background-color);
  border: 1px solid var(--page-nav-border-color);
  -moz-context-properties: fill, fill-opacity;
  fill: var(--icon-color);
  display: grid;
  grid-template-columns: min-content 1fr;
  gap: var(--space-medium);
  align-items: center;
  font-family: inherit;
  font-size: inherit;
  width: 100%;
  font-weight: normal;
  border-radius: var(--page-nav-button-border-radius);
  color: var(--page-nav-button-text-color);
  text-align: start;
  transition: background-color 150ms;
  padding: var(--page-nav-button-padding);
}

a[href] {
  text-decoration: none;
  box-sizing: border-box;
}

button:hover {
  cursor: pointer;
}

@media not (prefers-contrast) {
  a[href],
  button {
    position: relative;
  }

  button::before {
    content: "";
    display: block;
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 4px;
    background-color: transparent;
    border-start-start-radius: var(--page-nav-button-border-radius);
    border-end-start-radius: var(--page-nav-button-border-radius);
  }

  button[selected]::before {
    background-color: var(--color-accent-primary);
  }

  a[href]:hover,
  button:hover:not([selected]) {
    color: var(--page-nav-button-text-color-hover);
    background-color: var(--page-nav-button-background-color-hover);

    &:active {
      color: var(--page-nav-button-text-color-active);
      background-color: var(--page-nav-button-background-color-active);
    }
  }

  button[selected] {
    color: var(--color-accent-primary);
    background-color: var(--page-nav-button-background-color-selected);
    font-weight: var(--font-weight-bold);
  }
}

a[href]:focus-visible,
button:focus-visible,
button[selected]:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 0;
  border-radius: var(--border-radius-small);
}

.page-nav-icon {
  height: var(--icon-size-default);
  width: var(--icon-size-default);
  -moz-context-properties: fill;
  fill: currentColor;
}

@media (prefers-contrast) {
  a[href],
  button {
    transition: none;
    border-color: ButtonText;
    background-color: var(--button-background-color);
  }

  a[href]:hover,
  button:hover {
    color: SelectedItem;
  }

  button[selected] {
    color: SelectedItemText;
    background-color: SelectedItem;
    border-color: SelectedItem;
  }
}

slot {
  margin: 0;
  padding-inline-start: 0;
  user-select: none;
}

@media (max-width: 52rem) {
  a[href],
  button {
    grid-template-columns: min-content;
    justify-content: center;
    margin-inline: 0;
  }

  slot {
    display: none;
  }
}
