/**
 * Fonts
 */

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 100 900;
  src: url("/assets/fonts/Roboto-VariableFont_wdth,wght.ttf") format("truetype");
}

@font-face {
  font-family: "Roboto";
  font-style: italic;
  font-weight: 100 900;
  src: url("/assets/fonts/Roboto-Italic-VariableFont_wdth,wght.ttf")
    format("truetype");
}

@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 100 900;
  src: url("/assets/fonts/RobotoMono-VariableFont_wght.ttf") format("truetype");
}

/**
 * Standard HTML elements
 */

* {
  box-sizing: border-box;
}

:root {
  --background-color: #fff;
  --font-family: "Roboto", "Helvetica", Arial, sans-serif;
  --contrast-text-color: black;
  --muted-background-color: #f6f8fa;
  --primary-color: #0172ad;
  --secondary-color: #5d6b89;
  --text-color: #373c44;
}

body {
  background-color: var(--background-color);
  color: var(--text-color);
  display: grid;
  font-family: var(--font-family);
  font-size: 18px;
  gap: 2rem;
  line-height: 1.5;
  max-width: 1200px;
  margin: auto;
  padding: 2rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--contrast-text-color);
  position: relative;

  &:first-child {
    margin-top: 0;
  }

  a.anchor {
    visibility: hidden;
    left: -.75em;
    width: 100%;
    font-weight: normal;
    text-decoration: none;
    position: absolute;
  }

  &:hover {
    a.anchor {
      visibility: visible;
    }
  }
}

a {
  color: var(--primary-color);
}

pre,
code {
  font-family: "Roboto Mono", monospace;
  font-size: 0.9em;
  overflow: auto;
}

pre {
  background: var(--muted-background-color);
  padding: 0.1rem;
}

code.hljs {
  background: none;
  padding: 0;
}

header,
nav {
  a {
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }
  }
}

header {
  align-items: center;
  color: var(--contrast-text-color);
  display: grid;
  grid-template-columns: auto 1fr;

  #linkHome {
    align-items: center;
    color: var(--contrast-text-color);
    display: flex;
    font-weight: bold;

    img {
      height: 2rem;
    }
  }

  #links {
    display: grid;
    gap: 1rem;
    grid-auto-flow: column;
    justify-content: end;
  }
}

main {
  overflow-x: hidden;

  > :first-child {
    margin-top: 0;
  }
}

/**
 * Specific elements
 */

#sideNav {
  display: none;
}

nav {
  a {
    color: var(--secondary-color);
  }

  ul {
    list-style: none;
    margin: 0;
    overflow: visible;
    padding: 0;

    h3 {
      color: inherit;
      font-size: 0.95em;
      margin-bottom: 0;
      margin-top: 1rem;
    }

    > * {
      padding: 0.25rem 0;
    }
  }

  li {
    position: relative;

    &:has(> [aria-current]) {
      &::before {
        content: url(/assets/svg/triangle.svg);
        height: 0.5em;
        left: -1em;
        position: absolute;
        width: 0.5em;
      }
    }
  }
}

#navMenu {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  cursor: default;

  nav {
    background: var(--background-color);
    border: 1px solid var(--secondary-color);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    padding: 0.5em 1.5em;
    position: absolute;
    z-index: 10; /* Pagefind magnifying glass icon is 9 */
  }
}

/**
 * Spec pages
 */
img[align="left"] {
  padding-right: 20px;
}

/* Pagefind search UI */
#search {
  --pagefind-ui-background: var(--muted-background-color);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border: var(--secondary-color);
  --pagefind-ui-border-radius: 0;
  --pagefind-ui-font: var(--font-family);
  --pagefind-ui-scale: 0.9;
  --pagefind-ui-text: var(--text-color);

  .pagefind-ui__search-clear {
    border: none;
  }

  .pagefind-ui__result-title {
    font-weight: normal;
  }

  .pagefind-ui__result-link {
    color: var(--primary-color);
  }
}

/* Desktop */
/* This breakpoint width should match what's in page.ori.html */
@media (min-width: 1000px) {
  body {
    grid-template-columns: auto 1fr;
    column-gap: 0;
  }

  header {
    grid-column: 1 / span 2;
    grid-template-columns: subgrid;
    #links {
      padding-left: 2rem;
    }
  }

  #navMenu {
    display: none;
  }

  #sideNav {
    display: block;
  }

  main {
    padding-left: 2rem;
  }

}

/* Dark mode */
@media only screen and (prefers-color-scheme: dark) {
  :root {
    --background-color: #13171f;
    --contrast-text-color: white;
    --muted-background-color: #262a2f;
    --primary-color: #01aaff;
    --secondary-color: #969eaf;
    --text-color: #c2c7d0;
    color-scheme: dark;
  }

  header {
    #linkHome {
      img {
        content: url("/assets/svg/logo/logo-horizontal-dark.svg");
      }
    }
  }
}
