@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-next-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/atkinson-hyperlegible-next-italic-latin.woff2") format("woff2");
}

:root {
  --background: #1a1613;
  --surface: #2b2420;
  --masthead: #3c342f;
  --blue: #6d8aa4;
  --blue-dark: #425d75;
  --coral: #bd7352;
  --text: #f4eee6;
  --muted: #c2b7a9;
  --accent: #e6ad45;
  --link-hover: #ffd06d;
  --code: #f3ede5;
  --masthead-link: #f7f1e9;
  --prose-heading: #e6ad45;
  --inline-code-background: #352c27;
  --code-block-background: #2f2926;
  --code-block-shadow: rgb(5 3 2 / 62%);
  --quote: #efcb9f;
  --diagram-text: #f8f2ea;
  --syntax-comment: #9b948d;
  --syntax-keyword: #6facdf;
  --syntax-number: #e6ad45;
  --syntax-string: #b3d07a;
  --scrollbar: #665a50;
  --scrollbar-hover: #89796b;
  color-scheme: dark;
}

html[data-theme="light"] {
  --background: #f3ede3;
  --surface: #dfd5c7;
  --masthead: #e2d1bd;
  --blue: #829aae;
  --blue-dark: #526b80;
  --coral: #b86745;
  --text: #241b16;
  --muted: #5f544b;
  --accent: #935713;
  --link-hover: #5c3916;
  --code: #30251e;
  --masthead-link: #3b2a1d;
  --prose-heading: #7d471e;
  --inline-code-background: #e4dbcf;
  --code-block-background: #e7ded2;
  --code-block-shadow: rgb(67 49 34 / 20%);
  --quote: #604c3b;
  --diagram-text: #f7f1e8;
  --syntax-comment: #625950;
  --syntax-keyword: #315f82;
  --syntax-number: #b05f08;
  --syntax-string: #476f27;
  --scrollbar: #aa9e90;
  --scrollbar-hover: #786b5f;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--background);
  font-size: 17px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar {
  display: none;
}

.page-scrollbar {
  position: fixed;
  z-index: 10;
  top: 4px;
  right: 2px;
  bottom: 4px;
  width: 6px;
  pointer-events: none;
}

.page-scrollbar-thumb {
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 64px;
  background: var(--scrollbar);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
}

.page-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

.page-scrollbar-thumb:active {
  cursor: grabbing;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: "Atkinson Hyperlegible Next", "Segoe UI", sans-serif;
  font-size: 19px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  text-decoration: underline;
}

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

.wrap {
  width: min(100% - 40px, 820px);
  margin-inline: auto;
}

.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;
}

.masthead {
  position: relative;
  min-height: 136px;
  overflow: hidden;
  isolation: isolate;
  background: var(--masthead);
}

.masthead::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image: url("../images/banner-annealed.svg");
  background-position: center 1%;
  background-repeat: no-repeat;
  background-size: cover;
  filter: brightness(0.8) saturate(0.9);
  transform: scale(1.05);
}

.masthead-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.35rem;
  min-height: 136px;
  padding-bottom: 1.35rem;
}

.site-name {
  color: #f1eee7;
  font-size: 1.7rem;
  font-weight: 600;
  text-decoration: none;
  text-shadow: 0 1px 2px #0b0f14;
}

.site-name:hover {
  color: var(--link-hover);
  text-decoration: none;
}

.masthead nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 1rem;
}

.masthead nav a {
  color: #f1eee7;
  text-shadow: 0 1px 2px #0b0f14;
}

.masthead nav a:hover {
  color: var(--link-hover);
}

main {
  padding-block: 2.25rem 3rem;
}

section + section {
  margin-top: 2.4rem;
}

.intro {
  max-width: 48rem;
}

.intro p {
  margin: 0;
}

.intro p:first-child {
  color: var(--text);
  font-size: 1.12rem;
}

.intro p + p {
  margin-top: 0.85rem;
  font-family: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
  font-size: 0.92rem;
}

h1,
h2,
h3 {
  margin-top: 0;
  color: var(--text);
  font-weight: 600;
  line-height: 1.18;
}

h1 {
  margin-bottom: 0.45rem;
  font-size: clamp(2rem, 6vw, 2.7rem);
  letter-spacing: -0.025em;
}

h2 {
  margin-bottom: 0.8rem;
  font-size: 1.7rem;
  letter-spacing: -0.015em;
}

h3 {
  margin-bottom: 0.2rem;
  font-size: 1.12rem;
}

.projects {
  display: grid;
  gap: 0.9rem;
}

.project h3 {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}

.project h3 span {
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
  font-size: 0.82rem;
  font-weight: 400;
}

.project p {
  max-width: 46rem;
  margin: 0;
  color: var(--muted);
}

.article-list {
  display: grid;
  gap: 0.55rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.article-list li {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 0.05rem;
}

.article-list time,
.article-heading time {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
  font-size: 0.88rem;
}

.page-heading {
  margin-bottom: 1.3rem;
}

.article-list-all {
  gap: 0.7rem;
}

.prose {
  max-width: 46rem;
}

.article-heading {
  margin-bottom: 1.25rem;
}

.article-heading h1 {
  max-width: none;
  font-size: clamp(1.6rem, 5vw, 2.35rem);
}

.prose p,
.prose ul,
.prose ol {
  margin-block: 0.85rem;
}

.prose h2 {
  margin: 1.9rem 0 0.55rem;
  color: var(--prose-heading);
  font-size: 1.55rem;
}

.prose h3 {
  margin: 1.5rem 0 0.45rem;
  color: var(--prose-heading);
  font-size: 1.2rem;
}

.prose code {
  font-family: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
  font-size: 0.88em;
}

.prose p code {
  padding: 0.08em 0.25em;
  color: var(--code);
  background: var(--inline-code-background);
}

.highlight {
  overflow-x: auto;
  margin-block: 1.05rem;
  padding: 0.9rem 1rem;
  color: var(--code);
  background: var(--code-block-background);
  border-radius: 6px;
  box-shadow:
    0 10px 15px -6px var(--code-block-shadow),
    0 4px 6px -4px var(--code-block-shadow);
}

.highlight pre {
  margin: 0;
  line-height: 1.55;
  tab-size: 4;
}

.highlight .c,
.highlight .c1,
.highlight .cm {
  color: var(--syntax-comment);
}

.highlight .k,
.highlight .kt {
  color: var(--syntax-keyword);
}

.highlight .mi,
.highlight .kc,
.highlight .nb {
  color: var(--syntax-number);
}

.highlight .s,
.highlight .s1,
.highlight .s2 {
  color: var(--syntax-string);
}

.prose blockquote {
  margin: 1.2rem 0;
  color: var(--quote);
  font-size: 1.12rem;
  font-style: italic;
}

.verse {
  margin-block: 0.85rem 1rem;
  white-space: pre-wrap;
}

.scansion {
  overflow-x: auto;
  margin: 1.05rem 0;
  padding: 0.85rem 1rem 0.7rem;
  color: var(--code);
  background: var(--code-block-background);
  border-radius: 6px;
  box-shadow:
    0 10px 15px -6px var(--code-block-shadow),
    0 4px 6px -4px var(--code-block-shadow);
}

.scansion-line {
  display: flex;
  align-items: center;
  width: max-content;
  min-width: 100%;
  font-family: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
}

.scansion-syllable {
  display: grid;
  min-width: 2.25rem;
  justify-items: center;
  line-height: 1.25;
}

.scansion-syllable > span {
  font-size: 0.9rem;
}

.scansion-syllable b {
  color: var(--code);
  font-weight: 400;
}

.scansion-syllable.is-long > span {
  color: var(--syntax-number);
}

.scansion-syllable.is-short > span {
  color: var(--syntax-keyword);
}

.scansion-syllable.is-anceps > span {
  color: var(--muted);
}

.scansion-caesura {
  margin-inline: 0.2rem;
  color: var(--quote);
  font-family: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
}

.scansion-footbreak {
  margin-inline: 0.12rem;
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
}

.scansion figcaption {
  margin-top: 0.55rem;
}

.formatting-note {
  margin-block: 1.2rem;
}

.formatting-note summary {
  color: var(--accent);
  cursor: pointer;
}

.formatting-note summary:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.formatting-note[open] summary {
  margin-bottom: 0.65rem;
}

.technical-figure {
  margin: 1.35rem 0;
}

.memory-diagram {
  display: flex;
  min-height: 5rem;
  font-family: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.memory-diagram span {
  display: grid;
  place-items: center;
}

.memory-used {
  flex: 0 0 38%;
  color: var(--background);
  background: var(--coral);
}

.memory-free {
  flex: 1;
  color: var(--diagram-text);
  background: var(--masthead);
}

figcaption {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.article-navigation {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 2rem;
  margin-top: 2rem;
  font-size: 0.95rem;
}

.site-footer {
  padding-block: 0.5rem 2rem;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.site-footer small {
  font-size: 0.82rem;
}

.theme-toggle {
  display: inline-grid;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 0;
  place-items: center;
  color: var(--accent);
  background: transparent;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

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

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

.theme-toggle[hidden] {
  display: none;
}

@media (max-width: 620px) {
  body {
    font-size: 18px;
  }

  .wrap {
    width: min(100% - 28px, 820px);
  }

  .masthead,
  .masthead-inner {
    min-height: 116px;
  }

  .masthead::before {
    background-size: 100% 100%;
    transform: none;
  }

  .masthead-inner {
    gap: 0.55rem;
    padding-bottom: 1rem;
  }

  .masthead nav {
    gap: 1rem;
    font-size: 0.95rem;
  }

  main {
    padding-block: 1.75rem 2.4rem;
  }

  section + section {
    margin-top: 2rem;
  }

  .highlight {
    margin-block: 0.85rem;
    padding: 0.7rem 0.75rem;
  }

  .highlight code {
    font-size: 0.8em;
  }

  .highlight pre {
    line-height: 1.45;
  }

  .scansion {
    padding-inline: 0.75rem;
  }

  .scansion-syllable {
    min-width: 2rem;
  }

  .project h3 {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.15rem;
  }

}

@media print {
  .masthead {
    min-height: auto;
    background: white;
  }

  .masthead-inner {
    min-height: auto;
    padding-block: 1rem;
  }

  .masthead nav,
  .article-navigation,
  .page-scrollbar,
  .theme-toggle {
    display: none;
  }

  .masthead::before {
    display: none;
  }

  body,
  html {
    color: black;
    background: white;
  }
}
