/* Cookie Dough Ergo
   ---------------------------------------------------------------------------
   A mishearing of "cogito, ergo sum" turned into a place to think out loud.
   The design holds those two things at once: dough-warm and unserious in its
   colour, disciplined and quiet everywhere the reading happens. */

:root {
  --dough:      #FCEFD5;  /* page */
  --dough-deep: #F5E0B7;  /* header and footer bands, pull quotes */
  --cocoa:      #3B2A20;  /* body text, warm rather than tinted black */
  --chip:       #241611;  /* headings and the chocolate-chip marks */
  --ink:        #2F4FCC;  /* links: the cogito half of the joke */
  --jam:        #C2295B;  /* hover only, used sparingly */

  --measure: 40rem;       /* ~67 characters at the body size */
  --serif: "Newsreader", Charter, "Iowan Old Style", Georgia, serif;
  --display: "Fraunces", "Newsreader", Georgia, serif;
}

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

body {
  margin: 0;
  /* Keeps the footer band at the bottom of short pages (tags, empty archive). */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--dough);
  color: var(--cocoa);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.1875rem);
  font-optical-sizing: auto;
  line-height: 1.65;          /* serif text wants the extra leading */
  text-rendering: optimizeLegibility;
}

.wrapper {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.25rem;
}

main.wrapper { flex: 1 0 auto; }

/* ---------------------------------------------------------------- headings */

h1, h2, h3, h4 {
  font-family: var(--display);
  font-variation-settings: "SOFT" 40, "WONK" 1;  /* Fraunces' playful axes */
  color: var(--chip);
  line-height: 1.15;
  text-wrap: balance;
  margin: 2.25rem 0 0.75rem;
}

h1 { font-size: 2.1rem;  font-weight: 700; letter-spacing: -0.015em; }
h2 { font-size: 1.55rem; font-weight: 600; }
h3 { font-size: 1.2rem;  font-weight: 600; }

/* Post and page titles lead the column, so they lose the top gap. */
main > h1:first-child,
main > div > h1:first-child { margin-top: 1.75rem; }

p { margin: 0 0 1.15rem; }

/* ------------------------------------------------------------------- links */

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  transition: color 120ms ease;
}
a:hover { color: var(--jam); }

/* Headings that are links stay heading-coloured; blue is for inline links. */
h1 a, h2 a, h3 a { color: var(--chip); text-decoration: none; }
h1 a:hover, h2 a:hover, h3 a:hover { color: var(--ink); text-decoration: underline; }

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

/* ------------------------------------------------------------------ header */

.site-header {
  background: var(--dough-deep);
  border-bottom: 1px solid rgba(36, 22, 17, 0.14);
  padding: 2.5rem 0 1.5rem;
  margin-bottom: 2.5rem;
}

.site-title { margin: 0; font-size: clamp(2rem, 1.4rem + 3vw, 3rem); }

.site-title-link {
  position: relative;
  display: inline-block;
  color: var(--chip);
  text-decoration: none;
}

/* The one idea on the site: what was actually said, printed small above what
   was heard. An overlapping ghost was tried first and read as a printing
   error rather than an echo. */
.site-title-ghost {
  display: block;
  font-family: var(--display);
  font-size: 0.95rem;
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "SOFT" 60, "WONK" 1;
  letter-spacing: 0.01em;
  color: var(--ink);
  opacity: 0.6;
  margin-bottom: 0.15rem;
}
.site-title-link:hover .site-title-ghost { opacity: 0.85; }

.site-description {
  margin: 0.6rem 0 0;
  max-width: 30rem;
  font-size: 1rem;
  font-style: italic;
  color: rgba(59, 42, 32, 0.8);
}

.site-nav {
  margin-top: 1.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  font-family: var(--display);
  font-size: 0.95rem;
  font-variation-settings: "SOFT" 40, "WONK" 0;
}

.site-nav .page-link {
  color: var(--chip);
  text-decoration: none;
  border-bottom: 2px solid rgba(47, 79, 204, 0.35);
  padding-bottom: 1px;
}
.site-nav .page-link:hover { color: var(--jam); border-bottom-color: var(--jam); }

/* -------------------------------------------------------- post furnishings */

blockquote {
  margin: 1.75rem 0;
  padding: 1rem 1.4rem;
  background: var(--dough-deep);
  border-radius: 0.4rem 1.1rem 0.5rem 1rem;  /* hand-dropped, not a card */
  font-style: italic;
}
blockquote p:last-child { margin-bottom: 0; }

img { max-width: 100%; height: auto; border-radius: 0.35rem; }

/* ----------------------------------------------------------------- figures */

/* Markdown has no caption syntax, so a captioned image is written as a raw
   <figure> block. Markdown is inert inside one, so emphasis or links in the
   caption have to be hand-tagged: <em>, <a href>. */

figure { margin: 2.25rem 0; }

figure img {
  display: block;          /* removes the inline baseline gap under the image */
  height: auto;            /* max-width: 100% comes from the global img rule */
}

figcaption {
  margin-top: 0.6rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(59, 42, 32, 0.72);
}

/* Caption links shouldn't shout at this size. */
figcaption a { text-decoration-thickness: 1px; }

hr {
  border: 0;
  height: 1px;
  background: rgba(36, 22, 17, 0.18);
  margin: 2.5rem 0;
}

/* The date and tag lines quickblog emits under each post. */
main p i { color: rgba(59, 42, 32, 0.72); font-size: 0.94rem; }

.tag a {
  display: inline-block;
  padding: 0.05em 0.55em;
  margin-right: 0.2rem;
  background: var(--dough-deep);
  border-radius: 999px;
  font-style: normal;
  font-size: 0.88rem;
  text-decoration: none;
}
.tag a:hover { background: var(--jam); color: var(--dough); }

.archive-link { margin: 2.5rem 0 3rem; }

/* ------------------------------------------------------------- footnotes */

/* nextjournal's markdown parses [^1] definitions but quickblog never places
   them, so footnotes are written by hand: a --- rule followed by a numbered
   list at the foot of the post. That shape is what these rules target, so no
   extra markup is needed in the Markdown. */

hr:has(+ ol) {
  width: 4rem;
  margin: 3rem 0 1.25rem;
  background: rgba(36, 22, 17, 0.3);
}

hr + ol {
  font-size: 0.92rem;
  line-height: 1.5;
  color: rgba(59, 42, 32, 0.82);
  padding-left: 1.3rem;
  margin: 0 0 1rem;
}

hr + ol li { margin-bottom: 0.5rem; padding-left: 0.2rem; }
hr + ol li::marker { color: rgba(59, 42, 32, 0.55); }

/* The return arrow is navigation, not part of the note. */
hr + ol a[href^="#ref-"] {
  text-decoration: none;
  margin-left: 0.15rem;
  opacity: 0.65;
}
hr + ol a[href^="#ref-"]:hover { opacity: 1; }

/* Jumping to a note shouldn't land it flush against the viewport edge. */
[id^="fn-"], [id^="ref-"] { scroll-margin-top: 2rem; }

/* Mark the note you just jumped to. The id sits on an empty anchor inside
   the list item, so the highlight has to be hung on the parent. */
hr + ol li:has(> a[id^="fn-"]:target) {
  background: var(--dough-deep);
  border-radius: 0.3rem;
  box-shadow: 0 0 0 0.4rem var(--dough-deep);
}

/* Reference markers read as apparatus rather than prose links. */
main p a[href^="#fn-"] {
  text-decoration: none;
  font-size: 0.9em;
  padding: 0 0.05em;
}
main p a[href^="#fn-"]:hover { text-decoration: underline; }

/* ------------------------------------------------------- index and listing */

/* Each post on the index is separated by three chocolate chips rather than a
   rule, which is the only place the name is allowed to be literal. */
main > div + div { margin-top: 1rem; padding-top: 2.5rem; position: relative; }
main > div + div::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4.4rem;
  height: 0.5rem;
  background-image: radial-gradient(circle, var(--chip) 45%, transparent 46%);
  background-size: 1.5rem 100%;
  opacity: 0.55;
}

ul.index { list-style: none; padding-left: 0; }

.index li {
  margin-bottom: 0.85rem;
  padding-left: 1.4rem;
  position: relative;
}

/* Chip-shaped bullets: irregular corners so they read as chips, not discs. */
.index li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 0.5rem;
  height: 0.5rem;
  background: var(--chip);
  border-radius: 60% 40% 55% 45% / 50% 62% 38% 50%;
}

.listing { max-width: 100%; }

/* -------------------------------------------------------------------- code */

code, pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}
code { white-space: pre-wrap; word-break: break-word; }

p > code, li > code {
  background: var(--dough-deep);
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
}

/* Prism ships a white background that fights the dough. */
pre[class*="language-"] {
  background: #FFF8EA;
  border: 1px solid rgba(36, 22, 17, 0.14);
  border-radius: 0.4rem;
  padding: 1rem 1.1rem;
  overflow-x: auto;
}
code[class*="language-"], pre[class*="language-"] { text-shadow: none; color: var(--cocoa); }

/* ------------------------------------------------------------------ footer */

.site-footer {
  margin-top: 4rem;
  flex-shrink: 0;
  padding: 1.75rem 0 2.25rem;
  background: var(--dough-deep);
  border-top: 1px solid rgba(36, 22, 17, 0.14);
  font-size: 0.92rem;
}

.copyright { margin: 0; color: var(--cocoa); }

.colophon {
  margin: 0.35rem 0 0;
  color: rgba(59, 42, 32, 0.7);
  font-style: italic;
}

/* ----------------------------------------------------------------- motion  */

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media (max-width: 32rem) {
  .site-header { padding-top: 1.75rem; }
}
