/* =================================================================
   DB Cost & Quota Automation Hub — design system
   Light, professional palette (teal + warm amber accents).
   ================================================================= */
:root {
  --bg: #f5f9f8;
  --surface: #ffffff;
  --surface-alt: #eef5f3;
  --ink: #14302e;
  --ink-soft: #4a635f;
  --ink-faint: #6b817d;
  --primary: #0b6e6e;
  --primary-700: #0a5757;
  --primary-400: #13a89e;
  --accent: #e8743b;
  --accent-soft: #f6b73c;
  --border: #d7e6e2;
  --border-strong: #b9d2cd;
  --code-bg: #f2f8f6;
  --code-border: #dcebe8;
  --inline-bg: #e7f1ee;
  --ring: rgba(19, 168, 158, 0.45);
  --shadow-sm: 0 1px 2px rgba(13, 64, 60, 0.06), 0 2px 8px rgba(13, 64, 60, 0.05);
  --shadow-md: 0 6px 20px rgba(13, 64, 60, 0.10);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 64px;
  --maxw: 1240px;
  --measure: 78ch;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", "Fira Code",
    Consolas, "Liberation Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px); /* keep anchors clear of sticky header */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;          /* footer sticks to bottom */
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: clamp(16px, 0.96rem + 0.15vw, 18px);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.site-main { flex: 1 0 auto; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 48px);
}

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

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 200;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ----------------------------- header ----------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 700;
}
.brand-logo { display: block; transition: transform 0.25s ease; }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.06); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 1.05rem; color: var(--primary-700); }
.brand-sub { font-size: 0.78rem; color: var(--ink-faint); font-weight: 600; letter-spacing: 0.02em; }

.primary-nav ul {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
}
.primary-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.2s ease, color 0.2s ease;
}
.primary-nav a:hover { background: var(--surface-alt); color: var(--primary-700); }
.primary-nav a.is-current {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.nav-icon { width: 20px; height: 20px; flex: none; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--primary-700);
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 820px) {
  .nav-toggle { display: flex; }
  .primary-nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  .primary-nav.open { max-height: 70vh; }
  .primary-nav ul { flex-direction: column; padding: 12px; gap: 4px; }
  .primary-nav a { width: 100%; }
}

/* ----------------------------- footer ----------------------------- */
.site-footer {
  flex-shrink: 0;
  margin-top: 64px;
  background: var(--primary-700);
  color: #d8efeb;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  justify-content: space-between;
  padding-block: 40px 24px;
}
.footer-brand { display: flex; gap: 14px; max-width: 460px; }
.footer-name { margin: 0 0 4px; font-weight: 700; color: #fff; }
.footer-desc { margin: 0; font-size: 0.9rem; color: #aed8d2; line-height: 1.5; }
.footer-heading { font-weight: 700; color: #fff; margin: 0 0 10px; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer-nav a { color: #cdeae5; }
.footer-nav a:hover { color: var(--accent-soft); }
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-block: 16px;
  font-size: 0.82rem;
  color: #9cc9c3;
}

/* ------------------------------ hero ------------------------------ */
.hero {
  background:
    radial-gradient(1200px 400px at 50% -120px, #d7f0eb 0%, transparent 70%),
    linear-gradient(180deg, #eef7f5 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}
.hero-inner { text-align: center; padding-block: clamp(36px, 6vw, 72px); }
.hero-logo-row { display: block; }
.hero-logo {
  width: clamp(120px, 18vw, 168px);
  height: auto;
  filter: drop-shadow(0 10px 22px rgba(11, 110, 110, 0.22));
  transition: transform 0.4s ease;
}
.hero-logo:hover { transform: translateY(-4px) scale(1.03); }
.hero-title {
  margin: 18px 0 10px;
  font-size: clamp(2rem, 1.4rem + 3vw, 3.4rem);
  line-height: 1.08;
  background: linear-gradient(90deg, var(--primary-700), var(--primary-400) 55%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-tagline {
  max-width: 64ch;
  margin: 0 auto;
  font-size: clamp(1.05rem, 1rem + 0.5vw, 1.3rem);
  color: var(--ink-soft);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  margin-top: 32px;
}
.cta {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  padding: 16px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-width: 280px;
  flex: 1 1 300px;
  max-width: 440px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.cta:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.cta-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  flex: none;
}
.cta-icon svg { width: 28px; height: 28px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cta-teal .cta-icon { background: linear-gradient(135deg, var(--primary-400), var(--primary-700)); }
.cta-amber .cta-icon { background: linear-gradient(135deg, var(--accent-soft), var(--accent)); }
.cta-text { display: flex; flex-direction: column; }
.cta-label { font-weight: 700; color: var(--ink); font-size: 1.02rem; line-height: 1.25; }
.cta-go { font-size: 0.85rem; color: var(--accent); font-weight: 600; }
.cta:hover .cta-go { color: var(--primary-700); }

/* --------------------------- home content ------------------------- */
.section-heading {
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  color: var(--primary-700);
  margin-top: 56px;
}
.home-intro p { max-width: none; color: var(--ink-soft); }
.home-intro strong { color: var(--ink); }

.topic-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin-top: 8px;
}
.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.topic-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.topic-card h3 { margin: 0 0 8px; font-size: 1.2rem; }
.topic-card h3 a { color: var(--primary-700); }
.topic-card h3 a:hover { color: var(--accent); }
.topic-card p { margin: 0 0 14px; color: var(--ink-soft); font-size: 0.95rem; }
.topic-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.topic-links a {
  display: inline-block;
  padding: 4px 0 4px 18px;
  position: relative;
  font-weight: 600;
  font-size: 0.93rem;
}
.topic-links a::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--accent);
  transition: transform 0.2s ease;
}
.topic-links a:hover::before { transform: translateX(3px); }

/* ----------------------------- article ---------------------------- */
.article-main { padding-top: 8px; }
.article { padding-top: 24px; }
.article-body {
  /* Fill the full width of the container (which is itself capped to --maxw,
     so it never spans the whole page or becomes a thin column). */
  width: 100%;
  max-width: none;
}

.article-body h1 {
  font-size: clamp(1.9rem, 1.4rem + 2.4vw, 3rem);
  line-height: 1.1;
  margin: 8px 0 24px;
  background: linear-gradient(90deg, var(--primary-700), var(--primary-400) 60%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.article-body h2 {
  font-size: clamp(1.4rem, 1.15rem + 1vw, 1.85rem);
  color: var(--primary-700);
  margin-top: 2.2em;
  padding-bottom: 0.3em;
  border-bottom: 2px solid var(--border);
}
.article-body h3 {
  font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem);
  color: var(--primary);
  margin-top: 1.8em;
}
.article-body h4 { color: var(--ink); margin-top: 1.5em; }
.article-body p { color: var(--ink-soft); }
.article-body strong { color: var(--ink); }
.article-body ul, .article-body ol { color: var(--ink-soft); padding-left: 1.4em; }
.article-body li { margin: 0.35em 0; }
.article-body li::marker { color: var(--accent); }

.article-body a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  transition: color 0.18s ease, text-decoration-color 0.18s ease;
}
.article-body a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.article-body blockquote {
  margin: 1.5em 0;
  padding: 0.6em 1.2em;
  border-left: 4px solid var(--primary-400);
  background: var(--surface-alt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
}

/* heading anchor links */
.header-anchor {
  text-decoration: none;
  color: var(--border-strong);
  margin-left: 0.35em;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
:is(h1, h2, h3, h4):hover .header-anchor,
.header-anchor:focus-visible { opacity: 1; }
.header-anchor:hover { color: var(--accent); }
:is(h1, h2, h3, h4, h5, h6)[id] { scroll-margin-top: calc(var(--header-h) + 16px); }

/* --------------------------- breadcrumbs -------------------------- */
.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--ink-faint);
}
.breadcrumbs li { display: inline-flex; align-items: center; }
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; color: var(--border-strong); }
.breadcrumbs a { color: var(--ink-soft); font-weight: 600; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs li[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ----------------------------- inline code ------------------------ */
.article-body :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--inline-bg);
  color: var(--primary-700);
  padding: 0.12em 0.4em;
  border-radius: 5px;
  border: 0;
  word-break: break-word;
}

/* ---------------------------- code blocks ------------------------- */
.code-block {
  position: relative;
  margin: 1.6em 0;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: var(--code-bg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.code-block::before {
  content: attr(data-lang);
  position: absolute;
  top: 8px;
  left: 14px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  pointer-events: none;
}
.code-block pre {
  margin: 0;
  padding: 38px 18px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
  background: transparent;
  color: #21413d;
}
.code-block code { font-family: inherit; background: none; padding: 0; color: inherit; }
.code-copy {
  position: absolute;
  top: 7px;
  right: 8px;
  z-index: 2;
  font: 600 0.72rem/1 var(--font);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--primary-700);
  background: var(--surface);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.code-block:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.code-copy.copied { background: var(--primary-400); color: #fff; border-color: var(--primary-400); opacity: 1; }
@media (hover: none) { .code-copy { opacity: 1; } }

/* Prism — light theme tuned to palette */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7c948f; font-style: italic; }
.token.punctuation { color: #5a716d; }
.token.keyword, .token.control, .token.directive, .token.important { color: #0a7d8c; font-weight: 600; }
.token.boolean, .token.number, .token.constant { color: #b3602e; }
.token.string, .token.char, .token.attr-value { color: #2f8f5b; }
.token.function, .token.class-name { color: #b0501f; }
.token.builtin, .token.symbol { color: #0b6e6e; }
.token.operator, .token.entity, .token.url { color: #5a716d; background: none; }
.token.property, .token.tag, .token.attr-name { color: #0a7d8c; }
.token.variable { color: #1d6f4f; }
.token.regex { color: #b3602e; }
.token.decorator, .token.annotation { color: #c06a2b; }

/* ----------------------------- tables ----------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 1.6em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.article-body table {
  border-collapse: collapse;
  width: 100%;
  min-width: 480px;
  font-size: 0.92rem;
}
.article-body th, .article-body td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.article-body thead th {
  background: var(--surface-alt);
  color: var(--primary-700);
  font-weight: 700;
  position: sticky;
  top: 0;
}
.article-body tbody tr:nth-child(even) { background: #f8fbfa; }
.article-body tbody tr:hover { background: var(--surface-alt); }

/* ------------------------- task checkboxes ------------------------ */
.task-item {
  list-style: none;          /* remove the leading dot/bullet */
  margin-left: -1.4em;
  padding-left: 0;
}
.task-item::marker { content: ""; }
.task-checkbox {
  width: 1.05em;
  height: 1.05em;
  margin-right: 0.5em;
  accent-color: var(--primary);
  vertical-align: -0.12em;
  cursor: pointer;
}
.task-item.checked { text-decoration: line-through; color: var(--ink-faint); }

/* ----------------------------- KaTeX ------------------------------ */
.katex-block {
  margin: 1.6em 0;
  padding: 16px 18px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary-400);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.katex-block .katex-display { margin: 0; }

/* ----------------------------- mermaid ---------------------------- */
.mermaid {
  margin: 1.6em 0;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.mermaid:not([data-processed]) { color: var(--ink-faint); font-family: var(--font-mono); font-size: 0.85rem; }
.mermaid[data-processed] {
  position: relative;
  cursor: zoom-in;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.mermaid[data-processed]:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

/* "click to enlarge" affordance shown in the diagram corner */
.diagram-expand-hint {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--primary-700);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.mermaid[data-processed]:hover .diagram-expand-hint,
.mermaid[data-processed]:focus-visible .diagram-expand-hint {
  opacity: 1;
  background: var(--primary);
  color: #fff;
}
.diagram-expand-hint svg { width: 16px; height: 16px; }

/* fullscreen diagram lightbox */
.diagram-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
  background: rgba(8, 38, 36, 0.82);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.diagram-lightbox__inner {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: clamp(16px, 3vw, 32px);
  max-width: 96vw;
  max-height: 92vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  animation: diagram-lightbox-pop 0.18s ease;
}
@keyframes diagram-lightbox-pop {
  from { transform: scale(0.96); }
  to { transform: scale(1); }
}
.diagram-lightbox__inner svg { display: block; margin: auto; }
.diagram-lightbox__close {
  position: fixed;
  top: clamp(12px, 2vw, 24px);
  right: clamp(12px, 2vw, 24px);
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--primary-700);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.diagram-lightbox__close:hover { background: var(--primary); color: #fff; transform: scale(1.06); }

/* --------------------------- FAQ accordions ----------------------- */
.faq-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 10px 0;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.faq-accordion > summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 48px 14px 18px;
  font-weight: 700;
  color: var(--primary-700);
  position: relative;
}
.faq-accordion > summary::-webkit-details-marker { display: none; }
.faq-accordion > summary::after {
  content: "+";
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--accent);
  transition: transform 0.2s ease;
}
.faq-accordion[open] > summary::after { content: "−"; }
.faq-accordion[open] > summary { border-bottom: 1px solid var(--border); }
.faq-accordion .faq-body { padding: 4px 18px 16px; color: var(--ink-soft); }

/* ----------------------------- related ---------------------------- */
.related { margin-top: 48px; }
.related-title { font-size: 1.3rem; color: var(--primary-700); }
.card-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card a { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; height: 100%; }
.card-heading { font-weight: 700; color: var(--primary-700); }
.card:hover .card-heading { color: var(--accent); }
.card-summary { font-size: 0.88rem; color: var(--ink-soft); line-height: 1.5; }

.pill-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.pill-list a {
  display: inline-block;
  padding: 8px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary-700);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.pill-list a:hover { background: var(--primary); color: #fff; transform: translateY(-2px); }

/* ------------------------- reduced motion ------------------------- */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
