/* ============================================================
   INK THEME — main.css
   Minimal dark serif blog
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Mono:ital,wght@0,400;0,500;1,400&family=Playfair+Display:ital,wght@0,400;0,700;1,400&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:          #080808;
  --text:        #e0e0e0;
  --primary:     #d0d0d0;
  --muted:       #888888;
  --subtle:      #555555;
  --border:      #1a1a1a;
  --border-mid:  #252525;
  --code-bg:     #0d0d0d;
  --selection-bg:#262626;

  --font-serif:  'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-display:'Playfair Display', Georgia, serif;
  --font-mono:   'IBM Plex Mono', 'Courier New', monospace;

  --content-w:   680px;
  --wide-w:      960px;

  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  height: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

/* ── Background effects (matching existing site) ───────────── */
html::before {
  content: '';
  position: fixed;
  inset: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 700px at 50% 0%,
      rgba(200,200,200,0.06) 0%,
      rgba(180,180,180,0.05) 20%,
      rgba(160,160,160,0.04) 40%,
      rgba(140,140,140,0.03) 60%,
      rgba(120,120,120,0.02) 80%,
      rgba(100,100,100,0.01) 100%);
  z-index: -1;
  pointer-events: none;
}

body {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.75;
  color: var(--text);
  background: transparent;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Dither canvas overlay (matching existing site) ─────────── */
#dither-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: overlay;
  opacity: 0.55;
}

/* ── Selection ─────────────────────────────────────────────── */
::selection {
  background-color: var(--selection-bg);
  color: var(--primary);
}

/* ── Scrollbar ─────────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: #262626 transparent;
}
*::-webkit-scrollbar { width: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #262626; border-radius: 4px; }

/* ── Layout ─────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  max-width: var(--wide-w);
  margin: 0 auto;
  padding: 2.5rem 2rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.site-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.site-title:hover { color: var(--primary); }

.site-nav {
  display: flex;
  gap: 2rem;
}
.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}
.site-nav a:hover,
.site-nav a.active { color: var(--primary); }

.site-main {
  max-width: var(--wide-w);
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
  min-height: calc(100vh - 200px);
}

.site-footer {
  max-width: var(--wide-w);
  margin: 0 auto;
  padding: 1.5rem 2rem 2.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--subtle);
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.site-footer a { color: var(--subtle); text-decoration: none; }
.site-footer a:hover { color: var(--primary); }
.footer-sep { color: var(--border-mid); }

/* ── Home page ──────────────────────────────────────────────── */
.home-wrap { max-width: var(--content-w); }

.home-intro {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.home-intro p {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--muted);
  font-style: italic;
}
.home-desc {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--muted);
  font-style: italic;
}

.home-search-wrap {
  margin-bottom: 3rem;
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}
@media (max-width: 640px) {
  .home-grid { grid-template-columns: 1fr; gap: 2rem; }
}

.home-section {}
.section-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--subtle);
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}
.section-label a { color: inherit; text-decoration: none; }
.section-label a:hover { color: var(--primary); }

.see-all {
  display: inline-block;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--subtle);
  text-decoration: none;
  letter-spacing: 0.03em;
}
.see-all:hover { color: var(--primary); }

/* ── Post list ─────────────────────────────────────────────── */
.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-item {
  display: grid;
  grid-template-columns: 7rem 1fr;
  grid-template-rows: auto auto;
  column-gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
  transition: background 0.15s;
}
.post-item:first-child { border-top: 1px solid var(--border); }

.post-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--subtle);
  letter-spacing: 0.03em;
  white-space: nowrap;
  padding-top: 0.15em;
}

.post-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  line-height: 1.4;
}
.post-title:hover { color: var(--primary); }

.post-desc {
  grid-column: 2;
  font-family: var(--font-serif);
  font-size: 0.88rem;
  color: var(--muted);
  font-style: italic;
  display: block;
  margin-top: 0.15rem;
}

.post-tags {
  grid-column: 2;
  display: block;
  margin-top: 0.2rem;
}

.devlog-item .post-title {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
}
.devlog-item .post-title:hover { color: var(--primary); }

/* ── Tag chips ──────────────────────────────────────────────── */
.tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--subtle);
  text-decoration: none;
  letter-spacing: 0.03em;
  margin-right: 0.4rem;
  transition: color 0.15s;
}
.tag:hover { color: var(--primary); }

/* ── Search ─────────────────────────────────────────────────── */
.search-input-row {
  display: flex;
  align-items: center;
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.6rem 0;
  outline: none;
  -webkit-appearance: none;
  min-width: 0;
}
.search-input::placeholder { color: var(--subtle); }
.search-input::-webkit-search-cancel-button { display: none; }

.search-kbd {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--subtle);
  border: 1px solid var(--border-mid);
  padding: 0.15rem 0.4rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.section-empty {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--subtle);
  padding: 0.75rem 0;
}

.search-filter-bar {
  margin-bottom: 1.5rem;
}

/* ── Tag filter bar ─────────────────────────────────────────── */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.tag-filter {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--subtle);
  background: transparent;
  border: 1px solid var(--border-mid);
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.03em;
}
.tag-filter:hover { color: var(--primary); border-color: var(--muted); }
.tag-filter.active {
  color: var(--text);
  border-color: var(--muted);
  background: rgba(255,255,255,0.04);
}

.no-results {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--subtle);
  padding: 2rem 0;
}

/* ── List header ────────────────────────────────────────────── */
.list-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.list-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text);
  letter-spacing: 0.01em;
  margin-bottom: 0.5rem;
}
.list-desc {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Blog list specifics ────────────────────────────────────── */
.blog-list .post-item {
  grid-template-columns: 7.5rem 1fr;
  gap: 0.5rem 1rem;
  padding: 0.9rem 0;
}

/* ── Single post ────────────────────────────────────────────── */
.post-wrap {
  max-width: var(--content-w);
}

.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.post-meta {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.post-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--subtle);
  letter-spacing: 0.04em;
}
.post-reading {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--subtle);
}
.post-day {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--subtle);
  letter-spacing: 0.03em;
}

.post-title-large {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.post-subtitle {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 1rem;
}

.post-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.75rem;
}
.post-tags-row .tag { font-size: 0.72rem; }

/* ── Table of contents ──────────────────────────────────────── */
.toc {
  margin-bottom: 2.5rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.01);
}
.toc-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtle);
  display: block;
  margin-bottom: 0.75rem;
}
.toc nav ul {
  list-style: none;
  padding-left: 0;
}
.toc nav ul ul { padding-left: 1.25rem; }
.toc nav a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.7;
  display: block;
}
.toc nav a:hover { color: var(--primary); }

/* ── Post content (prose) ───────────────────────────────────── */
.post-content {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text);
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}
.post-content h2 { font-size: 1.45rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.post-content h3 { font-size: 1.2rem; }
.post-content h4 { font-size: 1.05rem; }

.post-content p { margin-bottom: 1.25rem; }

.post-content a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: rgba(208,208,208,0.4);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}
.post-content a:hover { text-decoration-color: var(--primary); }

.post-content strong { font-weight: 600; color: var(--text); }
.post-content em { font-style: italic; }

.post-content ul, .post-content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}
.post-content li { margin-bottom: 0.35rem; }

.post-content blockquote {
  border-left: 2px solid var(--border-mid);
  margin: 1.5rem 0;
  padding: 0.5rem 0 0.5rem 1.5rem;
  color: var(--muted);
  font-style: italic;
}

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

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}
.post-content th, .post-content td {
  border: 1px solid var(--border-mid);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.post-content th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: rgba(255,255,255,0.02);
}

.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  opacity: 0.9;
}

/* ── Code — inline ──────────────────────────────────────────── */
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--code-bg);
  border: 1px solid var(--border-mid);
  padding: 0.1em 0.35em;
  border-radius: 2px;
  color: var(--primary);
}

/* ── Code — block ───────────────────────────────────────────── */
.post-content pre {
  position: relative;
  margin: 1.5rem 0;
  background: var(--code-bg) !important;
  border: 1px solid var(--border-mid);
  overflow-x: auto;
}
.post-content pre code {
  display: block;
  padding: 1.25rem 1.5rem;
  font-size: 0.82rem;
  line-height: 1.65;
  background: transparent;
  border: none;
  color: var(--text);
  white-space: pre;
  overflow: visible;
}

/* language label */
.post-content pre[class*="language-"]::before,
.post-content .highlight::before {
  content: attr(data-lang);
  display: block;
}

/* copy button (injected by JS) */
.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--subtle);
  background: var(--code-bg);
  border: 1px solid var(--border-mid);
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.04em;
  z-index: 2;
}
.code-copy-btn:hover { color: var(--primary); border-color: var(--muted); }
.code-copy-btn.copied { color: var(--primary); }

/* highlight wrapper */
.highlight {
  position: relative;
  margin: 1.5rem 0;
}
.highlight pre {
  margin: 0 !important;
}

/* ── Post footer ────────────────────────────────────────────── */
.post-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
}
.post-nav-prev,
.post-nav-next {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
.post-nav-prev:hover,
.post-nav-next:hover { color: var(--primary); }
.post-nav-next { margin-left: auto; }

.back-link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--subtle);
  text-decoration: none;
}
.back-link:hover { color: var(--primary); }

/* ── Devlog ─────────────────────────────────────────────────── */
.devlog-wrap { max-width: var(--content-w); }

/* Calendar */
.calendar-wrap {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.calendar-nav {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.cal-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--subtle);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.cal-btn:hover { color: var(--primary); }
.cal-month {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  min-width: 8rem;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-day-header {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--subtle);
  text-align: center;
  padding: 0.3rem 0;
  letter-spacing: 0.05em;
}
.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 2.2rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--subtle);
  text-align: center;
}
.cal-day.has-entry {
  color: var(--primary);
  cursor: pointer;
}
.cal-day.has-entry::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted);
}
.cal-day.has-entry:hover { color: var(--text); }
.cal-day.has-entry:hover::after { background: var(--primary); }
.cal-day.today {
  color: var(--text);
}
.cal-day.today::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid var(--border-mid);
  pointer-events: none;
}
.cal-day.empty { pointer-events: none; }

/* Devlog list */
.devlog-list .post-item {
  grid-template-columns: 7.5rem 1fr;
}
.devlog-single {}

/* ── List wrap (blog/tags) ──────────────────────────────────── */
.list-wrap { max-width: var(--content-w); }

/* ── Tags taxonomy page ─────────────────────────────────────── */
.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 0.5rem;
  margin-top: 1.5rem;
}
.tags-cloud a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
.tags-cloud a:hover { color: var(--primary); }
.tags-cloud .tag-count {
  font-size: 0.62rem;
  color: var(--subtle);
  margin-left: 0.2rem;
}

/* ── 404 ────────────────────────────────────────────────────── */
.error-wrap {
  padding: 4rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.error-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--subtle);
  letter-spacing: 0.1em;
}
.error-msg {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-style: italic;
  color: var(--muted);
}

/* ── MathJax adjustments ────────────────────────────────────── */
.MathJax { font-size: 1em !important; }
mjx-container { overflow-x: auto; }
mjx-container[display="true"] {
  margin: 1.5rem 0 !important;
  overflow-x: auto;
}

/* ── Footnotes ──────────────────────────────────────────────── */
.post-content .footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--muted);
}
.post-content .footnotes ol { padding-left: 1.25rem; }
.post-content sup a {
  font-family: var(--font-mono);
  font-size: 0.65em;
  text-decoration: none;
  color: var(--muted);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 17px; }

  .site-header {
    padding: 1.5rem 1rem 1rem;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }
  .site-nav { gap: 1.25rem; }

  .site-main { padding: 2rem 1rem 4rem; }
  .site-footer { padding: 1rem 1rem 2rem; }

  .post-title-large { font-size: 1.7rem; }

  .post-item {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
  .post-date { display: none; }

  .blog-list .post-item { grid-template-columns: 1fr; }
  .devlog-list .post-item { grid-template-columns: 1fr; }

  .home-search-wrap { margin-bottom: 2rem; }

  .calendar { gap: 1px; }
  .cal-day { min-height: 1.8rem; font-size: 0.65rem; }

  *,*::before,*::after {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
  }
  html::before { background-image: none; }
  #dither-canvas { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
