/* Poor Yorick's Almanack — stylesheet
   Light/dark tokens with a data-theme override. See the theme-toggle script. */

@import url("https://fonts.googleapis.com/css2?family=IM+Fell+English:ital@0;1&family=IM+Fell+English+SC&family=JetBrains+Mono:wght@400&display=swap");

/* ── Color tokens ── */
:root {
  --bg:           #f5f0e8;
  --bg-raised:    #ede7d7;
  --fg:           #1e1208;
  --fg-muted:     #5a4a32;
  --accent:       #7b3f1a;
  --accent-hover: #a0521f;
  --rule:         #c4a97a;
  --code-bg:      #e8e0ce;
  --selection-bg: #d4b896;
  color-scheme: light;
}

/* Follow the OS setting unless the visitor has chosen light explicitly */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #1a1812;
    --bg-raised:    #22201a;
    --fg:           #e8b84b;
    --fg-muted:     #a07830;
    --accent:       #f0c060;
    --accent-hover: #ffd980;
    --rule:         #5a4820;
    --code-bg:      #201e18;
    --selection-bg: #5a4010;
    color-scheme: dark;
  }
}

/* Explicit dark choice from the toggle */
:root[data-theme="dark"] {
  --bg:           #1a1812;
  --bg-raised:    #22201a;
  --fg:           #e8b84b;
  --fg-muted:     #a07830;
  --accent:       #f0c060;
  --accent-hover: #ffd980;
  --rule:         #5a4820;
  --code-bg:      #201e18;
  --selection-bg: #5a4010;
  color-scheme: dark;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; }

::selection { background: var(--selection-bg); color: var(--fg); }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'IM Fell English', Georgia, 'Times New Roman', serif;
  font-size: clamp(1rem, 1.1vw + 0.6rem, 1.2rem);
  line-height: 1.75;
  margin: 0;
  padding-left:  max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0;
}

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

.site-wrapper {
  max-width: 42rem;
  margin-inline: auto;
  padding-block: 2.5rem 4rem;
}

/* ── Theme toggle ── */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  color: var(--fg-muted);
  font-family: 'IM Fell English SC', Georgia, serif;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  z-index: 100;
}
.theme-toggle:hover { color: var(--accent); }

/* ── Site header ── */
.site-header {
  text-align: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--rule);
}

.site-header::after {
  content: "❧";
  display: block;
  color: var(--rule);
  font-size: 1.4rem;
  margin-top: 0.75rem;
}

.site-title {
  font-family: 'IM Fell English SC', 'IM Fell English', Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: normal;
  letter-spacing: 0.03em;
  margin: 0 0 0.25rem;
  line-height: 1.2;
  color: var(--fg);
}

.site-tagline {
  font-style: italic;
  color: var(--fg-muted);
  font-size: 0.9em;
  margin: 0;
}

.site-nav {
  margin-top: 1rem;
  font-family: 'IM Fell English SC', 'IM Fell English', Georgia, serif;
  font-size: 0.85em;
  letter-spacing: 0.08em;
}

.site-nav a {
  color: var(--fg-muted);
  text-decoration: none;
  margin-inline: 0.6rem;
}
.site-nav a:hover { color: var(--accent); }

/* ── Typography ── */
h1, h2, h3 {
  font-family: 'IM Fell English SC', 'IM Fell English', Georgia, serif;
  font-weight: normal;
  line-height: 1.25;
  text-wrap: balance;
  color: var(--fg);
  margin-block: 1.6em 0.5em;
}

h1 { font-size: 1.9em; }
h2 { font-size: 1.45em; }
h3 { font-size: 1.2em; }

p { margin-block: 0 1em; }

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

hr { border: none; border-top: 1px solid var(--rule); margin-block: 2rem; }

.ornament {
  text-align: center;
  color: var(--rule);
  font-size: 1.2rem;
  margin-block: 2rem;
  letter-spacing: 0.4em;
}

/* ── Post list ── */
.post-list { list-style: none; padding: 0; margin: 0; }

.post-list-item {
  padding-block: 1.4rem;
  border-bottom: 1px solid var(--rule);
}
.post-list-item:last-child { border-bottom: none; }

.post-list-title { margin: 0 0 0.2rem; font-size: 1.25em; }
.post-list-title a { color: var(--fg); text-decoration: none; }
.post-list-title a:hover { color: var(--accent); }

.post-meta {
  font-family: 'IM Fell English SC', Georgia, serif;
  font-size: 0.8em;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  margin-bottom: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  align-items: center;
}

.tag {
  font-family: 'IM Fell English SC', Georgia, serif;
  font-size: 0.75em;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  border: 1px solid var(--rule);
  padding: 0.1em 0.5em;
  text-decoration: none;
}
.tag:hover { color: var(--accent); border-color: var(--accent); }

.post-list-summary {
  font-size: 0.95em;
  color: var(--fg-muted);
  font-style: italic;
  margin: 0;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: 'IM Fell English SC', Georgia, serif;
  font-size: 0.85em;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.pagination a { color: var(--fg-muted); text-decoration: none; }
.pagination a:hover { color: var(--accent); }

/* ── Single post ── */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.post-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  margin-block: 0 0.4rem;
}

/* Drop cap */
.post-content > p:first-of-type::first-letter {
  float: left;
  font-family: 'IM Fell English SC', Georgia, serif;
  font-size: 3.5em;
  line-height: 0.8;
  padding-right: 0.1em;
  margin-top: 0.05em;
  color: var(--accent);
}

.post-content blockquote {
  background: var(--bg-raised);
  border-left: 3px solid var(--rule);
  margin-inline: 0;
  padding: 0.75rem 1.25rem;
  font-style: italic;
  color: var(--fg-muted);
}

.post-content code {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
}

.post-content pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
}
.post-content pre code { background: none; padding: 0; }

.post-content figure {
  margin: 1.75rem 0;
  text-align: center;
}
.post-content figure img {
  display: block;
  margin-inline: auto;
}
.post-content figcaption {
  font-family: 'IM Fell English SC', Georgia, serif;
  font-size: 0.85em;
  letter-spacing: 0.04em;
  font-style: italic;
  color: var(--fg-muted);
  margin-top: 0.5rem;
}

.post-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: 'IM Fell English SC', Georgia, serif;
  font-size: 0.82em;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  text-align: center;
}
.post-footer a { color: var(--fg-muted); text-decoration: none; }
.post-footer a:hover { color: var(--accent); }

/* ── Site footer ── */
.site-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--rule);
  text-align: center;
  font-family: 'IM Fell English SC', Georgia, serif;
  font-size: 0.78em;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}
