/* ———————————————————————————————————————————————
   A warm, personal, lightweight stylesheet.
   Colors live in the :root block below — change them
   there and the whole site follows.
   ——————————————————————————————————————————————— */

/* EB Garamond, self-hosted (latin subset; other scripts fall back
   to the system serifs in the font stack) */
@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/EBGaramond-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/EBGaramond-Italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  /* The dark "jungle at dusk" palette is the site's default face.
     The toggle (theme.js) switches to the light cream palette below
     and remembers the choice. */
  --paper: #161f18;      /* jungle at dusk */
  --paper-raised: #1f2a21;
  --ink: #eae5d8;        /* kept cream rather than green — reads as lamplight */
  --ink-soft: #9ea491;
  --accent: #72c290;     /* fern glow */
  --accent-soft: #2c5e42;
  --rule: #2d3b2f;
  /* flourish colors (dot, heading stroke, wavy underline, asterism) */
  --pop: #b6d43a;        /* lime glow */
  --pop-strong: #b6d43a;
  /* selected-text color: ordinary ink on the green highlight */
  --selection-ink: var(--ink);
  /* the outfield philosopher's paints (sprite injected by runner.js;
     his laurel uses --accent directly) */
  --spr-outline: #10150f;
  --spr-cloth: #f2eede;      /* chiton + ball */
  --spr-skin: #d19a6b;
  --spr-beard: #a89e88;
  --spr-wood: #9c6b3e;       /* glove, sandal soles, torch handle */
  --spr-fold: #d6d0bc;       /* himation fold line */
  --spr-flair: var(--pop);   /* meander hem — follows the flourishes */
  --spr-flame: #f5883a;
  --spr-flame-core: #ffd45c;
  --spr-stitch: #c53042;     /* ball stitches (same in both themes) */
}

/* The light "warm cream" palette, applied only when the visitor flips
   the toggle (theme.js sets data-theme="light"). */
:root[data-theme="light"] {
  color-scheme: light;
  --paper: #faf6ec;        /* warm cream background */
  --paper-raised: #f0ecdc; /* slightly deeper paper, for cards */
  --ink: #26291f;          /* warm near-black text */
  --ink-soft: #626b52;     /* muted gray-green for secondary text */
  --accent: #276b4b;       /* rainforest emerald */
  --accent-soft: #8db892;
  --rule: #e2dfc8;         /* hairlines and borders */
  /* in light mode the flourishes follow the greens, not the lime */
  --pop: var(--accent-soft);
  --pop-strong: var(--accent);
  /* selection reads inverted in light mode: paper on green */
  --selection-ink: var(--paper);
  --spr-outline: #2b2620;
  --spr-cloth: #fffdf5;
  --spr-skin: #e0a877;
  --spr-beard: #c9bea8;
  --spr-wood: #8a5a33;
  --spr-fold: #e8e1cd;
  --spr-flair: #f0641e;    /* orange hem in light mode */
  --spr-flame: #ee7422;
  --spr-flame-core: #f9c440;
}

* { box-sizing: border-box; }

/* Garamond runs small for its point size, so the whole rem scale
   gets one notch up (16px → 18px) to compensate */
html { font-size: 112.5%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'EB Garamond', Garamond, 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.site-header, main, .site-footer {
  max-width: 42rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

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

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

/* anchor jumps (e.g. footnote backlinks) land below the sticky header */
:target { scroll-margin-top: 7rem; }

/* ——— Header & navigation ——— */

/* The header rides along: it hides while you scroll down to read, and
   slides back the moment you scroll up (theme.js toggles the classes). */
.site-header {
  padding-top: 2.75rem;
  padding-bottom: 0.9rem;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper);
  border-bottom: 1px solid transparent;
  transition: transform 0.25s ease, padding 0.25s ease,
              background-color 0.25s ease, border-color 0.25s ease;
}

.site-header.scrolled {
  padding-top: 0.9rem;
  border-bottom-color: var(--rule);
}

.site-header.header-hidden { transform: translateY(-100%); }

.wordmark {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}

.wordmark .dot { color: var(--pop-strong); }

.site-header nav {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.3rem;
  font-size: 0.98rem;
}

.site-header nav a {
  color: var(--ink-soft);
  text-decoration: none;
}

.site-header nav a:hover { color: var(--accent); }

.site-header nav a[aria-current="page"] {
  color: var(--accent);
  text-decoration: underline wavy;
  text-decoration-color: var(--pop);
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
}

/* the light/dark switch (inserted by theme.js) */
.theme-toggle {
  position: absolute;
  top: 2.55rem;
  right: 1.25rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  color: var(--ink-soft);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.theme-toggle:hover {
  color: var(--pop-strong);
  border-color: var(--accent-soft);
}

.site-header.scrolled .theme-toggle { top: 0.7rem; }

body, .theme-toggle {
  transition: background-color 0.25s ease, color 0.25s ease,
              top 0.25s ease;
}

/* the back-to-top button (inserted by theme.js on long pages) */
.to-top {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 45;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  color: var(--ink-soft);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease, color 0.25s ease;
}

.to-top.show { opacity: 1; visibility: visible; }

.to-top:hover {
  color: var(--pop-strong);
  border-color: var(--accent-soft);
}

/* ——— Main content ——— */

main { padding-top: 2.5rem; padding-bottom: 1rem; }

main a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2.5px;
}

main a:hover { text-decoration-thickness: 2px; }

h1 {
  font-size: 1.9rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.3rem;
  margin: 2.5rem 0 1rem;
}

/* the little stroke under every h2: one stroke, two poles —
   after the site owner's thesis that accepting p and rejecting ¬p
   are two descriptions of one act */
h2::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  margin-top: 0.4rem;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0 50%, var(--pop) 50% 100%);
}

/* ——— About page intro ——— */

/* present for screen readers and document structure, not shown */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.intro {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

/* with no visible heading, the first line should sit flush with the
   top of the portrait */
.intro p:first-of-type { margin-top: 0; }

.portrait {
  flex-shrink: 0;
  width: 7.5rem;
  height: 7.5rem;
  border-radius: 14px;
  rotate: -2deg;
  object-fit: cover;
  border: 1px solid var(--rule);
  box-shadow: 5px 5px 0 var(--paper-raised);
}

/* placeholder version, until a real photo replaces it */
div.portrait {
  display: grid;
  place-items: center;
  background: var(--paper-raised);
  color: var(--ink-soft);
  font-size: 2.1rem;
  letter-spacing: 0.05em;
}

.contact-line {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ——— Entries (writing, teaching) ——— */

.entry { margin-bottom: 1.75rem; }

.entry h3 {
  font-size: 1.08rem;
  font-weight: 600;
  margin: 0 0 0.15rem;
}

.entry .meta {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.94rem;
  margin: 0;
}

.entry .links {
  font-size: 0.9rem;
  margin: 0.25rem 0 0;
}

.entry details { margin-top: 0.4rem; }

.entry summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink-soft);
  width: fit-content;
}

.entry summary:hover { color: var(--accent); }

.entry details p {
  font-size: 0.95rem;
  color: var(--ink-soft);
  border-left: 2px solid var(--rule);
  padding-left: 0.9rem;
  margin: 0.5rem 0 0;
}

/* ——— Flourishes ——— */

.asterism {
  text-align: center;
  color: var(--pop-strong);
  font-size: 1.1rem;
  margin: 3.5rem 0 0;
  user-select: none;
}

/* the ornament is a baseball (the favicon is its twin) */
.asterism .footer-ball {
  display: block;
  width: 18px;
  height: 18px;
  margin-inline: auto;
}

.footer-ball circle {
  fill: var(--spr-cloth);
  stroke: var(--spr-outline);
  stroke-width: 2;
}

.footer-ball path {
  fill: none;
  stroke: var(--spr-stitch);
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-dasharray: 2.4 1.9;
}

blockquote {
  margin: 1.5rem 0;
  padding-left: 1.1rem;
  border-left: 3px solid var(--accent-soft);
  font-style: italic;
  color: var(--ink-soft);
}

blockquote cite { font-style: normal; font-size: 0.9rem; }

/* ——— Footer ——— */

.site-footer {
  padding-top: 1rem;
  padding-bottom: 3rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  text-align: center;
}

/* ——— Small screens ——— */

@media (max-width: 34rem) {
  .intro { flex-direction: column; }
  h1 { font-size: 1.6rem; }
}

/* ——— The outfield philosopher ———
   A pixel-art Greek philosopher (injected by runner.js) chases a fly
   ball along the bottom of the page: once per visit, replayable by
   clicking the wordmark's green dot. To remove him: delete runner.js,
   its <script> line in each page, this section, and the --spr-*
   variables in the color blocks above. */

.runner-svg { display: block; width: 48px; height: auto; }
.ball-svg { display: block; width: 12px; height: auto; }

.runner-svg .pk, .ball-svg .pk { fill: var(--spr-outline); }
.runner-svg .pw, .ball-svg .pw { fill: var(--spr-cloth); }
.runner-svg .pr, .ball-svg .pr { fill: var(--spr-stitch); }
.runner-svg .pt { fill: var(--spr-skin); }
.runner-svg .pg { fill: var(--spr-beard); }
.runner-svg .pn { fill: var(--spr-wood); }
.runner-svg .ps { fill: var(--spr-fold); }
.runner-svg .pa { fill: var(--accent); }    /* laurel */
.runner-svg .po { fill: var(--spr-flair); } /* meander hem */
.runner-svg .pf { fill: var(--spr-flame); }
.runner-svg .py { fill: var(--spr-flame-core); }

.runner {
  position: fixed;
  left: 0;
  bottom: 0.4rem;
  z-index: 60;
  pointer-events: none;
  visibility: hidden;
  transform: translateX(-90px);
  will-change: transform;
}

.runner.running {
  visibility: visible;
  animation: runner-cross 8.5s linear forwards;
}

@keyframes runner-cross {
  from { transform: translateX(-90px); }
  to   { transform: translateX(calc(100vw + 50px)); }
}

/* two-frame gait (the torch flame flickers with it) plus a lean-and-bob */
.runner .fb, .runner .fc { opacity: 0; }
.runner.running .fa { animation: runner-gait-a 0.32s steps(1, end) infinite; }
.runner.running .fb { animation: runner-gait-b 0.32s steps(1, end) infinite; }
.runner.running .runner-svg { animation: runner-bob 0.32s ease-in-out infinite alternate; }
@keyframes runner-gait-a { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes runner-gait-b { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }
@keyframes runner-bob {
  from { transform: rotate(3deg) translateY(0); }
  to   { transform: rotate(3deg) translateY(-2px); }
}

/* the fly ball, animated relative to the runner so the catch lands in
   the glove at any viewport width: he gets a head start, the ball is
   hit in from the left edge at ~2.3x his speed, apex at 60% of the
   crossing, gloved at 74% */
.runner .ballw { position: absolute; left: 0; top: 0; opacity: 0; }
.runner.running .ballw { animation: runner-ball-show 8.5s linear forwards; }
.runner.running .ballx { animation: runner-ball-x 8.5s linear forwards; }
.runner.running .bally { animation: runner-ball-y 8.5s linear forwards; }
@keyframes runner-ball-show {
  0%, 44% { opacity: 0; }
  45%, 100% { opacity: 1; }
}
@keyframes runner-ball-x {
  0%, 45% { transform: translateX(calc(7px - 45vw)); }
  74%, 100% { transform: translateX(36px); }
}
@keyframes runner-ball-y {
  0%, 45% { transform: translateY(-30px); animation-timing-function: cubic-bezier(0.2, 0.6, 0.5, 1); }
  60% { transform: translateY(-340px); animation-timing-function: cubic-bezier(0.5, 0, 0.9, 0.6); }
  74%, 100% { transform: translateY(2px); }
}

/* reduced motion: the automatic appearance becomes a quiet fade in the
   corner, ball already gloved, torch aloft. A click on the dot is an
   explicit request (runner.js adds .force), so it still plays the
   full sprint. */
@media (prefers-reduced-motion: reduce) {
  .runner:not(.force) { left: auto; right: 1rem; transform: none; }
  .runner:not(.force).running { animation: runner-appear 3s ease forwards; }
  .runner:not(.force).running .fa,
  .runner:not(.force).running .fb { animation: none; opacity: 0; }
  .runner:not(.force).running .fc { opacity: 1; }
  .runner:not(.force).running .runner-svg { animation: none; }
  .runner:not(.force) .ballw { display: none; }
  @keyframes runner-appear {
    0% { opacity: 0; } 25% { opacity: 1; }
    75% { opacity: 1; } 100% { opacity: 0; }
  }
}

.wordmark .dot { cursor: pointer; }
