/* ============================================
   Kaga Chung — Personal Site
   Aesthetic: editorial-quiet, ink on paper
   ============================================ */

:root {
  --ink: #3d2f1f;             /* 濃啡 — body & headings */
  --ink-soft: #6a5840;        /* secondary text */
  --ink-faded: #998566;       /* meta, dates */
  --paper: #ebe5d4;           /* linen base */
  --paper-warm: #e0d8c2;      /* card / image bg */
  --accent: #3a5a3a;          /* 墨綠 — used rarely */
  --rule: #c9bfa3;
  --shadow: 0 1px 2px rgba(61, 47, 31, 0.05), 0 8px 24px rgba(61, 47, 31, 0.07);
  --shadow-hover: 0 4px 8px rgba(61, 47, 31, 0.08), 0 20px 40px rgba(61, 47, 31, 0.14);

  --font-display: 'Cormorant Garamond', 'Noto Serif HK', Georgia, serif;
  --font-body: 'Noto Serif HK', 'Cormorant Garamond', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --max-w: 1400px;
  --col-gap: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;

  /* subtle paper texture — barely perceptible */
  background-image:
    radial-gradient(at 20% 30%, rgba(58, 90, 58, 0.02) 0px, transparent 50%),
    radial-gradient(at 80% 70%, rgba(61, 47, 31, 0.03) 0px, transparent 50%);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

/* ============================================
   Masthead
   ============================================ */
.masthead {
  padding: 64px 32px 32px;
  max-width: var(--max-w);
  margin: 0 auto;
  border-bottom: 1px solid var(--rule);
}

.masthead-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.site-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(36px, 5vw, 56px);
  letter-spacing: -0.02em;
  line-height: 1;
}

.site-title a:hover { color: var(--ink); }

.site-tagline {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faded);
  letter-spacing: 0.02em;
  line-height: 1.8;
  text-align: right;
}

/* ============================================
   Tag bar
   ============================================ */
.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag {
  font-family: var(--font-mono);
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

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

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

/* ============================================
   Masonry — CSS columns
   ============================================ */
.masonry {
  padding: 48px 32px;
  max-width: var(--max-w);
  margin: 0 auto;
  column-count: 3;
  column-gap: var(--col-gap);
}

@media (max-width: 960px) { .masonry { column-count: 2; } }
@media (max-width: 600px) { .masonry { column-count: 1; padding: 32px 20px; } }

.card {
  break-inside: avoid;
  margin-bottom: var(--col-gap);
  background: #f0ebd9;
  border-radius: 2px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  overflow: hidden;
  display: block;
  cursor: pointer;
  position: relative;
  animation: cardIn 0.6s ease both;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

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

/* stagger */
.card:nth-child(1) { animation-delay: 0.02s; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.14s; }
.card:nth-child(5) { animation-delay: 0.18s; }
.card:nth-child(6) { animation-delay: 0.22s; }
.card:nth-child(7) { animation-delay: 0.26s; }
.card:nth-child(8) { animation-delay: 0.3s; }
.card:nth-child(n+9) { animation-delay: 0.34s; }

.card-cover {
  width: 100%;
  display: block;
  background: var(--paper-warm);
}

.card-body {
  padding: 24px 24px 28px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
  color: var(--ink);
}

.card.text-only .card-title {
  font-size: 28px;
}

.card-excerpt {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faded);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card-meta .dot { opacity: 0.5; }

.card-tags {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.card-tag::before { content: '#'; opacity: 0.6; }

/* Featured card variant — for benchmark pieces */
.card.featured {
  background: var(--ink);
  color: var(--paper);
}

.card.featured .card-title,
.card.featured .card-excerpt,
.card.featured .card-meta,
.card.featured .card-tag {
  color: var(--paper);
}

.card.featured .card-tag { color: var(--paper-warm); opacity: 0.85; }
.card.featured .card-excerpt { color: rgba(245, 241, 232, 0.75); }
.card.featured .card-meta { color: rgba(245, 241, 232, 0.5); }

/* ============================================
   Footer
   ============================================ */
.footer {
  border-top: 1px solid var(--rule);
  padding: 32px;
  max-width: var(--max-w);
  margin: 64px auto 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faded);
}

.footer .dot { opacity: 0.5; }
.footer a:hover { color: var(--accent); }

/* ============================================
   Article page (post.html template)
   ============================================ */
.article {
  max-width: 680px;
  margin: 0 auto;
  padding: 64px 32px 96px;
}

.article-header { margin-bottom: 48px; }

.article-back {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faded);
  margin-bottom: 32px;
  display: inline-block;
  letter-spacing: 0.02em;
}

.article-back:hover { color: var(--accent); }

.article-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 4.5vw, 48px);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin-bottom: 20px;
}

.article-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faded);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.article-cover {
  width: 100%;
  margin-bottom: 48px;
  border-radius: 2px;
}

.article-body {
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink);
}

.article-body p { margin-bottom: 1.4em; }
.article-body p:first-letter {
  /* removed by default — opt in per-post if wanted */
}

.article-body h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  margin-top: 2em;
  margin-bottom: 0.6em;
  letter-spacing: -0.01em;
}

.article-body h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  margin-top: 1.6em;
  margin-bottom: 0.5em;
}

.article-body blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 24px;
  margin: 1.6em 0;
  color: var(--ink-soft);
  font-style: italic;
}

.article-body img {
  width: 100%;
  margin: 2em 0;
  border-radius: 2px;
}

.article-body em { font-style: italic; }
.article-body strong { font-weight: 600; }

.article-body a {
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}
.article-body a:hover { border-color: var(--accent); color: var(--accent); }

.article-tags {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.article-tags a {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.article-tags a::before { content: '#'; opacity: 0.6; }
