/*
 * Documentation styles for saidaengine.com.
 *
 * The pages under /docs/ are generated from the Saida platform's own
 * documentation build, so everything below the "Developer documentation"
 * banner in this file is that site's stylesheet, copied verbatim. Only the
 * part above it — the design tokens, the reset and the small site bar — is
 * specific to this static site.
 *
 * Regenerate with scripts/port-docs.py rather than editing the HTML by hand.
 */

:root {
  --paper: #f7f4e8;
  --paper-deep: #efe9d5;
  --paper-mark: rgba(8, 71, 125, 0.055);
  --ink: #08477d;
  --ink-soft: #3f6a8e;
  --pencil: #cfc7ad;
  --pencil-dark: #918a75;
  --brand: #b9da37;
  --brand-deep: #63a72c;
  --brand-soft: #eaf6c2;
  --accent: #4fb44a;
  --success: #3c9854;
  --warning: #c68421;
  --danger: #c84b3a;
  --shadow-line: 0 5px 0 rgba(8, 71, 125, 0.14);
  --radius: 8px;
  --font-hand: "Cabin Sketch", "Comic Sans MS", cursive;
  --font-ui: "M PLUS Rounded 1c", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  padding: 18px;
  color: var(--ink);
  font-family: var(--font-ui);
  background:
    linear-gradient(90deg, var(--paper-mark) 1px, transparent 1px),
    linear-gradient(var(--paper-mark) 1px, transparent 1px),
    radial-gradient(circle at 0 0, rgba(185, 218, 55, 0.12), transparent 24rem),
    var(--paper);
  background-size: 28px 28px, 28px 28px, auto, auto;
}

button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

/* --- site bar ------------------------------------------------------------ */

.doc-sitebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 4px 0 14px;
}

.doc-home {
  font-family: var(--font-hand);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
}

.doc-home:hover {
  color: var(--brand-deep);
}

.doc-sitebar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.doc-sitebar nav a {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 7px 11px;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: var(--shadow-line);
}

.doc-sitebar nav a:hover {
  background: var(--brand-soft);
}

.doc-sitebar nav a[aria-current="page"] {
  background: var(--brand);
  color: var(--ink);
}

/* --- documentation index ------------------------------------------------- */

.doc-index {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.doc-index-card {
  display: grid;
  align-content: start;
  gap: 6px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  padding: 20px;
  box-shadow: var(--shadow-line);
}

.doc-index-card:hover {
  background: var(--brand-soft);
}

.doc-index-card h2 {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 2rem;
  line-height: 0.95;
}

.doc-index-card p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.doc-index-more {
  margin-top: 6px;
  color: var(--brand-deep);
  font-weight: 800;
}

@media (max-width: 860px) {
  .doc-index {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  body {
    padding: 12px;
  }

  .doc-home {
    font-size: 1.5rem;
  }
}
/*
 * UI font.
 *
 * Self-hosted rather than pulled from Google Fonts. The site's own
 * Content-Security-Policy allows `style-src 'self' 'unsafe-inline'` only, so
 * the @import that used to sit here was blocked in every browser and
 * --font-ui silently fell back to system-ui on every page.
 *
 * M PLUS Rounded 1c is a Japanese family that Google splits into hundreds of
 * per-glyph chunks, so only its two Latin subsets are vendored, at the four
 * weights this stylesheet asks for. CJK text keeps falling back to the system
 * font exactly as it already did. Each unicode-range is Google's own, so a
 * page downloads only the subset it actually needs.
 */
@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/mplus-rounded-1c-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/mplus-rounded-1c-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/mplus-rounded-1c-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/mplus-rounded-1c-500-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/mplus-rounded-1c-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/mplus-rounded-1c-700-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/mplus-rounded-1c-800-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/mplus-rounded-1c-800-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/*
 * Display font.
 *
 * We used to use Gaegu, but it has NO glyphs for accented Latin letters
 * (é, è, à, ç, ü, ñ, ß, œ...) — it only ships ASCII plus Hangul — so every
 * accented French/German/Spanish character fell back to an unrelated system
 * serif and broke the display look mid-word.
 *
 * "Cabin Sketch" is a hand-drawn sketch font that covers the full Western
 * Latin range (accents included) and ships real 400 and 700 weights, so
 * every language renders in one uniform typeface with proper (non-synthetic)
 * bold. We self-host both weights to avoid Google's fragile per-glyph subset
 * chunking.
 */
@font-face {
  font-family: "Cabin Sketch";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/cabin-sketch-400.woff2") format("woff2");
}
@font-face {
  font-family: "Cabin Sketch";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/cabin-sketch-700.woff2") format("woff2");
}

/* ---------------------------------------------------------------------------
 * Developer documentation (/docs/scripting)
 *
 * A two-column reading layout: a sticky table of contents on the left, long
 * prose with code and tables on the right. Everything below reuses the paper
 * tokens from :root so the guide reads as the same site, not as an embedded
 * documentation tool.
 * ------------------------------------------------------------------------ */

.doc-page {
  width: min(1280px, 100%);
  margin: 26px auto 0;
  padding-bottom: 60px;
}

.doc-hero {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: rgba(251, 248, 237, 0.92);
  padding: 22px;
  box-shadow: var(--shadow-line);
}

.doc-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-deep);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.doc-hero h1 {
  max-width: 900px;
  margin: 8px 0 0;
  font-family: var(--font-hand);
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 0.88;
}

.doc-hero-lede {
  max-width: 780px;
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.55;
}

.doc-hero-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.doc-hero-facts > div {
  display: grid;
  align-content: start;
  gap: 4px;
  border: 2px solid var(--pencil);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
  padding: 11px 12px;
}

.doc-hero-facts strong {
  color: var(--brand-deep);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.doc-hero-facts span {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
}

.doc-hero-note {
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
}

.doc-hero-note a,
.doc-content a:not(.doc-anchor) {
  border-bottom: 2px solid var(--brand);
  color: var(--ink);
  font-weight: 800;
}

.doc-hero-note a:hover,
.doc-content a:not(.doc-anchor):hover {
  background: var(--brand-soft);
}

.doc-body {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  align-items: start;
  gap: 22px;
  margin-top: 20px;
}

/* --- table of contents --- */

.doc-toc {
  position: sticky;
  top: 14px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: rgba(251, 248, 237, 0.94);
  padding: 14px;
  box-shadow: var(--shadow-line);
}

.doc-toc-title {
  font-family: var(--font-hand);
  font-size: 1.5rem;
  line-height: 1;
}

.doc-toc-part {
  display: grid;
  gap: 6px;
}

.doc-toc-label {
  color: var(--brand-deep);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.doc-toc ul {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-toc a {
  display: grid;
  gap: 1px;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 5px 8px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
}

.doc-toc a small {
  color: var(--pencil-dark);
  font-size: 0.72rem;
  font-weight: 600;
}

.doc-toc a:hover {
  border-left-color: var(--brand);
  background: var(--brand-soft);
}

/* --- sections --- */

.doc-content {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.doc-section {
  scroll-margin-top: 16px;
  border-top: 2px dashed var(--pencil);
  padding: 26px 0 12px;
}

.doc-content > .doc-section:first-child {
  border-top: 0;
  padding-top: 8px;
}

.doc-section h2 {
  position: relative;
  margin: 0;
  font-family: var(--font-hand);
  font-size: clamp(2rem, 4vw, 2.9rem);
  line-height: 0.95;
}

.doc-anchor {
  position: absolute;
  left: -0.85em;
  color: var(--pencil);
  font-size: 0.72em;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.doc-section h2:hover .doc-anchor,
.doc-anchor:focus-visible {
  opacity: 1;
}

.doc-section h3 {
  margin: 26px 0 0;
  font-family: var(--font-hand);
  font-size: 1.65rem;
  line-height: 1;
}

.doc-section-lede {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--brand-deep);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.5;
}

.doc-section p {
  max-width: 800px;
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.62;
}

.doc-section strong {
  color: var(--ink);
}

.doc-section code {
  border-radius: 4px;
  background: var(--paper-deep);
  padding: 1px 5px;
  color: var(--ink);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

.doc-steps {
  display: grid;
  gap: 8px;
  max-width: 800px;
  margin: 14px 0 0;
  padding-left: 22px;
  color: var(--ink-soft);
  line-height: 1.55;
}

.doc-steps li::marker {
  color: var(--brand-deep);
  font-weight: 800;
}

/* --- callouts --- */

.doc-callout {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  max-width: 820px;
  margin: 18px 0 0;
  border: 2px solid var(--ink);
  border-left-width: 6px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  padding: 13px 14px;
}

.doc-callout strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.95rem;
}

.doc-callout p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.93rem;
  line-height: 1.55;
}

.doc-callout > svg {
  margin-top: 2px;
}

.doc-callout-note {
  border-left-color: var(--ink-soft);
}

.doc-callout-note > svg {
  color: var(--ink-soft);
}

.doc-callout-tip {
  border-left-color: var(--brand-deep);
  background: rgba(236, 250, 193, 0.5);
}

.doc-callout-tip > svg {
  color: var(--brand-deep);
}

.doc-callout-warn {
  border-left-color: var(--warning);
  background: rgba(198, 132, 33, 0.08);
}

.doc-callout-warn > svg {
  color: var(--warning);
}

/* --- tables --- */

.doc-table-scroll {
  overflow-x: auto;
  margin: 16px 0 0;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: rgba(251, 248, 237, 0.9);
  box-shadow: var(--shadow-line);
}

.doc-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.doc-table th {
  border-bottom: 2px solid var(--ink);
  padding: 9px 12px;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.doc-table td {
  border-bottom: 1px solid var(--pencil);
  padding: 9px 12px;
  color: var(--ink-soft);
  line-height: 1.5;
  vertical-align: top;
}

.doc-table tr:last-child td {
  border-bottom: 0;
}

.doc-table tbody tr:hover td {
  background: rgba(185, 235, 16, 0.09);
}

.doc-table-code td:first-child {
  width: 42%;
  color: var(--ink);
  font-weight: 700;
}

.doc-table-code td:first-child code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}

/* --- code blocks --- */

.doc-code {
  min-width: 0;
  margin: 16px 0 0;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-line);
}

.doc-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper-deep);
  padding: 6px 8px 6px 12px;
}

.doc-code-title {
  color: var(--ink);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.doc-code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 3px 8px;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
}

.doc-code-copy:hover {
  background: var(--brand-soft);
}

.doc-code pre {
  overflow-x: auto;
  margin: 0;
  padding: 13px 14px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.83rem;
  line-height: 1.62;
  tab-size: 4;
}

.doc-code figcaption {
  border-top: 1px solid var(--pencil);
  padding: 6px 12px;
  color: var(--pencil-dark);
  font-size: 0.76rem;
  font-weight: 700;
}

.doc-code-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.tok-plain {
  color: var(--ink);
}

.tok-comment {
  color: var(--pencil-dark);
  font-style: italic;
}

.tok-string {
  color: #1f7a4d;
}

.tok-number {
  color: #a1621a;
}

.tok-keyword {
  color: #8c3fa0;
  font-weight: 700;
}

.tok-engine {
  color: var(--brand-deep);
  font-weight: 700;
}

/* --- api reference --- */

.doc-api-group {
  scroll-margin-top: 16px;
  margin-top: 8px;
}

.doc-api-group h3 code {
  background: none;
  padding: 0;
  font-size: 1em;
}

/* --- footer nav --- */

.doc-related {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
  border-top: 2px dashed var(--pencil);
  padding-top: 20px;
}

.doc-related a {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 8px 11px;
  color: var(--ink);
  font-weight: 800;
  box-shadow: var(--shadow-line);
}

.doc-related a:hover {
  background: var(--brand-soft);
}

.doc-bullets {
  display: grid;
  gap: 8px;
  max-width: 800px;
  margin: 14px 0 0;
  padding-left: 22px;
  color: var(--ink-soft);
  line-height: 1.55;
}

.doc-bullets li::marker {
  color: var(--brand-deep);
}

.doc-steps .doc-bullets {
  margin-top: 8px;
}

.doc-section kbd {
  display: inline-block;
  border: 2px solid var(--pencil);
  border-bottom-width: 3px;
  border-radius: 5px;
  background: var(--paper);
  padding: 0 5px;
  color: var(--ink);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.8em;
  font-weight: 700;
  line-height: 1.5;
}

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

  .doc-toc {
    position: static;
    max-height: none;
  }

  .doc-toc ul {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .doc-hero-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .doc-code-pair {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 620px) {
  .doc-hero {
    padding: 16px;
  }

  .doc-hero-facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .doc-toc ul {
    grid-template-columns: minmax(0, 1fr);
  }

  .doc-anchor {
    display: none;
  }

  .doc-code pre {
    font-size: 0.78rem;
  }
}
