:root {
  --primary: #7a7e73;
  --primary-content: #f8f8f8;
  --primary-dark: #60635b;
  --primary-light: #93978d;

  --secondary: #77737e;
  --secondary-content: #f8f8f8;
  --secondary-dark: #5e5b63;
  --secondary-light: #918d97;

  --background: #f0f1ef;
  --foreground: #fbfbfb;
  --border: #e0e2dd;

  --copy: #272923;
  --copy-light: #686e5e;
  --copy-lighter: #8f9584;

  --success: #737e73;
  --warning: #7e7e73;
  --error: #7e7373;
  --success-content: #f8f8f8;
  --warning-content: #f8f8f8;
  --error-content: #f8f8f8;

  --header-height: 4rem;

  --max-width: 1024px;
  --side-padding: 2em;
}

/*
 * from https://css-tricks.com/an-interview-with-elad-shechter-on-the-new-css-reset/
 * Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property
 */
*:where(:not(iframe, canvas, img, svg, video):not(svg *)) {
  all: unset;
  display: revert;
}
/* Preferred box-sizing value */
*,
*::before,
*::after {
  box-sizing: border-box;
}
/* my own reset */
ul {
  list-style-position: inside;
}

body {
  font-family: sans-serif;
  font-size: clamp(1rem, 0.7rem + 0.9vw, 1.3rem);
  line-height: 2rem;

  color: var(--copy);
  background: var(--background);
  font-size: 1.2em;
}

.editor-content {
  display: none;
}

.cms-editor-active .editor-content {
  display: block;
}

a {
  text-decoration: none;
  cursor: pointer;
}

a:hover,
a:focus,
a:active {
  text-decoration: underline;
}

header {
  position: sticky;
  top: 0;
  width: 100%;
  height: var(--header-height);

  background: var(--primary);
  color: var(--primary-content);
  font-size: 0.9rem;
  font-weight: 600;

  & > .container {
    height: 100%;

    max-width: var(--max-width);
    margin: 0 auto;

    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  & .logo-link {
    height: 100%;
    padding: 0 var(--side-padding);
    display: inline-flex;
    align-items: center;

    & > img {
      height: calc(var(--header-height) - 1rem);
      /* white */
      filter: invert(92%) sepia(100%) saturate(0%) hue-rotate(202deg)
        brightness(106%) contrast(106%);
    }
  }

  & nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 100%;

    & a {
      height: 100%;
      line-height: var(--header-height);
      padding: 0 2rem;

      &:hover,
      &:focus,
      &.active {
        background-color: var(--primary-dark);
        text-decoration: none;
      }
    }
  }

  & wc-menu-button {
    width: 37px;
    --wc-menu-button-color: var(--primary-content);
    margin-right: var(--side-padding);
    margin-top: 0.75rem;
  }
}

wc-menu-button,
side-drawer {
  display: none;
}

@media (max-width: 768px) {
  wc-menu-button,
  side-drawer {
    display: block;
  }

  header nav {
    display: none;
  }
}

main {
  background: var(--foreground);

  max-width: var(--max-width);
  padding: 2rem 0 2em 0;
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;

  & h1 {
    font-size: 2rem;
    font-weight: 600;
  }

  & h2 {
    font-size: 1.75rem;
    font-weight: 600;
  }

  & h3 {
    font-size: 1.5rem;
    font-weight: 600;
  }

  & h4 {
    font-size: 1.25rem;
    font-weight: 600;
  }

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

  & > p,
  & > h1,
  & > h2,
  & > h3,
  & > h4 {
    width: 100%;
  }

  /*
   * markdown files nest img inside a <p> tag so we have use :not(:has)
   * here so images still go full-bleed, but everything else has padding
   * and a max-width
   */
  & > :not(:has(> img)):not(:has(> picture)):not(blockquote) {
    padding: 0 var(--side-padding);
    max-width: 70ch;
  }

  & img {
    width: 100%;
    max-height: 600px;
    height: auto;
    object-fit: contain;
  }

  & button,
  & calendar-multi::part(button) {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    outline: 1px solid var(--primary);
    cursor: default;
  }

  & button:hover,
  & button:focus-visible,
  calendar-multi::part(button):hover,
  calendar-multi::part(button):focus-visible {
    background: var(--primary);
    color: var(--primary-content);
  }

  & blockquote {
    width: 100%;
    background: var(--primary);
    color: var(--primary-content);

    font-size: 1.25rem;
    font-weight: 600;
    font-style: italic;

    & a {
      text-decoration: underline;
      text-underline-offset: 0.25rem;
      color: color-mix(in srgb, var(--primary-content) 95%, var(--primary) 5%);
    }

    @supports (text-decoration: underline dotted) {
      & a {
        text-decoration: underline dotted;
      }
    }

    & > p {
      width: 100%;
      max-width: 70ch;
      margin: 0 auto;
      padding: 2rem var(--side-padding);
    }
  }
}

side-drawer {
  width: 350px;
  max-width: 65vw;

  & > :first-child {
    height: 100%;
    width: 100%;

    padding: 1rem 0;

    background: var(--primary);
    color: var(--primary-content);

    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  & nav {
    display: flex;
    flex-direction: column;

    font-size: 1.25rem;
    gap: 0;

    & a {
      width: 100%;
      line-height: 4rem;
      padding: 0 2rem;

      &:hover,
      &:focus,
      &.active {
        background-color: var(--primary-dark);
        text-decoration: none;
      }
    }
  }

  & .logo-and-name {
    color: var(--primary-content);
    padding: 1rem;

    & > img {
      /* white */
      filter: invert(92%) sepia(100%) saturate(0%) hue-rotate(202deg)
        brightness(106%) contrast(106%);
    }
  }
}

table {
  border: 1px solid var(--border);
  table-layout: fixed;
  width: 100%;
}

th {
  font-weight: 700;
  background-color: var(--background);
  text-wrap: balance;
}

table,
th,
td {
  border-collapse: collapse;
  border: 1px solid var(--border);
}

footer {
  background: var(--foreground);

  max-width: var(--max-width);
  padding: 2rem var(--side-padding);
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 1rem;

  font-size: 1rem;
  font-weight: 600;

  border-top: 1px solid var(--border);

  & a {
    text-decoration: dotted underline;
    text-underline-offset: 0.25rem;
    color: color-mix(in srgb, var(--copy) 80%, var(--primary) 20%);
  }
}

strong {
  font-weight: 700;
}

em {
  font-style: italic;
}

.logo-and-name {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;

  font-size: 2rem;
  text-wrap: wrap;
  color: var(--copy-light);

  & > img {
    width: 3rem;
    filter: invert(51%) sepia(5%) saturate(562%) hue-rotate(40deg)
      brightness(95%) contrast(88%);
  }
}

.align-left {
  text-align: left;
}
.align-center {
  text-align: center;
}
.align-right {
  text-align: right;
}
