/* Artemis brand theme for the Scalar docs site.
 * Colors mirror packages/ui-library/src/global.css (primary purple #6e04bd on
 * warm cream). Mapped onto Scalar's --scalar-* theme variables. */

:root {
  --scalar-color-accent: #6e04bd;
}

.light-mode {
  /* Text */
  --scalar-color-1: #554e46; /* primary text (dark brown) */
  --scalar-color-2: #82838d; /* secondary text */
  --scalar-color-3: #a09587; /* muted text */
  --scalar-color-accent: #6e04bd; /* Artemis purple */

  /* Surfaces */
  --scalar-background-1: #fefbf7; /* page background (cream) */
  --scalar-background-2: #f4f1ed; /* panels / muted */
  --scalar-background-3: #e3e0dd; /* deeper surfaces */
  --scalar-background-accent: #e2deff; /* light-purple accent wash */
  --scalar-border-color: #d7cfc5;

  /* Buttons */
  --scalar-button-1: #6e04bd;
  --scalar-button-1-hover: #4a3f93;
  --scalar-button-1-color: #ffffff;

  /* Semantic (success/error/warning/info) */
  --scalar-color-green: #4c9784;
  --scalar-color-red: #c43750;
  --scalar-color-yellow: #d4a71b;
  --scalar-color-orange: #d4a71b;
  --scalar-color-blue: #499fcf;
  --scalar-color-purple: #6e04bd;

  /* Sidebar */
  --scalar-sidebar-background-1: #fefbf7;
  --scalar-sidebar-color-1: #554e46;
  --scalar-sidebar-color-2: #82838d;
  --scalar-sidebar-border-color: #e3e0dd;
  --scalar-sidebar-item-hover-background: #f4f1ed;
  --scalar-sidebar-item-hover-color: #6e04bd;
  --scalar-sidebar-item-active-background: #e2deff;
  --scalar-sidebar-color-active: #6e04bd;
  --scalar-sidebar-search-background: #ffffff;
  --scalar-sidebar-search-border-color: #d7cfc5;
  --scalar-sidebar-search-color: #82838d;
}

.dark-mode {
  /* Text */
  --scalar-color-1: rgba(255, 255, 255, 0.86);
  --scalar-color-2: rgba(255, 255, 255, 0.55);
  --scalar-color-3: rgba(255, 255, 255, 0.35);
  --scalar-color-accent: #aaa1ee; /* lighter purple for contrast on dark */

  /* Surfaces */
  --scalar-background-1: #1f1f22;
  --scalar-background-2: #2a2a2e;
  --scalar-background-3: #343438;
  --scalar-background-accent: #2a226a;
  --scalar-border-color: rgba(255, 255, 255, 0.1);

  /* Buttons */
  --scalar-button-1: #6e04bd;
  --scalar-button-1-hover: #7d73c9;
  --scalar-button-1-color: #ffffff;

  /* Semantic */
  --scalar-color-green: #5bb59f;
  --scalar-color-red: #eb4260;
  --scalar-color-yellow: #ffc820;
  --scalar-color-orange: #ffc820;
  --scalar-color-blue: #58bff9;
  --scalar-color-purple: #aaa1ee;

  /* Sidebar */
  --scalar-sidebar-background-1: #1f1f22;
  --scalar-sidebar-color-1: rgba(255, 255, 255, 0.86);
  --scalar-sidebar-color-2: rgba(255, 255, 255, 0.55);
  --scalar-sidebar-border-color: rgba(255, 255, 255, 0.1);
  --scalar-sidebar-item-hover-background: #2a2a2e;
  --scalar-sidebar-item-hover-color: #cbc4fc;
  --scalar-sidebar-item-active-background: #2a226a;
  --scalar-sidebar-color-active: #cbc4fc;
  --scalar-sidebar-search-background: #2a2a2e;
  --scalar-sidebar-search-border-color: rgba(255, 255, 255, 0.1);
}

/* Tables and code blocks ship with margin-bottom: 0, so the following text sits
 * too close. Give them breathing room above and below (applies to every article). */
.page-mdx__content figure.t-editor__table-wrapper,
.page-mdx__content .t-editor__code-container,
.page-mdx__content pre.t-editor__code {
  margin-top: 1rem !important;
  margin-bottom: 1.25rem !important;
}

/* Markdown tables auto-size their columns to content, so sibling 2-column tables
 * (e.g. the webhook event tables) don't line up. For 2-column tables, fix the
 * layout so the first column is a consistent width; wider tables size naturally. */
.page-mdx__content table:has(thead th:nth-child(2):last-child) {
  table-layout: fixed;
  width: 100%;
}
.page-mdx__content table:has(thead th:nth-child(2):last-child) th:first-child,
.page-mdx__content table:has(thead th:nth-child(2):last-child) td:first-child {
  width: 35%;
}
.page-mdx__content table th,
.page-mdx__content table td {
  overflow-wrap: anywhere;
}

/* In auto-layout (3+ column) tables, keep a first-column code identifier on one
 * line so it isn't broken mid-token — the column grows to fit instead. */
.page-mdx__content table:not(:has(thead th:nth-child(2):last-child)) td:first-child code {
  white-space: nowrap;
}

/* Content layout
 * - Stable scrollbar gutter so the header (and "Open Artemis" CTA) don't shift
 *   between pages that scroll (guides) and pages that don't (API reference).
 * - Tighten the oversized gap between the page toolbar and the first heading.
 * - Widen the text column by reclaiming the generous horizontal padding. */
html {
  scrollbar-gutter: stable;
}
.page-mdx {
  padding-left: 24px !important;
  padding-right: 24px !important;
}
.page-mdx__content {
  max-width: 900px !important;
}
.page-mdx__content h1 {
  margin-top: 24px !important;
}

/* Center Mermaid diagrams (they render left-aligned by default). */
.page-mdx__content .t-editor__mermaid-wrapper svg {
  display: block;
  margin-inline: auto;
}

/* Hide the sidebar footer ("Powered by Scalar" + the color-mode toggle). */
.border-t:has(a[href*="scalar.com"]) {
  display: none !important;
}

/* Hide the color-mode toggle — the site is locked to the Artemis light theme.
 * (Belt-and-suspenders: also covered by hiding the footer above.) */
button[aria-label="Set dark mode"],
button[aria-label="Set light mode"] {
  display: none !important;
}

/* Header layout: keep the primary nav (Overview / API Reference) on the left,
 * next to the logo, and pin the "Open Artemis" CTA to the far right. */
.header .header-right {
  justify-content: flex-start;
}
.header .header-right .navigation {
  flex: 1 1 auto;
}
.header .header-right .navigation > :last-child {
  margin-left: auto;
}

/* Active-section underline under the header nav link (Overview / API Reference). */
.header .header-right .navigation .link-active {
  position: relative;
}
.header .header-right .navigation .link-active::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 2px;
  border-radius: 1px;
  background: var(--scalar-color-accent);
}

/* Scalar preserves custom callout elements in MDX without styling them. */
.page-mdx__content scalar-callout[type="warning"] {
  display: block;
  margin-block: 1rem 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid color-mix(in srgb, var(--scalar-color-yellow) 55%, var(--scalar-border-color));
  border-left: 4px solid var(--scalar-color-yellow);
  border-radius: 8px;
  background: color-mix(in srgb, var(--scalar-color-yellow) 14%, var(--scalar-background-1));
  color: var(--scalar-color-1);
}

.page-mdx__content scalar-callout[type="warning"] > :first-child {
  margin-top: 0;
}

.page-mdx__content scalar-callout[type="warning"] > :last-child {
  margin-bottom: 0;
}

.header .navigation a[href="/api-v2-reference"]::after {
  content: 'Beta';
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--scalar-border-color);
  border-radius: 4px;
  background: var(--scalar-background-2);
  color: var(--scalar-color-1);
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.4;
  vertical-align: middle;
}
