:root {
  --bg: #0a0a0a;
  --bg-elev: #141414;
  --bg-card: #1a1a1a;
  --red: #e3001b;
  --red-glow: #ff1f3a;
  --text: #f5f5f5;
  --text-dim: #a0a0a0;
  --border: #2a2a2a;
  --max: 1100px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--red-glow); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== NAV ===== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  max-width: var(--max);
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.brand img { width: 32px; height: 32px; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }

/* ===== HERO ===== */
.hero {
  padding: 5rem 0 4rem;
  background:
    radial-gradient(ellipse at top,
      rgba(227,0,27,0.15), transparent 60%);
}
.hero h1 {
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 800;
  margin-bottom: 1.25rem;
}
.hero h1 .accent { color: var(--red); }
.hero p.lede {
  font-size: 1.2rem;
  color: var(--text-dim);
  max-width: 640px;
  margin-bottom: 2rem;
}
.hero-cta {
  display: inline-block;
  background: var(--red);
  color: #fff;
  padding: 0.85rem 1.6rem;
  border-radius: 6px;
  font-weight: 600;
  transition: background 0.15s;
}
.hero-cta:hover { background: var(--red-glow); text-decoration: none; }

/* ===== PACMAN BANNER ===== */
/* ===== PACMAN BANNER ===== */
.pacman-stage {
  position: relative;
  width: 100%;
  height: 140px;
  overflow: hidden;
  background: #050505;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Conveyor: holds the moving coins, gets masked to fade them at the mouth */
.pacman-conveyor {
  position: absolute;
  inset: 0;
  z-index: 1;
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0px,
    transparent 80px,
    rgba(0,0,0,0.4) 140px,
    #000 200px,
    #000 100%);
          mask-image: linear-gradient(
    to right,
    transparent 0px,
    transparent 80px,
    rgba(0,0,0,0.4) 140px,
    #000 200px,
    #000 100%);
}

.pacman-track {
  position: absolute;
  top: 50%;
  left: 0;
  margin-top: -26px;
  display: flex;
  align-items: center;
  gap: 90px;
  padding-left: 100vw;
  white-space: nowrap;
  animation: pacman-march 22s linear infinite;
  will-change: transform;
}

.coin {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  box-shadow: 0 0 12px rgba(255,255,255,0.08);
}
.coin img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  display: block;
}

@keyframes pacman-march {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(-50% - 50vw)); }
}

/* The E — chomping animation using clipped halves of the logo */
.pacman-eater {
  position: absolute;
  left: 32px;
  top: 50%;
  margin-top: -60px;
  width: 120px;
  height: 120px;
  z-index: 10;
  filter: drop-shadow(0 0 18px rgba(227,0,27,0.7));
  pointer-events: none;
  overflow: hidden;
}

.pacman-upper,
.pacman-lower {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-image: url("/assets/logo.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: 0 0;
}

.pacman-upper {
  clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);
  -webkit-clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);
  z-index: 2;
}

.pacman-lower {
  clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
  -webkit-clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
  transform-origin: 0% 50%;
  animation: chomp-jaw 0.55s ease-in-out infinite;
  z-index: 1;
}

@keyframes chomp-jaw {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(22deg); }
}

@media (max-width: 600px) {
  .pacman-stage { height: 100px; }
  .pacman-eater {
    width: 80px;
    height: 80px;
    margin-top: -40px;
    left: 14px;
  }
  .coin { width: 38px; height: 38px; }
  .pacman-track { margin-top: -19px; gap: 60px; }
}

/* ===== SECTIONS ===== */
section { padding: 4rem 0; }
.section-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}
.section-sub {
  color: var(--text-dim);
  margin-bottom: 2.5rem;
}

/* ===== POST GRID ===== */
.posts {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  transition: transform 0.2s, border-color 0.2s;
  display: block;
  color: var(--text);
}
.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--red);
  text-decoration: none;
}
.post-card .date {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  display: block;
}
.post-card h3 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
}
.post-card p {
  color: var(--text-dim);
  font-size: 0.95rem;
}
.tag {
  display: inline-block;
  background: rgba(227,0,27,0.12);
  color: var(--red-glow);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  margin-right: 0.4rem;
  margin-top: 0.8rem;
}

/* ===== ARTICLE PAGE ===== */
article.post {
  padding: 3rem 0 5rem;
  max-width: 720px;
  margin: 0 auto;
}
article.post h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin-bottom: 1rem;
}
article.post .meta {
  color: var(--text-dim);
  margin-bottom: 2.5rem;
  font-size: 0.95rem;
}
article.post h2 {
  font-size: 1.6rem;
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.02em;
}
article.post h3 {
  font-size: 1.25rem;
  margin: 2rem 0 0.8rem;
}
article.post p { margin-bottom: 1.25rem; font-size: 1.08rem; }
article.post blockquote {
  border-left: 3px solid var(--red);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-dim);
  font-style: italic;
}
article.post code {
  background: var(--bg-elev);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}

/* ===== FOOTER ===== */
footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}
footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

@media (max-width: 600px) {
  .nav-links { gap: 1rem; }
  .nav-links a { font-size: 0.85rem; }
  .hero { padding: 3rem 0 2.5rem; }
}

/* ===== COMMENTS ===== */
.comments { padding: 2rem 0 5rem; max-width: 720px; }
.comments h2 {
  font-size: 1.5rem;
  margin-bottom: 1.2rem;
  letter-spacing: -0.02em;
}
#commentForm, .reply-form {
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin-bottom: 2rem;
}
#commentForm input, #commentForm textarea,
.reply-form input, .reply-form textarea {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  color: #f5f5f5;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
}
#commentForm button, .reply-form button {
  background: #e3001b;
  color: #fff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.cm {
  padding: 0.9rem 1rem;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  margin-bottom: 0.6rem;
}
.cm-head {
  color: #a0a0a0;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.cm-head b { color: #f5f5f5; font-weight: 600; }
.cm p { margin: 0.3rem 0 0.6rem; font-size: 0.96rem; }
.cm-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.cm-actions button {
  background: transparent;
  border: 1px solid #2a2a2a;
  color: #a0a0a0;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: color 0.15s, border-color 0.15s;
}
.cm-actions button:hover { color: #fff; border-color: #555; }
.cm-actions .score {
  min-width: 24px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #ddd;
  font-weight: 500;
}
/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 3rem;
  flex-wrap: wrap;
}

.page-btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.95rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
  min-width: 38px;
}

.page-btn:hover {
  background: #1f1f1f;
  border-color: #444;
}

.page-btn.current {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  font-weight: 600;
}

.page-ellipsis {
  color: var(--text-dim);
  padding: 0 0.35rem;
  font-weight: 600;
}

/* ===== Search ===== */
.search-container {
  position: relative;
  max-width: 480px;
  margin: 0 auto 2rem;
}

#search-input {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  font-family: inherit;
  font-size: 0.98rem;
  transition: border-color 0.15s, background 0.15s;
}

#search-input::placeholder {
  color: var(--text-dim);
}

#search-input:focus {
  outline: none;
  border-color: var(--red);
  background: #1a1a1a;
}

.search-container::before {
  content: "⌕";
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 1.1rem;
  pointer-events: none;
}

#search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 100;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.search-result {
  display: block;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background 0.1s;
}

.search-result:hover {
  background: #1f1f1f;
  text-decoration: none;
}

.search-result:last-child {
  border-bottom: none;
}

.search-result-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.search-result-snippet {
  font-size: 0.84rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.search-result mark,
.search-result-snippet mark {
  background: rgba(227, 0, 27, 0.25);
  color: #fff;
  padding: 0 2px;
  border-radius: 2px;
}

.search-empty,
.search-more {
  padding: 0.85rem 1.1rem;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-style: italic;
  text-align: center;
}

/* ===== Reading progress bar ===== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--red), var(--red-glow));
  z-index: 1000;
  transition: width 0.05s linear;
  pointer-events: none;
}

/* ===== Article navigation (prev/next) ===== */
.article-nav {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.article-nav-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 2rem;
}

.article-nav-link {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  color: var(--text);
  transition: transform 0.2s, border-color 0.2s;
}

.article-nav-link:hover {
  transform: translateY(-2px);
  border-color: var(--red);
  text-decoration: none;
}

.article-nav-link.next {
  text-align: right;
}

.article-nav-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.article-nav-title {
  display: block;
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text);
}

@media (max-width: 600px) {
  .article-nav-inner {
    grid-template-columns: 1fr;
  }
  .article-nav-link.next {
    text-align: left;
  }
}

/* ===== Share tooltip ===== */
.share-tooltip {
  position: absolute;
  display: none;
  z-index: 200;
  transform: translateX(-50%);
}

.share-tooltip button {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 0.55rem 0.95rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: background 0.15s;
}

.share-tooltip button:hover {
  background: var(--red-glow);
}

.share-tooltip::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--red);
}

/* ===== Highlight target (for text fragments + scroll anchors) ===== */
article.post p:target,
article.post h2:target,
article.post h3:target,
::target-text {
  background: rgba(227, 0, 27, 0.18);
  border-radius: 3px;
}
/* ===== Sidechain reference table ===== */
.sidechain-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.95rem;
}

.sidechain-table thead {
  background: var(--bg-elev);
}

.sidechain-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.sidechain-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.sidechain-table tbody tr:last-child td {
  border-bottom: none;
}

.sidechain-table tbody tr:hover {
  background: rgba(227, 0, 27, 0.04);
}

.sidechain-table td:first-child {
  width: 80px;
  color: var(--text-dim);
  font-family: 'Inter', monospace;
  font-weight: 600;
  font-size: 0.88rem;
}

.sidechain-table td strong {
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 600px) {
  .sidechain-table {
    font-size: 0.88rem;
  }
  .sidechain-table th,
  .sidechain-table td {
    padding: 0.6rem 0.7rem;
  }
}