/*
 * Design parameters (from the project brief):
 *   - dark grey on light grey in light mode, the inverse in dark mode
 *   - system monospaced font
 *   - base font size slightly above average (~14pt / 18px)
 *   - no header; single column; fluid width up to a max on desktop
 *
 * Theme selection:
 *   :root                      -> light (default)
 *   @media (prefers-color-scheme: dark) :root -> follow a dark OS ("system")
 *   :root[data-theme="light"]  -> forced light  (set by the toggle)
 *   :root[data-theme="dark"]   -> forced dark   (set by the toggle)
 * The forced rules come last and outweigh the media query, so an explicit
 * choice always wins; with no choice, the OS preference is followed.
 */

:root {
  color-scheme: light dark;
  --bg: #e7e7e7;
  --fg: #232323;
  --muted: #6b6b6b;
  --rule: #c9c9c9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1d1d;
    --fg: #d8d8d8;
    --muted: #9a9a9a;
    --rule: #454545;
  }
}

:root[data-theme="light"] {
  --bg: #e7e7e7;
  --fg: #232323;
  --muted: #6b6b6b;
  --rule: #c9c9c9;
}

:root[data-theme="dark"] {
  --bg: #1d1d1d;
  --fg: #d8d8d8;
  --muted: #9a9a9a;
  --rule: #454545;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 112.5%; /* ~18px / ~14pt base */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  /* font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "DejaVu Sans Mono", monospace; */
  font-family: "Anonymous Pro", monospace;
  line-height: 1.6;
}

/* Single column, fluid to the viewport, capped for comfortable reading. */
main {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 4rem 1.25rem 6rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.25;
  margin: 2rem 0 1rem;
}

h1:first-child,
h2:first-child,
h3:first-child {
  margin-top: 0;
}

p,
ul,
ol,
blockquote,
pre,
table {
  margin: 0 0 1rem;
}

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

blockquote {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

pre,
code {
  font-family: inherit;
}

pre {
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
}

code {
  padding: 0.1em 0.3em;
  border: 1px solid var(--rule);
  white-space: nowrap;
}

pre code {
  padding: 0;
  border: 0;
}

img {
  max-width: 100%;
  height: auto;
}

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

th,
td {
  border: 1px solid var(--rule);
  padding: 0.4em 0.6em;
  text-align: left;
}

/* Theme toggle: small, quiet, tucked into the top-right corner. */
.theme-toggle {
  position: fixed;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
}

.theme-toggle button {
  font: inherit;
  font-size: 0.7rem;
  padding: 0.2em 0.5em;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule);
  cursor: pointer;
}

.theme-toggle button:hover {
  color: var(--fg);
}

.theme-toggle button[aria-pressed="true"] {
  color: var(--bg);
  background: var(--fg);
  border-color: var(--fg);
}

@media (prefers-reduced-motion: no-preference) {
  .theme-toggle button {
    transition: color 0.1s, background-color 0.1s;
  }
}

/* Quiet "home" link at the foot of every non-homepage. */
.home-link {
  max-width: 42rem;
  margin: -3rem auto 0;
  padding: 0 1.25rem 4rem;
  text-align: center;
  color: var(--muted);
}

.home-link a {
  color: inherit;
}
