/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --paper:   #f2ece0;
  --ink:     #1c1a17;
  --faded:   #6b6458;
  --red:     #d63a2f;
  --cyan:    #2fd6c8;
  --rule:    #c9bfaf;
}

/* ─── Base ───────────────────────────────────────────────────── */
html { font-size: 18px; }

body {
  font-family: 'Playfair Display', Georgia, serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.75;
  min-height: 100vh;

  /* subtle paper grain via SVG noise */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

/* ─── Glitch keyframes ───────────────────────────────────────── */
@keyframes glitch-skew {
  0%   { transform: skewX(0deg); }
  2%   { transform: skewX(-3deg); }
  4%   { transform: skewX(0deg); }
  96%  { transform: skewX(0deg); }
  98%  { transform: skewX(2deg); }
  100% { transform: skewX(0deg); }
}

@keyframes glitch-clip-1 {
  0%   { clip-path: inset(40% 0 50% 0); transform: translate(-4px, 0); }
  20%  { clip-path: inset(10% 0 80% 0); transform: translate(4px, 0); }
  40%  { clip-path: inset(70% 0 5%  0); transform: translate(-4px, 0); }
  60%  { clip-path: inset(30% 0 40% 0); transform: translate(4px, 0); }
  80%  { clip-path: inset(80% 0 10% 0); transform: translate(-4px, 0); }
  100% { clip-path: inset(40% 0 50% 0); transform: translate(-4px, 0); }
}

@keyframes glitch-clip-2 {
  0%   { clip-path: inset(60% 0 20% 0); transform: translate(4px, 0); }
  20%  { clip-path: inset(20% 0 60% 0); transform: translate(-4px, 0); }
  40%  { clip-path: inset(5%  0 75% 0); transform: translate(4px, 0); }
  60%  { clip-path: inset(50% 0 30% 0); transform: translate(-4px, 0); }
  80%  { clip-path: inset(15% 0 65% 0); transform: translate(4px, 0); }
  100% { clip-path: inset(60% 0 20% 0); transform: translate(4px, 0); }
}

/* ─── Glitch text component ─────────────────────────────────── */
.glitch {
  position: relative;
  display: inline-block;
  animation: glitch-skew 6s infinite linear;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  pointer-events: none;
}

.glitch::before {
  color: var(--red);
  animation: glitch-clip-1 4s infinite linear;
  opacity: 0.85;
}

.glitch::after {
  color: var(--cyan);
  animation: glitch-clip-2 4s infinite linear;
  opacity: 0.85;
}

/* ─── Header / Nav ───────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--rule);
  padding: 1.4rem 0;
  margin-bottom: 3.5rem;
  position: relative;
}

/* misregistered rule — a second line, slightly off */
header::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0; right: 0;
  height: 1px;
  background: var(--red);
  opacity: 0.25;
}

nav {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 2rem;
}

.site-title {
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 1.75rem;
}

nav ul a {
  font-family: 'Courier Prime', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--faded);
  transition: color 0.15s;
}

nav ul a:hover { color: var(--ink); }

/* ─── Main container ─────────────────────────────────────────── */
main {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.5rem 6rem;
}

/* ─── Footer ─────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--rule);
  text-align: center;
  padding: 2rem;
  font-family: 'Courier Prime', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--faded);
  position: relative;
}

footer::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 0; right: 0;
  height: 1px;
  background: var(--cyan);
  opacity: 0.2;
}

/* ─── Landing page ───────────────────────────────────────────── */
.home {
  padding: 5rem 0 3rem;
}

.home h1 {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.home .tagline {
  font-family: 'Courier Prime', monospace;
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--faded);
  margin-bottom: 2.5rem;
}

.home .tagline::before {
  content: '※ ';
  color: var(--red);
}

.home p:not(.tagline) {
  font-size: 1.05rem;
  color: var(--faded);
  border-left: 2px solid var(--rule);
  padding-left: 1rem;
  position: relative;
}

/* misregistered border bleed */
.home p:not(.tagline)::before {
  content: '';
  position: absolute;
  left: -3px; top: 0; bottom: 0;
  width: 2px;
  background: var(--red);
  opacity: 0.3;
}

.home a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--red);
}

.home a:hover {
  text-decoration-color: var(--ink);
}

/* ─── Blog listing ───────────────────────────────────────────── */
.post-list > h1 {
  font-family: 'Courier Prime', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faded);
  margin-bottom: 2.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.post-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0 1.5rem;
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--rule);
  position: relative;
}

.post-summary::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0; right: 0;
  height: 1px;
  background: var(--cyan);
  opacity: 0.12;
}

.post-summary h2 {
  font-size: 1.15rem;
  font-weight: 400;
  font-style: italic;
  grid-column: 1;
}

.post-summary h2 a {
  text-decoration: none;
  color: var(--ink);
  background-image: linear-gradient(var(--red), var(--red));
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.25s ease;
}

.post-summary h2 a:hover {
  background-size: 100% 1px;
}

.post-summary time {
  font-family: 'Courier Prime', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--faded);
  white-space: nowrap;
  grid-column: 2;
}

.post-summary p {
  grid-column: 1 / -1;
  font-size: 0.9rem;
  color: var(--faded);
  margin-top: 0.3rem;
}

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

.post-header::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0; right: 0;
  height: 1px;
  background: var(--cyan);
  opacity: 0.2;
}

.post-header h1 {
  font-size: 2.4rem;
  font-weight: 700;
  font-style: italic;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.post-header time {
  font-family: 'Courier Prime', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--faded);
}

/* ─── Post body typography ───────────────────────────────────── */
.post-content {
  font-size: 1.05rem;
}

.post-content > * + * { margin-top: 1.4rem; }

.post-content h2 {
  font-size: 1.4rem;
  font-style: italic;
  margin-top: 2.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
}

.post-content h3 {
  font-family: 'Courier Prime', monospace;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faded);
  margin-top: 2rem;
}

.post-content a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--red);
}

.post-content a:hover {
  text-decoration-color: var(--ink);
}

.post-content strong {
  font-weight: 700;
}

.post-content em {
  font-style: italic;
}

.post-content blockquote {
  border-left: 3px solid var(--ink);
  padding: 0.1rem 0 0.1rem 1.5rem;
  color: var(--faded);
  font-style: italic;
  position: relative;
}

.post-content blockquote::before {
  content: '';
  position: absolute;
  left: -5px; top: 0; bottom: 0;
  width: 3px;
  background: var(--red);
  opacity: 0.3;
}

.post-content code {
  font-family: 'Courier Prime', monospace;
  font-size: 0.88em;
  background: rgba(0,0,0,0.05);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}

.post-content pre {
  background: var(--ink);
  color: var(--paper);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-family: 'Courier Prime', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  position: relative;
}

/* glitch top edge on code blocks */
.post-content pre::before {
  content: '';
  position: absolute;
  top: -2px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--red), var(--cyan));
  opacity: 0.6;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.post-content img {
  max-width: 100%;
  display: block;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
  position: relative;
}

.post-content hr::after {
  content: '§';
  position: absolute;
  top: -0.75em;
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  padding: 0 0.5rem;
  color: var(--rule);
  font-size: 1rem;
}

/* ─── Post footer ────────────────────────────────────────────── */
.post-footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.post-footer a {
  font-family: 'Courier Prime', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--faded);
}

.post-footer a:hover { color: var(--ink); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  html { font-size: 16px; }
  .home h1 { font-size: 2.5rem; }
  .post-header h1 { font-size: 1.8rem; }
  .post-summary { grid-template-columns: 1fr; }
  .post-summary time { grid-column: 1; }
}
