:root {
  --bg: #f6f1e7;
  --text: #2e2a24;
  --accent: #3d7a4f;
  --accent-soft: #6ba478;
  --hover: #b8860b;
  --selection: rgba(61, 122, 79, 0.2);
  --border: color-mix(in srgb, var(--text) 15%, transparent);

  --fs-page-title: clamp(2.1875rem, 1.9rem + 1vw, 2.5rem);
  --fs-nav-title: clamp(2rem, 1.25rem + 3.1vw, 3rem);
  --fs-section: clamp(1.6rem, 1.35rem + 1vw, 1.875rem);
  --fs-subhead: clamp(1.25rem, 1.15rem + 0.4vw, 1.4rem);
  --fs-body: clamp(1.125rem, 0.85rem + 1.6vw, 1.5rem);
  --fs-nav-links: clamp(1.4rem, 1.1rem + 1.25vw, 1.75rem);
  --fs-small: clamp(0.9rem, 0.85rem + 0.25vw, 1rem);
  --fs-micro: clamp(0.75rem, 0.7rem + 0.2vw, 0.8rem);

  background-color: var(--bg);
  color: var(--text);
  color-scheme: light;

  font-family: Georgia, "Times New Roman", serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14201a;
    --text: #d8e0d6;
    --accent: #7fc472;
    --accent-soft: #5fa15a;
    --hover: #d4a040;
    --selection: rgba(127, 196, 114, 0.28);

    color-scheme: dark;
  }
}

:root[data-theme="light"] {
  --bg: #f6f1e7;
  --text: #2e2a24;
  --accent: #3d7a4f;
  --accent-soft: #6ba478;
  --hover: #b8860b;
  --selection: rgba(61, 122, 79, 0.2);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #14201a;
  --text: #d8e0d6;
  --accent: #7fc472;
  --accent-soft: #5fa15a;
  --hover: #d4a040;
  --selection: rgba(127, 196, 114, 0.28);

  color-scheme: dark;
}

::selection {
  background-color: var(--selection);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  display: flex;
  flex-direction: column;
  width: 80%;
  max-width: 1700px;
  padding: 0 2%;
  margin: 0 auto;
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: underline dashed;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
  transition: .2s ease color;
}
a:hover {
  color: var(--hover);
  text-decoration: underline;
  transition: .2s ease color;
}
a.current {
  color: var(--hover);
}

a span {
  text-decoration: none;
}

a .faded {
  display: inline-block;
  text-decoration: none;
}

.title-link,
.title-link:hover {
  color: var(--text);
  text-decoration: none;
}

.faded {
  opacity: .55;
}

main {
  display: flex;
  flex-direction: column;
  flex: 1;
  content-visibility: auto;
  contain-intrinsic-size: 800px;
}

.three-stars {
  text-align: center;
  letter-spacing: 1.5rem;
  opacity: .35;
  font-size: var(--fs-section);
  font-family: Georgia, "Times New Roman", serif;
  margin-top: auto;
}

@media (max-width: 960px) {
  body {
    width: 100%;
    padding: 0 3%;
  }

  img, video, canvas, iframe, svg {
    max-width: 100%;
    height: auto;
  }

  pre, code {
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
  }
}

#page-loader {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  width: 100%;
  height: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#page-loader.active {
  opacity: 1;
  background: var(--accent-soft);
  overflow: hidden;
}

#page-loader.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: -30%;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--hover), transparent);
  animation: loader-peg 0.8s ease-in-out infinite;
}

#page-loader.done {
  opacity: 1;
  background: var(--accent-soft);
}

#page-loader.done::after {
  content: none;
}

@keyframes loader-peg {
  0%   { left: -30%; }
  100% { left: 100%; }
}

.theme-toggle {
  font: inherit;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: inherit;
  text-decoration: none;
}
.theme-toggle::before {
  content: "[";
  margin-right: 0;
  transition: margin-right 0.2s ease;
}
.theme-toggle::after {
  content: "]";
  margin-left: 0;
  transition: margin-left 0.2s ease;
}
@media (hover: hover) {
  .theme-toggle:hover {
    color: var(--hover);
    text-decoration: underline;
  }
  .theme-toggle:hover::before {
    margin-right: 0.15em;
  }
  .theme-toggle:hover::after {
    margin-left: 0.15em;
  }
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
