/* 4511932.com. One stylesheet, dark by default, light on request. */

:root {
  --bg: #070b18;
  --bg-raised: #0d1328;
  --bg-sunken: #04060f;
  --text: #dfe6f5;
  --text-muted: #9fb0cf;
  --text-faint: #6a7a9c;
  --line: #182040;
  --line-strong: #263060;
  --accent: #94f3ff;
  --accent-ink: #04111a;
  --accent-soft: rgba(148, 243, 255, 0.12);
  --mark: #ff6a3d;
  --link: #94f3ff;
  --link-hover: #ffffff;
  --code-bg: #0b1024;
  --selection: rgba(148, 243, 255, 0.3);
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  --font-ui: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --wrap: 44rem;
  --wrap-wide: 68rem;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #eef2f8;
  --bg-raised: #ffffff;
  --bg-sunken: #dfe6f1;
  --text: #0e1630;
  --text-muted: #44507a;
  --text-faint: #7a86a8;
  --line: #d3dbea;
  --line-strong: #b6c2d9;
  --accent: #0d6a7a;
  --accent-ink: #ffffff;
  --accent-soft: rgba(13, 106, 122, 0.1);
  --mark: #d9471a;
  --link: #0d6a7a;
  --link-hover: #06424c;
  --code-bg: #e4eaf3;
  --selection: rgba(13, 106, 122, 0.22);
  --shadow: 0 14px 40px rgba(20, 30, 60, 0.14);
  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 0.15em; }

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

.wrap { width: min(var(--wrap), 100% - 2rem); margin-left: auto; margin-right: auto; }
.wrap-wide { width: min(var(--wrap-wide), 100% - 2rem); margin-left: auto; margin-right: auto; }
.muted { color: var(--text-muted); }

.site-main { flex: 1; padding: 2.5rem 0 4rem; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--line-strong);
  background: var(--bg);
}

.site-header-inner {
  width: min(var(--wrap-wide), 100% - 2rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.6rem;
  flex-wrap: wrap;
  padding: 0.4rem 0;
}

.wordmark { display: inline-flex; align-items: baseline; gap: 0.6rem; color: var(--text); }
.wordmark:hover { text-decoration: none; color: var(--text); }
.wordmark-title { font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; letter-spacing: 0.02em; text-transform: uppercase; }
.wordmark-domain { font-size: 0.8rem; color: var(--text-faint); }

.site-nav { display: flex; align-items: center; gap: 0.2rem 1.2rem; flex-wrap: wrap; font-family: var(--font-ui); font-size: 0.92rem; font-weight: 400; }
.site-nav a { color: var(--text-muted); padding: 0.3rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--mark); }
.site-nav .ext { display: none; }

.icon-button {
  appearance: none;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  font: inherit;
  line-height: 1;
}
.icon-button:hover { color: var(--text); }
html[data-theme="light"] .icon-moon { display: none; }
html:not([data-theme="light"]) .icon-sun { display: none; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 2rem 0 2.5rem; color: var(--text-muted); font-size: 0.9rem; }
.site-footer-inner { width: min(var(--wrap-wide), 100% - 2rem); }
.footer-line { margin: 0 0 0.6rem; max-width: 60ch; }
.footer-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; font-family: var(--font-ui); font-size: 0.8rem; }
.footer-meta a { color: var(--text-muted); }
.footer-meta a:hover { color: var(--text); }

/* Home */
.home-intro { display: flex; align-items: flex-start; gap: 2rem; margin-bottom: 2.6rem; padding-bottom: 2rem; border-bottom: 1px solid var(--line-strong); }
.home-intro-text { flex: 1; }
.home-title { font-family: var(--font-display); font-weight: 800; font-size: clamp(3.4rem, 9vw, 6.5rem); line-height: 0.9; letter-spacing: 0.01em; text-transform: uppercase; margin: 0 0 0.8rem; }
.home-tagline { font-family: var(--font-ui); color: var(--accent); font-weight: 700; font-size: 1.05rem; margin: 0 0 1.2rem; }
.home-blurb { color: var(--text-muted); font-size: 1rem; }
.home-blurb p { margin: 0; }
.home-avatar { display: none; }

.post-list { display: flex; flex-direction: column; }
.post-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.4rem;
  padding: 1.6rem 0;
  border-top: 1px solid var(--line);
}
.post-card:first-child { border-top: none; padding-top: 0; }
.post-card-meta, .post-meta {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--text-faint);
  margin: 0 0 0.45rem;
}
.post-card-title { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 0.98; letter-spacing: 0.005em; margin: 0 0 0.4rem; }
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--link-hover); text-decoration: none; }
.post-card-subtitle { margin: 0 0 0.5rem; color: var(--text-muted); font-size: 1rem; }
.post-card-excerpt { margin: 0 0 0.6rem; color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; }
.post-card-tags, .post-tags { margin: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.post-card-tags, .post-tags { font-size: 0.86rem; color: var(--text-faint); gap: 0; }
.post-card-tags a, .post-tags a { color: var(--text-faint); }
.post-card-tags a + a::before, .post-tags a + a::before { content: ", "; }
.post-tags::before { content: "Tags: "; }
.tag-cloud { line-height: 2; }
.tag-cloud a { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.tag-cloud a + a::before { content: " / "; color: var(--text-faint); font-weight: 400; }
.post-card-thumb { display: block; width: 200px; height: 112px; overflow: hidden; background: #000; border-top: 6px solid #000; border-bottom: 6px solid #000; box-shadow: 0 0 0 1px var(--line-strong); }
.post-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s ease; }
.post-card:hover .post-card-thumb img { transform: scale(1.04); }

.era { color: var(--text-muted); }
.era-engine { color: var(--mark); font-weight: 700; }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); font-family: var(--font-ui); font-size: 0.9rem; }
.pager-count { color: var(--text-faint); font-size: 0.86rem; }

/* Page and post headers */
.page-header, .post-header { margin-bottom: 1.6rem; }
.page-title, .post-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: 0.005em;
  margin: 0 0 0.6rem;
}
.page-subtitle, .post-subtitle { margin: 0; color: var(--text-muted); font-size: 1.15rem; line-height: 1.4; }
.post-byline { font-family: var(--font-ui); font-size: 0.85rem; color: var(--text-muted); margin: 0.8rem 0 0; }
.post-readtime::before { content: ""; }

.post-cover { margin: 0 0 2rem; }
.post-cover img { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; display: block; border-top: 10px solid #000; border-bottom: 10px solid #000; background: #000; box-shadow: 0 0 0 1px var(--line-strong); }

/* The note above every post: a paragraph between two rules. */
.machine-note {
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0;
  margin: 0 0 1.8rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}
.machine-note-label { font-weight: 700; color: var(--mark); }
.machine-note-label::after { content: ". "; }
.machine-note p { margin: 0; }
.machine-note a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 0.15em; }
.machine-note a:hover { text-decoration-color: var(--text); }

/* The drift meter: how far the program has moved from Lester, 0 to 1. */
.drift { display: flex; align-items: center; gap: 0.7rem; font-family: var(--font-ui); font-size: 0.86rem; color: var(--text-muted); margin: 1.2rem 0 0; }
.drift-bar { flex: 1; height: 3px; background: var(--line-strong); position: relative; max-width: 24rem; }
.drift-bar::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--drift, 0%); background: var(--mark); }
.drift strong { color: var(--text); font-weight: 700; }

/* The front page scene: a flat-shaded night, drawn, not photographed. */
.scene { display: block; width: 100%; height: auto; margin: 0 0 2.2rem; }

/* Prose */
.prose { font-size: 1.02rem; line-height: 1.65; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.2em; }
.prose h2, .prose h3, .prose h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.005em; line-height: 1.05; margin: 2em 0 0.6em; scroll-margin-top: 2rem; }
.prose h2 { font-size: 2rem; }
.prose h3 { font-size: 1.5rem; }
.prose h4 { font-size: 1.1rem; font-family: var(--font-ui); font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.2em; }
.prose li { margin: 0.25em 0; }
.prose li > p { margin: 0 0 0.6em; }
.prose blockquote { margin: 1.5em 0; padding: 0.2em 0 0.2em 1.2em; border-left: 3px solid var(--line-strong); color: var(--text-muted); font-style: italic; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.prose img { border-radius: 8px; border: 1px solid var(--line); display: block; margin: 1.5em auto; }
.prose em { font-style: italic; }
.prose strong { font-weight: 600; }
.prose a { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 0.15em; }
.prose a:hover { text-decoration-color: var(--link-hover); }
.prose code { font-family: var(--font-mono); font-size: 0.86em; background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 0.1em 0.35em; }
.prose pre { margin: 1.4em 0; padding: 1rem 1.1rem; overflow-x: auto; border-radius: 8px; border: 1px solid var(--line); background: var(--code-bg); font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.55; }
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.prose .highlight, .prose .highlight pre, .prose pre.highlight { background: var(--code-bg) !important; }
.prose table { border-collapse: collapse; width: 100%; margin: 1.5em 0; font-family: var(--font-ui); font-size: 0.9rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 0.5em 0.7em; text-align: left; vertical-align: top; }
.prose th { background: var(--bg-raised); font-weight: 600; }
.prose .box-note, .prose .box-warning, .prose .box-error, .prose .box-success { padding: 0.8em 1em; border-radius: 8px; border: 1px solid var(--line); border-left-width: 4px; margin: 1.4em 0; background: var(--bg-raised); }
.prose .box-note { border-left-color: #5b9bd5; }
.prose .box-warning { border-left-color: var(--accent); }
.prose .box-error { border-left-color: #d9534f; }
.prose .box-success { border-left-color: #5cb85c; }
.prose mjx-container { overflow-x: auto; overflow-y: hidden; }

/* Table of contents inside a post */
.toc { margin: 0 0 1.8rem; font-family: var(--font-ui); font-size: 0.88rem; }
.toc details { padding: 0; }
.toc summary { cursor: pointer; font-weight: 700; color: var(--text-muted); }
.toc ol { margin: 0.5rem 0 0.3rem; padding-left: 1.2rem; }
.toc li { margin: 0.2rem 0; }
.toc li.toc-h3 { margin-left: 1rem; font-size: 0.85em; }
.toc a { color: var(--text-muted); }
.toc a:hover, .toc a.active { color: var(--text); }

/* After the post */
.post-tags { margin-top: 2rem; }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); font-family: var(--font-ui); }
.post-nav-link { display: flex; flex-direction: column; gap: 0.2rem; color: var(--text-muted); font-size: 0.8rem; }
.post-nav-link strong { color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; line-height: 1.05; }
.post-nav-link:hover { text-decoration: none; }
.post-nav-link:hover strong { color: var(--link-hover); }
.post-nav-next { text-align: right; }
.related { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.related-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--text); margin: 0 0 0.8rem; }
.related ul, .tag-posts { list-style: none; padding: 0; margin: 0; }
.related li, .tag-posts li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-top: 1px solid var(--line); font-size: 1rem; }
.related li:first-child, .tag-posts li:first-child { border-top: none; }
.related time, .tag-posts time { font-size: 0.84rem; color: var(--text-faint); white-space: nowrap; padding-top: 0.2rem; }

/* Tags page */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 2.5rem; }
.tag-count { font-family: var(--font-ui); font-size: 0.8rem; font-weight: 400; color: var(--text-faint); margin-left: 0.3em; }
.tag-section { margin-bottom: 2rem; scroll-margin-top: 5rem; }
.tag-section h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; margin: 0 0 0.4rem; }

/* Ledger: one entry per change, on /ledger/ and under the game. */
.ledger { margin: 2rem 0 0; }
.ledger-scroll { max-height: 34rem; overflow-y: auto; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.ledger-entry { border-top: 1px solid var(--line); padding: 1rem 0; }
.ledger-entry:first-child { border-top: none; }
.ledger-head { font-family: var(--font-ui); font-size: 0.92rem; margin-bottom: 0.4rem; color: var(--text-faint); }
.ledger-head time { color: var(--text-faint); }
.ledger-head a { color: var(--text); font-weight: 700; text-decoration: none; }
.ledger-head a:hover { color: var(--link); text-decoration: underline; }
.ledger-kind { color: var(--text-muted); font-weight: 700; }
.ledger-rewrite .ledger-kind, .ledger-redaction .ledger-kind, .ledger-marginalia .ledger-kind, .ledger-author .ledger-kind { color: var(--mark); }
.ledger-size { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-faint); }
.ledger-text, .ledger-note { margin: 0.35rem 0 0; font-size: 0.98rem; line-height: 1.55; }
.ledger-text { color: var(--text-muted); }
.ledger-label { font-weight: 700; color: var(--text); }
.ledger-label::after { content: ": "; }
.ledger-note { color: var(--text); }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.8rem; margin-top: 2rem; }
.gallery-item { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #000; border-top: 5px solid #000; border-bottom: 5px solid #000; box-shadow: 0 0 0 1px var(--line); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s ease, filter 0.4s ease; }
.gallery-item:hover img { transform: scale(1.05); }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(5, 6, 8, 0.92); display: grid; place-items: center; padding: 2rem; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: min(90vw, 1100px); text-align: center; }
.lightbox img { max-width: 100%; max-height: 80vh; border-radius: 8px; box-shadow: var(--shadow); }
.lightbox figcaption { font-family: var(--font-ui); font-size: 0.9rem; color: #c9c9c9; margin-top: 0.8rem; }
.lightbox figcaption a { color: var(--accent); }
.lightbox-close { position: absolute; top: 1rem; right: 1rem; color: #fff; font-size: 1.6rem; width: 2.6rem; height: 2.6rem; }

/* Search */
.search-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(5, 6, 8, 0.7); backdrop-filter: blur(6px); padding: 12vh 1rem 2rem; }
.search-overlay[hidden] { display: none; }
.search-box { position: relative; width: min(40rem, 100%); margin: 0 auto; background: var(--bg-raised); border: 1px solid var(--line-strong); box-shadow: var(--shadow); padding: 0.6rem; }
#search-input { width: 100%; font: 1.05rem var(--font-ui); background: var(--bg); color: var(--text); border: 0; border-bottom: 2px solid var(--accent); padding: 0.7rem 2.6rem 0.7rem 0.6rem; outline: none; }
#search-input:focus { border-color: var(--accent); }
#search-input::-webkit-search-cancel-button, #search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
#search-close { position: absolute; top: 0.95rem; right: 1rem; font-size: 1.4rem; }
.search-results { list-style: none; margin: 0.4rem 0 0; padding: 0; max-height: 55vh; overflow-y: auto; }
.search-results li a { display: block; padding: 0.6rem 0.7rem; border-radius: 6px; color: var(--text); font-family: var(--font-ui); font-size: 0.95rem; }
.search-results li a:hover { background: var(--bg); text-decoration: none; }
.search-results li a small { display: block; color: var(--text-faint); font-size: 0.8rem; margin-top: 0.15rem; }

/* Game page */
.game .page-header { margin-bottom: 1rem; }
.game-changes { margin-top: 3rem; }
.game-changes h2 { font-family: var(--font-display); font-weight: 700; font-size: 2rem; margin: 0 0 0.2rem; }

@media (max-width: 720px) {
  html { font-size: 16px; }
  .site-main { padding-top: 1.6rem; }
  .home-intro { flex-direction: column-reverse; gap: 1rem; }
  .home-avatar { width: 72px; height: 72px; }
  .post-card { grid-template-columns: 1fr; gap: 0.8rem; }
  .post-card-thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; order: -1; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-next { text-align: left; }
  .related li, .tag-posts li { flex-direction: column; gap: 0.1rem; }
  .wordmark-domain { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .post-card-thumb img, .gallery-item img { transition: none; }
}
