/* Learning from a Learner: the whole look of the site lives in this one file.
   Edit it in static/css/style.css. The build copies it into site/css/, so changes made
   directly in site/ are overwritten the next time you build. */

/* ---------- 1. Colours, type and sizes ---------- */
:root {
  --paper: #faf6ee;        /* cream page */
  --paper-deep: #f3ecdf;   /* code, cards, author note */
  --ink: #1b2a41;          /* deep navy text (14:1 on paper) */
  --ink-soft: #4b5868;     /* dates, captions, summaries (6.7:1) */
  --gold: #b8862b;         /* rules and ornaments only: too light for small text (3:1) */
  --gold-text: #8a6417;    /* gold for small text and labels (5:1) */
  --sage: #5f7a61;         /* topic tags (borders) */
  --sage-text: #4a634d;    /* topic tag text (5.8:1) */
  --rule: #e4dccb;         /* hairlines */
  --selection: #eadbb8;

  --serif: "Source Serif 4", "Source Serif Pro", Georgia, Cambria, "Times New Roman", serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;

  --measure: 34rem;        /* about 65 to 70 characters per line */
  --wide: 54rem;           /* video grid, masthead */
  --gutter: 1.25rem;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 106.25%;      /* 17px on phones */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (min-width: 40em) { html { font-size: 112.5%; } }   /* 18px */
@media (min-width: 60em) { html { font-size: 118.75%; } }  /* 19px */

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 1rem;
  line-height: 1.65;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

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

a { color: inherit; }

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.005em;
  text-wrap: balance;
  margin: 0;
}

p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--gold-text);
  outline-offset: 3px;
  border-radius: 2px;
}
main:focus { outline: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  padding: 0.55rem 0.9rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.85rem;
  text-decoration: none;
  border-radius: 0 0 4px 4px;
}
.skip-link:focus { top: 0; }

/* Small letter-spaced capitals, used for labels, dates and the menu */
.kicker,
.section-label,
.entry-meta,
.post-meta,
.year,
.site-nav a,
.nav-toggle,
.post-nav-label,
.video-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  line-height: 1.4;
}

/* ---------- 3. Masthead and menu ---------- */
.masthead { padding: 1.1rem 0 0; }

.masthead-inner {
  width: min(100% - 2 * var(--gutter), var(--wide));
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
}
.wordmark-mark { width: 1.6rem; height: 1.6rem; border-radius: 4px; flex: none; }
.wordmark-text {
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1.2;
}
/* The one flourish: a thin gold rule under the wordmark */
.wordmark-text::after {
  content: "";
  display: block;
  width: 2.6rem;
  height: 2px;
  margin-top: 0.4rem;
  background: var(--gold);
  transition: width 0.25s ease;
}
.wordmark:hover .wordmark-text::after { width: 100%; }

.nav-toggle {
  display: none;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.95rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  cursor: pointer;
}
.nav-toggle[aria-expanded="true"] { border-color: var(--gold); }
.js .nav-toggle { display: inline-flex; }

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.4rem;
}
.site-nav a {
  display: inline-block;
  padding: 0.3rem 0;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { border-bottom-color: var(--rule); }
.site-nav a[aria-current="page"] { border-bottom-color: var(--gold); }

/* Phones: the menu folds away behind the button (only when JavaScript is on to open it) */
@media (max-width: 47.99em) {
  .js .site-nav { display: none; flex-basis: 100%; }
  .js .site-nav.is-open { display: block; }
  .js .site-nav ul { flex-direction: column; gap: 0; padding-top: 0.25rem; }
  .js .site-nav li + li { border-top: 1px solid var(--rule); }
  .js .site-nav a { display: block; padding: 0.8rem 0; border-bottom: 0; }
  .js .site-nav a[aria-current="page"] { color: var(--gold-text); }
}

/* Wider screens: a centred masthead, like the title page of a book */
@media (min-width: 48em) {
  .masthead { padding-top: 2.4rem; }
  .masthead-inner {
    flex-direction: column;
    justify-content: center;
    gap: 1.1rem;
    padding-bottom: 1.2rem;
  }
  .wordmark { gap: 0.8rem; }
  .wordmark-mark { width: 1.9rem; height: 1.9rem; }
  .wordmark-text { font-size: 1.6rem; text-align: center; }
  .wordmark-text::after { margin: 0.5rem auto 0; }
  .js .nav-toggle { display: none; }
  .site-nav ul { justify-content: center; gap: 0.25rem 2rem; }
}

/* ---------- 4. Page frame ---------- */
main {
  flex: 1 0 auto;
  width: min(100% - 2 * var(--gutter), var(--measure));
  margin: 0 auto;
  padding: 2.5rem 0 1rem;
}
main.main--wide { width: min(100% - 2 * var(--gutter), var(--wide)); }

@media (min-width: 48em) { main { padding-top: 3.5rem; } }

.kicker { color: var(--gold-text); margin-bottom: 0.9rem; }
.kicker a { color: inherit; text-decoration: none; }
.kicker a:hover { text-decoration: underline; text-underline-offset: 0.25em; }

.page-header,
.post-header { text-align: center; margin-bottom: 2.6rem; }

.page-title,
.post-title {
  font-size: clamp(2rem, 1.35rem + 2.6vw, 2.85rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
}

.dek {
  margin: 1rem auto 0;
  max-width: 30rem;
  color: var(--ink-soft);
  font-size: 1.14rem;
  font-style: italic;
  line-height: 1.5;
  text-wrap: pretty;
}

.post-meta { margin-top: 1.4rem; color: var(--ink-soft); }
.sep { margin: 0 0.6em; color: var(--gold); }

.list-intro { margin: 1rem auto 0; max-width: 30rem; color: var(--ink-soft); font-style: italic; }
.list-intro a { text-decoration-color: var(--gold); text-underline-offset: 0.18em; }

.empty { color: var(--ink-soft); font-style: italic; text-align: center; padding: 2rem 0; }

/* ---------- 5. Reading (the body of every essay and page) ---------- */
.prose {
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
  text-wrap: pretty;
}
@media (min-width: 40em) { .prose { hyphens: manual; -webkit-hyphens: manual; } }

.prose > * + * { margin-top: 1.15em; }

.prose a,
.footer-links a,
.author-note a,
.feed-card a,
.home-start a,
.more a {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-thickness 0.15s ease, color 0.15s ease;
}
.prose a:hover,
.footer-links a:hover,
.author-note a:hover,
.feed-card a:hover,
.home-start a:hover,
.more a:hover { text-decoration-thickness: 2px; color: var(--gold-text); }

.prose h2 { font-size: 1.42rem; margin-top: 2.3em; }
.prose h3 { font-size: 1.18rem; margin-top: 2em; }
.prose h4, .prose h5, .prose h6 { font-size: 1rem; margin-top: 1.8em; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: 0.7em; }

.prose strong { font-weight: 650; }

.prose ul, .prose ol { padding-left: 1.35em; margin-bottom: 0; }
.prose li + li { margin-top: 0.4em; }
.prose li > ul, .prose li > ol { margin-top: 0.4em; }
.prose li > p + p { margin-top: 0.8em; }
.prose li::marker { color: var(--gold-text); }

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 0.1em 0 0.1em 1.3rem;
  border-left: 2px solid var(--gold);
  font-style: italic;
}
.prose blockquote > * + * { margin-top: 0.9em; }
.prose blockquote em { font-style: normal; }

/* Pull quote: {{pull: ...}} in Markdown */
.pull-quote {
  margin: 2.4em 0;
  padding: 1.5rem 0.5rem 0;
  text-align: center;
  font-size: 1.36rem;
  font-style: italic;
  line-height: 1.42;
  text-wrap: balance;
}
.pull-quote::before {
  content: "";
  display: block;
  width: 3rem;
  height: 2px;
  margin: 0 auto 1.4rem;
  background: var(--gold);
}
.prose > .pull-quote + * { margin-top: 2.4em; }

.prose hr {
  border: 0;
  height: 1px;
  width: 4rem;
  margin: 2.6em auto;
  background: var(--gold);
}

.prose code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--paper-deep);
  padding: 0.12em 0.32em;
  border-radius: 3px;
}
.prose pre {
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.55;
  hyphens: none;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }

.prose figure { margin-left: 0; margin-right: 0; }
.prose figure img { display: block; margin: 0 auto; border-radius: 2px; }
figcaption {
  margin-top: 0.7rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
  line-height: 1.5;
}

.prose table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.prose th, .prose td { border-bottom: 1px solid var(--rule); padding: 0.45rem 0.6rem; text-align: left; }

/* ---------- 6. Video (click to play) ---------- */
.video { margin: 2.2rem 0; }
.post > .video,
.home-video .video {
  /* a little wider than the text column on big screens */
  width: min(100vw - 2 * var(--gutter), 44rem);
  margin-left: 50%;
  transform: translateX(-50%);
}
.video-frame,
.video-card-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--ink);
  border-radius: 4px;
}
.video-frame iframe,
.video-frame img,
.video-card-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
}
.video-facade { position: absolute; inset: 0; display: block; color: var(--paper); }
.video-facade::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(27, 42, 65, 0.78), rgba(27, 42, 65, 0.08) 55%);
}
.video-play {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 4.4rem;
  height: 4.4rem;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(250, 246, 238, 0.95);
  box-shadow: 0 6px 24px rgba(27, 42, 65, 0.35);
  transition: background 0.2s ease, transform 0.2s ease;
}
.video-play::after {
  content: "";
  position: absolute;
  left: 54%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 0.68rem 0 0.68rem 1.12rem;
  border-color: transparent transparent transparent var(--ink);
}
.video-play--small { width: 3.1rem; height: 3.1rem; }
.video-play--small::after { border-width: 0.5rem 0 0.5rem 0.82rem; }
.video-facade:hover .video-play,
.video-facade:focus-visible .video-play,
.video-card-thumb:hover .video-play { background: #fff; transform: translate(-50%, -50%) scale(1.06); }
.video-facade:hover .video-play::after { border-left-color: var(--gold-text); }
.video-label {
  position: absolute;
  left: 1.1rem;
  bottom: 0.9rem;
  z-index: 1;
  color: var(--paper);
}
.video-facade:focus-visible { outline-offset: -4px; outline-color: var(--paper); }

/* ---------- 7. Lists of essays ---------- */
.entry { padding: 1.5rem 0 1.6rem; border-top: 1px solid var(--rule); }
.entry:last-of-type { border-bottom: 1px solid var(--rule); }
.entry-meta { color: var(--ink-soft); }
.entry-title { font-size: 1.36rem; line-height: 1.24; margin: 0.4rem 0 0.45rem; }
.entry-title a {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(var(--gold), var(--gold));
  background-size: 0 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.25s ease;
}
.entry-title a:hover { background-size: 100% 1px; }
.entry-summary { color: var(--ink-soft); font-size: 0.97rem; line-height: 1.55; text-wrap: pretty; }

.year,
.section-label {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--gold-text);
}
.year::after,
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--gold); opacity: 0.45; }
.year { margin: 2.6rem 0 0.2rem; }
.listing > .year:first-of-type { margin-top: 0; }
.section-label { margin-bottom: 0.4rem; }
.year + .entry,
.section-label + .entry { border-top: 0; }

.more { margin-top: 1.2rem; text-align: right; font-size: 0.92rem; font-style: italic; }

.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.tags a {
  display: inline-block;
  padding: 0.18rem 0.75rem;
  border: 1px solid rgba(95, 122, 97, 0.45);
  border-radius: 999px;
  background: rgba(95, 122, 97, 0.07);
  color: var(--sage-text);
  font-size: 0.8rem;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tags a:hover { background: rgba(95, 122, 97, 0.15); border-color: var(--sage); }

.tag-index { list-style: none; padding: 0; margin: 0; columns: 2 12rem; column-gap: 2rem; }
.tag-index li { padding: 0.5rem 0; border-bottom: 1px solid var(--rule); break-inside: avoid; }
.tag-index a { color: var(--sage-text); text-decoration: none; }
.tag-index a:hover { text-decoration: underline; text-underline-offset: 0.2em; }
.count { color: var(--ink-soft); font-size: 0.8rem; margin-left: 0.3rem; }

/* Watch page */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
  gap: 2.4rem 1.8rem;
}
.video-card .entry-meta { margin-top: 0.9rem; }
.video-card .entry-title { font-size: 1.18rem; }

/* ---------- 8. End of a post ---------- */
.post-footer { margin-top: 3.2rem; }
.end-mark {
  width: 0.55rem;
  height: 0.55rem;
  margin: 0 auto 2.4rem;
  background: var(--gold);
  transform: rotate(45deg);
}
.post-footer .tags { margin-bottom: 2.4rem; }

.author-note,
.feed-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.2rem 1.3rem;
  background: var(--paper-deep);
  border-radius: 4px;
  font-size: 0.92rem;
  line-height: 1.55;
}
.author-note img { flex: none; width: 2.3rem; height: 2.3rem; border-radius: 5px; }

.feed-card { display: block; margin-top: 2.6rem; border-left: 2px solid var(--gold); border-radius: 0 4px 4px 0; }
.feed-card > * + * { margin-top: 0.6rem; }
.feed-card .kicker { margin-bottom: 0; }
.feed-url code { font-family: var(--mono); font-size: 0.85em; overflow-wrap: anywhere; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2.4rem; }
.post-nav a {
  display: block;
  padding: 1rem 0 0;
  border-top: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
}
.post-nav a:hover .post-nav-title { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 0.2em; }
.post-nav-label { display: block; color: var(--gold-text); margin-bottom: 0.3rem; }
.post-nav-title { display: block; font-size: 0.98rem; line-height: 1.35; font-weight: 600; }
.post-nav-newer { grid-column: 2; text-align: right; }

.page-list { margin-top: 3rem; }

/* ---------- 8b. Comments (under each post; script in js/comments.js) ---------- */
.comments { margin-top: 3.6rem; }
.comments-count,
.comments-note { color: var(--ink-soft); font-style: italic; font-size: 0.95rem; }
.comments-count { margin-top: 0.6rem; }

.comment-list { list-style: none; margin: 1.2rem 0 0; padding: 0; }
.comment { padding: 1.2rem 0 1.3rem; border-top: 1px solid var(--rule); }
.comment:last-child { border-bottom: 1px solid var(--rule); }
.comment-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.8rem; margin-bottom: 0.45rem; }
.comment-name { font-weight: 600; }
.comment-date { color: var(--ink-soft); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase; }
.comment-body { font-size: 0.97rem; line-height: 1.6; overflow-wrap: anywhere; }
.comment-body > p + p { margin-top: 0.8em; }

.comment-form {
  margin-top: 2.4rem;
  padding: 1.4rem 1.3rem 1.5rem;
  background: var(--paper-deep);
  border-left: 2px solid var(--gold);
  border-radius: 0 4px 4px 0;
}
.comment-form-title { font-size: 1.18rem; }
.comment-form .comments-note { margin-top: 0.3rem; }
.comment-form .field { margin-top: 1.1rem; }
.comment-form label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; font-weight: 600; }
.field-hint { font-weight: 400; font-style: italic; color: var(--ink-soft); }
.comment-form input,
.comment-form textarea {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.5;
}
.comment-form textarea { resize: vertical; min-height: 8rem; }
.comment-form input:focus,
.comment-form textarea:focus { border-color: var(--gold); outline: 2px solid var(--gold-text); outline-offset: 1px; }

/* The trap for robots: off screen, skipped by keyboards and screen readers. */
.comment-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.comment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin-top: 1.2rem; }
.comment-form button {
  min-height: 2.75rem;
  padding: 0 1.3rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.comment-form button:hover { background: #2a3d5a; }
.comment-form button:disabled { opacity: 0.6; cursor: wait; }
.comment-status { font-size: 0.92rem; font-style: italic; color: var(--ink-soft); }
.comment-status.is-done { color: var(--sage-text); }
.comment-status.is-error { color: #8a2a17; }

/* ---------- 9. Home ---------- */
.home-intro { text-align: center; margin-bottom: 3.6rem; }
.home-title {
  font-size: clamp(2.1rem, 1.3rem + 3vw, 3.1rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.home-statement { margin-top: 1.8rem; text-align: left; font-size: 1.06rem; }
.home-start { margin-top: 1.8rem; font-style: italic; }
.home-section { margin-top: 3.6rem; }
.home-video .video { margin-top: 1.2rem; }
.home-video .entry-title { margin-top: 1rem; }

/* ---------- 10. Footer ---------- */
.site-footer {
  margin-top: 5rem;
  padding: 2.4rem var(--gutter) 3rem;
  border-top: 1px solid var(--rule);
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.6;
}
.site-footer p + p { margin-top: 0.45rem; }
.footer-mark { display: block; margin: 0 auto 1rem; width: 1.5rem; height: 1.5rem; border-radius: 4px; opacity: 0.9; }
.footer-sign { color: var(--ink); }
.footer-privacy { font-style: italic; }

/* ---------- 11. Comfort and print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

@media print {
  html { font-size: 11pt; }
  body { background: #fff; }
  .masthead, .site-footer, .nav-toggle, .skip-link, .post-nav, .author-note, .video, .feed-card, .comments { display: none; }
  main { width: auto; padding: 0; }
  .prose a::after { content: " (" attr(href) ")"; font-size: 0.85em; color: var(--ink-soft); }
}
