/* Tokens carried over from the site's Ghost "Source" theme settings. */
:root {
  --bg: #e8e1dc;
  --ink: #15171a;
  --muted: #5d5a56;
  --line: #cfc6bf;
  --surface: #f3eeea;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --wide: 1200px;
  --text: 680px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}
img, video, iframe { max-width: 100%; }
img { height: auto; display: block; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
time { color: var(--muted); font-size: 0.875rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  padding: 0.5rem 1rem;
  background: var(--ink);
  color: var(--bg);
  z-index: 10;
}
.skip-link:focus { top: 1rem; }

/* --- Header and footer --------------------------------------------------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.25rem var(--gutter);
  border-bottom: 1px solid var(--line);
}
.site-logo { order: 1; flex: none; }
.site-logo img { width: 48px; height: 48px; object-fit: contain; }
.site-name { order: 2; margin: 0; font-size: 1.125rem; font-weight: 700; letter-spacing: -0.01em; }
.site-name a { text-decoration: none; }
.site-nav { order: 3; display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; margin-left: auto; }
.site-nav a { text-decoration: none; padding: 0.5rem 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 3rem;
  max-width: var(--wide);
  margin: 4rem auto 0;
  padding: 2rem var(--gutter) 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}
.site-footer p { margin: 0; max-width: 60ch; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

main { max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }

/* --- Shared story parts --------------------------------------------------- */
.eyebrow {
  display: inline-block;
  margin-bottom: 0.375rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
}
.eyebrow:hover { color: var(--ink); }
.card-title a, .highlight-title a, .side-title a { text-decoration: none; }
.card-title a:hover, .highlight-title a:hover, .side-title a:hover { text-decoration: underline; text-underline-offset: 0.15em; }
.card-excerpt { margin: 0 0 0.5rem; color: var(--muted); font-family: var(--serif); }
.placeholder { object-fit: contain !important; padding: 25%; background: var(--surface); opacity: 0.6; }

/* --- Home: highlight ------------------------------------------------------ */
.highlight {
  display: grid;
  gap: 2.5rem;
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--line);
}
.highlight-media { display: block; margin-bottom: 1rem; }
.highlight-media img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.highlight-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.highlight-side { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.25rem; align-content: start; }
.highlight-side li {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.highlight-side li:last-child { border-bottom: 0; padding-bottom: 0; }
.side-media img { width: 96px; aspect-ratio: 1; object-fit: cover; }
.side-title { margin: 0 0 0.25rem; font-size: 1.0625rem; line-height: 1.25; }

/* --- Card grids ------------------------------------------------------------ */
.section-heading {
  margin: 2.5rem 0 1.5rem;
  font-size: 0.875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 2.5rem 2rem; }
.card { display: flex; flex-direction: column; min-width: 0; }
.card-media { display: block; margin-bottom: 0.875rem; }
.card-media img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.card-title { margin: 0 0 0.375rem; font-size: 1.25rem; line-height: 1.2; letter-spacing: -0.01em; }
.card-excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

/* --- Tag and author archives ----------------------------------------------- */
.archive-header { padding: 3rem 0 2.5rem; }
.archive-header h1 { margin: 0 0 0.5rem; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; letter-spacing: -0.02em; }
.archive-header p { margin: 0 0 0.5rem; max-width: 60ch; font-family: var(--serif); font-size: 1.125rem; }
.archive-header .archive-count { color: var(--muted); font-family: var(--sans); font-size: 0.875rem; }
.avatar { width: 96px; height: 96px; margin-bottom: 1rem; border-radius: 50%; object-fit: cover; }

/* --- Article --------------------------------------------------------------- */
.article-header { max-width: var(--text); margin: 0 auto; padding: 3rem 0 1.5rem; }
.article-title { margin: 0 0 0.75rem; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; letter-spacing: -0.02em; }
.article-excerpt { margin: 0 0 1rem; color: var(--muted); font-family: var(--serif); font-size: 1.25rem; line-height: 1.4; }
.article-meta { margin: 0; color: var(--muted); font-size: 0.875rem; }
.article-meta a { text-decoration: none; font-weight: 600; color: var(--ink); }
.article-meta a:hover { text-decoration: underline; }
.article-feature { max-width: 1000px; margin: 0 auto 2.5rem; }
.article-feature.narrow { max-width: var(--text); }
.article-feature img { width: 100%; }
.article-feature figcaption, .article-content figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
}

.article-content {
  max-width: var(--text);
  margin: 0 auto;
  padding-top: 0.5rem;
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.65;
}
.article-content > * { margin-top: 0; margin-bottom: 1.5rem; }
/* flow-root: a one-line opening paragraph must not let the drop cap push the next block aside. */
.article-content > p:first-child { display: flow-root; }
.article-content > p:first-child::first-letter {
  float: left;
  margin: 0.08em 0.12em 0 0;
  font-size: 3.4em;
  line-height: 0.85;
  font-weight: 700;
}
.article-content h1, .article-content h2, .article-content h3,
.article-content h4, .article-content h5, .article-content h6 {
  margin: 2.5rem 0 0.75rem;
  font-family: var(--sans);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.article-content h2 { font-size: 1.75rem; }
.article-content h3 { font-size: 1.375rem; }
.article-content h4 { font-size: 1.125rem; }
.article-content a { text-underline-offset: 0.15em; }
.article-content ul, .article-content ol { padding-left: 1.5rem; }
.article-content li + li { margin-top: 0.375rem; }
.article-content hr { margin: 3rem 0; border: 0; border-top: 1px solid var(--line); }
.article-content blockquote { margin-left: 0; margin-right: 0; padding-left: 1.25rem; border-left: 3px solid var(--ink); font-style: italic; }
.article-content blockquote p:last-child { margin-bottom: 0; }
.article-content pre {
  padding: 1rem;
  overflow-x: auto;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.875rem;
  line-height: 1.5;
}
.article-content code { font-size: 0.875em; }
.article-content table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; font-family: var(--sans); font-size: 0.9375rem; }
.article-content th, .article-content td { padding: 0.5rem 0.75rem; border: 1px solid var(--line); text-align: left; }
.article-content iframe { display: block; margin-left: auto; margin-right: auto; }
.article-content .video-embed { width: 100%; height: auto; }
.article-content figure { margin-left: 0; margin-right: 0; }
.article-content .twitter-tweet { margin-left: auto; margin-right: auto; }

/* Koenig cards from Ghost's editor. */
.kg-card { margin-bottom: 1.5rem; }
.kg-image { margin: 0 auto; }
.kg-width-wide, .kg-width-full { position: relative; left: 50%; transform: translateX(-50%); }
.kg-width-wide { width: min(1000px, calc(100vw - 2 * var(--gutter))); max-width: none; }
.kg-width-full { width: 100vw; max-width: none; }
.kg-width-wide img, .kg-width-full img { width: 100%; }
.kg-embed-card { display: flex; flex-direction: column; align-items: center; }
.kg-embed-card > * { max-width: 100%; }

.kg-gallery-container { display: flex; flex-direction: column; gap: 0.5rem; }
.kg-gallery-row { display: flex; gap: 0.5rem; }
.kg-gallery-image { min-width: 0; }
.kg-gallery-image img { width: 100%; height: 100%; object-fit: cover; }

.kg-button-card { display: flex; justify-content: center; }
.kg-btn {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
}
.kg-btn:hover { opacity: 0.85; }

.kg-bookmark-card { font-family: var(--sans); }
.kg-bookmark-container {
  display: flex;
  min-height: 140px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
}
.kg-bookmark-content { flex: 1 1 60%; min-width: 0; padding: 1rem 1.25rem; }
.kg-bookmark-title { font-size: 1rem; font-weight: 600; line-height: 1.3; }
.kg-bookmark-description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.4;
}
.kg-bookmark-metadata {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.625rem;
  color: var(--muted);
  font-size: 0.8125rem;
}
.kg-bookmark-icon { width: 18px; height: 18px; }
.kg-bookmark-author::after { content: "·"; margin-left: 0.375rem; }
.kg-bookmark-author:last-child::after { content: none; }
.kg-bookmark-thumbnail { position: relative; flex: 0 1 35%; min-width: 0; }
.kg-bookmark-thumbnail img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.kg-file-card-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--sans);
  text-decoration: none;
}
.kg-file-card-contents { min-width: 0; }
.kg-file-card-title { font-weight: 600; line-height: 1.3; }
.kg-file-card-caption, .kg-file-card-metadata { color: var(--muted); font-size: 0.875rem; }
.kg-file-card-filename { display: inline; }
.kg-file-card-filesize::before { content: " · "; }
.kg-file-card-icon { flex: none; width: 24px; height: 24px; }
.kg-file-card-icon svg { width: 100%; height: 100%; }

.article-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; max-width: var(--text); margin: 3rem auto 0; }
.article-tags a {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--line);
  font-size: 0.875rem;
  text-decoration: none;
}
.article-tags a:hover { border-color: var(--ink); }
.article-tags:empty { display: none; }

@media (min-width: 900px) {
  .highlight { grid-template-columns: 3fr 2fr; gap: 3rem; }
}

@media (max-width: 600px) {
  .site-nav { margin-left: 0; width: 100%; gap: 0.25rem 1.25rem; }
  .kg-bookmark-container { flex-direction: column-reverse; }
  .kg-bookmark-thumbnail { flex: none; height: 160px; }
}
