/* Headless CMS — Refined Static Theme */
:root {
  --color-bg: #fafafa;
  --color-text: #1a1a2e;
  --color-muted: #6b7280;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-soft: rgba(37, 99, 235, 0.08);
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-callout-bg: #eff6ff;
  --color-callout-border: #bfdbfe;
  --color-callout-text: #1e40af;
  --color-table-header: #f8fafc;
  --color-table-row: #ffffff;
  --color-table-alt: #f1f5f9;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --max-width: 760px;
  --gap-sm: 0.75rem;
  --gap-md: 1.25rem;
  --gap-lg: 2rem;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.08);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html.theme-dark {
  --color-bg: #0f0f1a;
  --color-text: #e8e8ef;
  --color-muted: #9ca3af;
  --color-accent: #60a5fa;
  --color-accent-hover: #93c5fd;
  --color-accent-soft: rgba(96, 165, 250, 0.12);
  --color-surface: #181825;
  --color-border: #27273a;
  --color-callout-bg: #1e1b4b;
  --color-callout-border: #4338ca;
  --color-callout-text: #a5b4fc;
  --color-table-header: #1a1a2e;
  --color-table-row: #131320;
  --color-table-alt: #1a1a2e;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.3);
}

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

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

body {
  font-family: var(--font-body);
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gap-md);
  width: 100%;
}

/* ========== HEADER ========== */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.875rem 0;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  background-color: rgba(var(--color-surface-rgb, 255, 255, 255), 0.85);
  transition: var(--transition);
}

html.theme-dark .site-header {
  background-color: rgba(24, 24, 37, 0.85);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-md);
}

.site-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.03em;
  line-height: 1.2;
  transition: color 0.2s;
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
  position: relative;
}

.site-nav a:hover { color: var(--color-accent); }

.site-nav a::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-accent);
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 1px;
}

.site-nav a:hover::after { width: 100%; }

.search-input {
  padding: 0.45rem 0.7rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  background: var(--color-bg);
  color: var(--color-text);
  width: 150px;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  width: 200px;
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.theme-toggle {
  background: transparent;
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.65rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  transform: translateY(-1px);
}

/* ========== BREADCRUMBS ========== */
.breadcrumbs {
  padding: 0.65rem 0;
  font-size: 0.78rem;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.75rem;
}

.breadcrumbs ol {
  list-style: none;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 0.4rem;
  color: var(--color-border);
}

.breadcrumbs a {
  color: var(--color-muted);
  text-decoration: none;
  transition: color 0.2s;
}

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

/* ========== HERO ========== */
.hero {
  padding: 3rem 0 2rem;
  text-align: center;
  position: relative;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 0.6rem;
  letter-spacing: -0.04em;
  line-height: 1.1;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-text) 0%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lead {
  font-size: 1.15rem;
  color: var(--color-muted);
  margin: 0 auto;
  max-width: 520px;
  line-height: 1.5;
}

/* ========== POST LIST / CARDS ========== */
.post-list {
  display: grid;
  gap: var(--gap-lg);
  padding: 0.5rem 0 2rem;
}

.post-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

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

.post-card-image {
  width: 100%;
  height: 220px;
  overflow: hidden;
  position: relative;
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.post-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  line-height: 1.35;
  font-weight: 700;
}

.post-card h2 a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s;
}

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

.excerpt {
  margin: 0 0 0.75rem;
  color: var(--color-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  flex: 1;
}

.post-meta {
  font-size: 0.8rem;
  color: var(--color-muted);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.read-time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--color-accent-soft);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

/* ========== TAGS ========== */
.post-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.tag {
  display: inline-flex;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: 999px;
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid transparent;
}

.tag:hover {
  background: var(--color-accent);
  color: #fff;
  transform: translateY(-1px);
}

.tag.category {
  color: #059669;
  background: rgba(5, 150, 105, 0.08);
}

.tag.category:hover {
  background: #059669;
  color: #fff;
}

html.theme-dark .tag { background: rgba(96, 165, 250, 0.12); }
html.theme-dark .tag:hover { background: var(--color-accent); }
html.theme-dark .tag.category { color: #34d399; background: rgba(52, 211, 153, 0.12); }
html.theme-dark .tag.category:hover { background: #059669; }

/* ========== SINGLE POST ========== */
.post {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

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

.post-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin: 0 0 0.75rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.post-content {
  padding: 1.75rem 2rem 2.5rem;
}

.post-content p {
  margin: 0 0 1.1rem;
  line-height: 1.75;
}

.post-content h2 {
  font-size: 1.35rem;
  margin: 2rem 0 0.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.post-content h3 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.6rem;
  font-weight: 700;
  color: var(--color-text);
}

.post-content ul, .post-content ol {
  padding-left: 1.5rem;
  margin: 0 0 1.1rem;
}

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

.post-content blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-text);
  font-style: italic;
}

.post-content pre {
  background: var(--color-bg);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.6;
  border: 1px solid var(--color-border);
  margin: 0 0 1.25rem;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.88rem;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  display: block;
  margin: 1.25rem 0;
  box-shadow: var(--shadow-md);
}

.post-content figure {
  margin: 1.25rem 0;
}

.post-content figcaption {
  font-size: 0.82rem;
  color: var(--color-muted);
  text-align: center;
  margin-top: 0.4rem;
}

/* Featured image */
.featured-image {
  margin: 0;
  width: 100%;
  max-height: 420px;
  overflow: hidden;
  position: relative;
}

.featured-image img {
  width: 100%;
  height: 420px;
  object-fit: cover;
  display: block;
}

.featured-image figcaption {
  font-size: 0.8rem;
  color: var(--color-muted);
  text-align: center;
  margin-top: 0.5rem;
  padding: 0 1rem;
}

/* Callout */
.callout {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--color-callout-border);
  background: var(--color-callout-bg);
  color: var(--color-callout-text);
  margin: 1.25rem 0;
}

.callout-title {
  font-weight: 700;
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.callout p {
  margin: 0;
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

/* Table */
.post-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.25rem 0;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.post-table th,
.post-table td {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.post-table th {
  background: var(--color-table-header);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.post-table tr:last-child td { border-bottom: none; }

.post-table tr:nth-child(even) { background: var(--color-table-alt); }

/* Embed */
.embed-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  margin: 1.25rem 0;
  box-shadow: var(--shadow-md);
}

.embed-container iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* ========== AUTHOR CARD ========== */
.author-card {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  padding: 1.5rem 2rem;
  margin: 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-accent-soft);
}

.author-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.author-info {
  flex: 1;
}

.author-name {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.3rem;
  color: var(--color-text);
}

.author-bio {
  font-size: 0.88rem;
  color: var(--color-muted);
  margin: 0;
  line-height: 1.55;
}

/* ========== TAXONOMY PAGE ========== */
.taxonomy-page h1 {
  font-size: 1.6rem;
  margin: 1.5rem 0 0.3rem;
  font-weight: 800;
}

.taxonomy-desc {
  color: var(--color-muted);
  margin: 0 0 1.5rem;
  font-size: 1rem;
}

/* ========== FOOTER ========== */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem 0;
  margin-top: auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-muted);
  background: var(--color-surface);
}

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

.pagination span {
  font-size: 0.85rem;
  color: var(--color-muted);
  font-weight: 500;
}

.pagination .btn {
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
  background: var(--color-surface);
  transition: var(--transition);
  font-weight: 500;
}

.pagination .btn:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent);
  transform: translateY(-1px);
}

/* ========== SEARCH RESULTS ========== */
.search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  padding: 0.5rem 0;
}

.search-results:empty { display: none; }

.search-result-item {
  display: block;
  padding: 0.6rem 0.85rem;
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s;
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item:hover { background: var(--color-bg); }

.search-result-title { font-weight: 600; font-size: 0.92rem; }
.search-result-excerpt { font-size: 0.8rem; color: var(--color-muted); margin-top: 0.15rem; }

/* ========== RESPONSIVE ========== */
@media (min-width: 768px) {
  .post-list {
    grid-template-columns: repeat(2, 1fr);
  }
  .post-card:first-child {
    grid-column: span 2;
    flex-direction: row;
  }
  .post-card:first-child .post-card-image {
    width: 45%;
    height: auto;
    min-height: 260px;
  }
  .post-card:first-child .post-card-body {
    width: 55%;
    justify-content: center;
  }
  .post-card:first-child h2 {
    font-size: 1.5rem;
  }
}

@media (max-width: 600px) {
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .site-nav { width: 100%; }
  .hero h1 { font-size: 1.8rem; }
  .post-card:first-child { grid-column: span 1; flex-direction: column; }
  .post-card:first-child .post-card-image { width: 100%; height: 220px; }
  .post-header { padding: 1.5rem 1.25rem; }
  .post-content { padding: 1.25rem 1.25rem 1.5rem; }
  .author-card { flex-direction: column; align-items: center; text-align: center; padding: 1.25rem; }
  .search-input { width: 100%; }
  .search-input:focus { width: 100%; }
}
