/**
  Variables for simple theming.
  Simple dark mode included
**/
:root {
  /* Base Shades - These stay constant regardless of theme */
  --shade-0: rgb(0, 0, 0);
  --shade-5: rgb(5, 5, 5);
  --shade-25: rgb(25, 25, 25);
  --shade-50: rgb(50, 50, 50);
  --shade-75: rgb(75, 75, 75);
  --shade-100: rgb(100, 100, 100);
  --shade-125: rgb(125, 125, 125);
  --shade-150: rgb(150, 150, 150);
  --shade-175: rgb(175, 175, 175);
  --shade-200: rgb(200, 200, 200);
  --shade-225: rgb(225, 225, 225);
  --shade-250: rgb(250, 250, 250);
  --shade-255: rgb(255, 255, 255);

  /* Status Colors */
  --color-danger: red;
  --color-success: green;
  --color-caution: orange;
  --color-accent: hotpink;

  /* Semantic Colors - Light Mode Defaults */
  --background: #f5f5f5;
  --text: var(--shade-0);
  --surface-light: var(--shade-225);
  --surface-medium: var(--shade-175);
  --surface-dark: var(--shade-50);
  --border: var(--shade-50);
  --surface-hover: var(--shade-175);
  --surface-active: var(--shade-25);
  --text-inverse: var(--shade-255);

  /* Utility Variables */
  --border-radius: 4px;
  --section-border: 1px solid rgba(0 0 0 / 0.5);
  --form-border: 1px solid rgba(0 0 0 / 0.3);
}

/*
  Change semantic colors for dark mode
*/
@media (prefers-color-scheme: dark) {
  :root {
    /* Semantic Colors - Dark Mode Values */
    --background: #232323;
    --text: var(--shade-255);
    --surface-light: var(--shade-50);
    --surface-medium: var(--shade-100);
    --surface-dark: var(--shade-225);
    --border: var(--shade-200);
    --surface-hover: var(--shade-100);
    --surface-active: var(--shade-225);
    --text-inverse: var(--shade-0);

    --section-border: 1px solid rgba(230 230 230 / 0.5);
    --form-border: 1px solid rgba(230 230 230 / 0.3);
  }
}

@layer vanillaHTML;

@layer vanillaHTML {
  *:focus,
  *:focus-visible {
    outline-color: var(--color-accent);
    outline-style: solid;
    outline-width: 3px;
  }

  @font-face {
    font-family: Inter-Italic;
    src: url("/Inter-VariableFont_opsz\,wght.ttf");
  }
  @font-face {
    font-family: Inter-Regular;
    src: url("/Inter-VariableFont_opsz\,wght.ttf");
  }
  body {
    font-family: "Inter-Regular";
    background-color: var(--background);
    color: var(--text);
    font-size: 1.05em;
    accent-color: var(--color-accent);
    font-optical-sizing: auto;
    font-style: normal;
  }
  body > header {
    border-bottom: 1px solid;
  }
  body > header > nav {
    max-width: 1200px;
    margin: auto;
    padding: 2rem;
  }
  body > header > nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
  body > header > nav > menu {
    list-style-type: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0;
  }

  a:not([class]) {
    display: inline-block;
    text-decoration: underline;
    border: none;
    padding: 0 0.25rem;
    position: relative;
  }

  main {
    max-width: 1200px;
    margin: auto;
    padding: 2rem;
    padding-top: 0;
  }
  section {
    border: var(--section-border);
    display: grid;
    gap: 1rem;
    margin-block: 4rem;
  }
  section:first-child {
    margin-block-start: 2rem;
  }
  section > :last-child {
    margin-block-end: 1rem;
  }
  section > header {
    background: var(--surface-dark);
    color: var(--text-inverse);
    padding: 1rem;
  }
  section > header > hgroup {
    box-shadow: none;
  }
  section > *:not(header) {
    margin-inline: 1rem;
  }
  section > header > hgroup:has(small) > p {
    margin-top: 0;
  }
  :has(h1, h2, h3, h4, p, figure, blockquote, dl, dd) {
    h1,
    h2,
    h3,
    h4,
    p,
    figure,
    blockquote,
    dl,
    dd {
      &:nth-child(1) {
        margin-block-start: 0;
      }
    }
  }

  code {
    background: var(--border);
    padding: 0.15rem;

    color: var(--text-inverse);
    border: 1px solid var(--surface-light);
    font-size: 0.95rem;
  }

  div:has(table) {
    max-width: 100%;
    overflow: auto;
  }

  table {
    margin-block-start: 1rem;

    border: var(--form-border);
    border-spacing: 0;
    overflow: hidden;
    width: 100%;
  }

  td,
  th {
    padding: 1rem;
  }

  tbody td,
  th {
    border-bottom: var(--form-border);
  }

  tr:nth-child(even),
  th {
    background-color: var(--surface-light);
  }

  td:not(:nth-last-child(1)),
  th:not(:nth-last-child(1)) {
    border-right: var(--form-border);
  }

  tfoot tr td:nth-child(1) {
    border-top: var(--section-border);
  }

  aside {
    color: white;
    background: var(--shade-75);
    display: block;
    padding: 1rem;
    border-left: 5px solid var(--surface-medium);
  }
  aside[role="alert"] {
    --light-danger: #ffc4c4;
    border-color: var(--color-danger);
    background: var(--light-danger);
    color: black;
  }
  form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border: var(--form-border);
    padding: 1rem;

    margin-block-start: 1rem;
  }

  fieldset {
    border: var(--form-border);
  }

  input,
  input + label,
  label:has(input) {
    cursor: pointer;
  }

  input[type="email"],
  input[type="password"],
  input[type="text"],
  input[type="search"] {
    padding: 0.5rem;
    border: var(--section-border);
    width: fit-content;
    cursor: text;
  }

  form:has(input[type="email"])
    input[type="email"]:not(:placeholder-shown):valid,
  form:has(input[type="password"])
    input[type="password"]:not(:placeholder-shown):valid {
    outline-color: var(--color-success);
  }

  form:has(input[type="email"])
    input[type="email"]:not(:placeholder-shown):invalid,
  form:has(input[type="password"])
    input[type="password"]:not(:placeholder-shown):invalid {
    outline-color: var(--color-caution);
  }

  form:has(input[type="email"]) input[type="email"]:focus,
  form:has(input[type="password"]) input[type="password"]:focus {
    outline-color: var(--color-danger);
  }

  input[type="range"] {
    display: block;
    cursor: ew-resize;
  }

  input[type="color"] {
    inline-size: 40px;
    block-size: 40px;
  }

  button:not([popovertarget]) {
    padding: 0.5rem 1rem;
    border: var(--section-border);
    background-color: var(--text);
    color: var(--background);

    width: fit-content;
    cursor: pointer;
  }

  button:not([popovertarget]):hover {
    background-color: var(--surface-dark);
  }

  button:not([popovertarget]):active {
    background: var(--surface-active);
    scale: 0.95;
  }

  details {
    border: var(--form-border);
  }

  details div {
    padding: 1rem;
    border-top: var(--form-border);
  }

  summary {
    color: var(--text);
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
  }

  details:not([open]) summary:focus,
  details:not([open]) summary:focus-visible,
  details:not([open]) summary:hover {
    background-color: var(--surface-hover);
    color: var(--text);
  }

  details[open] summary {
    background-color: var(--surface-dark);
    color: var(--text-inverse);
  }

  details[open] summary:hover {
    background-color: var(--surface-hover);
    color: var(--text);
  }

  abbr {
    font-style: italic;
    border-bottom: 1px dotted;
  }

  textarea {
    resize: none;
    padding: 0.75rem;
  }

  div:has(> blockquote) {
    background-color: var(--text);
    color: var(--background);
    padding: 0.75rem;
  }

  div:has(> blockquote) > p {
    text-align: right;
    margin-inline-start: 20px;
    margin-inline-end: 20px;
  }

  blockquote {
    margin-inline-start: 20px;
  }

  blockquote p::before {
    content: "\201C";
  }

  blockquote p::after {
    content: "\201D";
  }
}

dt {
  font-size: 1.125rem;
  font-weight: 600;
  border-bottom: 1px solid;
  width: fit-content;
}

dd {
  margin-block-start: 0.5rem;
  margin-block-end: 0.75rem;
}

dd:before {
  content: "\25B6";
  font-size: 0.75rem;
}

footer {
  background: var(--surface-dark);
  color: var(--text-inverse);
  min-height: 30vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
footer p {
  margin: 0;
}
footer menu {
  list-style-type: none;
  margin: 0;
  padding: 0;
}
footer > div {
  padding: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
}
footer > aside {
  border: none;
  padding: 0.5rem 1rem;
  color: white;
  background: var(--shade-100);
}
