/* ============================================================
   BACKGROUND — change this one line to restyle the whole site.
   Accepts any CSS value: a hex color, an rgb(), a gradient,
   or url('path/to/image.jpg') for a full-bleed texture.

   Examples:
     --site-bg: #0d0d0d;                          dark mode
     --site-bg: #1a1a2e;                          midnight navy
     --site-bg: linear-gradient(135deg, #f5f0e8, #e8e0d0);
     --site-bg: url('/img/paper-texture.jpg');
   ============================================================ */

:root {
  --site-bg: #f5f0e8;

  /* Typography */
  --color-ink:       #1a1612;
  --color-ink-muted: #5a5248;
  --color-ink-faint: #9a9088;
  --color-accent:    #7a3b1e;
  --color-rule:      #c8bfb0;

  /* Spacing scale */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  2rem;
  --space-xl:  4rem;
  --space-2xl: 6rem;

  /* Type scale */
  --text-sm:   0.875rem;
  --text-base: 1.125rem;
  --text-lg:   1.375rem;
  --text-xl:   1.75rem;
  --text-2xl:  2.25rem;
  --text-3xl:  3rem;
  --text-4xl:  4rem;

  /* Layout */
  --measure: 68ch;
  --gutter:  clamp(1.25rem, 5vw, 3rem);
}

/* ============================================================
   CORNER DECORATIONS
   ============================================================ */

.corner {
  position: fixed;
  width: clamp(80px, 10vw, 140px);
  height: auto;
  pointer-events: none;
  z-index: 100;
  mix-blend-mode: multiply;
}

.corner--tl { top: 0;    left: 0;  transform: rotate(0deg); }
.corner--tr { top: 0;    right: 0; transform: rotate(90deg); }
.corner--bl { bottom: 0; left: 0;  transform: rotate(270deg); }
.corner--br { bottom: 0; right: 0; transform: rotate(180deg); }

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--site-bg);
  color: var(--color-ink);
  font-family: 'IM Fell English', Georgia, 'Times New Roman', serif;
  font-size: var(--text-base);
  line-height: 1.75;
  min-height: 100vh;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: 'IM Fell English', Georgia, serif;
  font-weight: 400;
  line-height: 1.2;
  color: var(--color-ink);
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(var(--text-2xl), 5vw, var(--text-4xl)); }
h2 { font-size: clamp(var(--text-xl),  4vw, var(--text-3xl)); }
h3 { font-size: clamp(var(--text-lg),  3vw, var(--text-2xl)); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  margin-bottom: 1.5em;
  hanging-punctuation: first;
}

/* Optical margin alignment for punctuation */
p:first-of-type,
.post-body > p:first-child {
  text-indent: 0;
}

p + p {
  text-indent: 1.5em;
  margin-bottom: 0;
  margin-top: 0;
}

p + p + p {
  text-indent: 1.5em;
}

/* Only the first paragraph after headings gets no indent */
h1 + p, h2 + p, h3 + p, h4 + p, h5 + p, h6 + p,
.post-body > p:first-child {
  text-indent: 0;
}

em, i {
  font-style: italic;
}

strong, b {
  font-weight: 700;
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease, opacity 0.15s ease;
}

a:hover {
  opacity: 0.7;
}

blockquote {
  border-left: 2px solid var(--color-rule);
  margin: var(--space-lg) 0 var(--space-lg) var(--space-md);
  padding: var(--space-sm) 0 var(--space-sm) var(--space-lg);
  color: var(--color-ink-muted);
  font-style: italic;
}

blockquote p {
  text-indent: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--color-rule);
  margin: var(--space-xl) auto;
  width: 30%;
}

code {
  font-family: 'Courier New', monospace;
  font-size: 0.875em;
  background: rgba(0,0,0,0.06);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}

pre {
  background: rgba(0,0,0,0.06);
  border-left: 2px solid var(--color-rule);
  padding: var(--space-md) var(--space-lg);
  overflow-x: auto;
  margin: var(--space-lg) 0;
}

pre code {
  background: none;
  padding: 0;
}

ul, ol {
  padding-left: 1.5em;
  margin-bottom: 1.5em;
}

li {
  margin-bottom: 0.35em;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.site-wrapper {
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ============================================================
   SITE HEADER
   ============================================================ */

.site-header {
  padding: var(--space-xl) 0 var(--space-lg);
  border-bottom: 1px solid var(--color-rule);
  margin-bottom: var(--space-xl);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.site-title {
  font-size: clamp(var(--text-lg), 3vw, var(--text-2xl));
  letter-spacing: 0.04em;
  text-transform: lowercase;
  font-style: italic;
}

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

.site-title a:hover {
  opacity: 0.6;
}

.site-nav {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-nav a {
  font-size: var(--text-sm);
  text-decoration: none;
  color: var(--color-ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

/* ============================================================
   SITE FOOTER
   ============================================================ */

.site-footer {
  border-top: 1px solid var(--color-rule);
  margin-top: var(--space-2xl);
  padding: var(--space-xl) 0;
  color: var(--color-ink-faint);
  font-size: var(--text-sm);
  font-style: italic;
  text-align: center;
}

/* ============================================================
   INDEX / POST LIST
   ============================================================ */


.index-intro {
  color: var(--color-ink-muted);
  font-style: italic;
  max-width: 50ch;
  margin-top: 0;
  margin-bottom: var(--space-xl);
  text-indent: 0;
}

.index-hero {
  display: block;
  width: 100%;
  max-width: 460px;
  height: auto;
  margin: 0 auto var(--space-xl);
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-rule);
}

.post-list-item:first-child {
  border-top: 1px solid var(--color-rule);
}

.post-list-title {
  font-size: var(--text-lg);
  font-weight: 400;
}

.post-list-title a {
  text-decoration: none;
  color: var(--color-ink);
  font-style: italic;
}

.post-list-title a:hover {
  color: var(--color-accent);
}

.post-list-date {
  font-size: var(--text-sm);
  color: var(--color-ink-faint);
  white-space: nowrap;
  font-style: normal;
}

/* ============================================================
   SINGLE POST
   ============================================================ */

.post-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-rule);
}

.post-title {
  font-style: italic;
  margin-bottom: var(--space-md);
  line-height: 1.15;
}

.post-meta {
  display: flex;
  gap: var(--space-lg);
  align-items: center;
  flex-wrap: wrap;
  color: var(--color-ink-faint);
  font-size: var(--text-sm);
}

.post-meta time {
  font-style: normal;
}

.post-meta .reading-time {
  font-style: italic;
}

.post-meta .post-tags {
  display: flex;
  gap: var(--space-sm);
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-meta .post-tags li a {
  color: var(--color-ink-faint);
  font-size: var(--text-sm);
  text-decoration: none;
  border-bottom: 1px solid var(--color-rule);
}

.post-meta .post-tags li a:hover {
  color: var(--color-ink);
  border-bottom-color: var(--color-ink);
}

/* Drop cap on first paragraph of post body */
.post-body > p:first-child::first-letter {
  float: left;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 4.5em;
  line-height: 0.78;
  padding-right: 0.08em;
  padding-top: 0.05em;
  color: var(--color-ink);
  font-style: normal;
}

.post-body {
  max-width: var(--measure);
}

/* Post description / lede */
.post-description {
  font-size: var(--text-lg);
  color: var(--color-ink-muted);
  font-style: italic;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-rule);
  line-height: 1.5;
}

/* Section breaks inside posts */
.post-body h2 {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  font-style: italic;
}

.post-body h3 {
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

/* ============================================================
   MEDIA FIGURES (images, video, audio)
   ============================================================ */

.media-figure {
  margin: var(--space-xl) 0;
  display: block;
}

.media-figure img {
  display: block;
  width: 100%;
  height: auto;
  /* Subtle border for images on light backgrounds */
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.media-figure figcaption {
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
  font-style: italic;
  text-align: center;
  line-height: 1.5;
}

/* Video figures */
.media-figure--video video,
.media-figure--video .youtube-wrapper {
  display: block;
  width: 100%;
}

/* Responsive YouTube iframe */
.youtube-wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
}

.youtube-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Audio figures */
.media-figure--audio audio {
  display: block;
  width: 100%;
  margin-bottom: var(--space-sm);
}

/* ============================================================
   WIDE FIGURES — break out of the measure for a cinematic feel
   ============================================================ */

@media (min-width: 900px) {
  .media-figure--wide {
    margin-left: calc(var(--measure) * -0.12);
    margin-right: calc(var(--measure) * -0.12);
  }
}

/* ============================================================
   TAG PAGE
   ============================================================ */

.tag-header {
  margin-bottom: var(--space-xl);
}

.tag-name {
  font-style: italic;
  color: var(--color-accent);
}

/* ============================================================
   404
   ============================================================ */

.not-found {
  padding: var(--space-2xl) 0;
  text-align: center;
}

.not-found h1 {
  font-size: var(--text-4xl);
  font-style: italic;
  margin-bottom: var(--space-md);
}

/* ============================================================
   UTILITIES
   ============================================================ */

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

/* ============================================================
   MOBILE ADJUSTMENTS
   ============================================================ */

@media (max-width: 600px) {
  .post-list-item {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }

  .post-list-date {
    order: -1;
    font-size: 0.8rem;
  }

  .site-header {
    padding: var(--space-lg) 0;
  }

  .post-body > p:first-child::first-letter {
    font-size: 3.8em;
  }
}
