/* Fonts: Inter (local), Playfair Display & Source Serif 4 (Google) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --color-bg: hsl(40, 33%, 97%);
  --color-surface: hsl(40, 30%, 100%);
  --color-text: hsl(30, 15%, 15%);
  --color-text-muted: hsl(30, 10%, 45%);
  --color-accent: hsl(25, 70%, 45%);
  --color-accent-hover: hsl(25, 70%, 35%);
  --color-border: hsl(35, 20%, 88%);
  --color-border-light: hsl(35, 20%, 92%);
  --color-category: hsl(25, 70%, 45%);

  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --container-width: 1100px;
  --radius: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
}

/* Dark theme */
[data-theme="dark"] {
  --color-bg: hsl(220, 15%, 10%);
  --color-surface: hsl(220, 15%, 14%);
  --color-text: hsl(220, 15%, 88%);
  --color-text-muted: hsl(220, 10%, 55%);
  --color-accent: hsl(25, 65%, 55%);
  --color-accent-hover: hsl(25, 65%, 65%);
  --color-border: hsl(220, 12%, 22%);
  --color-border-light: hsl(220, 12%, 18%);
  --color-category: hsl(25, 65%, 55%);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
}
[data-theme="dark"] .post-content pre {
  background: hsl(220, 15%, 8%);
}
[data-theme="dark"] .post-content blockquote {
  background: hsla(220, 15%, 18%, 0.6);
}
[data-theme="dark"] #comment-message .alert-success {
  background: hsl(160, 30%, 12%); color: hsl(160, 50%, 65%); border-color: hsl(160, 30%, 22%);
}
[data-theme="dark"] #comment-message .alert-error {
  background: hsl(0, 30%, 14%); color: hsl(0, 60%, 65%); border-color: hsl(0, 30%, 22%);
}
[data-theme="dark"] .badge-pending {
  background: hsl(40, 40%, 14%); color: hsl(45, 80%, 65%);
}
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .form-group select {
  background: hsl(220, 15%, 10%); color: var(--color-text); border-color: var(--color-border);
}

/* Font sizes */
[data-font-size="sm"] { font-size: 14px; }
[data-font-size="lg"] { font-size: 18px; }

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); line-height: 1.7; color: var(--color-text); background: var(--color-bg); }
a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); }
img { max-width: 100%; height: auto; display: block; }

/* Container */
.container { max-width: var(--container-width); margin: 0 auto; padding: 0 24px; }

/* ====== HEADER ====== */
.site-header { background: var(--color-surface); border-bottom: 2px solid var(--color-text); }
.header-inner { padding: 0; }
.header-top { text-align: center; padding: 32px 0 20px; }
.site-brand { color: inherit; text-decoration: none; }
.site-brand:hover { text-decoration: none; color: inherit; }
.site-title { font-family: var(--font-display); font-size: 2.4rem; font-weight: 700; letter-spacing: -0.02em; display: block; }
.site-description { color: var(--color-text-muted); margin: 6px 0 0; font-family: var(--font-ui); font-size: 0.9rem; font-style: italic; }

.header-top { position: relative; }

/* Header Toolbar — top-right corner */
.header-toolbar {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 10px;
}
.font-size-controls { display: flex; align-items: baseline; gap: 2px; }
.fs-btn {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-ui); color: var(--color-text-muted);
  padding: 4px 5px; line-height: 1; transition: color 0.2s;
  font-size: 0.75rem; font-weight: 500;
}
.fs-btn[data-size="md"] { font-size: 0.95rem; }
.fs-btn.fs-btn--lg { font-size: 1.15rem; }
.fs-btn:hover { color: var(--color-accent); }
.fs-btn.active { color: var(--color-accent); font-weight: 700; }

.theme-toggle {
  background: none; border: 1px solid var(--color-border); border-radius: 50%;
  width: 32px; height: 32px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--color-text-muted); transition: color 0.2s, border-color 0.2s;
}
.theme-toggle:hover { color: var(--color-accent); border-color: var(--color-accent); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.main-nav { display: flex; justify-content: flex-start; gap: 0; flex-wrap: nowrap; }
.main-nav a {
  flex: 1;
  text-align: center;
  white-space: nowrap;
  font-family: var(--font-ui);
  color: var(--color-text);
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 10px;
  transition: color 0.2s, background 0.2s;
}
.main-nav a:hover { color: var(--color-accent); background: hsla(25, 70%, 45%, 0.05); text-decoration: none; }
.main-nav a.active { color: var(--color-accent); background: hsla(25, 70%, 45%, 0.05); border-bottom: 2px solid var(--color-accent); }

/* ====== MAIN ====== */
.site-main { padding: 40px 0 60px; min-height: 60vh; }

/* ====== POST GRID ====== */
.posts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 28px; }

/* Featured first post spans full width */
.post-card--featured { grid-column: 1 / -1; }
.post-card--featured .post-thumbnail img { height: 420px; }
.post-card--featured .post-card-title { font-size: 1.8rem; }
.post-card--featured .post-excerpt { font-size: 1.05rem; }

/* ====== POST CARD ====== */
.post-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}
.post-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.post-thumbnail img { width: 100%; height: 220px; object-fit: cover; }
.post-card-body { padding: 22px 24px 24px; }

.post-meta {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.post-category {
  color: var(--color-category);
  font-weight: 600;
}
.post-category:hover { color: var(--color-accent-hover); text-decoration: none; }
.post-meta time { color: var(--color-text-muted); }
.post-meta a:not(.post-category) { color: var(--color-accent); font-weight: 500; }

.post-card-title { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: 10px; line-height: 1.3; font-weight: 600; }
.post-card-title a { color: var(--color-text); }
.post-card-title a:hover { color: var(--color-accent); text-decoration: none; }

.post-excerpt { color: var(--color-text-muted); font-size: 0.95rem; margin-bottom: 14px; line-height: 1.6; }

.read-more {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.read-more:hover { color: var(--color-accent-hover); text-decoration: none; }

/* ====== SINGLE POST ====== */
.post-single {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 48px 56px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 32px;
}
.post-header { margin-bottom: 28px; text-align: center; }
.post-header h1 { font-family: var(--font-display); font-size: 2.4rem; line-height: 1.25; margin-top: 12px; font-weight: 700; }
.post-header .post-meta { justify-content: center; }

.post-featured-image { margin: 0 -56px 32px; }
.post-featured-image img { width: 100%; height: auto; }

.post-content { font-size: 1.1rem; line-height: 1.85; }
.post-content h2 { font-family: var(--font-display); font-size: 1.6rem; margin: 2em 0 0.6em; font-weight: 600; }
.post-content h3 { font-family: var(--font-display); font-size: 1.3rem; margin: 1.5em 0 0.5em; font-weight: 600; }
.post-content p { margin-bottom: 1.3em; }
.post-content img { margin: 1.5em 0; border-radius: var(--radius); }
.post-content a { color: var(--color-accent); text-decoration: underline; text-decoration-color: hsla(25, 70%, 45%, 0.3); text-underline-offset: 2px; }
.post-content a:hover { text-decoration-color: var(--color-accent); }
.post-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding: 16px 24px;
  margin: 1.5em 0;
  background: hsla(40, 33%, 95%, 0.6);
  font-style: italic;
  color: var(--color-text-muted);
}
.post-content pre {
  background: hsl(30, 10%, 12%);
  color: hsl(40, 20%, 88%);
  padding: 20px 24px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5em 0;
  font-size: 0.9em;
}
.post-content code { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 0.9em; }
.post-content ul, .post-content ol { padding-left: 1.5em; margin-bottom: 1.3em; }

/* ====== TAGS ====== */
.post-tags { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--color-border); display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  display: inline-block;
  background: hsla(25, 50%, 45%, 0.08);
  color: var(--color-accent);
  padding: 5px 14px;
  border-radius: 20px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.2s;
}
.tag:hover { background: hsla(25, 50%, 45%, 0.15); text-decoration: none; }

.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
  gap: 20px;
}
.post-nav-prev, .post-nav-next { flex: 1; min-width: 0; }
.post-nav-next { text-align: right; }
.post-nav-label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.post-nav a {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  transition: color 0.2s;
}
.post-nav a:hover { color: var(--color-accent); text-decoration: none; }

.comments-empty {
  color: var(--color-text-muted);
  font-style: italic;
  font-size: 0.95rem;
  padding: 12px 0;
}

.similar-posts {
  margin-top: 40px;
}
.similar-posts h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}
.similar-posts-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}
.similar-card {
  background: var(--color-card-bg, #fff);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.similar-card-img img {
  width: 100%;
  aspect-ratio: 3/2;
  object-fit: cover;
  display: block;
}
.similar-card-body {
  padding: 10px 12px 12px;
}
.similar-card-date {
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  color: var(--color-accent);
  font-weight: 500;
}
.similar-card-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 4px;
}
.similar-card-title a {
  color: var(--color-text);
  text-decoration: none;
}
.similar-card-title a:hover {
  color: var(--color-accent);
}
.similar-card-more {
  font-size: 0.7rem;
  margin-top: 6px;
  display: inline-block;
}

/* ====== ARCHIVE HEADER ====== */
.archive-header { margin-bottom: 32px; padding-bottom: 20px; border-bottom: 1px solid var(--color-border); }
.archive-header h1 { font-family: var(--font-display); font-size: 2rem; font-weight: 700; }
.archive-header p { color: var(--color-text-muted); margin-top: 6px; font-size: 1rem; }

/* ====== PAGINATION ====== */
.pagination { display: flex; justify-content: center; align-items: center; gap: 4px; margin-top: 40px; flex-wrap: wrap; }
.pagination a, .pagination .current, .pagination .disabled, .pagination .dots {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; padding: 0 12px;
  border-radius: var(--radius); font-family: var(--font-ui); font-weight: 500; font-size: 0.9rem;
  transition: all .15s ease;
}
.pagination a { background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); }
.pagination a:hover { background: var(--color-accent); border-color: var(--color-accent); color: #fff; text-decoration: none; }
.pagination .current { background: var(--color-accent); color: #fff; border: 1px solid var(--color-accent); }
.pagination .disabled { color: var(--color-border); cursor: default; border: 1px solid var(--color-border-light); background: var(--color-bg); }
.pagination .dots { border: none; color: var(--color-text-muted); min-width: 24px; padding: 0; }

/* ====== COMMENTS ====== */
.comments-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 36px 48px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.comments-section h2 { font-family: var(--font-display); margin-bottom: 20px; font-size: 1.4rem; }
.comment { padding: 18px 0; border-bottom: 1px solid var(--color-border-light); }
.comment:last-child { border-bottom: none; }
.comment-meta { font-family: var(--font-ui); font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: 6px; }
.comment-meta strong { color: var(--color-text); }
.comment-body { font-size: 0.95rem; line-height: 1.7; }

/* Pending Comments */
.comment--pending { opacity: 0.8; border-left: 3px solid var(--color-accent); padding-left: 15px; }
.badge-pending { display: inline-block; background: #fef3c7; color: #92400e; font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; margin-left: 8px; font-weight: 500; }

/* Button Loading Spinner */
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after { content: ''; position: absolute; width: 16px; height: 16px; top: 50%; left: 50%; margin: -8px 0 0 -8px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: btn-spin 0.6s linear infinite; }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Comment Pagination */
.comment-pagination { display: flex; justify-content: center; gap: 6px; margin-top: 24px; font-family: var(--font-ui); font-size: 0.9rem; }
.comment-pagination a, .comment-pagination .current { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--radius); text-decoration: none; }
.comment-pagination a { border: 1px solid var(--color-border); color: var(--color-text); }
.comment-pagination a:hover { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.comment-pagination .current { background: var(--color-accent); color: #fff; }

/* Comment Form */
.comment-form-wrapper { margin-bottom: 32px; padding-bottom: 28px; border-bottom: 1px solid var(--color-border); }
.comment-form-wrapper h3 { font-family: var(--font-display); margin-bottom: 18px; font-size: 1.2rem; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-family: var(--font-ui); font-weight: 600; margin-bottom: 5px; font-size: 0.88rem; color: var(--color-text); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  font-size: 0.95rem; font-family: var(--font-body);
  background: var(--color-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: var(--color-accent);
  box-shadow: 0 0 0 3px hsla(25, 70%, 45%, 0.1);
}

/* ====== BUTTONS ====== */
.btn {
  display: inline-block; padding: 10px 22px;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  font-family: var(--font-ui); font-size: 0.88rem; font-weight: 600;
  cursor: pointer; text-align: center;
  background: var(--color-surface); color: var(--color-text);
  text-decoration: none; transition: all 0.2s;
}
.btn:hover { background: var(--color-bg); text-decoration: none; }
.btn-primary { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }

/* ====== ERROR PAGE ====== */
.error-page { text-align: center; padding: 100px 0; }
.error-page h1 { font-family: var(--font-display); font-size: 6rem; color: var(--color-border); line-height: 1; }
.error-page p { margin: 20px 0 30px; color: var(--color-text-muted); font-size: 1.1rem; }

/* ====== ALERTS ====== */
#comment-message .alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 15px; font-family: var(--font-ui); font-size: 0.9rem; }
#comment-message .alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
#comment-message .alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }

/* ====== FOOTER ====== */
.site-footer {
  padding: 28px 0;
  border-top: 2px solid var(--color-text);
  color: var(--color-text-muted);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  background: var(--color-surface);
}
.footer-heading {
  color: var(--color-text);
  font-size: 0.9rem;
  margin: 0 0 10px;
  font-weight: 600;
}
.footer-categories {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 20px;
  margin-bottom: 20px;
}
.footer-categories a {
  color: var(--color-text-muted);
  text-decoration: none;
}
.footer-categories a:hover {
  color: var(--color-text);
  text-decoration: underline;
}
.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
}
.footer-links a {
  color: var(--color-text-muted);
  text-decoration: none;
}
.footer-links a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* ====== NAV TOGGLE (HAMBURGER) ====== */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  margin: 5px 0;
  transition: transform 0.3s, opacity 0.3s;
}
.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  .posts-grid { grid-template-columns: 1fr; gap: 20px; }
  .post-card--featured .post-thumbnail img { height: 240px; }
  .post-card--featured .post-card-title { font-size: 1.4rem; }
  .post-thumbnail img { height: 200px; }
  .site-title { font-size: 1.8rem; margin-top: -5px; }
  .header-top { display: block; text-align: left; position: relative; padding: 10px 0 12px; }
  .header-toolbar { position: absolute; right: 0; top: 10px; transform: none; }
  .nav-toggle { display: block; order: 3; }
  .main-nav {
    display: none;
    flex-direction: column;
    flex-wrap: wrap;
  }
  .main-nav.open { display: flex; }
  .main-nav a {
    flex: none;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.85rem;
  }
  .main-nav a:last-child { border-bottom: none; }
  .main-nav a.active { border-bottom: 1px solid var(--color-border); }
  .site-main { padding: 15px 0; }
  .footer-heading { text-align: center; }
  .footer-categories { grid-template-columns: repeat(2, 1fr); max-width: fit-content; margin: 0 auto 16px; text-align: left; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .archive-header { text-align: center; }
  .similar-posts { padding: 24px 20px; }
  .similar-posts-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .post-single { padding: 24px 20px; }
  .post-featured-image { margin: 0 -20px 24px; }
  .post-header { text-align: left; }
  .post-header .post-meta { justify-content: flex-start; }
  .post-header h1 { font-size: 1.7rem; }
  .comments-section { padding: 24px 20px; }
  .container { padding: 0 16px; }
  .footer-categories { grid-template-columns: repeat(2, 1fr); }
  .site-description { font-size: 0.85rem; }
  .similar-posts-grid { grid-template-columns: 1fr; }
}
