:root {
  --bg: #ffffff;
  --surface: #f5f5f5;
  --text: #1a1a1a;
  --border: #d0d0d0;
  --accent: #00478f;
}

:root[data-theme="dark"] {
  --bg: #121212;
  --surface: #1e1e1e;
  --text: #f0f0f0;
  --border: #3a3a3a;
  --accent: #7ab8f5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --surface: #1e1e1e;
    --text: #f0f0f0;
    --border: #3a3a3a;
    --accent: #7ab8f5;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

th {
  background: var(--surface);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.nav-toggle {
  display: none;
}

#theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 25;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
}

/* Icon shown reflects the theme currently in effect: sun for light,
   moon for dark. Mirrors the light/dark variable rules above so it
   stays in sync without needing JS to run first. */
#theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] #theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] #theme-toggle .icon-moon {
  display: inline;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #theme-toggle .icon-sun {
    display: none;
  }

  :root:not([data-theme="light"]) #theme-toggle .icon-moon {
    display: inline;
  }
}

#site-nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
}

#site-nav-image {
  display: none;
}

#site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#site-nav li + li {
  margin-top: 0.5rem;
}

#site-nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  border-left: 3px solid transparent;
}

#site-nav a.is-active {
  border-left-color: var(--accent);
  font-weight: 600;
}

main {
  padding: 2rem 1.5rem;
  max-width: 53.55rem;
}

@media (min-width: 768px) {
  body {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
  }

  #site-nav {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }

  #site-nav-image {
    display: block;
    width: 100%;
    height: 300px;
    object-fit: cover;
    margin-bottom: 1.5rem;
  }
}

@media (max-width: 767.98px) {
  body {
    padding-top: 3.5rem;
  }

  main section {
    scroll-margin-top: 4rem;
  }

  .nav-toggle {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3.5rem;
    z-index: 20;
    padding: 0 1rem;
    font-size: 1.25rem;
    background: var(--surface);
    color: var(--text); /* keep the icon visible in dark mode */
    border: none;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }

  #theme-toggle {
    top: 0.5rem;
  }

  #site-nav {
    display: none;
  }

  #site-nav.is-open {
    display: block;
    position: fixed; /* keep the menu on-screen after scrolling */
    top: 3.5rem;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 15;
    background: var(--bg);
  }
}
