/* GemDiagram docs — dark theme, reuses developer/promo/style2.css tokens. */

:root {
  --bg: #0b0d11;
  --surface: #14171d;
  --surface-2: #1a1e26;
  --border: #232733;
  --border-ui: #696d79; /* 3:1 min against --surface — use for input/interactive control borders */
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --accent: #4c9be6;
  --accent-2: #7b6fe0;
  --note: #4c9be6;
  --tip: #45b87f;
  --warning: #d9a23b;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 2.4.11 Focus Not Obscured: keep focused elements clear of the sticky docs header. */
html {
  scroll-padding-top: 4.5rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 8px 16px;
  background: var(--accent);
  color: #061018;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.docs-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.docs-header .brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.docs-header .brand-mark { width: 22px; height: 22px; flex-shrink: 0; color: var(--accent); }
.docs-header .brand-name { color: var(--text); }
.docs-header .brand-sub { color: var(--muted); font-weight: 400; }
.docs-header-nav { margin-left: auto; display: flex; gap: 1.5rem; align-items: center; }
.docs-header-nav a { color: var(--text); font-size: 0.875rem; }
.docs-header-nav .nav-cta { background: linear-gradient(180deg, #5aa7ee, #3f86d4); color: #fff; padding: 10px 18px; border-radius: 6px; font-weight: 700; text-decoration: none; font-size: 14px; white-space: nowrap; }
.docs-nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  padding: .35rem .55rem;
  min-width: 24px;
  min-height: 24px;
  cursor: pointer;
}

/* 3-column layout: sidebar | content | toc rail */
.docs-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 220px;
  gap: 2rem;
  max-width: 1240px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  align-items: start;
}

.docs-sidebar { position: sticky; top: 4.5rem; max-height: calc(100vh - 5rem); overflow-y: auto; }

/* Search */
.docs-search { position: relative; margin-bottom: 1.5rem; }
.docs-search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-ui);
  color: var(--text);
  border-radius: 6px;
  padding: .5rem .6rem .5rem 1.85rem;
  font-size: .85rem;
  font-family: inherit;
}
.docs-search-input::placeholder { color: var(--muted); }
.docs-search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.docs-search-icon {
  position: absolute;
  left: .55rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .8rem;
  pointer-events: none;
}
.docs-search-hint {
  position: absolute;
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .65rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .05rem .35rem;
  pointer-events: none;
}
.docs-search-input:focus ~ .docs-search-hint, .docs-search-input:not(:placeholder-shown) ~ .docs-search-hint { display: none; }
.docs-search-results {
  position: absolute;
  top: calc(100% + .4rem);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 65vh;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  display: none;
}
.docs-search-results.is-open { display: block; }
.docs-search-result {
  display: block;
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.docs-search-result:last-child { border-bottom: none; }
.docs-search-result:hover, .docs-search-result.is-selected { background: var(--surface); text-decoration: none; }
.docs-search-result-cat { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .15rem; }
.docs-search-result-title { font-weight: 600; font-size: .88rem; }
.docs-search-result-title mark, .docs-search-result-snippet mark { background: none; color: var(--accent); font-weight: 700; padding: 0; }
.docs-search-result-snippet { font-size: .78rem; color: var(--muted); margin-top: .2rem; line-height: 1.4; }
.docs-search-empty { padding: .75rem; color: var(--muted); font-size: .85rem; text-align: center; }
.docs-nav-cat { margin-bottom: 1.5rem; }
.docs-nav-cat-title {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 .5rem;
}
.docs-nav ul { list-style: none; margin: 0; padding: 0; }
.docs-nav li { margin: 0; }
.docs-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .35rem .5rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: .9rem;
}
.docs-nav a:hover { color: var(--text); text-decoration: none; background: var(--surface); }
.docs-nav a.is-active { color: var(--text); background: var(--surface-2); font-weight: 600; }

.badge {
  font-size: .65rem;
  font-style: normal;
  font-weight: 600;
  padding: .1rem .4rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-starter { color: var(--accent); border-color: var(--accent); }
.badge-studio  { color: #7d71e0; border-color: var(--accent-2); }
.badge-pro { color: var(--warning); border-color: var(--warning); }

/* Content */
.docs-breadcrumb { color: var(--muted); font-size: .85rem; margin: 0 0 1.25rem; }
.docs-breadcrumb span[aria-hidden] { margin: 0 .35em; }

.docs-main h1 { font-size: 2rem; line-height: 1.2; margin: .2em 0 .6em; }
.docs-main h2 { font-size: 1.4rem; margin-top: 2em; padding-bottom: .3em; border-bottom: 1px solid var(--border); scroll-margin-top: 5rem; }
.docs-main h3 { font-size: 1.1rem; margin-top: 1.6em; scroll-margin-top: 5rem; }
.docs-main p, .docs-main li { color: var(--text); }
.docs-main ul, .docs-main ol { padding-left: 1.4em; }

.docs-main code {
  background: var(--surface);
  padding: .15em .4em;
  border-radius: 4px;
  font-size: .9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.docs-main pre {
  position: relative;
  background: var(--surface);
  padding: 1rem;
  border-radius: 8px;
  overflow: auto;
  border: 1px solid var(--border);
}
.docs-main pre code { background: none; padding: 0; }
.docs-copy-btn {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: var(--surface-2);
  border: 1px solid var(--border-ui);
  color: var(--muted);
  font-size: .7rem;
  padding: .25rem .5rem;
  min-height: 24px;
  min-width: 24px;
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}
.docs-main pre:hover .docs-copy-btn,
.docs-copy-btn:focus-visible { opacity: 1; }
.docs-copy-btn.is-copied { color: var(--tip); opacity: 1; }
@media (prefers-reduced-motion: reduce) { .docs-copy-btn { transition: none; } }

.docs-main table { width: 100%; border-collapse: collapse; margin: 1.2em 0; font-size: .92rem; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.docs-main th, .docs-main td { border: 1px solid var(--border); padding: .5em .7em; text-align: left; }
.docs-main thead th { background: var(--surface); color: var(--text); }
.docs-main tbody tr:nth-child(even) { background: var(--surface); }

.docs-main img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); }

/* .shot overlay figures */
.shot { margin: 1.6em 0; display: inline-block; max-width: 100%; text-align: center; }
.shot-frame { position: relative; display: inline-block; max-width: 100%; }
.shot img { display: block; max-width: 100%; height: auto; cursor: zoom-in; }
.shot-zoom { display: block; max-width: 100%; padding: 0; border: none; background: none; cursor: zoom-in; }
.shot-zoom img { pointer-events: none; }
.shot .mark {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 3px rgba(76, 155, 230, .35);
}
.shot .box {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 0 0 3px rgba(76, 155, 230, .25);
  pointer-events: none;
}
.shot .arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 8px 0 8px;
  border-color: var(--accent) transparent transparent transparent;
  transform: translate(-50%, -50%) rotate(180deg);
  pointer-events: none;
}
.shot figcaption {
  margin-top: .6em;
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
}

.docs-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 50;
  cursor: zoom-out;
}
.docs-lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.docs-lightbox-close {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-ui);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}
.docs-lightbox-close:hover { background: var(--surface-2); }

.docs-main blockquote {
  margin: 1.2em 0;
  padding: .2em 1rem;
  border-left: 3px solid var(--accent-2);
  color: var(--muted);
}
.docs-main blockquote p:last-child { margin-bottom: 0; }

.callout {
  margin: 1.4em 0;
  padding: .8em 1em;
  border-radius: 8px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--note);
  background: var(--surface);
}
.callout p:last-child { margin-bottom: 0; }
.callout-title {
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 .35em;
  color: var(--note);
}
.callout-tip { border-left-color: var(--tip); }
.callout-tip .callout-title { color: var(--tip); }
.callout-warning { border-left-color: var(--warning); }
.callout-warning .callout-title { color: var(--warning); }

.docs-prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.docs-prevnext-link {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.docs-prevnext-link:hover { background: var(--surface); text-decoration: none; }
.docs-prevnext-link.is-next { text-align: right; grid-column: 2; }
.docs-prevnext-label { font-size: .75rem; color: var(--muted); }
.docs-prevnext-title { font-weight: 600; }

/* TOC rail */
.docs-toc-rail { position: sticky; top: 4.5rem; }
.docs-toc-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .5rem; }
.docs-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.docs-toc li { margin: 0; }
.docs-toc a { display: block; padding: .25rem .75rem; color: var(--muted); font-size: .85rem; }
.docs-toc a:hover { color: var(--text); text-decoration: none; }
.docs-toc-h3 a { padding-left: 1.5rem; font-size: .8rem; }

.docs-footer {
  margin-top: 3rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
}

/* Responsive: sidebar becomes a drawer, TOC rail hides */
@media (max-width: 980px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); }
  .docs-toc-rail { display: none; }
  .docs-nav-toggle { display: inline-block; }
  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-height: none;
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 1rem;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 20;
    overflow-y: auto;
  }
  .docs-sidebar.is-open { transform: translateX(0); }
}

@media (max-width: 640px) {
  .docs-layout { padding: 1.25rem 1rem; gap: 1.25rem; }
  .docs-main h1 { font-size: 1.5rem; }
  .docs-main h2 { font-size: 1.2rem; }
  .docs-prevnext { grid-template-columns: 1fr; }
  .docs-prevnext-link.is-next { text-align: left; grid-column: 1; }
  .docs-header { flex-wrap: wrap; row-gap: .5rem; }
  .docs-header-nav { margin-left: 0; width: 100%; gap: .75rem 1rem; flex-wrap: wrap; }
}
