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

/* ─── Variables ─────────────────────────────────────── */
:root {
  --fg:      #111111;
  --fg-dim:  #999999;
  --bg:      #ffffff;
  --border:  #e8e8e8;
  --code-bg: #f6f6f6;
  --max:     880px;
  --font:    'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:    ui-monospace, 'SF Mono', Menlo, Monaco, 'Cascadia Code', monospace;
}

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

body {
  font-family: var(--font);
  font-feature-settings: 'calt' 1, 'kern' 1;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ─── Animations ────────────────────────────────────── */
@keyframes appear {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.07); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Home ──────────────────────────────────────────── */
body.is-home {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.home-link {
  display: block;
  color: var(--fg);
  text-decoration: none;
  opacity: 0;
  animation: appear 0.9s ease forwards 0.3s;
}

.home-logo {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  animation: breathe 5s ease-in-out infinite 1.2s;
  transform-origin: center;
  transition: transform 0.3s ease;
}

.home-link:hover .home-logo {
  animation: none;
  transform: scale(1.1);
}

.home-tagline {
  margin-top: 22px;
  font-size: 14px;
  font-weight: 400;
  color: var(--fg-dim);
  letter-spacing: 0.01em;
  text-align: center;
  line-height: 1.7;
  opacity: 0;
  animation: appear 0.7s ease forwards 0.55s;
}

.home-nav {
  display: flex;
  gap: 24px;
  margin-top: 22px;
  opacity: 0;
  animation: appear 0.7s ease forwards 0.75s;
}

.home-nav a {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.home-nav a:hover { color: var(--fg); }

/* ─── Site nav (blog / post pages) ─────────────────── */
.site-nav {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 10;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.98);
}

.nav-link:hover { color: var(--fg); }

/* ─── Reading progress bar ──────────────────────────── */
#progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 1px;
  background: var(--fg);
  width: 0%;
  z-index: 100;
  transition: width 0.08s linear;
}

/* ─── Blog listing ──────────────────────────────────── */
.blog-wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 100px 24px 80px;
}

.post-list { list-style: none; }

.post-item {
  opacity: 0;
  animation: slideUp 0.45s ease forwards;
}
.post-item:nth-child(1)  { animation-delay: 0.10s; }
.post-item:nth-child(2)  { animation-delay: 0.17s; }
.post-item:nth-child(3)  { animation-delay: 0.24s; }
.post-item:nth-child(4)  { animation-delay: 0.31s; }
.post-item:nth-child(5)  { animation-delay: 0.38s; }
.post-item:nth-child(6)  { animation-delay: 0.45s; }
.post-item:nth-child(7)  { animation-delay: 0.52s; }
.post-item:nth-child(8)  { animation-delay: 0.59s; }
.post-item:nth-child(9)  { animation-delay: 0.66s; }
.post-item:nth-child(10) { animation-delay: 0.73s; }

.post-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: padding-left 0.2s ease;
}

.post-link:hover { padding-left: 6px; }

.post-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.post-date {
  font-size: 12px;
  font-weight: 400;
  color: var(--fg-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Post / About page shell ───────────────────────── */
.post-wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 80px 24px 120px;
  opacity: 0;
  animation: appear 0.6s ease forwards 0.1s;
}

.post-header {
  margin-bottom: 52px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: clamp(22px, 4vw, 29px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 16px;
}

.post-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg-dim);
}

.post-info span::before {
  content: '·';
  margin-right: 8px;
}

/* ═══════════════════════════════════════════════════════
   MARKDOWN BODY
═══════════════════════════════════════════════════════ */
.post-body {
  font-size: 15.5px;
  line-height: 1.75;
  font-weight: 400;
}

/* ── Headings ── */
.post-body h2 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 52px 0 0;
}

.post-body h2 + p,
.post-body h2 + ul,
.post-body h2 + ol  { margin-top: 16px; }

.post-body h3 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 36px 0 0;
}

.post-body h3 + p,
.post-body h3 + ul,
.post-body h3 + ol  { margin-top: 12px; }

.post-body h4 {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: 32px 0 12px;
}

/* ── Paragraphs ── */
.post-body p { margin-bottom: 22px; }

/* ── Links ── */
.post-body a {
  color: var(--fg);
  text-decoration-line: underline;
  text-decoration-color: #c8c8c8;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}

.post-body a:hover { text-decoration-color: var(--fg); }

/* ── Inline emphasis ── */
.post-body strong { font-weight: 700; }
.post-body em     { font-style: italic; }

/* ── HR ── */
.post-body hr {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, #c8c8c8 15%, #c8c8c8 85%, transparent);
  margin: 52px 0;
}

/* ── Unordered lists — editorial dash ── */
.post-body ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 22px;
}

.post-body ul > li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 9px;
  line-height: 1.7;
}

.post-body ul > li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--fg-dim);
  line-height: inherit;
}

.post-body ul li > ul            { margin-top: 8px; margin-bottom: 0; }
.post-body ul li > ul > li::before { content: '·'; }

/* ── Ordered lists ── */
.post-body ol {
  padding-left: 26px;
  margin-bottom: 22px;
}

.post-body ol > li {
  margin-bottom: 9px;
  padding-left: 4px;
  line-height: 1.7;
}

.post-body li > ul,
.post-body li > ol { margin-top: 8px; margin-bottom: 0; }

/* ── Blockquote ── */
.post-body blockquote {
  margin: 32px 0;
  padding: 2px 0 2px 22px;
  border-left: 2px solid #d4d4d4;
}

.post-body blockquote p {
  margin: 0;
  font-size: 17px;
  color: #555;
  line-height: 1.72;
  font-style: italic;
}

.post-body blockquote p + p { margin-top: 14px; }

/* ── Inline code ── */
.post-body :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.83em;
  background: var(--code-bg);
  border: 1px solid #e2e2e2;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0;
  color: #2a2a2a;
}

/* ── Code blocks ── */
.post-body pre {
  background: var(--code-bg);
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  padding: 20px 22px;
  overflow-x: auto;
  margin: 28px 0;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
  tab-size: 2;
}

.post-body pre code {
  font-family: var(--mono);
  font-size: 13px;
  background: none;
  border: none;
  padding: 0;
  letter-spacing: 0;
  color: inherit;
}

.highlight { background: none !important; }

/* copy button */
.code-wrap { position: relative; }

.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--bg);
  border: 1px solid #dedede;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--fg-dim);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
  letter-spacing: 0.02em;
}

.code-wrap:hover .copy-btn          { opacity: 1; }
.copy-btn:hover                     { color: var(--fg); border-color: #bbb; }

/* ── Tables ── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 28px 0;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 0;
}

.post-body thead { border-bottom: 2px solid var(--border); }

.post-body th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg-dim);
  padding: 0 14px 10px;
}

.post-body td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}

.post-body tr:last-child td        { border-bottom: none; }
.post-body tbody tr:hover td       { background: #fafafa; }

/* ── Images ── */
.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
  margin: 28px auto;
}

.post-body figure      { margin: 28px 0; }

/* ── Post / About footer logo ── */
.post-footer-logo {
  display: flex;
  justify-content: center;
  margin-top: 72px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}

.post-footer-logo img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  opacity: 0.55;
  transition: opacity 0.2s;
}

.post-footer-logo img:hover { opacity: 1; }

.post-body figcaption {
  font-size: 13px;
  color: var(--fg-dim);
  text-align: center;
  margin-top: 10px;
}

/* ── Misc ── */
.post-body del         { opacity: 0.5; text-decoration: line-through; }
.post-body mark        { background: #fff5c2; padding: 1px 4px; border-radius: 2px; }
.post-body sup,
.post-body sub         { font-size: 0.75em; line-height: 0; }
.post-body abbr[title] { text-decoration: underline dotted; cursor: help; }

.post-body kbd {
  font-family: var(--mono);
  font-size: 0.8em;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-bottom: 2px solid #bbb;
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 640px) {
  .site-nav         { top: 20px; left: 20px; }
  .blog-wrap        { padding: 76px 20px 60px; }
  .post-wrap        { padding: 64px 20px 80px; }
  .post-body        { font-size: 15px; }
  .post-body h2     { font-size: 20px; }
  .post-body h3     { font-size: 17px; }
  .post-body pre    { padding: 16px 18px; }
  .post-link        { gap: 16px; }
  .post-date        { font-size: 11px; }
}

@media (max-width: 420px) {
  .post-link {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
}
