/* ============================================================
   weblog — an old-school theme
   Inspirations: jwz.org/blog, simonwillison.net
   Philosophy: content first, plain semantic HTML, no JS required,
   readable typography, visible link conventions.
   ============================================================ */

:root {
  --fg:           #111;
  --fg-muted:     #555;
  --fg-faint:     #888;
  --bg:           #fdfdfb;          /* not pure white, off-paper */
  --bg-alt:       #f4f1e8;          /* faint cream for blocks */
  --rule:         #d8d4c5;          /* sepia rule */
  --link:         #0044aa;          /* classic deep blue */
  --link-visited: #6a1b9a;          /* classic visited purple */
  --link-hover:   #cc2200;
  --accent:       #8b0000;          /* dark red for tags / accents */
  --code-bg:      #ececec;

  --serif:  Georgia, 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Times New Roman', serif;
  --sans:   -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono:   ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', monospace;

  --measure:    38rem;               /* readable line length */
  --sidebar:    14rem;               /* sidebar width */
  --gutter:     2.5rem;              /* gap between content and sidebar */
}

/* Dark palette. Applied when:
   - user explicitly chose dark via the toggle (data-theme="dark"), OR
   - user is on auto (no data-theme set) AND system prefers dark.
   The :not() guards make sure an explicit data-theme="light" wins over system dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg:           #e6e2d8;
    --fg-muted:     #a7a395;
    --fg-faint:     #7a7668;
    --bg:           #161513;
    --bg-alt:       #201d18;
    --rule:         #3a362d;
    --link:         #82b1ff;
    --link-visited: #d7a4ff;
    --link-hover:   #ff8a6b;
    --accent:       #ff8a6b;
    --code-bg:      #24211c;
  }
}
:root[data-theme="dark"] {
  --fg:           #e6e2d8;
  --fg-muted:     #a7a395;
  --fg-faint:     #7a7668;
  --bg:           #161513;
  --bg-alt:       #201d18;
  --rule:         #3a362d;
  --link:         #82b1ff;
  --link-visited: #d7a4ff;
  --link-hover:   #ff8a6b;
  --accent:       #ff8a6b;
  --code-bg:      #24211c;
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  font-family: var(--serif);
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page {
  /* Left-anchored, fills the viewport. Content grows to fill width - sidebar. */
  margin: 0;
  padding: 1.5rem 1.25rem 4rem;
}

@media (min-width: 60rem) {
  .page {
    padding: 2.5rem clamp(8rem, 18vw, 28rem) 4rem clamp(8rem, 18vw, 28rem);
  }
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--sidebar);
    column-gap: var(--gutter);
    align-items: start;
  }
}

.content { min-width: 0; }

/* ---------- Masthead ---------- */

.masthead {
  border-bottom: 2px solid var(--fg);
  padding-bottom: 0.6rem;
  margin-bottom: 2rem;
}

.site-title {
  font-family: var(--sans);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 0.1rem;
  line-height: 1.1;
}
.site-title a { color: var(--fg); text-decoration: none; }
.site-title a:hover { color: var(--link-hover); }

.tagline {
  font-family: var(--sans);
  font-style: italic;
  color: var(--fg-muted);
  font-size: 0.95rem;
  margin: 0 0 0.6rem;
}

.site-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--sans);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.site-nav li {
  display: inline;
}
.site-nav li + li::before {
  content: " · ";
  color: var(--fg-faint);
  margin: 0 0.25rem;
}
.site-nav a { color: var(--fg-muted); text-decoration: none; }
.site-nav a:hover { color: var(--link-hover); text-decoration: underline; }
.site-nav li.active a { color: var(--fg); border-bottom: 2px solid var(--fg); padding-bottom: 1px; }
.site-nav .feed { color: var(--accent); }

/* Theme toggle: a button styled as a nav link */
.theme-toggle {
  font: inherit;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--link-hover); text-decoration: underline; }
.theme-toggle #theme-label { font-weight: 700; }

/* ---------- Links (classic) ---------- */

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
a:visited { color: var(--link-visited); }
a:hover, a:focus { color: var(--link-hover); }

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

.day {
  margin-bottom: 3rem;
}

.day-heading {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 1rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
}
.day-heading a {
  color: inherit;
  text-decoration: none;
}
.day-heading a:hover { color: var(--link-hover); }

/* ---------- Posts ---------- */

.post {
  margin: 0 0 2.5rem;
}
.post:last-child { border-bottom: none; }

.post-header { margin-bottom: 0.6rem; }

.post-title {
  font-family: var(--sans);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.15rem;
}
.post-title a { color: var(--fg); text-decoration: none; }
.post-title a:hover { color: var(--link-hover); text-decoration: underline; }

.post-full .post-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-bottom: 0.4rem;
}

.post-meta {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--fg-faint);
  margin: 0;
}
.post-meta a {
  color: var(--fg-faint);
  text-decoration: none;
}
.post-meta a:hover { color: var(--link-hover); text-decoration: underline; }
.post-meta time { font-variant-numeric: tabular-nums; }

.permalink {
  font-family: var(--mono);
}

.post-body {
  margin-top: 0.4rem;
}

.post-body p {
  margin: 0 0 1rem;
}

.post-body p:last-child { margin-bottom: 0; }

.post-body h2, .post-body h3, .post-body h4 {
  font-family: var(--sans);
  line-height: 1.25;
  margin: 1.8rem 0 0.6rem;
}
.post-body h2 { font-size: 1.3rem; }
.post-body h3 { font-size: 1.1rem; }
.post-body h4 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; }

.post-body img, .post-body video {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem 0;
}

.post-body pre {
  background: var(--code-bg);
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  border-left: 3px solid var(--rule);
}
.post-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.05em 0.3em;
  border-radius: 2px;
}
.post-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.post-body blockquote {
  margin: 1rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 3px solid var(--rule);
  color: var(--fg-muted);
  font-style: italic;
}

.post-body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

.more {
  font-family: var(--sans);
  font-size: 0.9rem;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.more a { font-style: italic; }
.more-stats {
  color: var(--fg-faint);
  font-size: 0.78rem;
}

.post-stats { white-space: nowrap; }
.post-stats .sep { margin: 0 0.15em; color: var(--fg-faint); }
.post-meta .post-stats { color: inherit; }

/* ---------- Link post ---------- */

.post-link .post-title a[rel="external"]::after {
  content: " ↗";
  font-size: 0.8em;
  color: var(--fg-faint);
}
.post-link .host {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--fg-faint);
  letter-spacing: -0.02em;
}
.via {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-style: italic;
  margin: 0.6rem 0 0;
}

/* ---------- Quote post ---------- */

.post-quote .quote {
  margin: 0.4rem 0 0.6rem;
  padding: 0.5rem 0 0.5rem 1.2rem;
  border-left: 4px solid var(--accent);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--fg);
}
.post-quote .quote p { margin: 0 0 0.7rem; }
.post-quote .quote p:last-of-type { margin-bottom: 0.3rem; }
.quote-attribution {
  display: block;
  margin-top: 0.4rem;
  font-style: normal;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--fg-muted);
}
.quote-attribution cite { font-style: normal; }
.commentary {
  font-size: 0.96rem;
}

/* ---------- Tags ---------- */

.post-tags {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--fg-faint);
  margin: 0.8rem 0 0;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}
.post-tags a {
  color: var(--accent);
  text-decoration: none;
}
.post-tags a:hover { text-decoration: underline; }

/* ---------- Previously (jwz-style inline) ---------- */

.previously {
  margin: 2.5rem 0 0;
  padding-top: 1rem;
  font-family: var(--sans);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--fg-muted);
}
.previously a { color: var(--link); }

/* ---------- Post reply ---------- */

.post-reply {
  margin: 2.5rem 0 0;
  padding-top: 1rem;
  font-family: var(--sans);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--fg-muted);
}
.post-reply p { margin: 0; }
.post-reply a { color: var(--link); }

/* ---------- Webmentions ---------- */

.webmentions {
  margin: 3rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}
.webmentions h4 {
  font-family: var(--sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  margin: 0 0 0.8rem;
}

.webmention-facepile {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1.2rem;
}
.facepile-item {
  display: inline-block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  text-decoration: none;
  position: relative;
  flex-shrink: 0;
}
.facepile-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.facepile-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-family: var(--sans);
  font-weight: 700;
  color: var(--fg-muted);
  font-size: 0.85rem;
}
.facepile-item.facepile-like-of     { border-color: var(--accent); }
.facepile-item.facepile-repost-of   { border-color: var(--link); }
.facepile-item.facepile-bookmark-of { border-color: var(--fg-muted); }

.webmention-replies {
  list-style: none;
  padding: 0;
  margin: 0;
}
.webmention-reply {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  background: var(--bg-alt);
  border-left: 3px solid var(--rule);
}
.webmention-reply.wm-in-reply-to { border-left-color: var(--link); }
.webmention-reply.wm-mention-of  { border-left-color: var(--fg-faint); }

.reply-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
}
.reply-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--rule);
  flex-shrink: 0;
}
.reply-meta {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--fg-muted);
}
.reply-meta a { color: var(--fg); text-decoration: none; }
.reply-meta a:hover { color: var(--link-hover); text-decoration: underline; }
.reply-body {
  font-size: 0.95rem;
}
.reply-body p { margin: 0 0 0.6rem; }
.reply-body p:last-child { margin-bottom: 0; }

/* ---------- Sidebar ---------- */

.sidebar {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.sidebar-block {
  margin: 0 0 2.2rem;
}
.sidebar-block:first-child { margin-top: 0.2rem; }

.sidebar-block h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg);
  margin: 0 0 0.6rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--rule);
}

/* Sidebar menu */
.sidebar-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-menu li {
  padding: 0.15rem 0;
  font-size: 0.88rem;
}
.sidebar-menu a {
  color: var(--fg);
  text-decoration: none;
}
.sidebar-menu a:hover { color: var(--link-hover); text-decoration: underline; }
.sidebar-menu li.active a {
  color: var(--accent);
  font-weight: 700;
}

/* Archives */
.archive-list { list-style: none; padding: 0; margin: 0; }
.archive-list > li.archive-year { margin: 0 0 0.5rem; }
.archive-list > li.archive-year > a {
  font-weight: 700;
  font-family: var(--mono);
  color: var(--fg);
  text-decoration: none;
  font-size: 0.85rem;
}
.archive-list > li.archive-year > a:hover { color: var(--link-hover); }
.archive-months {
  list-style: none;
  padding: 0 0 0 0.6rem;
  margin: 0.15rem 0 0;
  border-left: 1px solid var(--rule);
}
.archive-months li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.1rem 0 0.1rem 0.5rem;
  font-size: 0.8rem;
}
.archive-months a {
  color: var(--fg-muted);
  text-decoration: none;
}
.archive-months a:hover { color: var(--link-hover); text-decoration: underline; }
.archive-months .count {
  color: var(--fg-faint);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

/* 88x31 buttons */
.sidebar-buttons .buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.sidebar-buttons .buttons a {
  display: inline-block;
  line-height: 0;
}
.sidebar-buttons .buttons img {
  width: 88px;
  height: 31px;
  display: block;
  image-rendering: pixelated;       /* keep classic crisp pixels for true 88x31 GIFs */
  border: 1px solid var(--rule);
  background: var(--bg);
}
.sidebar-buttons .buttons a:hover img { border-color: var(--link); }

/* Webrings */
.sidebar-webrings .webring {
  margin: 0 0 1rem;
  padding: 0.5rem 0.7rem;
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
}
.sidebar-webrings .webring:last-child { margin-bottom: 0; }
.sidebar-webrings .webring-name {
  margin: 0 0 0.2rem;
  font-weight: 700;
  color: var(--fg);
}
.sidebar-webrings .webring-name a { color: var(--fg); text-decoration: none; }
.sidebar-webrings .webring-name a:hover { color: var(--link-hover); text-decoration: underline; }
.sidebar-webrings .webring-desc {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.45;
}
.sidebar-webrings .webring-desc a { color: var(--link); }
.sidebar-webrings .webring-nav {
  margin: 0;
  font-size: 0.78rem;
  color: var(--fg-faint);
}
.sidebar-webrings .webring-nav a { color: var(--link); text-decoration: none; }
.sidebar-webrings .webring-nav a:hover { text-decoration: underline; }

/* On narrow viewports the sidebar stacks below the content with a clear break */
@media (max-width: 59.99rem) {
  .sidebar {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--fg);
  }
}

/* ---------- Pagination ---------- */

.pagination {
  margin: 3rem 0 0;
  padding-top: 1rem;
  border-top: 2px solid var(--fg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.9rem;
}
.pagination .page-count {
  color: var(--fg-faint);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.pagination a { text-decoration: none; }
.pagination a:hover { text-decoration: underline; }

/* ---------- Archive ---------- */

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}
.page-header h1 {
  font-family: var(--sans);
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0;
}
.page-feed {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin: 0.4rem 0 0;
}
.page-feed a { color: var(--accent); }

/* Static pages (about, now, colophon, …) */
.page-static .page-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.page-subtitle {
  font-family: var(--serif);
  font-style: italic;
  color: var(--fg-muted);
  font-size: 1.05rem;
  margin: 0.3rem 0 0;
}
.page-updated {
  font-family: var(--sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-faint);
  margin: 0.6rem 0 0;
}
.page-body {
  margin-top: 1.6rem;
  font-size: 1.02rem;
}
.page-body p { margin: 0 0 1rem; }
.page-body h2, .page-body h3 {
  font-family: var(--sans);
  line-height: 1.25;
  margin: 1.8rem 0 0.5rem;
}
.page-body h2 { font-size: 1.3rem; }
.page-body h3 { font-size: 1.05rem; }
.page-body ul, .page-body ol {
  padding-left: 1.4rem;
  margin: 0 0 1rem;
}
.page-body ul li { margin: 0.2rem 0; }

.archive-year > h2 {
  font-family: var(--sans);
  font-size: 1.5rem;
  font-weight: 800;
  border-bottom: 2px solid var(--fg);
  margin: 2rem 0 0.8rem;
  padding-bottom: 0.2rem;
}
.archive-year > h2 a { color: var(--fg); text-decoration: none; }
.archive-month h3 {
  font-family: var(--sans);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  margin: 1.2rem 0 0.4rem;
}
.archive-month ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.archive-month li {
  display: grid;
  grid-template-columns: 3.6rem 4.2rem 1fr;
  gap: 0.6rem;
  font-size: 0.95rem;
  padding: 0.2rem 0;
}
.archive-month time {
  color: var(--fg-faint);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.type-badge {
  font-family: var(--sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}
.type-badge.type-entries     { color: var(--fg-muted); }
.type-badge.type-links       { color: var(--link); }
.type-badge.type-quotes      { color: var(--accent); }

/* ---------- Tag cloud ---------- */

.tag-cloud {
  list-style: none;
  padding: 0;
  margin: 0;
  line-height: 2.2;
}
.tag-cloud li {
  display: inline;
  margin-right: 0.6rem;
}
.tag-cloud a {
  color: var(--accent);
  text-decoration: none;
}
.tag-cloud a:hover { text-decoration: underline; }
.tag-cloud .count {
  color: var(--fg-faint);
  font-family: var(--mono);
  font-size: 0.75rem;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--fg-faint);
  text-align: center;
}
.site-footer a { color: var(--fg-muted); }

/* ---------- Selection ---------- */

::selection {
  background: #ffe066;
  color: #111;
}
