/* ==========================================================================
   KutBlog — Minimal Theme Stylesheet
   Modern, spacious, minimalist, thumbnail-first & mobile-first
   ========================================================================== */

/* ── 1. Variables & Design Tokens ────────────────────────────────────────── */
:root {
  /* Light Theme (Default) */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-card: #ffffff;
  --surface-hover: #f1f5f9;
  --surface-subtle: #f8fafc;
  
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  
  --badge-bg: #f1f5f9;
  --badge-text: #334155;
  
  --header-bg: rgba(255, 255, 255, 0.82);
  --header-border: rgba(226, 232, 240, 0.8);
  
  --card-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
  --card-shadow-hover: 0 16px 36px -4px rgba(15, 23, 42, 0.09), 0 6px 16px -2px rgba(15, 23, 42, 0.04);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --max-w-content: 1180px;
  --max-w-article: 760px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Theme via attribute or media query fallback */
[data-theme="dark"] {
  --bg: #090d16;
  --surface: #101626;
  --surface-card: #121828;
  --surface-hover: #19233a;
  --surface-subtle: #162034;
  
  --border: #1e293b;
  --border-subtle: #151f30;
  --border-focus: rgba(129, 140, 248, 0.45);
  
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --badge-bg: #1e293b;
  --badge-text: #cbd5e1;
  
  --header-bg: rgba(16, 22, 38, 0.85);
  --header-border: rgba(30, 41, 59, 0.8);
  
  --card-shadow: 0 4px 24px -2px rgba(0, 0, 0, 0.45);
  --card-shadow-hover: 0 16px 40px -4px rgba(0, 0, 0, 0.65);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090d16;
    --surface: #101626;
    --surface-card: #121828;
    --surface-hover: #19233a;
    --surface-subtle: #162034;
    
    --border: #1e293b;
    --border-subtle: #151f30;
    --border-focus: rgba(129, 140, 248, 0.45);
    
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;
    
    --badge-bg: #1e293b;
    --badge-text: #cbd5e1;
    
    --header-bg: rgba(16, 22, 38, 0.85);
    --header-border: rgba(30, 41, 59, 0.8);
    
    --card-shadow: 0 4px 24px -2px rgba(0, 0, 0, 0.45);
    --card-shadow-hover: 0 16px 40px -4px rgba(0, 0, 0, 0.65);
  }
}

/* ── 2. Reset & Core Typography (Mobile First) ─────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

/* ── 3. Layout Structure ─────────────────────────────────────────────────── */
.site-container {
  width: 100%;
  max-width: var(--max-w-content);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-main {
  flex: 1;
  padding: 2.5rem 0 4rem;
}

/* ── 4. Header & Navigation (Mobile First) ───────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--header-border);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 1rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.brand-link .site-logo-img {
  height: 32px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  vertical-align: middle;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 2px 8px var(--accent-light);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links {
  display: none; /* Hidden on mobile */
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  padding: 0.35rem 0;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--accent);
  border-radius: var(--radius-pill);
}

/* Icon Buttons (Search, Theme Toggle, Mobile Menu) */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Mobile Menu Button */
.menu-btn {
  display: flex;
}

/* Mobile Drawer Overlay */
.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.mobile-drawer.open {
  opacity: 1;
  visibility: visible;
}

.mobile-drawer-content {
  position: absolute;
  top: 69px;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem;
  transform: translateY(-10px);
  transition: transform var(--transition-normal);
  box-shadow: var(--card-shadow);
}

.mobile-drawer.open .mobile-drawer-content {
  transform: translateY(0);
}

.mobile-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mobile-nav-list a {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-subtle);
}

.mobile-nav-list a:hover {
  background: var(--surface-hover);
  color: var(--accent);
}

/* Search Dropdown / Input Bar */
.search-bar-wrap {
  position: relative;
}

.search-modal {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem;
  box-shadow: var(--card-shadow-hover);
  z-index: 101;
}

.search-modal.open {
  display: block;
  animation: fadeInDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-form {
  display: flex;
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  gap: 0.5rem;
}

.search-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-form input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
}

.search-form input::placeholder {
  color: var(--text-subtle);
}

.search-form button {
  color: var(--text-muted);
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 5. Page Title & Filter Header ───────────────────────────────────────── */
.page-header {
  margin-bottom: 2.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.page-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 0.75rem;
}

.page-header-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.2;
}

.page-header-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ── 6. Thumbnail-First Card Grid (Mobile First) ─────────────────────────── */
.post-grid {
  display: grid;
  grid-template-columns: 1fr; /* Mobile: 1 column */
  gap: 2.25rem;
}

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

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
  border-color: rgba(var(--accent-rgb), 0.3);
}

/* Thumbnail Box: 16/9 Ratio with Floating Badges */
.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: var(--surface-subtle);
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

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

/* Minimalist Placeholder when article has no featured image */
.card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--surface-subtle) 0%, var(--surface-hover) 100%);
  position: relative;
  overflow: hidden;
}

.card-placeholder::before {
  content: '';
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-light) 0%, transparent 70%);
}

.card-placeholder-icon {
  width: 48px;
  height: 48px;
  color: var(--text-subtle);
  opacity: 0.6;
}

/* Floating Badges on Thumbnail */
.card-badges {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 0.5rem;
  z-index: 2;
}

.card-category {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.card-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-subtle);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.75rem;
  transition: color var(--transition-fast);
}

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

.card-excerpt {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.card-footer-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: transform var(--transition-fast);
}

.post-card:hover .card-footer-arrow {
  transform: translateX(3px);
}

/* ── 7. Single Article View (Clean & Spacious Reading) ───────────────────── */
.article-wrap {
  max-width: var(--max-w-article);
  margin: 0 auto;
}

.article-hero {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  margin-bottom: 2.25rem;
  aspect-ratio: 16 / 9;
  background: var(--surface-subtle);
}

.article-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-header {
  margin-bottom: 2.5rem;
}

.article-meta-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.article-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-light);
  color: var(--accent);
}

.article-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.article-lead {
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--text-muted);
  font-weight: 400;
  border-left: 3px solid var(--accent);
  padding-left: 1.25rem;
  margin-bottom: 2rem;
}

/* Prose Typography */
.prose {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text);
}

.prose p {
  margin-bottom: 1.75rem;
}

.prose h2 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-top: 3rem;
  margin-bottom: 1rem;
  line-height: 1.25;
}

.prose h3 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 2.25rem;
  margin-bottom: 0.85rem;
}

.prose ul, .prose ol {
  margin-bottom: 1.75rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.6rem;
}

.prose blockquote {
  border-left: 4px solid var(--accent);
  background: var(--surface-card);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 2rem 0;
  font-style: italic;
  color: var(--text-muted);
}

.prose code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.prose pre {
  background: #0d1117;
  color: #e6edf3;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 2rem 0;
  border: 1px solid var(--border);
}

.prose hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 3rem 0;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose a:hover {
  opacity: 0.85;
}

.yt-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 2rem 0;
  box-shadow: var(--card-shadow);
}

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

/* Article Tags */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 2.5rem 0 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.tag-badge {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  transition: all var(--transition-fast);
}

.tag-badge:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}

.article-back-bar {
  margin-top: 2rem;
}

.article-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--surface-card);
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
}

.article-back-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateX(-2px);
}

/* ── 8. Mastodon Comments ────────────────────────────────────────────────── */
.comments-section {
  margin-top: 4rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.comments-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.comments-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.mc-comment {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.mc-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.mc-avatar img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.mc-author-info strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
}

.mc-author-info span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.mc-body {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

/* ── 9. Pagination ───────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 3.5rem;
}

.page-btn {
  min-width: 42px;
  height: 42px;
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-card);
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
}

.page-btn:hover {
  color: var(--text);
  border-color: var(--border-focus);
  background: var(--surface-hover);
}

.page-btn.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* ── 10. 404 & Empty State ───────────────────────────────────────────────── */
.empty-box {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4rem 2rem;
  text-align: center;
  box-shadow: var(--card-shadow);
  max-width: 600px;
  margin: 0 auto;
}

.empty-code {
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--border);
  margin-bottom: 1rem;
}

.empty-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.empty-desc {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #ffffff;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--accent-light);
}

/* ── 11. Footer ──────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 3rem 0;
  margin-top: auto;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

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

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

/* ── 12. Progressive Enhancement: Tablet & Desktop ───────────────────────── */
@media (min-width: 640px) {
  .post-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 columns on tablet */
    gap: 2rem;
  }
}

@media (min-width: 1024px) {
  .site-main {
    padding: 3.5rem 0 6rem;
  }
  
  .nav-links {
    display: flex; /* Visible on desktop */
  }
  
  .menu-btn {
    display: none; /* Hide hamburger on desktop */
  }
  
  .post-grid {
    grid-template-columns: repeat(3, 1fr); /* 3 columns on desktop */
    gap: 2.25rem;
  }
  
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}
