:root {
  --night: #14161a;
  --bone: #e6e0d2;
  --ash: #8f8b83;
  --faint: #3d3f45;
  --tint: #23262b;
  --chalk: #f2d98a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  background: var(--night);
  color: var(--bone);
  font-family: "EB Garamond", Garamond, "Times New Roman", serif;
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-kerning: normal;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 1.5rem 4rem;
  overflow-x: clip;
}

/* a little grain over everything, like ink on rough paper */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0.09;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .9  0 0 0 0 .88  0 0 0 0 .82  0 0 0 1.6 -.55'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
}

main, footer, .running {
  max-width: 35rem;
  margin-left: auto;
  margin-right: auto;
}

::selection { background: var(--chalk); color: var(--night); }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: transparent; }
a:focus-visible {
  outline: 1px dashed var(--chalk);
  outline-offset: 5px;
  border-radius: 2px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ornament {
  text-align: center;
  color: var(--ash);
  font-size: 1.5rem;
  line-height: 1;
  margin: 0;
}

/* the running head, like the top of a book page */
.running {
  text-align: center;
  padding-top: 2.2rem;
  font-size: 1.1rem;
  font-variant-caps: small-caps;
  letter-spacing: 0.06em;
}
.running a { color: var(--ash); text-decoration: none; }
.running a:hover { color: var(--bone); }

/* ---------- home ---------- */

.title-page {
  text-align: center;
  padding: clamp(5rem, 20vh, 11rem) 0 clamp(3.5rem, 10vh, 6rem);
}

.portrait {
  display: block;
  width: 5.5rem;
  height: 5.5rem;
  object-fit: cover;
  border-radius: 50%;
  margin: 0 auto 2rem;
  filter: grayscale(1) contrast(1.05);
}

.name {
  font-size: clamp(3.6rem, 12vw, 6.75rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
  margin: 0;
}

.hour {
  font-style: italic;
  color: var(--ash);
  font-size: clamp(1.2rem, 2.8vw, 1.45rem);
  line-height: 1.45;
  max-width: 32ch;
  min-height: 2.9em;
  margin: 1.5rem auto 2.75rem;
}
.hour .clock { font-variant-numeric: lining-nums tabular-nums; }

.note {
  font-size: 1.3rem;
  line-height: 1.6;
}
.note p, .contact { margin: 0 0 1em; }
.plain { margin-top: clamp(4rem, 14vh, 8rem); }
.contact { font-size: 1.3rem; line-height: 1.6; }

.section {
  font-size: 1.2rem;
  font-weight: 400;
  font-variant-caps: small-caps;
  letter-spacing: 0.05em;
  color: var(--ash);
  margin: 3.25rem 0 0.9rem;
}

.recent {
  list-style: none;
  padding: 0;
  margin: 0 0 1.1rem;
  font-size: 1.3rem;
}
.recent li {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.4em 0;
}
.recent a { text-decoration: none; }
.recent .is-thought { font-style: italic; }
.recent time {
  flex: none;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ash);
}
.all { font-size: 1.15rem; margin: 0 0 3.25rem; }
.all a { color: var(--ash); }

.note .more { margin-top: 1.4em; }
.note .more a { color: var(--ash); }
.note .more a:hover { color: var(--bone); }

.section-intro { font-size: 1.3rem; line-height: 1.6; margin: 0 0 2rem; }

/* projects as a deck of cards: one centered on top, the others tucked behind it at a tilt.
   Without JavaScript it's a plain list. chalk.js adds .is-ready, gives each card a
   data-pos (0 is on top) and adds the arrows and counter. Each card has a sketched frame. */
.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 2.75rem;
}
.cards a, .cards img { -webkit-user-drag: none; }
.deck.is-ready .cards {
  grid-template-areas: "stack";
  gap: 0;
  width: min(21rem, 76vw);
  margin: 1.6rem auto 0;
  touch-action: pan-y;
  cursor: grab;
}
.deck.is-ready .cards.dragging { cursor: grabbing; user-select: none; }
.deck.is-ready .card {
  grid-area: stack;
  background: var(--night);
  transform-origin: 50% 85%;
  transition: transform 0.36s steps(4, end), opacity 0.36s steps(4, end);
}
.deck.is-ready .card[data-pos="0"] { z-index: 3; }
.deck.is-ready .card[data-pos="1"] { z-index: 2; transform: translate(30px, 8px) rotate(5deg); opacity: 0.5; }
.deck.is-ready .card[data-pos="2"] { z-index: 1; transform: translate(-28px, 12px) rotate(-4.5deg); opacity: 0.3; }
.deck.is-ready .card:not([data-pos="0"]) { pointer-events: none; }
/* cards underneath only show their picture at the edges, not their words */
.deck.is-ready .card .card-body { transition: opacity 0.36s steps(3, end); }
.deck.is-ready .card:not([data-pos="0"]) .card-body { opacity: 0; }

.deck-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 2.4rem;
}
.deck-count {
  min-width: 4.5em;
  text-align: center;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ash);
}
.deck + .aside { text-align: center; margin-top: 1rem; }

/* hand-drawn chalk arrows */
.deck-btn {
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.deck-btn svg { display: block; width: 100%; height: 100%; overflow: visible; }
.deck-btn.prev svg { transform: scaleX(-1); }
.deck-btn path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.deck-btn .rest { stroke: var(--ash); stroke-width: 2; }
.deck-btn .lit path { stroke: var(--chalk); stroke-width: 2.4; display: none; }
.deck-btn:hover .rest,
.deck-btn:focus-visible .rest { opacity: 0; }
.deck-btn:hover .lit path,
.deck-btn:focus-visible .lit path {
  display: block;
  opacity: 0;
  animation: chalk-boil 0.42s step-end infinite;
}
.deck-btn .lit .f1 { animation-delay: -0.14s !important; }
.deck-btn .lit .f2 { animation-delay: -0.28s !important; }
.deck-btn:focus-visible { outline: 1px dashed var(--chalk); outline-offset: 2px; }
.card {
  position: relative;
  padding: 0.85rem 0.85rem 1rem;
}
.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9; /* YouTube's own shape, so nothing gets cut off */
  object-fit: cover;
  border-radius: 2px;
  background: var(--tint);
  filter: grayscale(0.75) brightness(0.72) contrast(1.05);
  transition: filter 0.3s steps(3, end);
}
.card:hover .thumb, .card:focus-within .thumb { filter: none; }
.card-title {
  font-size: 1.65rem;
  font-weight: 400;
  line-height: 1.2;
  margin: 1rem 0 0.35rem;
}
.card-title a { text-decoration: none; }
.card-text {
  font-size: 1.2rem;
  line-height: 1.5;
  margin: 0;
}
.card-meta {
  font-style: italic;
  color: var(--ash);
  font-size: 1.05rem;
  margin: 0.6rem 0 0;
}

/* small round channel logos */
.avatar {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: -0.14em;
  margin-right: 0.38em;
  background: var(--tint);
}

/* "featured by" on the EcoZone card */
.card a.featured {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.9rem 0 0.35rem;
  padding: 0.45rem 0.95rem 0.5rem 0.5rem;
  background: rgba(242, 217, 138, 0.05);
  color: var(--chalk);
  text-decoration: none;
}
/* its own sketched box: faint chalk at rest, lights up and boils on hover (see .frame) */
.featured > .frame { top: -14px; left: -14px; width: calc(100% + 28px); height: calc(100% + 28px); }
.featured > .frame .rest { stroke: rgba(242, 217, 138, 0.45); }
.featured .avatar {
  width: 2.1rem;
  height: 2.1rem;
  margin: 0;
  flex: none;
}
.featured b {
  display: block;
  font-weight: 500;
  font-size: 1.1rem;
  line-height: 1.2;
}
.featured small {
  display: block;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ash);
}
.featured:hover small { color: var(--bone); }

.aside {
  font-style: italic;
  color: var(--ash);
  font-size: 1.15rem;
  margin: 0.4rem 0 3.5rem;
}

.card .also {
  position: relative;
  z-index: 1;
  color: var(--bone);
}

.frame {
  position: absolute;
  top: -20px;
  left: -20px;
  width: calc(100% + 40px);
  height: calc(100% + 40px);
  overflow: visible;
  pointer-events: none;
}
.frame path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.frame .rest {
  stroke: var(--faint);
  stroke-width: 1.5;
}
.frame .lit path {
  stroke: var(--chalk);
  stroke-width: 2.2;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  display: none;
}
/* a framed thing lights up its own frame when hovered or focused */
[data-frame]:is(:hover, :focus-within) > .frame .rest { opacity: 0; }
[data-frame]:is(:hover, :focus-within) > .frame .lit path {
  display: block;
  opacity: 0;
  animation:
    chalk-draw 0.3s steps(5, end) forwards,
    chalk-boil 0.42s step-end infinite;
}
[data-frame]:is(:hover, :focus-within) > .frame .lit .f1 { animation-delay: 0s, -0.14s; }
[data-frame]:is(:hover, :focus-within) > .frame .lit .f2 { animation-delay: 0s, -0.28s; }
/* while the UPDT tag is hovered, only the tag lights up, not the whole card */
.card:has(.featured:is(:hover, :focus-visible)) > .frame .rest { opacity: 1; }
.card:has(.featured:is(:hover, :focus-visible)) > .frame .lit path { display: none; }

/* the name: hover (or tap) and it turns to chalk and starts to boil */
.name-word {
  display: inline-block;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}
.name-word:hover, .name-word.is-lit {
  color: var(--chalk);
  text-shadow: 0 0 0.3em rgba(242, 217, 138, 0.4);
  animation: name-boil 0.42s step-end infinite;
}
@keyframes name-boil {
  0% { filter: url(#boil-1); }
  33.333% { filter: url(#boil-2); }
  66.666% { filter: url(#boil-3); }
}

/* the intro on the home page: the name writes itself in chalk at a low frame rate,
   boils for a moment, cools to ink, then the rest of the page comes up.
   index.html adds .intro right away and .go once the font is ready. */
.intro:not(.go) .title-page > *,
.intro:not(.go) main,
.intro:not(.go) footer { visibility: hidden; }

.intro.go .name-word {
  animation:
    name-write 0.7s steps(7, end) both,
    name-boil 0.42s step-end 0s 3,
    name-cool 0.45s steps(3, end) 1.05s both;
}
.intro.go .hour { animation: appear 0.45s steps(3, end) 0.8s both; }
.intro.go .ornament { animation: appear 0.3s steps(2, end) 1.1s both; }
.intro.go main,
.intro.go footer { animation: appear 0.5s steps(4, end) 1.3s both; }

@keyframes name-write {
  from { clip-path: inset(-30% 100% -30% -10%); }
  to { clip-path: inset(-30% -10% -30% -10%); }
}
@keyframes name-cool {
  from { color: var(--chalk); text-shadow: 0 0 0.3em rgba(242, 217, 138, 0.45); }
  to { color: var(--bone); text-shadow: 0 0 0 rgba(242, 217, 138, 0); }
}
@keyframes appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* a link that makes its whole row or card clickable */
.stretch::after {
  content: "";
  position: absolute;
  inset: 0;
}

/* bits for you to fill in; delete the class once done */
.todo {
  background: var(--tint);
  color: var(--ash);
  border-radius: 3px;
  padding: 0 0.3em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

footer {
  text-align: center;
  font-style: italic;
  color: var(--ash);
  font-size: 1.05rem;
  margin-top: clamp(4rem, 12vh, 7rem);
}

/* ---------- writing ---------- */

.title-block {
  text-align: center;
  margin-top: clamp(4rem, 14vh, 8rem);
}

.title {
  font-size: clamp(2.5rem, 7vw, 4rem);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.008em;
  margin: 0;
  text-wrap: balance;
}

.subtitle, .dateline {
  font-style: italic;
  color: var(--ash);
  font-size: 1.25rem;
  margin: 1rem 0 0;
}

.draft {
  font-style: italic;
  color: var(--chalk);
  margin-left: 0.5em;
}
.draft::before { content: "( "; }
.draft::after { content: " )"; }

.prose {
  font-size: 1.3rem;
  line-height: 1.6;
  margin-top: clamp(3rem, 9vh, 5rem);
  hyphens: auto;
}
@media (min-width: 40rem) {
  .article .prose { text-align: justify; }
}
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose pre { margin: 0 0 1em; }
.prose p + p { text-indent: 0; }

/* the first letter of an essay, set big like an old book */
.article .prose > p:first-child::first-letter {
  float: left;
  font-size: 3.55em;
  line-height: 0.8;
  padding: 0.06em 0.09em 0 0;
  text-transform: uppercase;
}

.prose h2 {
  font-size: 1.6rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.25;
  margin: 2.2em 0 0.5em;
  text-align: left;
}
.prose h3 {
  font-size: 1.3rem;
  font-weight: 400;
  font-variant-caps: small-caps;
  letter-spacing: 0.04em;
  margin: 1.9em 0 0.4em;
  text-align: left;
}
.prose ul, .prose ol { padding-left: 1.3em; text-align: left; }
.prose li { margin: 0.25em 0; }
.prose li::marker { color: var(--ash); }
.prose blockquote {
  margin: 1.6em 0 1.6em 1.6em;
  font-style: italic;
  color: var(--ash);
}
.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 2px;
  margin: 2em auto;
}
.prose code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  font-size: 0.75em;
  background: var(--tint);
  border-radius: 3px;
  padding: 0.1em 0.3em;
}
.prose pre {
  background: var(--tint);
  border-radius: 3px;
  padding: 1em 1.2em;
  overflow-x: auto;
  line-height: 1.5;
  text-align: left;
}
.prose pre code { background: none; padding: 0; }
.prose hr {
  border: 0;
  margin: 2.4em 0;
  text-align: center;
}
.prose hr::after {
  content: "∴";
  color: var(--ash);
  font-size: 1.5rem;
}

.article + .ornament, .thought + .ornament { margin-top: 4rem; }
footer.end { font-style: normal; font-size: 1.15rem; margin-top: 2.5rem; }

/* a thought on its own page, set like an aphorism */
article.thought {
  text-align: center;
  margin-top: clamp(5rem, 20vh, 10rem);
}
article.thought .dateline { margin: 0; }
article.thought .prose {
  font-style: italic;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  line-height: 1.4;
  margin-top: 1.4rem;
  hyphens: manual;
}

/* the list of everything */
.stream {
  list-style: none;
  padding: 0;
  margin: clamp(3.5rem, 10vh, 6rem) 0 0;
}
.entry {
  position: relative;
  margin: 0 0 3.2rem;
}
.entry-meta {
  font-style: italic;
  color: var(--ash);
  font-size: 1.1rem;
  margin: 0 0 0.3rem;
}
.entry-meta a { text-decoration: none; }
.entry-title {
  font-size: 1.85rem;
  line-height: 1.2;
  text-decoration: none;
}
.entry.thought .prose {
  margin-top: 0;
  font-style: italic;
  font-size: 1.5rem;
  line-height: 1.42;
}

.empty {
  text-align: center;
  font-style: italic;
  color: var(--ash);
  font-size: 1.3rem;
  margin-top: 3rem;
}

/* ---------- highlighted words with a pop-out note (see chalk.js) ---------- */

.term {
  display: inline-block;
  font: inherit;
  color: var(--chalk);
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: underline dotted rgba(242, 217, 138, 0.55);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.24em;
  transition: transform 0.2s steps(2, end);
  -webkit-tap-highlight-color: transparent;
}
.term:hover, .term.is-open { text-decoration-color: transparent; }
.term.is-open { transform: scale(1.09); }
.term:focus-visible {
  outline: 1px dashed var(--chalk);
  outline-offset: 5px;
  border-radius: 2px;
}

.callout {
  position: absolute;
  z-index: 4;
  width: max-content;
  max-width: min(15rem, calc(100vw - 2rem));
  padding: 0.85rem 1.05rem 1rem;
  background: var(--night);
  /* a dark margin around the note so text underneath doesn't show through its edges */
  box-shadow: 0 0 0 12px var(--night), 0 0 22px 16px rgba(20, 22, 26, 0.85);
  color: var(--bone);
  font-size: 1.08rem;
  line-height: 1.45;
  text-align: left;
  pointer-events: none;
  animation: appear 0.24s steps(3, end) 0.5s both;
}
.callout[hidden] { display: none; }
.callout b {
  display: block;
  font-weight: 400;
  font-style: italic;
  font-size: 1.3rem;
  color: var(--chalk);
  margin-bottom: 0.2rem;
}
.callout p { margin: 0; }

.callout-marks {
  position: absolute;
  overflow: visible;
  pointer-events: none;
}
.callout-marks path {
  fill: none;
  stroke: var(--chalk);
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
/* lens, then handle, then the line out, then the box: each drawn in a few choppy frames */
.callout-marks .lens { animation: chalk-draw 0.26s steps(5, end) forwards; }
.callout-marks .handle { stroke-width: 4.5; animation: chalk-draw 0.1s steps(2, end) 0.24s forwards; }
.callout-marks .lead { animation: chalk-draw 0.2s steps(4, end) 0.32s forwards; }
.callout-marks .box { stroke-width: 1.8; animation: chalk-draw 0.24s steps(4, end) 0.48s forwards; }
.callout-marks .knock { stroke: var(--night); stroke-width: 9; }
.callout-marks > g { opacity: 0; animation: chalk-boil 0.42s step-end infinite; }
.callout-marks > g.f1 { animation-delay: -0.14s; }
.callout-marks > g.f2 { animation-delay: -0.28s; }

/* ---------- chalk marks (see chalk.js) ---------- */

.chalk-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  z-index: 5;
  pointer-events: none;
}
.chalk {
  position: absolute;
  overflow: visible;
  pointer-events: none;
}
.chalk path {
  fill: none;
  stroke: var(--chalk);
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
  /* draws itself in a few choppy frames, then boils: one of three drawings at a time */
  animation:
    chalk-draw 0.3s steps(5, end) forwards,
    chalk-boil 0.42s step-end infinite;
}
.chalk[data-kind="double"] path { stroke-width: 3; }
.chalk path.f1 { animation-delay: 0s, -0.14s; }
.chalk path.f2 { animation-delay: 0s, -0.28s; }
.chalk.out { animation: chalk-out 0.16s steps(2, end) forwards; }

@keyframes chalk-draw { to { stroke-dashoffset: 0; } }
@keyframes chalk-boil {
  0% { opacity: 0.95; }
  33.333% { opacity: 0; }
  100% { opacity: 0; }
}
@keyframes chalk-out { to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .chalk path { animation: none; stroke-dashoffset: 0; }
  .chalk path.f0 { opacity: 0.95; }
  .chalk.out { animation: none; opacity: 0; }
  .name-word:hover, .name-word.is-lit { animation: none; filter: url(#boil-1); }
  [data-frame]:is(:hover, :focus-within) > .frame .lit path { animation: none; stroke-dashoffset: 0; }
  [data-frame]:is(:hover, :focus-within) > .frame .lit .f0 { opacity: 0.95; }
  .thumb { transition: none; }
  .deck.is-ready .card { transition: none; }
  .term { transition: none; }
  .callout { animation: none; }
  .callout-marks path { animation: none !important; stroke-dashoffset: 0; }
  .callout-marks > g { animation: none; }
  .callout-marks > g.f0 { opacity: 0.95; }
}
