/* Saraswati v2 - article reader (Halawi Media aligned). Upload to shivani-s3/saraswati/ */
:root {
  --brand-violet: #9b3df5;
  --brand-magenta: #c84fb4;
  --brand-coral: #ea6a5a;
  --brand-gradient: linear-gradient(100deg, #9b3df5 0%, #c84fb4 52%, #ea6a5a 100%);
  --brand-gradient-strong: linear-gradient(100deg, #8b35ec 0%, #b0409e 55%, #c94a3a 100%);
  --brand-violet-text: #c191ff;
  --brand-coral-text: #ff9384;
  --c-bg: #0a0a0c;
  --c-bg-raised: #111116;
  --c-surface: #17171e;
  --c-line: rgba(232, 222, 255, 0.09);
  --c-line-strong: rgba(232, 222, 255, 0.2);
  --c-text: #f6f3fa;
  --c-text-body: #cbc5d4;
  --c-text-muted: #9c95a8;
  --font-display: "Lexend", "Segoe UI", system-ui, sans-serif;
  --font-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --header-h: 68px;
  --radius: 14px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-glow: 0 18px 50px -18px rgba(155, 61, 245, 0.55);
  --measure: 42rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(155, 61, 245, 0.14), transparent 55%),
    var(--c-bg);
  color: var(--c-text-body);
  font-family: var(--font-sans);
  font-size: 1.125rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--brand-violet); color: #fff; }
:focus-visible { outline: 2px solid var(--brand-coral-text); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.skip-link { position: absolute; left: 1rem; top: -100px; z-index: 200; padding: 0.75rem 1rem; background: #fff; color: #000; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 1rem; }

.progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--brand-gradient); z-index: 1100;
}

.site-header {
  position: sticky; top: 0; z-index: 1000;
  backdrop-filter: blur(14px);
  background: rgba(10, 10, 12, 0.78);
  border-bottom: 1px solid var(--c-line);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0.85rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: var(--header-h);
}
.brand { display: inline-flex; align-items: center; gap: 0.7rem; font-family: var(--font-display); font-weight: 700; color: var(--c-text); }
.brand-mark { border-radius: 10px; object-fit: cover; box-shadow: 0 0 0 1px var(--c-line-strong); }
.header-nav { display: flex; align-items: center; gap: 0.75rem; }
.nav-link { color: var(--c-text-muted); font-size: 0.95rem; font-weight: 500; }
.nav-link:hover { color: var(--c-text); }
.nav-cta {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0.55rem 1.1rem;
  border-radius: 999px; font-size: 0.9rem; font-weight: 600; color: #fff;
  background: var(--brand-gradient-strong); box-shadow: var(--shadow-glow);
  transition: transform 0.2s var(--ease), filter 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.nav-cta:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 20px 44px -14px rgba(155, 61, 245, 0.7);
}
.nav-cta:active {
  transform: translateY(0);
  filter: brightness(0.96);
  box-shadow: 0 10px 28px -16px rgba(155, 61, 245, 0.55);
}
.nav-cta:focus-visible {
  outline: 2px solid #ff9384;
  outline-offset: 3px;
}

.layout {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 2rem;
  flex: 1;
}
.layout:not(:has(.toc)) {
  grid-template-columns: minmax(0, 1fr);
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .toc { display: none; }
}

.toc {
  position: sticky; top: calc(var(--header-h) + 1rem); align-self: start;
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  font-size: 0.88rem;
  max-height: calc(100vh - var(--header-h) - 2rem);
  overflow: auto;
}
.toc-label {
  margin: 0 0 0.65rem; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--brand-violet-text);
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li + li { margin-top: 0.45rem; }
.toc a { color: var(--c-text-muted); line-height: 1.35; }
.toc a:hover, .toc a.is-active { color: var(--c-text); }

.article-wrap { min-width: 0; }
.article-hero { margin-bottom: 1.75rem; max-width: var(--measure); }
.article-hero .meta { margin: 0 0 0.75rem; font-size: 0.9rem; color: var(--c-text-muted); }
.article-hero h1 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 1.2rem + 2vw, 2.75rem);
  line-height: 1.15; letter-spacing: -0.02em; color: var(--c-text);
}
.dek { margin: 0; color: var(--c-text-body); font-size: 1.15rem; max-width: 54ch; }

.prose { max-width: var(--measure); }
.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--c-text); font-family: var(--font-display);
  letter-spacing: -0.02em; line-height: 1.2; margin: 2rem 0 0.75rem;
}
.prose h1 { font-size: 1.85rem; }
.prose h2 { font-size: 1.45rem; }
.prose h3 { font-size: 1.2rem; font-family: var(--font-sans); }
.prose p { margin: 0 0 1.1rem; }
.prose a {
  color: var(--brand-violet-text);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.prose a:hover { color: var(--c-text); }
.prose strong { color: var(--c-text); font-weight: 600; }
.prose img {
  display: block;
  margin: 1.4rem 0; border-radius: 12px;
  border: 1px solid var(--c-line); max-height: 520px; width: 100%; object-fit: cover;
}
/* Belt-and-suspenders: if marked still wraps img + text in one <p>, stack cleanly */
.prose p:has(> img) {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.prose p:has(> img) br { display: none; }
.prose p:has(> img) img { margin: 0; }
.prose blockquote {
  margin: 1.25rem 0; padding: 0.85rem 1.1rem;
  border-left: 3px solid var(--brand-violet);
  background: rgba(155, 61, 245, 0.08);
  color: var(--c-text-body); border-radius: 0 10px 10px 0;
}
.prose ul, .prose ol { margin: 0 0 1.1rem; padding-left: 1.4rem; }
.prose li { margin-bottom: 0.35rem; }
.prose ul ul, .prose ol ul, .prose ul ol, .prose ol ol { margin: 0.35rem 0; }
.prose code {
  font-size: 0.92em; background: var(--c-surface);
  padding: 0.1em 0.35em; border-radius: 6px; border: 1px solid var(--c-line);
}
.prose pre {
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: 12px; padding: 1rem; overflow-x: auto; margin: 1.2rem 0;
}
.prose hr { border: 0; border-top: 1px solid var(--c-line); margin: 2rem 0; }

.share-bar {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin: 2rem 0 1.5rem; padding-top: 1.25rem;
  border-top: 1px solid var(--c-line); max-width: var(--measure);
}
.share-btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; min-height: 38px;
  padding: 0.45rem 0.9rem; border-radius: 999px;
  border: 1px solid var(--c-line-strong); background: transparent;
  color: var(--c-text); font: 600 0.85rem/1 var(--font-sans);
}
.share-btn:hover { border-color: transparent; background: var(--brand-gradient-strong); color: #fff; }

.related { max-width: var(--measure); margin: 1.5rem 0; }
.related h2 {
  font-family: var(--font-display); font-size: 1.15rem; color: var(--c-text);
  margin: 0 0 0.75rem;
}
.related ul { list-style: none; margin: 0; padding: 0; }
.related li + li { margin-top: 0.5rem; }
.related a { color: var(--brand-violet-text); font-weight: 500; }
.related a:hover { color: var(--c-text); }

.back { max-width: var(--measure); margin: 1.5rem 0 0; }
.back a { color: var(--c-text-muted); font-weight: 500; }
.back a:hover { color: var(--c-text); }

.site-footer {
  margin-top: auto; border-top: 1px solid var(--c-line); background: var(--c-bg-raised);
}
.footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 1.4rem 1.25rem;
  display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem;
  align-items: center; justify-content: space-between;
}
.footer-brand { margin: 0; font-size: 0.9rem; color: var(--c-text-muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.65rem 1rem; }
.footer-links a { color: var(--brand-violet-text); font-size: 0.9rem; font-weight: 500; }
.footer-links a:hover { color: var(--c-text); }

@media (max-width: 640px) {
  body { font-size: 1.0625rem; }
  .nav-link { display: none; }
}

/* ---- generic markdown engine (alerts, footnotes, mark, deflist, embeds, mermaid) ---- */
/* GFM alerts — default variants only */
.prose .markdown-alert {
  margin: 1.25rem 0;
  padding: 0.85rem 1.1rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--c-line);
  border-left-width: 3px;
  background: rgba(255, 255, 255, 0.03);
}
.prose .markdown-alert > :last-child { margin-bottom: 0; }
.prose .markdown-alert-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.45rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--c-text);
}
.prose .markdown-alert .octicon { fill: currentColor; flex-shrink: 0; }
.prose .markdown-alert-note { border-left-color: #58a6ff; }
.prose .markdown-alert-note .markdown-alert-title { color: #58a6ff; }
.prose .markdown-alert-tip { border-left-color: #3fb950; }
.prose .markdown-alert-tip .markdown-alert-title { color: #3fb950; }
.prose .markdown-alert-important { border-left-color: #a371f7; }
.prose .markdown-alert-important .markdown-alert-title { color: #a371f7; }
.prose .markdown-alert-warning { border-left-color: #d29922; }
.prose .markdown-alert-warning .markdown-alert-title { color: #d29922; }
.prose .markdown-alert-caution { border-left-color: #f85149; }
.prose .markdown-alert-caution .markdown-alert-title { color: #f85149; }

/* Footnotes */
.prose .footnotes {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--c-line);
  font-size: 0.95rem;
  color: var(--c-text-muted);
}
.prose .footnotes ol { padding-left: 1.25rem; }
.prose .footnotes li { margin-bottom: 0.5rem; }
.prose a[data-footnote-ref],
.prose a[data-footnote-backref] {
  color: var(--brand-violet-text);
  text-decoration: none;
}

/* ==highlight== → <mark> */
.prose mark {
  background: rgba(210, 153, 34, 0.35);
  color: var(--c-text);
  padding: 0.05em 0.25em;
  border-radius: 3px;
}

/* Definition lists */
.prose dl {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 10px;
}
.prose dt {
  margin: 0.65rem 0 0.15rem;
  font-weight: 700;
  color: var(--c-text);
}
.prose dt:first-child { margin-top: 0; }
.prose dd {
  margin: 0 0 0.35rem 1rem;
  color: var(--c-text-body);
}

/* Standalone YouTube / Vimeo embeds */
.prose .embed-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 1.4rem 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--c-line);
  background: #000;
}
.prose .embed-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Mermaid diagrams */
.prose pre.mermaid {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 12px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.2rem 0;
  text-align: center;
}

/* GFM tables (if not already covered) */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.98rem;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td {
  border: 1px solid var(--c-line);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.prose th {
  background: var(--c-surface);
  color: var(--c-text);
  font-weight: 600;
}
.prose del { color: var(--c-text-muted); }
