/* Dark is the default theme; light applies when <html data-theme="light">. */
:root {
  color-scheme: dark;
  --bg: #151515;
  --bg-lines: repeating-linear-gradient(to bottom, #0f0f0f 0, #0f0f0f 1px, #1b1b1b 1px, #1b1b1b 4px);
  --logo-lines: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.2) 0, rgba(0, 0, 0, 0.2) 1px, transparent 1px, transparent 4px);
  --surface: #1f1f1f;
  --border: #2e2c25;
  --text: #e8e4d4;
  --muted: #9a9585;
  --accent: #c9b458;
  --accent-ink: #151515;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f5ee;
  --bg-lines: none;
  --logo-lines: none;
  --surface: #ffffff;
  --border: #e2ddcc;
  --text: #1c1c1c;
  --muted: #6b6757;
  --accent: #7a6a1f;
  --accent-ink: #ffffff;
}

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

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: var(--bg-lines);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.6 var(--sans);
}

a { color: var(--accent); }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* Header */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 600;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

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

.theme-toggle {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* Main */

.site-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 16px 4rem;
}

.page-title {
  margin: 0 0 1.25rem;
  font-size: 1.75rem;
  line-height: 1.25;
}

/* Tags */

.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tag {
  display: inline-block;
  padding: 0.125rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font: 0.8125rem/1.6 var(--mono);
  text-decoration: none;
}

.tag:hover { color: var(--accent); border-color: var(--accent); }

.tag.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Post list */

.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.post-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem;
  background: var(--surface);
}

.post-item:not([hidden]) ~ .post-item:not([hidden]) { border-top: 1px solid var(--border); }

.post-thumb {
  flex: 0 0 160px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 4px;
}

.post-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.post-title {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

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

.post-date { color: var(--muted); font-size: 0.875rem; }

.post-meta-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.sep {
  color: var(--muted);
  opacity: 0.6;
}

.post-blog-link,
.blog-post-link {
  color: var(--accent);
  text-decoration: none;
}

.post-blog-link:hover,
.blog-post-link:hover {
  text-decoration: underline;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.empty-note { color: var(--muted); }

@media (max-width: 520px) {
  .site-header { padding: 1rem 16px; }
  .brand { font-size: 1.15rem; }
  .brand img { width: 48px; height: 48px; }
  .post-item { flex-direction: column; }
  .post-thumb { flex-basis: auto; width: 100%; }
}

/* Post and page */

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: -0.5rem 0 1.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.video {
  aspect-ratio: 16 / 9;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #000;
}

.video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.watch-link { margin: 0.5rem 0 1.5rem; font-size: 0.875rem; }

.post-body { max-width: 70ch; }

/* Plan cut lists in post bodies. Wide tables scroll inside their own box on phones. */
.post-body table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.post-body th,
.post-body td {
  padding: 0.35rem 0.75rem 0.35rem 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.post-body th { color: var(--muted); font-weight: 600; }

/* Search */

.search { margin-bottom: 1rem; }

.search-input {
  width: 100%;
  max-width: 420px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.search-input::placeholder { color: var(--muted); }

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

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

/* Footer */

.site-footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 16px 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p { margin: 0; }

/* About page */

.about-logo {
  display: block;
  width: 220px;
  margin: 0 0 1.5rem;
}

.about-logo img { width: 100%; height: auto; }

/* Scanlines over the logo, masked to its shape. Fixed attachment lines them up with the page. */

.logo-lines {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.logo-lines::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--logo-lines);
  background-attachment: fixed;
  -webkit-mask: var(--logo) center / contain no-repeat;
  mask: var(--logo) center / contain no-repeat;
  pointer-events: none;
}

/* The header logo is small, so its lines cover more of it. Show them at half strength. */
.brand .logo-lines::after { opacity: 0.5; }
