/* ─── RESET & TOKENS ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #FAFAF7;
  --bg2: #F2F1EC;
  --text: #1A1A16;
  --text2: #5A5A54;
  --accent: #1D4ED8;
  --accent-light: #DBEAFE;
  --border: rgba(26,26,22,0.12);
  --card-bg: #FFFFFF;
  --code-bg: #1A1A2E;
  --code-text: #E2E8F0;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Serif 4', Georgia, serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
  --tag-html: #DC2626; --tag-html-bg: #FEF2F2;
  --tag-js: #92400E;  --tag-js-bg:  #FFFBEB;
  --tag-sql: #1D4ED8; --tag-sql-bg: #EFF6FF;
  --tag-cs:  #6D28D9; --tag-cs-bg:  #F5F3FF;
  --tag-api: #065F46; --tag-api-bg: #ECFDF5;
  --tag-azure: #0C4A6E; --tag-azure-bg: #E0F2FE;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06), 0 0 0 1px var(--border);
}

[data-theme="dark"] {
  --bg: #111110;
  --bg2: #1C1C1A;
  --text: #F0EFE8;
  --text2: #9A9A90;
  --accent: #60A5FA;
  --accent-light: #1E3A5F;
  --border: rgba(240,239,232,0.10);
  --card-bg: #1C1C1A;
  --code-bg: #0D0D1A;
  --shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 0 1px var(--border);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.7;
  transition: background 0.2s, color 0.2s;
}

/* ─── HEADER ─────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.header-inner {
  max-width: 1100px; margin: 0 auto;
  padding: 0 2rem;
  height: 60px;
  display: flex; align-items: center; gap: 2rem;
}
.logo {
  font-family: var(--font-mono);
  font-size: 1.1rem; font-weight: 500;
  color: var(--text);
  user-select: none;
}
.logo-bracket { color: var(--accent); }
.main-nav { display: flex; gap: 1.5rem; margin-left: auto; }
.main-nav a {
  font-family: var(--font-mono);
  font-size: 0.82rem; text-decoration: none;
  color: var(--text2);
  transition: color 0.15s;
  letter-spacing: 0.02em;
}
.main-nav a:hover { color: var(--text); }
.theme-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px;
  cursor: pointer; font-size: 1rem; color: var(--text);
  transition: background 0.15s;
}
.theme-toggle:hover { background: var(--bg2); }

/* ─── HERO ───────────────────────────────────────────── */
.hero {
  max-width: 1100px; margin: 0 auto;
  padding: 5rem 2rem 4rem;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: center;
}
.hero-eyebrow {
  font-family: var(--font-mono); font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent); margin-bottom: 1rem;
}
.hero-title {
  font-family: var(--font-display); font-size: clamp(2.4rem, 5vw, 3.8rem);
  line-height: 1.15; font-weight: 700;
  margin-bottom: 1.2rem; color: var(--text);
}
.hero-title em { font-style: normal; color: var(--accent); }
.hero-sub { font-size: 1.05rem; color: var(--text2); max-width: 480px; margin-bottom: 2rem; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-family: var(--font-mono); font-size: 0.74rem;
  padding: 4px 10px; border-radius: 4px; font-weight: 500;
}
.tag-html  { background: var(--tag-html-bg);  color: var(--tag-html);  }
.tag-js    { background: var(--tag-js-bg);    color: var(--tag-js);    }
.tag-sql   { background: var(--tag-sql-bg);   color: var(--tag-sql);   }
.tag-cs    { background: var(--tag-cs-bg);    color: var(--tag-cs);    }
.tag-api   { background: var(--tag-api-bg);   color: var(--tag-api);   }
.tag-azure { background: var(--tag-azure-bg); color: var(--tag-azure); }

/* Hero code block */
.code-block {
  background: var(--code-bg); border-radius: var(--radius);
  padding: 1.5rem; font-family: var(--font-mono); font-size: 0.85rem;
  line-height: 2; color: var(--code-text);
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.code-block .line { display: block; }
.kw  { color: #60A5FA; font-weight: 500; }
.cm  { color: #6B7280; }
.str { color: #86EFAC; }

/* ─── ARCHITECTURE ───────────────────────────────────── */
.arch-section { background: var(--bg2); padding: 4rem 2rem; }
.arch-inner { max-width: 900px; margin: 0 auto; }
.section-title {
  font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  margin-bottom: 0.5rem;
}
.section-sub { color: var(--text2); margin-bottom: 2.5rem; }
.arch-flow {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 1rem; justify-content: center;
}
.arch-node {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1.5rem;
  text-align: center; min-width: 130px;
  box-shadow: var(--shadow);
}
.arch-icon { font-size: 2rem; margin-bottom: 0.4rem; }
.arch-label { font-family: var(--font-mono); font-size: 0.85rem; font-weight: 500; }
.arch-desc  { font-size: 0.78rem; color: var(--text2); margin-top: 2px; }
.arch-node-azure {
  border-color: var(--accent);
  background: var(--accent-light);
}
.arch-arrow { font-size: 1.5rem; color: var(--text2); }
.arch-arrow-up { transform: rotate(-90deg); }

/* ─── TOPICS GRID ────────────────────────────────────── */
.topics-section, .recent-section { padding: 4rem 2rem; }
.section-inner { max-width: 1100px; margin: 0 auto; }
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem; margin-top: 2rem;
}
.post-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 0.75rem;
}
.post-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.1), 0 0 0 1px var(--border); }
.post-card-tag { display: flex; gap: 6px; flex-wrap: wrap; }
.post-card-title {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 700;
  line-height: 1.3; color: var(--text);
}
.post-card-excerpt { font-size: 0.9rem; color: var(--text2); flex: 1; }
.post-card-meta {
  font-family: var(--font-mono); font-size: 0.74rem; color: var(--text2);
  margin-top: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.75rem;
}
.loading-state { color: var(--text2); font-style: italic; padding: 2rem; }

/* ─── RECENT LIST ────────────────────────────────────── */
.recent-section { background: var(--bg2); }
.recent-list { display: flex; flex-direction: column; gap: 1px; margin-top: 2rem; }
.recent-item {
  display: flex; align-items: baseline; gap: 1.5rem;
  padding: 1rem 0; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: padding-left 0.15s;
}
.recent-item:hover { padding-left: 0.5rem; }
.recent-date { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text2); white-space: nowrap; min-width: 90px; }
.recent-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; color: var(--text); }
.recent-tags  { margin-left: auto; display: flex; gap: 6px; }

/* ─── ABOUT ──────────────────────────────────────────── */
.about-section { padding: 5rem 2rem; }
.about-inner { max-width: 700px; margin: 0 auto; }
.about-inner p { color: var(--text2); margin-bottom: 1rem; }
.cta-btn {
  display: inline-block; margin-top: 1.5rem;
  background: var(--accent); color: #fff;
  font-family: var(--font-mono); font-size: 0.85rem;
  padding: 0.7rem 1.5rem; border-radius: 8px;
  text-decoration: none; transition: opacity 0.15s;
}
.cta-btn:hover { opacity: 0.85; }

/* ─── MODAL ──────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); cursor: pointer; }
.modal-card {
  position: relative; background: var(--card-bg);
  border-radius: var(--radius); max-width: 760px; width: 100%;
  max-height: 85vh; overflow-y: auto;
  padding: 2.5rem; box-shadow: 0 30px 80px rgba(0,0,0,0.3);
  z-index: 1;
}
.modal-close {
  position: sticky; float: right; top: 0;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px;
  cursor: pointer; font-size: 0.9rem; color: var(--text);
}
#modalContent h2 { font-family: var(--font-display); font-size: 2rem; margin-bottom: 0.5rem; }
#modalContent .meta { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text2); margin-bottom: 1.5rem; }
#modalContent h3 { font-family: var(--font-display); font-size: 1.25rem; margin: 2rem 0 0.75rem; }
#modalContent p  { color: var(--text2); margin-bottom: 1rem; }
#modalContent pre {
  background: var(--code-bg); color: var(--code-text);
  border-radius: 8px; padding: 1.25rem; overflow-x: auto;
  font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.8;
  margin: 1rem 0;
}
#modalContent code {
  font-family: var(--font-mono); font-size: 0.82rem;
  background: var(--bg2); padding: 2px 6px; border-radius: 4px;
}
#modalContent ul { padding-left: 1.5rem; color: var(--text2); margin-bottom: 1rem; }
#modalContent li { margin-bottom: 0.3rem; }

/* ─── FOOTER ─────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border); padding: 2rem;
  background: var(--bg2);
}
.footer-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; gap: 2rem; align-items: center; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--text2);
}

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 768px) {
  .hero { grid-template-columns: 1fr; gap: 2rem; }
  .hero-graphic { order: -1; }
  .arch-flow { flex-direction: column; }
  .arch-arrow { transform: rotate(90deg); }
  .arch-arrow-up { transform: rotate(90deg); }
  .main-nav { display: none; }
}
