:root {
  color-scheme: light;
  --sb-primary: #6533d8;
  --sb-primary-dim: rgba(101, 51, 216, 0.14);
  --sb-primary-glow: rgba(101, 51, 216, 0.1);
  --sb-accent-orange: #f97316;
  --sb-cyan: #6533d8;
  --sb-purple: #f97316;
  --sb-magenta: #ea580c;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --elevated: #e8ebf2;
  --card: #ffffff;
  --border: rgba(15, 18, 30, 0.1);
  --border-hover: rgba(101, 51, 216, 0.42);
  --text-primary: #12131a;
  --text-secondary: #5c6378;
  --text-dim: #848ba3;
  --header-scrolled-bg: rgba(244, 245, 248, 0.92);
  --ambient-primary: rgba(101, 51, 216, 0.12);
  --ambient-purple: rgba(249, 115, 22, 0.08);
  --noise-opacity: 0.035;
  --blockquote-gradient: linear-gradient(
    135deg,
    rgba(101, 51, 216, 0.08),
    transparent
  );
  --article-card-outline: rgba(15, 18, 30, 0.12);
  --status-green: #00d4aa;
  --amber: #e8a838;
  --purple: #9b7ed8;
  --gray-muted: #6b7094;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background-color: var(--bg);
  min-height: 100%;
}

img.brand-logo {
  filter: brightness(0);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text-primary);
  font-family: "DM Sans", sans-serif;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

::selection {
  background: rgba(101, 51, 216, 0.35);
  color: var(--text-primary);
}

.link-muted-hover {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s ease;
}

.link-muted-hover:hover {
  color: var(--sb-primary);
}

/* ─── Blog shell ─── */

.blog-shell {
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ─── Ambient background effects ─── */

.ambient-glow-primary,
.ambient-glow-purple,
.noise-overlay {
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 0;
}

.ambient-glow-primary {
  height: 800px;
  inset: -300px -200px auto auto;
  width: 800px;
  background: radial-gradient(
    ellipse,
    var(--ambient-primary) 0%,
    transparent 60%
  );
}

.ambient-glow-purple {
  height: 600px;
  inset: auto auto -400px -200px;
  width: 600px;
  background: radial-gradient(
    ellipse,
    var(--ambient-purple) 0%,
    transparent 60%
  );
}

.noise-overlay {
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ─── Site header — accent stack: glow, bar, notch, wash ─── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  isolation: isolate;
  transition:
    background 0.3s ease,
    border-color 0.3s ease;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  background: transparent;
  border-bottom: 1px solid transparent;
}

.site-header.is-scrolled {
  background: var(--header-scrolled-bg);
  border-bottom-color: var(--border);
}

.site-header-deco {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
}

.site-header-accent-glow {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 56px;
  background: radial-gradient(
    ellipse 85% 120% at 50% -20%,
    rgba(101, 51, 216, 0.42) 0%,
    rgba(249, 115, 22, 0.18) 38%,
    transparent 62%
  );
  filter: blur(14px);
  opacity: 0.95;
}

.site-header-accent-line {
  position: relative;
  height: 5px;
  background: linear-gradient(
    90deg,
    #6533d8 0%,
    #7c4ce0 18%,
    #f97316 42%,
    #fb923c 50%,
    #f97316 58%,
    #6533d8 82%,
    #4c1d95 100%
  );
  box-shadow:
    0 0 20px rgba(101, 51, 216, 0.45),
    0 0 36px rgba(249, 115, 22, 0.2),
    0 3px 0 rgba(0, 0, 0, 0.15);
}

.site-header-accent-notch {
  position: absolute;
  left: 50%;
  top: 5px;
  width: min(200px, 42vw);
  height: 22px;
  transform: translateX(-50%);
  background: linear-gradient(
    105deg,
    #6533d8 0%,
    #8b5cf6 35%,
    #f97316 70%,
    #ea580c 100%
  );
  clip-path: polygon(6% 0, 94% 0, 100% 100%, 0 100%);
  box-shadow:
    0 8px 28px rgba(101, 51, 216, 0.35),
    0 4px 14px rgba(249, 115, 22, 0.25);
  opacity: 0.92;
}

.site-header-wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(101, 51, 216, 0.14) 0%,
    rgba(249, 115, 22, 0.05) 32%,
    transparent 78%
  );
}

.site-header-inner {
  position: relative;
  z-index: 3;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  border-radius: 8px;
}

.header-logo-lockup:focus-visible {
  outline: 2px solid var(--sb-primary);
  outline-offset: 3px;
}

.header-logo-lockup:hover .header-blog-pill {
  box-shadow: 0 0 0 1px rgba(101, 51, 216, 0.55);
}

.blog-brand-symbol {
  width: auto;
  height: 28px;
  display: block;
  flex-shrink: 0;
}

.blog-brand-wordmark {
  width: auto;
  height: 17px;
  display: block;
  flex-shrink: 0;
}

.header-blog-pill {
  font-family: "Space Grotesk", sans-serif;
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--sb-primary-dim);
  color: #6533d8;
  transition: box-shadow 0.15s ease;
}

.blog-header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.blog-header-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.blog-header-nav a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s ease;
}

.blog-header-nav a:hover {
  color: var(--sb-primary);
}

/* ─── Blog main area ─── */

.blog-main {
  position: relative;
  z-index: 1;
  flex: 1;
}

/* ─── Blog home ─── */

.blog-home {
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 40px;
  position: relative;
}

.blog-home-hero {
  margin-bottom: 64px;
}

.blog-home-title {
  margin: 0 0 16px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.blog-home-copy {
  margin: 0;
  max-width: 500px;
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ─── Homepage post cards ─── */

.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.article-card-link,
.article-card-link * {
  text-decoration: none;
}

.article-card-link {
  display: block;
  border-radius: 16px;
  padding: 1px;
  background: var(--article-card-outline);
  transition: background 0.35s ease;
}

.article-card-link:hover {
  background: linear-gradient(135deg, #6533d8, #f97316);
}

.article-card-link:focus-visible {
  outline: 2px solid var(--sb-primary);
  outline-offset: 3px;
}

.article-card-inner {
  border-radius: 15px;
  background: var(--surface);
  height: 100%;
  padding: 24px;
}

.blog-card-tags,
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.blog-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--sb-primary-dim);
  color: #6533d8;
  font-family: "Space Grotesk", sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.blog-card-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  transition: color 0.2s ease;
}

.article-card-link:hover .blog-card-title {
  color: var(--sb-primary);
}

.blog-card-description {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card-cover {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  aspect-ratio: 1200 / 630;
}

.blog-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.article-card-link:hover .blog-card-cover img {
  transform: scale(1.02);
}

.blog-card-meta {
  color: var(--text-dim);
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
}

/* ─── Homepage sort aside ─── */

.home-sort-aside {
  display: none;
}

.home-sort-nav {
  position: sticky;
  top: 100px;
  width: 200px;
  padding-left: 20px;
  border-left: 1px solid var(--border);
  text-align: left;
}

.home-sort-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-bottom: 16px;
  font-weight: 600;
}

.home-sort-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 0 5px 12px;
  margin-left: -21px;
  font-size: 13px;
  line-height: 1.4;
  font-family: "DM Sans", sans-serif;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-dim);
  border-left: 2px solid transparent;
  transition: color 0.15s ease;
}

.home-sort-option.is-active {
  color: #6533d8;
  border-left-color: #6533d8;
}

.home-sort-option:not(.is-active):hover {
  color: var(--sb-primary);
}

/* ─── Article shell ─── */

.article-shell {
  padding-bottom: 100px;
}

.article-hero,
.article-body {
  max-width: 800px;
  margin: 0 auto;
  padding-left: 40px;
  padding-right: 40px;
}

.article-hero {
  padding-top: 64px;
}

.article-cover {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 40px;
  border: 1px solid var(--border);
  aspect-ratio: 1200 / 630;
  max-height: 420px;
}

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

.article-title {
  margin: 0 0 20px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 48px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.gradient-text {
  background: linear-gradient(135deg, #6533d8, #f97316);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.article-description {
  margin: 0 0 32px;
  max-width: 600px;
  font-size: 18px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.article-author-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.article-author-avatar {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(
    135deg,
    rgba(101, 51, 216, 0.35),
    rgba(249, 115, 22, 0.28)
  );
  color: #6533d8;
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
  font-weight: 600;
}

.article-author-name {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
}

.article-author-meta {
  color: var(--text-dim);
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
}

.article-body {
  padding-top: 48px;
  position: relative;
}

.article-body-inner {
  position: relative;
}

/* ─── Table of contents ─── */

.toc-aside {
  display: none;
}

.toc-nav {
  position: sticky;
  top: 100px;
  width: 200px;
  padding-right: 20px;
  border-right: 1px solid var(--border);
  text-align: right;
}

.toc-title {
  margin-bottom: 16px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.toc-link {
  display: block;
  padding: 5px 12px 5px 0;
  margin-right: -21px;
  color: var(--text-dim);
  text-decoration: none;
  border-right: 2px solid transparent;
  font-size: 13px;
  line-height: 1.4;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.toc-link.toc-link-level-3 {
  padding-right: 14px;
}

.toc-link.is-active,
.toc-link:hover {
  color: var(--sb-primary);
  border-right-color: var(--sb-primary);
}

/* ─── Article prose ─── */

.article-prose {
  min-width: 0;
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: -0.005em;
  color: var(--text-secondary);
}

.article-prose h2 {
  margin: 48px 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-family: "Space Grotesk", sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.article-prose h3 {
  margin: 32px 0 10px;
  color: var(--text-primary);
  font-family: "Space Grotesk", sans-serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.article-prose p {
  margin: 0 0 20px;
}

.article-prose strong {
  color: var(--text-primary);
  font-weight: 600;
}

.article-prose a {
  color: var(--sb-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition:
    color 0.15s ease,
    opacity 0.15s ease;
}

.article-prose a:hover {
  color: var(--sb-primary);
  filter: brightness(1.2);
  text-decoration-thickness: 2px;
}

.article-prose blockquote {
  margin: 40px 0;
  padding: 24px 28px;
  border-left: 3px solid;
  border-image: linear-gradient(180deg, #6533d8, #f97316) 1;
  border-radius: 0 12px 12px 0;
  background: var(--blockquote-gradient);
  color: var(--text-secondary);
  font-style: italic;
}

.article-prose blockquote p {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
}

.article-prose pre {
  margin: 24px 0;
  padding: 20px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface) !important;
}

.article-prose :not(pre) > code {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--elevated);
  color: var(--sb-primary);
  font-size: 0.9em;
}

.article-prose table {
  width: 100%;
  margin: 24px 0;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.article-prose th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text-dim);
  font-family: "Space Grotesk", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

.article-prose td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
}

.article-prose tr:nth-child(even) td {
  background: var(--surface);
}

.article-prose ul,
.article-prose ol {
  margin: 0 0 20px;
  padding-left: 24px;
}

.article-prose li {
  margin-bottom: 8px;
}

.article-prose li::marker {
  color: var(--sb-primary);
}

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

.article-prose img {
  max-width: 100%;
  margin: 24px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* ─── Breakout wide ─── */

.breakout-wide {
  margin-left: -60px;
  margin-right: -60px;
}

/* ─── Interactive embed ─── */

.interactive-embed {
  margin: 0 0 56px;
}

.interactive-embed-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
}

.interactive-embed-accent {
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  z-index: 3;
  opacity: 0.5;
  background: linear-gradient(
    90deg,
    transparent,
    #6533d8,
    #f97316,
    transparent
  );
}

.interactive-embed-loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.interactive-embed.is-loaded .interactive-embed-loader {
  display: none;
}

.interactive-embed-loader-content {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.interactive-embed-loader-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #6533d8;
  animation: blog-pulse 1s infinite;
}

.interactive-embed-loader-text {
  color: var(--text-dim);
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
}

.interactive-embed iframe {
  display: block;
  width: 100%;
  border: 0;
  background: var(--bg);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.interactive-embed.is-loaded iframe {
  opacity: 1;
}

.interactive-embed-caption {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
}

/* ─── Article footer ─── */

.article-footer {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.article-footer-author {
  display: flex;
  align-items: center;
  gap: 12px;
}

.article-footer-buttons {
  display: flex;
  gap: 8px;
}

.blog-button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.blog-button:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.blog-button[data-state="success"] {
  color: var(--sb-primary);
  border-color: var(--border-hover);
}

/* ─── Blog footer ─── */

.blog-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 40px;
}

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

.blog-footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  border-radius: 6px;
}

.blog-footer-brand img {
  width: auto;
  height: 20px;
}

.blog-footer-copy {
  font-size: 13px;
}

.blog-footer-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.blog-footer-nav a {
  font-size: 13px;
}

.blog-empty-state {
  color: var(--text-dim);
}

/* ─── MDX custom components ─── */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.status-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.stat-card {
  min-width: 140px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 28px;
  border-radius: 14px;
}

.stat-card-value {
  line-height: 1;
  font-family: "Space Grotesk", sans-serif;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-card-label {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tier-table-wrap {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* ─── Animations ─── */

@keyframes blog-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeSlideUp 0.6s ease-out forwards;
}

/* ─── Responsive ─── */

@media (min-width: 1380px) {
  .toc-aside {
    display: block;
    position: absolute;
    left: -260px;
    top: 48px;
    width: 200px;
  }

  .home-sort-aside {
    display: block;
    position: absolute;
    right: -260px;
    top: 0;
    width: 200px;
    min-height: 120px;
  }
}

@media (max-width: 1100px) {
  .blog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .breakout-wide {
    margin-left: -20px;
    margin-right: -20px;
  }
}

@media (max-width: 768px) {
  .site-header-inner,
  .blog-home,
  .article-hero,
  .article-body,
  .blog-footer {
    padding-left: 20px;
    padding-right: 20px;
  }

  .site-header-inner {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    justify-content: center;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .blog-header-nav {
    display: none;
  }

  .blog-brand-wordmark {
    display: none;
  }

  .blog-grid {
    grid-template-columns: 1fr;
  }

  .article-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .article-footer-buttons {
    width: 100%;
  }

  .blog-button {
    flex: 1;
  }

  .blog-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}
