/* Ross Owen: square paper sheets, dark card stock by default, warm paper as the alternative. */
:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --gap: clamp(1rem, 2.4vw, 1.6rem);
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.28  0 0 0 0 0.2  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
[data-theme="dark"] {
  color-scheme: dark;
  --desk: #0f1012; --paper: #1b1c1f; --line: #8b8172; --rule: #34342f;
  --text: #ece6da; --muted: #aaa293; --accent: #dba664; --accent-2: #cf7c58; --on-accent: #1a1410;
}
[data-theme="paper"] {
  color-scheme: light;
  --desk: #e6dcc6; --paper: #f8f2e5; --line: #2f2a23; --rule: #cdbf9f;
  --text: #2b2620; --muted: #6a604f; --accent: #8f5420; --accent-2: #a3462a; --on-accent: #fbf6ec;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--desk); color: var(--text); font: 1.02rem/1.6 var(--sans); }
a { color: var(--accent); text-underline-offset: .2em; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
img, canvas { display: block; max-width: 100%; height: auto; }
canvas { width: 100%; }
.meta { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.tag { color: var(--accent-2); text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; }
.skip { position: absolute; left: -999rem; }
.skip:focus { left: 1rem; top: .5rem; z-index: 2; background: var(--paper); color: var(--text); padding: .5rem; }

.page { max-width: 74rem; margin: 0 auto; padding: var(--gap); display: grid; gap: var(--gap); }
.stack { display: grid; gap: var(--gap); }

/* A sheet: square corners, a hard edge, a small stacked shadow, fine grain. */
.sheet { position: relative; background: var(--paper); border: 1px solid var(--line); box-shadow: 4px 4px 0 var(--rule); }
.sheet::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: var(--grain); opacity: .22; mix-blend-mode: multiply; }
[data-theme="dark"] .sheet::before { mix-blend-mode: screen; opacity: .06; }
.sheet > * { position: relative; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: .75rem 1rem; flex-wrap: wrap;
       padding: .85rem 1.25rem; border-bottom: 1px solid var(--line); }
.pad { padding: clamp(1.25rem, 3.5vw, 2.25rem); }
.pad-x { padding: 0 1.25rem; }
.draft-banner { margin: 0; padding: .5rem 1rem; border-style: dashed; color: var(--accent); }

/* Header and footer */
header.bar { border-bottom: 1px solid var(--line); }
.name { font: 1.3rem var(--serif); color: var(--text); text-decoration: none; }
.header-right { display: flex; align-items: center; gap: .75rem 1.4rem; flex-wrap: wrap; }
nav { display: flex; gap: 1.3rem; }
nav a { color: var(--text); text-decoration: none; font-size: .95rem; border-bottom: 2px solid transparent; }
nav a:hover, nav a[aria-current] { border-bottom-color: var(--accent); }
footer.bar { border-bottom: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
footer .links a { color: var(--text); margin-right: 1.1rem; }
footer a { color: var(--text); }

/* Buttons */
.btn { font: inherit; font-size: .85rem; color: var(--text); background: transparent; border: 1px solid var(--line);
       padding: .3rem .8rem; cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.4; }
.btn:hover { color: var(--accent); border-color: var(--accent); }
.btn.primary, .btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.contact { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }
.contact .btn { font-size: .92rem; padding: .45rem 1rem; }
.filters, .topics { display: flex; flex-wrap: wrap; gap: .4rem; }
.topics .btn { font-size: .8rem; padding: .2rem .6rem; }

/* Headings */
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.15; }
h1 { font-size: clamp(2rem, 4.4vw, 3rem); margin: 0 0 1rem; letter-spacing: -.01em; }
.bar h1, h2 { font-size: 1.5rem; margin: 0; }
h2 a { color: var(--text); text-decoration: none; }
.lede { color: var(--muted); font-size: 1.1rem; margin: 0 0 1rem; }

/* Home intro */
.intro { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.intro .words { padding: clamp(1.5rem, 4vw, 2.75rem); border-right: 1px solid var(--line);
                display: flex; flex-direction: column; justify-content: center; }
.intro figure { margin: 0; display: flex; flex-direction: column; justify-content: space-between; }
.intro figure img, .intro figure canvas { width: 100%; height: auto; }
.intro figure img { aspect-ratio: 5 / 3; object-fit: cover; }
.intro figcaption { padding: .55rem 1rem; border-top: 1px solid var(--line); }

/* Work: a ruled grid of boxes that share their borders */
.work-wrap { overflow: hidden; }
.work { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.work li { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; display: flex; flex-direction: column; }
.work li[hidden] { display: none; }
.work .thumb img, .work .thumb canvas { width: 100%; aspect-ratio: 14 / 9; object-fit: cover; border-bottom: 1px solid var(--line); }
.work .body { padding: .85rem 1rem 1.1rem; }
.work h3 { font-size: 1.15rem; margin: .2rem 0 .3rem; }
.work h3 a { color: var(--text); text-decoration: none; }
.work h3 a:hover { color: var(--accent); }
.work p { margin: 0; color: var(--muted); font-size: .92rem; }

/* Writing */
.split { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); }
.split > div { padding: .25rem 1.25rem 1rem; }
.split aside { padding: 1.1rem 1.25rem; border-left: 1px solid var(--line); }
.year { font-size: 1.1rem; color: var(--muted); margin: 1.25rem 0 0; }
.posts { list-style: none; margin: 0; padding: 0; }
.posts li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--rule); }
.posts li:last-child { border-bottom: 0; }
.posts a { color: var(--text); text-decoration: none; font: 1.12rem var(--serif); }
.posts a:hover { color: var(--accent); }
.posts p { margin: .2rem 0 0; color: var(--muted); font-size: .92rem; }
aside h3 { font: 600 .75rem var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 .6rem; }
.years { list-style: none; margin: 0 0 1.5rem; padding: 0; border-top: 1px solid var(--rule); }
.years li { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.years a { color: var(--text); text-decoration: none; }
.years a:hover { color: var(--accent); }

/* Long-form pages */
.prose { max-width: 46rem; }
.prose > p, .prose li { font-size: 1.06rem; }
.prose h2 { font-size: 1.5rem; margin: 2rem 0 .5rem; }
.prose h3 { font-size: 1.2rem; margin: 1.5rem 0 .4rem; }
.prose figure { margin: 1.5rem 0; }
.prose figure img { width: auto; max-height: 88vh; }
.prose figure img, .prose figure canvas, .prose > p > img { border: 1px solid var(--line); }
.prose blockquote { margin: 1.25rem 0; padding-left: 1rem; border-left: 3px solid var(--accent); color: var(--muted); }
.prose code { font-size: .92em; }
.prose pre { overflow-x: auto; padding: 1rem; border: 1px solid var(--line); }
.terrain-lab { margin: 1.5rem 0; }
.terrain-lab canvas { border: 1px solid var(--line); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.25rem; margin-top: .75rem; font-size: .95rem; }
.controls select { font: inherit; font-size: .9rem; background: var(--paper); color: var(--text); border: 1px solid var(--line); padding: .2rem .4rem; }
.controls input[type="range"] { accent-color: var(--accent); vertical-align: middle; }

@media (max-width: 760px) {
  .intro, .split { grid-template-columns: 1fr; }
  .intro figure { order: -1; border-bottom: 1px solid var(--line); }
  .intro .words { border-right: 0; }
  .split aside { border-left: 0; border-top: 1px solid var(--line); }
  .posts li { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
