/* ============================================
   MODERN CARD THEME — Auto Dark/Light
   Inter + Fraunces
   ============================================ */

:root {
  --bg: #ffffff;
  --bg-2: #f5f5f5;
  --bg-3: #eeeeee;
  --border: #e5e5e5;
  --text: #111111;
  --text-2: #555555;
  --text-3: #999999;
  --accent: #2563EB;
  --accent-bg: rgba(37, 99, 235, 0.08);
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.1), 0 12px 40px rgba(0,0,0,0.08);
  --header-bg: rgba(255,255,255,0.9);
  --sans: 'Inter', system-ui, sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  --max: 1280px;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0f;
    --bg-2: #1a1a1a;
    --bg-3: #222222;
    --border: #2a2a2a;
    --text: #f0f0f0;
    --text-2: #aaaaaa;
    --text-3: #666666;
    --accent: #60a5fa;
    --accent-bg: rgba(96, 165, 250, 0.1);
    --card-bg: #1a1a1a;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
    --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.4), 0 12px 40px rgba(0,0,0,0.3);
    --header-bg: rgba(15,15,15,0.9);
  }
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-2: #1a1a1a;
  --bg-3: #222222;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --text-2: #aaaaaa;
  --text-3: #666666;
  --accent: #60a5fa;
  --accent-bg: rgba(96, 165, 250, 0.1);
  --card-bg: #1a1a1a;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.4), 0 12px 40px rgba(0,0,0,0.3);
  --header-bg: rgba(15,15,15,0.9);
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-2: #f5f5f5;
  --bg-3: #eeeeee;
  --border: #e5e5e5;
  --text: #111111;
  --text-2: #555555;
  --text-3: #999999;
  --accent: #2563EB;
  --accent-bg: rgba(37, 99, 235, 0.08);
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.1), 0 12px 40px rgba(0,0,0,0.08);
  --header-bg: rgba(255,255,255,0.9);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* ============================================
   SITE WRAPPER
   ============================================ */
.site-wrapper { min-height: 100vh; display: flex; flex-direction: column; }
.site-main { flex: 1; }

/* ============================================
   HEADER
   ============================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.site-brand { flex-shrink: 0; }

.site-name {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-logo { height: 36px; width: auto; }

.site-nav { flex: 1; }
.site-nav ul { list-style: none !important; padding: 0 !important; margin: 0 !important; display: flex !important; flex-direction: row !important; gap: 0.25rem; }

.site-nav .nav ul, .site-nav ul, .site-nav li {
  display: flex;
  list-style: none;
  gap: 0.25rem;
}

.site-nav .nav li a {
  display: block;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.site-nav .nav li a:hover {
  background: var(--bg-2);
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover { background: var(--bg-3); color: var(--text); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-moon { display: none; }

[data-theme="dark"] .theme-toggle .icon-sun,
:root:not([data-theme="light"]) .icon-sun { display: block; }

[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.btn-subscribe {
  height: 36px;
  padding: 0 1rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.btn-subscribe:hover { opacity: 0.88; }

/* ============================================
   TAG BADGE
   ============================================ */
.tag-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 4px;
  transition: background 0.15s;
}

.tag-badge:hover { background: var(--accent); color: #fff; }
.tag-badge.small { font-size: 0.62rem; height: 20px; }

/* ============================================
   HERO
   ============================================ */
.hero { margin-bottom: 0; border-bottom: 1px solid var(--border); }

.hero-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 500px;
  max-width: var(--max);
  margin: 0 auto;
}

.hero-image {
  overflow: hidden;
  order: 2;
}

.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.hero-card:hover .hero-image img { transform: scale(1.03); }

.hero-body {
  order: 1;
  padding: 3rem 3rem 3rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}

.hero-body.no-image {
  grid-column: 1 / -1;
  padding: 4rem 2rem;
  max-width: 800px;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hero-date {
  font-size: 0.78rem;
  color: var(--text-3);
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
}

.hero-excerpt {
  font-size: 1rem;
  color: var(--text-2);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
  margin-top: 0.5rem;
}

.author-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

/* ============================================
   CARD GRID
   ============================================ */
.home-body {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2.5rem 2rem 5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
}

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

.card-image-link { display: block; }

.card-image {
  aspect-ratio: 16/9;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.card:hover .card-image img { transform: scale(1.04); }

.card-body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-date {
  font-size: 0.72rem;
  color: var(--text-3);
}

.card-title {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  flex: 1;
}

.card-title a:hover { color: var(--accent); }

.card-excerpt {
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.author-thumb-sm {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.card-author {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
}

/* ============================================
   POST PAGE
   ============================================ */
.post-wrap {
  max-width: var(--max);
  margin: 0 auto;
}

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

.post-header-inner {
  max-width: 720px;
  margin: 0 auto;
}

.post-meta {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.post-title {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.post-subtitle {
  font-size: 1.1rem;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  font-style: italic;
}

.post-byline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.post-author-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.author-initials {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.author-name {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
}

.author-bio {
  font-size: 0.75rem;
  color: var(--text-3);
  display: block;
}

.post-date {
  font-size: 0.8rem;
  color: var(--text-3);
}

.post-hero-image {
  max-height: 560px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.post-hero-image img {
  width: 100%;
  max-height: 560px;
  object-fit: cover;
}

.post-hero-image figcaption {
  max-width: 720px;
  margin: 0.5rem auto;
  font-size: 0.78rem;
  color: var(--text-3);
  font-style: italic;
  padding: 0 2rem;
}

.post-content-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

/* ============================================
   GHOST CONTENT
   ============================================ */
.gh-content {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text);
}

.gh-content > * + * { margin-top: 1.5rem; }

.gh-content h2 {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-top: 2.5rem;
}

.gh-content h3 {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 2rem;
}

.gh-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}

.gh-content a:hover { text-decoration-color: var(--accent); }

.gh-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 1rem 1.5rem;
  background: var(--bg-2);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--text-2);
  font-size: 1.1rem;
}

.gh-content ul, .gh-content ol {
  padding-left: 1.5rem;
}

.gh-content li { margin-bottom: 0.35rem; }

.gh-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem auto;
  width: 30%;
}

.gh-content img {
  border-radius: 8px;
  width: 100%;
}

.gh-content figure { margin: 2rem 0; }

.gh-content figcaption {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-3);
  margin-top: 0.5rem;
  font-style: italic;
}

.gh-content code {
  font-family: 'SF Mono', monospace;
  font-size: 0.85em;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--accent);
}

.gh-content pre {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
}

.gh-content pre code {
  background: none;
  border: none;
  color: var(--text);
  padding: 0;
}

.kg-width-wide {
  margin-left: -6vw;
  margin-right: -6vw;
}

.kg-width-full {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  width: 100vw;
}

.kg-width-wide img, .kg-width-full img { width: 100%; }

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
  transition: border-color 0.15s, color 0.15s;
}

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

/* ============================================
   RELATED
   ============================================ */
.related-section {
  border-top: 1px solid var(--border);
  padding: 2.5rem 2rem 4rem;
  max-width: var(--max);
  margin: 0 auto;
}

.related-title {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.related-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
  transition: box-shadow 0.2s, transform 0.2s;
}

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

.related-image { aspect-ratio: 16/9; overflow: hidden; }
.related-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
.related-card:hover .related-image img { transform: scale(1.04); }

.related-body { padding: 1rem; }
.related-body h4 { font-family: var(--serif); font-size: 0.95rem; font-weight: 700; line-height: 1.3; margin: 0.4rem 0; }
.related-body h4 a:hover { color: var(--accent); }
.related-date { font-size: 0.72rem; color: var(--text-3); }

/* ============================================
   TAXONOMY (tag/author pages)
   ============================================ */
.taxonomy-wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 2rem 5rem;
}

.taxonomy-header {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.author-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.taxonomy-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 0.5rem;
}

.taxonomy-title {
  font-family: var(--serif);
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.taxonomy-desc {
  color: var(--text-2);
  margin-top: 0.5rem;
  max-width: 600px;
}

.author-header-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.author-header-initials {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 900;
  flex-shrink: 0;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem 0 0;
}

.pagination a {
  height: 36px;
  padding: 0 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  transition: border-color 0.15s, color 0.15s;
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.page-number { font-size: 0.82rem; color: var(--text-3); }

/* ============================================
   ERROR
   ============================================ */
.error-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 1rem;
  padding: 4rem 2rem;
}

.error-code {
  font-family: var(--serif);
  font-size: 6rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.error-title {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 700;
}

.error-back {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: 2.5rem 0;
}

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 2rem;
}

.footer-top {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.footer-brand {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 900;
  display: block;
  margin-bottom: 0.4rem;
}

.footer-desc { font-size: 0.85rem; color: var(--text-2); }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-nav .nav ul { display: flex; list-style: none; gap: 1rem; }
.footer-nav .nav a { font-size: 0.82rem; color: var(--text-2); transition: color 0.15s; }
.footer-nav .nav a:hover { color: var(--text); }
.footer-copy { font-size: 0.78rem; color: var(--text-3); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .related-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-card { grid-template-columns: 1fr; }
  .hero-image { order: 1; height: 300px; }
  .hero-body { order: 2; padding: 2rem; }
}

@media (max-width: 768px) {
  .header-inner { padding: 0 1rem; gap: 1rem; }
  .site-nav { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .home-body { padding: 1.5rem 1rem 3rem; }
  .post-header { padding: 2rem 1rem; }
  .post-content-wrap { padding: 2rem 1rem 3rem; }
  .related-section { padding: 2rem 1rem 3rem; }
  .footer-bottom { flex-direction: column; gap: 1rem; text-align: center; }
}

/* ============================================
   AUTHOR FIX — no duplicate, better avatar
   ============================================ */

.author-initials {
  font-size: 0;
  border: 2px solid var(--accent);
  background: var(--accent-bg);
}

.author-avatar {
  border: 2px solid var(--border);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.author-name {
  color: var(--text);
  font-size: 0.95rem;
}

.post-author-info a {
  color: var(--text);
  text-decoration: none;
}

/* ============================================
   AUTHOR — bigger avatar and name
   ============================================ */

.post-author-info .author-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
  flex-shrink: 0;
}

.post-author-info .author-initials {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.post-author-info .author-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: block;
  letter-spacing: -0.01em;
}

.post-author-info .author-bio {
  font-size: 0.8rem;
  color: var(--text-3);
  display: block;
  margin-top: 0.15rem;
}

.post-byline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}

.post-author-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
