:root {
  color-scheme: light dark;

  --grid-columns: 12;
  --grid-gap: 1.5rem;
  --content-col-start: 3;
  --content-col-end: 11;

  --font-serif: "Libre Baskerville", Georgia, serif;
  --font-mono: "Courier Prime", ui-monospace, monospace;

  --bg: #0b0b0f;
  --fg: #f2f2f2;
  --fg-dim: #a0a0a8;
  --rule: #2a2a30;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), 1fr);
  column-gap: var(--grid-gap);
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
  /* JS sets --intro-top-pad when the intro uses a top noise bar */
  padding-top: max(4rem, var(--intro-top-pad, 0px));
}

.grid > * {
  grid-column: var(--content-col-start) / var(--content-col-end);
}

.hero {
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--rule);
}

.hero-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 0.5rem;
}

.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin: 0;
}

.edge-toggle {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-dim);
  cursor: pointer;
}

.edge-toggle:hover {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.edge-toggle:focus-visible {
  outline: 1px solid var(--fg-dim);
  outline-offset: 4px;
}

.edge-toggle[aria-pressed="true"] {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

h1 {
  font-size: 3rem;
  line-height: 1.15;
  margin: 0 0 1rem;
}

.lede {
  max-width: 40em;
  color: var(--fg-dim);
  font-size: 1.15rem;
  margin: 0 0 1.5rem;
}

.cta {
  margin: 0 0 2rem;
}

.cta.contact-links {
  margin-bottom: 2rem;
}

.resume-link {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--fg);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
}

.resume-link:hover {
  color: var(--fg-dim);
  border-bottom-color: var(--fg-dim);
}

.resume-link:focus-visible {
  outline: 1px solid var(--fg-dim);
  outline-offset: 4px;
}

.resume-preview {
  margin: auto;
  padding: 0;
  border: 0;
  background: var(--bg);
  width: min(96vw, 72rem);
  height: min(92vh, 70rem);
  max-width: 96vw;
  max-height: 92vh;
  color: var(--fg);
}

.resume-preview::backdrop {
  background: rgba(11, 11, 15, 0.92);
}

.resume-preview[open] {
  display: flex;
  flex-direction: column;
  animation: lightbox-in 220ms ease-out;
}

.resume-preview-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.25rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.resume-preview-open {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.resume-preview-open:hover {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.resume-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  font-family: var(--font-mono);
}

.site-nav a {
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 1px solid transparent;
}

.site-nav a:hover {
  border-bottom-color: var(--fg);
}

.block {
  padding: 3rem 0;
  border-bottom: 1px solid var(--rule);
}

.block:last-of-type {
  border-bottom: none;
}

h2 {
  font-size: 1.75rem;
  margin: 0 0 1.25rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.num {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--fg-dim);
}

.project {
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
}

.project:first-of-type {
  margin-top: 0.5rem;
}

.project:last-child {
  padding-bottom: 0;
}

.project h3 {
  font-size: 1.15rem;
  font-weight: 400;
  margin: 0 0 0.35rem;
}

.project-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-dim);
  margin: 0 0 0.75rem;
}

.project-links {
  margin: 0.85rem 0 0;
}

.project-media {
  display: block;
  margin: 1.25rem 0 0;
  max-width: 40em;
}

.project-demo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  cursor: zoom-in;
}

.project-demo--art {
  aspect-ratio: 480 / 370;
  object-fit: contain;
  background: #000;
}

.project-demo:focus-visible {
  outline: 1px solid var(--fg-dim);
  outline-offset: 4px;
}

#writing::after {
  content: "";
  display: block;
  clear: both;
}

.about-body {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.about-copy p:last-child {
  margin-bottom: 0;
}

.portrait {
  display: block;
  /* Stacked: keep it well under the column width so it doesn't dominate. */
  width: min(68%, 12.5rem);
  margin: 0 0 1.75rem;
  flex-shrink: 0;
}

#about .portrait {
  margin-bottom: 0;
}

@media (min-width: 900px) {
  .about-body {
    flex-direction: row;
    align-items: flex-start;
    gap: 2.5rem;
  }

  .about-copy {
    flex: 1;
    min-width: 0;
  }

  .portrait {
    float: left;
    width: 18rem;
    margin: 0 2.5rem 1.5rem 0;
  }

  #about .portrait {
    float: none;
    margin: 0;
  }

  .portrait--right {
    float: right;
    margin: 0 0 1.5rem 2.5rem;
  }
}

@media (min-width: 1100px) {
  .portrait {
    width: 13.5rem;
  }

  #about .portrait {
    width: 13.5rem;
  }
}

.portrait-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: center top;
  cursor: zoom-in;
}

.portrait-img:focus-visible {
  outline: 1px solid var(--fg-dim);
  outline-offset: 4px;
}

.lightbox {
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  max-width: min(96vw, 56rem);
  max-height: 96vh;
  color: var(--fg);
}

.lightbox::backdrop {
  background: rgba(11, 11, 15, 0.92);
}

.lightbox[open] {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  animation: lightbox-in 220ms ease-out;
}

.lightbox-img {
  display: block;
  width: 100%;
  max-height: calc(96vh - 3rem);
  height: auto;
  object-fit: contain;
}

.lightbox-close {
  align-self: flex-end;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  color: var(--fg);
}

.lightbox-close:focus-visible {
  outline: 1px solid var(--fg-dim);
  outline-offset: 4px;
}

@keyframes lightbox-in {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

p {
  margin: 0 0 1.25rem;
  max-width: 40em;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: inherit;
}

.email-wrap {
  margin-top: 0.25rem;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin: 0;
}

.email-canvas {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  vertical-align: baseline;
}

.email-canvas canvas {
  display: block;
  height: 1.15em;
}

.email-canvas:hover canvas,
.email-canvas:focus-visible canvas {
  opacity: 0.75;
}

.email-canvas:focus-visible {
  outline: 1px solid var(--fg-dim);
  outline-offset: 4px;
}

.email-canvas.is-copied {
  cursor: default;
}

footer {
  padding-top: 2rem !important;
  border-bottom: none;
}

footer a {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--fg-dim);
}

footer a:hover {
  color: var(--fg);
}

/* Blog pages are generated from Markdown by build_blog.py. */
.blog-grid {
  min-height: 100vh;
}

.blog-hero h1 {
  max-width: 18em;
}

.post-date {
  margin: -0.35rem 0 1.5rem;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.blog-index {
  min-height: 18rem;
}

.empty-blog {
  display: grid;
  align-content: center;
  min-height: 12rem;
}

.empty-blog > p:last-child {
  margin-top: 0.35rem;
  font-size: 1.3rem;
}

.blog-entry {
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
}

.blog-entry:first-child {
  border-top: 0;
  padding-top: 0;
}

.blog-entry h2 {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 1.25rem;
}

.blog-entry h2 a {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.post-content {
  overflow-wrap: anywhere;
}

.post-content > :first-child {
  margin-top: 0;
}

.post-content h1 {
  font-size: 2rem;
  margin: 2.75rem 0 1rem;
}

.post-content h2 {
  display: block;
  margin: 2.75rem 0 1rem;
  font-size: 1.55rem;
}

.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 400;
}

.post-content ul,
.post-content ol {
  max-width: 40em;
  margin: 0 0 1.25rem;
  padding-left: 1.5rem;
}

.post-content li + li {
  margin-top: 0.45rem;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.post-content :not(pre) > code {
  padding: 0.08em 0.3em;
  border: 1px solid var(--rule);
  background: #111116;
}

.post-content pre {
  max-width: 100%;
  margin: 1.5rem 0;
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
  background: #111116;
  line-height: 1.45;
}

.post-content pre code {
  display: block;
  overflow-wrap: normal;
  white-space: pre;
}

/* Highlight.js tokens, tuned to the site's existing dark palette. */
.post-content .hljs {
  color: #c9d1d9;
  background: transparent;
}

.post-content .hljs-comment,
.post-content .hljs-quote {
  color: #8b949e;
  font-style: italic;
}

.post-content .hljs-keyword,
.post-content .hljs-selector-tag,
.post-content .hljs-type {
  color: #ff7b72;
}

.post-content .hljs-title,
.post-content .hljs-title.class_,
.post-content .hljs-title.function_,
.post-content .hljs-string,
.post-content .hljs-regexp {
  color: #a5d6ff;
}

.post-content .hljs-number,
.post-content .hljs-literal,
.post-content .hljs-symbol,
.post-content .hljs-bullet {
  color: #79c0ff;
}

.post-content .hljs-attr,
.post-content .hljs-attribute,
.post-content .hljs-built_in,
.post-content .hljs-name,
.post-content .hljs-selector-id,
.post-content .hljs-selector-class {
  color: #7ee787;
}

.post-content .hljs-variable,
.post-content .hljs-template-variable,
.post-content .hljs-params {
  color: #ffa657;
}

.post-content .hljs-meta,
.post-content .hljs-meta .hljs-keyword,
.post-content .hljs-doctag {
  color: #d2a8ff;
}

.post-content .hljs-emphasis {
  font-style: italic;
}

.post-content .hljs-strong {
  font-weight: 700;
}

.post-content blockquote {
  max-width: 40em;
  margin: 1.5rem 0;
  padding-left: 1.25rem;
  border-left: 1px solid var(--fg-dim);
  color: var(--fg-dim);
}

.post-content hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.blog-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
}

/* The character grid (js/text-grid.js). Absolutely positioned and as tall as
   the document, so it is part of the scrolling content: the compositor moves
   it with the page and nothing has to be repainted at a scroll offset. Being
   DOM text there is no backing store, which is what makes a document-tall
   grid affordable — the effects only ever *update* the rows near the viewport. */
.tg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9999;
  pointer-events: none;
  overflow: hidden;
  contain: layout paint style;
}

/* One plane per palette colour, stacked. Each is a single colour so its rows
   are plain text with no per-character markup — see text-grid.js. */
.tg-plane {
  position: absolute;
  top: 0;
  left: 0;
}

.tg-plane > div {
  height: 24px;
  white-space: pre;
}

/* One pixel per cell, scaled up so each pixel becomes a cell-sized block. */
.tg-bg {
  position: absolute;
  top: 0;
  left: 0;
  /* Order matters: each line overrides the one above, so the modern keyword
     goes LAST. Smooth interpolation here turns every cell into a soft blob
     instead of a hard rectangle. */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* Flappy overlays glyphs on the text grid; lock scroll while playing. */
body.flappy-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  :root {
    --content-col-start: 1;
    --content-col-end: 13;
  }

  h1 {
    font-size: 2.25rem;
  }
}
