/* ==========================================================
   Data Platform Design — Custom Theme
   Purple palette · Inter + Merriweather · Light/Dark mode
   ========================================================== */

/* --- Light theme (default) --- */
:root {
  --primary:          #7C3AED;
  --primary-hover:    #6D28D9;
  --primary-light:    #EDE9FE;
  --primary-glow:     rgba(124, 58, 237, 0.15);

  --bg:               #FFFFFF;
  --bg-secondary:     #F9F7FF;
  --bg-card:          #FFFFFF;
  --bg-card-hover:    #F5F3FF;
  --bg-code:          #1A0F35;

  --text:             #1C1117;
  --text-secondary:   #6B7280;
  --text-muted:       #9CA3AF;

  --border:           #E4DAFC;
  --border-light:     #F3F0FD;

  --nav-bg:           rgba(255, 255, 255, 0.9);
  --shadow-card:      0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(124,58,237,0.07);
  --shadow-card-hover:0 4px 16px rgba(0,0,0,0.11), 0 12px 40px rgba(124,58,237,0.14);

  --radius:           12px;
  --radius-sm:        6px;
  --transition:       140ms ease;

  color-scheme: light;
}

/* --- Dark theme --- */
html[data-theme="dark"] {
  --primary:          #A78BFA;
  --primary-hover:    #C4B5FD;
  --primary-light:    #2D1B69;
  --primary-glow:     rgba(167, 139, 250, 0.15);

  --bg:               #0C0712;
  --bg-secondary:     #140C22;
  --bg-card:          #160D26;
  --bg-card-hover:    #1E1238;
  --bg-code:          #0F0820;

  --text:             #F0E9FF;
  --text-secondary:   #C4B5E8;
  --text-muted:       #8B7DB5;

  --border:           #2D1B69;
  --border-light:     #1E1238;

  --nav-bg:           rgba(12, 7, 18, 0.92);
  --shadow-card:      0 1px 4px rgba(0,0,0,0.4), 0 4px 16px rgba(124,58,237,0.12);
  --shadow-card-hover:0 4px 20px rgba(0,0,0,0.5), 0 12px 40px rgba(124,58,237,0.25);

  color-scheme: dark;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition), color var(--transition);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--primary-hover); }

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

/* --- Layout containers --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.container--narrow {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
}

.main-content {
  flex: 1;
  padding-top: 80px;
}

/* =====================================================
   MASTHEAD
   ===================================================== */

.masthead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background-color var(--transition);
}

.masthead-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.masthead-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  margin-right: 8px;
}

.masthead-logo svg {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.masthead-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  transition: color var(--transition);
  white-space: nowrap;
}

.masthead-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: color var(--transition), background-color var(--transition);
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}
.nav-link--active {
  color: var(--primary);
  background: var(--primary-light);
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}
.theme-toggle svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

/* Hamburger (mobile) */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* Mobile nav */
@media (max-width: 768px) {
  .masthead-title { display: none; }

  .nav-toggle { display: flex; }

  .masthead-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  }
  .masthead-nav.masthead-nav--open {
    display: flex;
  }
  .nav-link {
    padding: 12px 16px;
    border-radius: 0;
    border-bottom: 1px solid var(--border-light);
  }
  .nav-link:last-child { border-bottom: none; }
}

/* =====================================================
   HERO (homepage)
   ===================================================== */

.hero {
  padding: 72px 0 52px;
  text-align: center;
}

.hero-title {
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.12;
  color: var(--text);
  margin-bottom: 18px;
}

.hero-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 460px;
  margin: 0 auto 40px;
  line-height: 1.65;
}

.text-primary { color: var(--primary); }

.hero-divider {
  width: 48px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), transparent);
  border-radius: 2px;
  margin: 0 auto;
}

/* =====================================================
   POST GRID
   ===================================================== */

.posts-section {
  padding-bottom: 64px;
}

.posts-heading {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 48px;
}

@media (max-width: 640px) {
  .post-grid { grid-template-columns: 1fr; }
}

/* =====================================================
   POST CARD
   ===================================================== */

.post-card {
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  transition: transform 200ms ease, box-shadow 200ms ease, background-color var(--transition), border-color var(--transition);
  overflow: hidden;
}

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

.post-card-link {
  display: flex;
  flex-direction: column;
  padding: 28px;
  text-decoration: none;
  color: inherit;
  height: 100%;
  min-height: 200px;
}

.post-card-category {
  display: inline-flex;
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 14px;
}

.post-card-title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: -0.3px;
  transition: color var(--transition);
}
.post-card:hover .post-card-title { color: var(--primary); }

.post-card-excerpt {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 20px;
  flex: 1;
}

.post-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: auto;
}

.post-card-meta-dot {
  opacity: 0.4;
}

/* =====================================================
   SINGLE ARTICLE
   ===================================================== */

.article {
  padding: 52px 0 96px;
}

.article-header {
  margin-bottom: 44px;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--border);
}

.article-category {
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 20px;
  text-decoration: none;
  transition: all var(--transition);
}
.article-category:hover {
  background: var(--primary);
  color: #fff;
}

.article-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.8px;
  color: var(--text);
  margin-bottom: 24px;
}

.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.article-meta-dot { opacity: 0.4; }

/* =====================================================
   TABLE OF CONTENTS
   ===================================================== */

.toc {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 20px 24px;
  margin-bottom: 48px;
}

.toc-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item {
  margin-bottom: 5px;
}

.toc-item a {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
  line-height: 1.5;
}
.toc-item a:hover { color: var(--primary); }

.toc-item--h3 { padding-left: 16px; }

/* =====================================================
   PROSE (article body)
   ===================================================== */

.prose {
  font-family: 'Merriweather', Georgia, 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.88;
  color: var(--text);
}

.prose h2 {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.25;
  margin-top: 52px;
  margin-bottom: 16px;
  color: var(--text);
  scroll-margin-top: 80px;
}

.prose h3 {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 36px;
  margin-bottom: 12px;
  color: var(--text);
  scroll-margin-top: 80px;
}

.prose h4 {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 10px;
  color: var(--text-secondary);
  scroll-margin-top: 80px;
}

.prose p { margin-bottom: 26px; }

.prose a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  transition: color var(--transition);
}
.prose a:hover { color: var(--primary-hover); }

.prose strong {
  font-weight: 700;
  color: var(--text);
}

.prose em { font-style: italic; }

.prose ul,
.prose ol {
  padding-left: 28px;
  margin-bottom: 26px;
}

.prose li {
  margin-bottom: 8px;
  padding-left: 4px;
}

.prose li > ul,
.prose li > ol {
  margin-top: 8px;
  margin-bottom: 0;
}

.prose blockquote {
  border-left: 4px solid var(--primary);
  margin: 36px 0;
  padding: 20px 28px;
  background: var(--bg-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text-secondary);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Menlo', monospace;
  font-size: 0.82em;
  background: var(--bg-secondary);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.prose pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  overflow-x: auto;
  margin-bottom: 36px;
  margin-top: 4px;
}

.prose pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: #e9d5ff;
  font-size: 14.5px;
  line-height: 1.72;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 36px;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  overflow-x: auto;
  display: block;
}

.prose thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.prose tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: top;
}

.prose tbody tr:last-child td { border-bottom: none; }

.prose img {
  border-radius: var(--radius);
  margin: 32px 0;
  box-shadow: var(--shadow-card);
}

/* =====================================================
   ARTICLE FOOTER (tags)
   ===================================================== */

.article-footer {
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.article-tags-heading {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 100px;
  transition: all var(--transition);
  text-decoration: none;
}
.tag:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* =====================================================
   PAGINATION
   ===================================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 0 64px;
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition);
}
.pagination-link:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.pagination-info {
  font-size: 14px;
  color: var(--text-muted);
}

/* =====================================================
   FOOTER
   ===================================================== */

.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 44px 0;
  margin-top: auto;
  transition: background-color var(--transition);
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.footer-brand svg {
  width: 24px;
  height: 24px;
}
.footer-brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: color var(--transition);
}

.footer-copy {
  font-size: 13px;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 20px;
}
.footer-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.footer-link:hover { color: var(--primary); }

@media (max-width: 580px) {
  .site-footer-inner { justify-content: center; text-align: center; }
  .footer-links { justify-content: center; }
}

/* =====================================================
   PAGE (generic content page: About, etc.)
   ===================================================== */

.page-wrapper {
  padding: 60px 0 96px;
}

.page-title {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text);
  margin-bottom: 36px;
  line-height: 1.15;
}

.page-content.prose {
  font-size: 17px;
}

/* =====================================================
   ARCHIVE (categories / tags)
   ===================================================== */

.archive-wrapper {
  padding: 56px 0 96px;
}

.archive-page-title {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text);
  margin-bottom: 52px;
  line-height: 1.15;
}

.archive-group {
  margin-bottom: 52px;
}

.archive-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary);
  background: var(--primary-light);
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.archive-list {
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.archive-item {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: background-color var(--transition);
}
.archive-item:last-child { border-bottom: none; }
.archive-item:hover { background: var(--bg-card-hover); }

.archive-item-title {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}
.archive-item-title:hover { color: var(--primary); }

.archive-item-date {
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* =====================================================
   SYNTAX HIGHLIGHTING (Rouge)
   ===================================================== */

.highlight { background: transparent; }
.highlight .c,
.highlight .c1,
.highlight .cm { color: #8B7DB5; font-style: italic; }
.highlight .k,
.highlight .kd,
.highlight .kn { color: #C4B5FD; font-weight: 600; }
.highlight .s,
.highlight .s1,
.highlight .s2 { color: #86EFAC; }
.highlight .n,
.highlight .na { color: #e9d5ff; }
.highlight .nf,
.highlight .nc { color: #93C5FD; }
.highlight .nb { color: #FCA5A5; }
.highlight .mi,
.highlight .mf,
.highlight .m { color: #FCD34D; }
.highlight .o { color: #C4B5FD; }
.highlight .p { color: #e9d5ff; }

/* =====================================================
   UTILITIES
   ===================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
