:root {
  color-scheme: light;
  --paper: #efe7d8;
  --ink: #111111;
  --muted: color-mix(in srgb, var(--ink) 64%, var(--paper));
  --faint: color-mix(in srgb, var(--ink) 12%, var(--paper));
  --accent: var(--ink);
  --weight: 400;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --measure: 40rem;
  --gutter: clamp(1rem, 5vw, 2.5rem);
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111316;
  --ink: #e8e6e1;
  --muted: color-mix(in srgb, var(--ink) 80%, var(--paper));
  --faint: color-mix(in srgb, var(--ink) 18%, var(--paper));
  --weight: 420;
}

/* Legacy aliases kept for scripts and older markup. */
:root, [data-theme="dark"] {
  --bg: var(--paper);
  --text: var(--ink);
  --rule: var(--faint);
  --accent-soft: color-mix(in srgb, var(--ink) 6%, transparent);
}

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

html { -webkit-text-size-adjust: 100%; min-height: 100%; scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: var(--weight);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

::selection { background: color-mix(in srgb, var(--ink) 18%, transparent); }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, var(--ink) 25%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
  transition: text-decoration-color .15s, color .15s;
}

a:hover { text-decoration-color: currentColor; }

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

/* Layout */

.site-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 0 var(--gutter);
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--measure);
  padding: 4.5rem 0 5rem;
}

/* Header */

.site-header {
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
  padding-top: 1.9rem;
  font-size: .8125rem;
}

.site-header .site-title {
  margin: 0;
  font: inherit;
  line-height: 1;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.6rem;
}

.site-header a,
.site-footer a {
  color: var(--muted);
  text-decoration: none;
  text-transform: lowercase;
}

.site-header a:hover,
.site-footer a:hover,
.site-header a.active,
.site-header a[aria-current="page"] { color: var(--ink); }

.home-face {
  font-size: 1rem;
  line-height: 1;
}

.theme-toggle {
  appearance: none;
  padding: .25rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

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

body[data-post-count="0"] .site-nav a[href="#writing"],
body[data-post-count="0"] .site-nav a[href="/#writing"],
body[data-post-count="0"] .writing {
  display: none;
}

/* Shared type */

.label {
  margin: 0;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 400;
  letter-spacing: .02em;
  text-transform: lowercase;
}

.page-title {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.1rem);
  font-weight: 550;
  line-height: 1.15;
  letter-spacing: -.02em;
  text-wrap: balance;
}

.meta,
.post-meta,
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1rem;
  color: var(--muted);
  font-size: .75rem;
  text-transform: lowercase;
}

/* Landing scene */

body.has-scene { position: relative; }

.mountain-scene,
.scene-fade {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  height: var(--scene-h, 100svh);
  pointer-events: none;
}

.mountain-scene { display: block; }

.scene-fade {
  background: linear-gradient(to bottom, transparent 68%, var(--paper) 100%);
}

body.has-scene .intro {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  box-sizing: border-box;
  min-height: calc(var(--scene-h, 100svh) - 8.4rem);
  padding-top: clamp(1.5rem, 10vh, 7rem);
}

body.has-scene .writing { padding-top: 1.5rem; }

@media (max-width: 699px) {
  body.has-scene .intro { padding-top: clamp(1rem, 6vh, 3rem); }
}

/* Landing intro */

.intro {
  color: color-mix(in srgb, var(--ink) 82%, var(--paper));
  font-size: .875rem;
  line-height: 1.85;
}

.intro p { margin: 0 0 1.4em; }
.intro p:last-child { margin: 0; }
.intro a { color: var(--ink); text-underline-offset: .3em; }

.intro > p:first-child::after {
  content: "";
  display: inline-block;
  width: .6em;
  height: 1.15em;
  margin-left: .3em;
  vertical-align: -.2em;
  background: currentColor;
  opacity: .75;
  animation: 1.1s step-end infinite cursor-blink;
}

@keyframes cursor-blink { 50% { opacity: 0; } }

.intro-links,
.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .6rem;
}

.intro-links a + a::before {
  content: "/";
  margin-right: .6rem;
  color: var(--muted);
}

/* Sections */

.writing { padding: 3.5rem 0 0; }

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.section-heading h1,
.about h2 {
  margin: 0;
  font-size: clamp(1.4rem, 3.5vw, 1.7rem);
  font-weight: 550;
  line-height: 1.2;
  letter-spacing: -.02em;
  text-transform: lowercase;
}

.section-heading span {
  color: var(--muted);
  font-size: .75rem;
  white-space: nowrap;
}

.empty-state { margin: 0; color: var(--muted); font-size: .875rem; }

.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .25rem 1.5rem;
  align-items: baseline;
  padding: .85rem 0;
  border-bottom: 1px solid var(--faint);
}

.post-list li:first-child { border-top: 1px solid var(--faint); }

.post-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .6em;
  min-width: 0;
}

.post-number {
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.4;
  padding-top: .1em;
  white-space: nowrap;
  opacity: .8;
}

.post-list a {
  min-width: 0;
  font-size: .9375rem;
  font-weight: 450;
  line-height: 1.4;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.post-list a:hover {
  text-decoration: underline 1px;
  text-underline-offset: .22em;
}

.post-meta { white-space: nowrap; }

/* About page */

main.wide { max-width: var(--measure); }

.page-header { margin-bottom: 2.5rem; }

.page-intro {
  max-width: 36rem;
  margin: .9rem 0 0;
  color: var(--muted);
  font-size: .9375rem;
  line-height: 1.75;
}

.about-section {
  padding: 1.75rem 0;
  border-top: 1px solid var(--faint);
}

.about-section:first-child { padding-top: 0; border-top: 0; }

.about-section h2 { margin: .2rem 0 .9rem; }

.about-section ul {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.about-section li { line-height: 1.6; }

.item-name {
  display: block;
  color: var(--ink);
  font-weight: 500;
}

.item-name a { text-decoration-color: color-mix(in srgb, var(--ink) 22%, transparent); }

.item-desc {
  display: block;
  margin-top: .1rem;
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.6;
}

@media (min-width: 1180px) {
  .about-section {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: 3rem;
    margin-left: -15rem;
  }
  .about-section h2 { margin: .2rem 0 0; }
}

/* Article */

.article-header { margin-bottom: 2.5rem; }

.article-header h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.1rem);
  font-weight: 550;
  line-height: 1.15;
  letter-spacing: -.02em;
  text-wrap: balance;
}

.article-header .article-meta { margin: .9rem 0 0; }

.article-meta [aria-hidden="true"] { display: none; }

.article-body { font-size: .9375rem; line-height: 1.75; }

.article-body > :first-child { margin-top: 0; }

.article-body p,
.article-body ul,
.article-body ol,
.article-body blockquote { margin: 0 0 1.1em; }

.article-body h2 {
  margin: 2.2em 0 .6em;
  font-size: 1.3rem;
  font-weight: 550;
  line-height: 1.3;
  letter-spacing: -.015em;
}

.article-body h3 {
  margin: 2em 0 .5em;
  font-size: 1.05rem;
  font-weight: 550;
}

.article-body strong { font-weight: 600; }

.article-body ul,
.article-body ol { padding-left: 1.3em; }

.article-body ul { list-style: none; }
.article-body ul > li { position: relative; }

.article-body ul > li::before {
  content: "";
  position: absolute;
  top: .78em;
  left: -1em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .6;
}

.article-body li { margin: .35em 0; }

.article-body blockquote {
  padding: .1em 0 .1em 1.1em;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

.article-body blockquote p { margin: .4em 0; }

.article-body a { overflow-wrap: anywhere; }

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

.article-body code { font-size: .88em; }

.article-body pre {
  margin: 1.5em 0;
  padding: .8rem .9rem;
  overflow-x: auto;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  font-size: .8125rem;
  line-height: 1.6;
}

.article-body pre code { font-size: inherit; }

.article-break,
.article-body hr {
  margin: 2.5em 0;
  border: 0;
  color: var(--muted);
  text-align: center;
}

.article-break::after,
.article-body hr::after {
  content: "· · ·";
  letter-spacing: .6em;
}

.article-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--faint);
  color: var(--muted);
  font-size: .8125rem;
  text-transform: lowercase;
}

.article-footer a { text-decoration: none; }

.article-footer a:hover {
  text-decoration: underline 1px;
  text-underline-offset: .22em;
}

/* Not found */

.not-found {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.not-found-code {
  margin: 0 0 .4rem;
  color: var(--muted);
  font-size: .75rem;
}

.not-found h1 {
  margin: 0 0 .9rem;
  font-size: clamp(1.7rem, 4vw, 2.1rem);
  font-weight: 550;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.not-found p { margin: 0 0 .6rem; font-size: .9375rem; }

/* Footer */

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  width: 100%;
  max-width: var(--measure);
  padding: 2rem 0 2.5rem;
  color: var(--muted);
  font-size: .75rem;
}

/* Theme reveal */

@property --reveal-radius {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@keyframes vt-reveal {
  to { --reveal-radius: calc(var(--reveal-r) + var(--reveal-feather)); }
}

:root[data-transition="theme"]::view-transition-old(root) { animation: none; }

:root[data-transition="theme"]::view-transition-new(root) {
  --reveal-feather: 64px;
  mix-blend-mode: normal;
  -webkit-mask-image: radial-gradient(circle at var(--reveal-x) var(--reveal-y), #000 calc(var(--reveal-radius) - var(--reveal-feather)), transparent var(--reveal-radius));
  mask-image: radial-gradient(circle at var(--reveal-x) var(--reveal-y), #000 calc(var(--reveal-radius) - var(--reveal-feather)), transparent var(--reveal-radius));
  animation: .8s cubic-bezier(.4, 0, .2, 1) both vt-reveal;
}

/* Responsive */

@media (max-width: 520px) {
  .site-nav { gap: 1rem; }
  .post-list li { grid-template-columns: 1fr; }
  .site-footer { flex-direction: column; gap: .2rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
  .intro > p:first-child::after { animation: none; }
}

/* Open Graph capture mode: the glen alone at 1200 x 630. */
html.og body > .site-shell { visibility: hidden; }
html.og .mountain-scene { width: 1200px; height: 630px; }
