/* Doastly User Manual — screen stylesheet (investor-grade).
   Design tokens per CLAUDE.md §12. DM Sans body, DM Mono mono, teal/navy brand.
   Light + dark mode. No hardcoded product-color decisions outside the token set. */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&family=DM+Mono:wght@400;500&display=swap');

:root {
  --teal: #59C5C5;
  --teal-dk: #3AA8A8;
  --teal-lt: #E8F7F7;
  --navy: #1A3A5C;
  --bg-light: #F7F5F2;
  --surface-light: #FFFFFF;
  --border-light: #EDE8E2;
  --text-dark: #1A2A1A;
  --text-mid: #7A6A5A;
  --text-soft: #A09080;

  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-pill: 999px;

  --rail-w: 320px;

  /* semantic (resolved per theme) */
  --page: var(--bg-light);
  --surface: var(--surface-light);
  --surface-2: var(--bg-light);
  --border: var(--border-light);
  --ink: var(--text-dark);
  --ink-mid: var(--text-mid);
  --ink-soft: var(--text-soft);
  --heading: var(--navy);
  --shadow-sm: 0 1px 2px rgba(26, 58, 92, 0.06), 0 4px 16px rgba(26, 58, 92, 0.05);
  --shadow-md: 0 6px 28px rgba(26, 58, 92, 0.10);
}

:root[data-theme="dark"],
.theme-dark {
  --page: #0E0F14;
  --surface: #131419;
  --surface-2: #191A21;
  --border: #252530;
  --ink: #E7E9EE;
  --ink-mid: #A6ABB8;
  --ink-soft: #767C8B;
  --heading: #EAF7F7;
  --teal-lt: #12242A;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 18px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 34px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0E0F14;
    --surface: #131419;
    --surface-2: #191A21;
    --border: #252530;
    --ink: #E7E9EE;
    --ink-mid: #A6ABB8;
    --ink-soft: #767C8B;
    --heading: #EAF7F7;
    --teal-lt: #12242A;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 18px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 34px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--page);
  font-size: 16px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; align-items: stretch; }

.rail {
  width: var(--rail-w);
  min-width: var(--rail-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 0 0 3rem;
}

.rail-head {
  padding: 1.6rem 1.35rem 1.1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--heading);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand .dot {
  width: 15px; height: 15px; border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--teal), var(--teal-dk));
  display: inline-block; box-shadow: 0 0 0 4px var(--teal-lt);
}
.brand small { display: block; font-weight: 400; font-size: 0.72rem; color: var(--ink-soft); letter-spacing: 0; margin-top: 1px; }

/* theme toggle */
.theme-toggle {
  position: absolute; top: 1.6rem; right: 1.2rem;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--ink-mid); width: 30px; height: 30px; border-radius: var(--r-pill);
  cursor: pointer; font-size: 0.85rem; line-height: 1; display: grid; place-items: center;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--teal); color: var(--teal-dk); }

.search-wrap { margin-top: 1rem; position: relative; }
#manual-search {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.62rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#manual-search:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-lt); }

#search-results { list-style: none; margin: 0.6rem 0 0; padding: 0; }
#search-results li { margin: 0; }
#search-results a {
  display: block; padding: 0.45rem 0.6rem; border-radius: var(--r-sm);
  text-decoration: none; color: var(--ink); font-size: 0.86rem;
}
#search-results a:hover { background: var(--teal-lt); }
#search-results .sr-part { display: block; font-size: 0.7rem; color: var(--ink-soft); }
.sr-empty { color: var(--ink-soft); font-size: 0.84rem; padding: 0.4rem 0.6rem; }

/* ---- Nav tree ---- */
nav.toc { padding: 0.85rem 0.65rem; }
nav.toc .part-group { margin-bottom: 0.5rem; }
nav.toc .part-label {
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  font-weight: 700;
  padding: 0.85rem 0.65rem 0.35rem;
}
nav.toc a.nav-item {
  display: block;
  padding: 0.42rem 0.7rem;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--ink-mid);
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}
nav.toc a.nav-item:hover { background: var(--surface-2); color: var(--ink); }
nav.toc a.nav-item.active {
  background: var(--teal-lt);
  border-left-color: var(--teal);
  color: var(--heading);
  font-weight: 500;
}

/* ---- Content ---- */
main.content {
  flex: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 2.75rem 3.25rem 6rem;
}

.doc-section {
  padding-top: 0.5rem;
  margin-bottom: 3.5rem;
  scroll-margin-top: 1rem;
}
.doc-section:not(:last-child) {
  border-bottom: 1px solid var(--border);
  padding-bottom: 2.25rem;
}

main.content h1 {
  font-size: 2.15rem; color: var(--heading); font-weight: 700;
  margin: 0 0 1.1rem; line-height: 1.2; letter-spacing: -0.02em;
}
main.content h2 {
  font-size: 1.42rem; color: var(--heading); font-weight: 700;
  margin: 2.4rem 0 0.8rem; letter-spacing: -0.01em; padding-bottom: 0.3rem;
}
main.content h3 {
  font-size: 1.12rem; color: var(--ink); font-weight: 700; margin: 1.6rem 0 0.5rem;
}
main.content p { margin: 0 0 1rem; }
main.content a { color: var(--teal-dk); text-underline-offset: 2px; }
main.content ul, main.content ol { margin: 0 0 1rem; padding-left: 1.4rem; }
main.content li { margin-bottom: 0.4rem; }
main.content li::marker { color: var(--teal-dk); }
main.content hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
main.content strong { color: var(--ink); font-weight: 700; }

main.content code {
  font-family: var(--font-mono); font-size: 0.85em;
  background: var(--teal-lt); color: var(--teal-dk);
  padding: 0.12em 0.42em; border-radius: 6px;
}
main.content pre {
  background: var(--navy); color: #E8F7F7;
  padding: 1.05rem 1.25rem; border-radius: var(--r-md); overflow-x: auto;
  font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.6;
  box-shadow: var(--shadow-sm);
}
main.content pre code { background: none; color: inherit; padding: 0; }

main.content blockquote {
  margin: 0 0 1.2rem; padding: 0.7rem 1.1rem;
  border-left: 4px solid var(--teal); background: var(--surface);
  border-radius: var(--r-sm); color: var(--ink-mid); box-shadow: var(--shadow-sm);
}

/* ---- Tables ---- */
main.content table {
  width: 100%; border-collapse: collapse; margin: 0 0 1.5rem;
  font-size: 0.92rem; background: var(--surface);
  border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
main.content th {
  background: var(--navy); color: #fff; text-align: left;
  padding: 0.62rem 0.9rem; font-weight: 500; font-size: 0.82rem; letter-spacing: 0.01em;
}
main.content td { padding: 0.58rem 0.9rem; border-top: 1px solid var(--border); vertical-align: top; }
main.content tr:nth-child(even) td { background: var(--surface-2); }

/* ---- Callouts (design-doc syntax) ---- */
.callout {
  border-radius: var(--r-md); padding: 0.95rem 1.15rem; margin: 0 0 1.4rem;
  border: 1px solid var(--border); position: relative; box-shadow: var(--shadow-sm);
}
.callout .callout-badge {
  display: inline-block; font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 0.16rem 0.6rem; border-radius: var(--r-pill); margin-bottom: 0.5rem;
}
.callout p:last-child { margin-bottom: 0; }

.callout-coming-soon { background: #FFF6E9; border-color: #F2D9A8; color: #6b4c14; }
.callout-coming-soon .callout-badge { background: #E89B2B; color: #fff; }

.callout-role { background: var(--teal-lt); border-color: #BEEAEA; }
.callout-role .callout-badge { background: var(--teal-dk); color: #fff; }

.callout-tip { background: #EAF6EE; border-color: #BFE3CB; color: #1f5c37; }
.callout-tip .callout-badge { background: #2E9E58; color: #fff; }

.callout-warning { background: #FCEDED; border-color: #F2C3C3; color: #8a2f27; }
.callout-warning .callout-badge { background: #C8453B; color: #fff; }

.callout-note { background: var(--surface); }
.callout-note .callout-badge { background: var(--navy); color: #fff; }

/* ---- AI callout + AI-feature section (the distinctive differentiator) ---- */
.callout-ai {
  background: linear-gradient(135deg, rgba(89,197,197,0.14) 0%, var(--surface) 62%);
  border: 1px solid rgba(89,197,197,0.5);
  box-shadow: 0 0 0 1px rgba(89,197,197,0.15), var(--shadow-md);
}
.callout-ai .callout-badge {
  background: linear-gradient(120deg, var(--teal-dk), var(--navy)); color: #fff;
}
.callout-ai .callout-badge::before { content: "✦ "; }

/* Section-level AI-feature frame: build.py adds .ai-feature to the <section> */
.doc-section.ai-feature {
  position: relative;
  background: linear-gradient(180deg, rgba(89,197,197,0.08) 0%, var(--surface) 220px);
  border: 1px solid rgba(89,197,197,0.35);
  border-radius: var(--r-lg);
  padding: 2rem 2.25rem 2.25rem;
  margin-bottom: 3.5rem;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.doc-section.ai-feature::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--teal), var(--teal-dk), var(--navy));
}
.doc-section.ai-feature.doc-section:not(:last-child) { border-bottom: 1px solid rgba(89,197,197,0.35); }
.ai-eyebrow {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--teal-dk); background: var(--teal-lt);
  border: 1px solid rgba(89,197,197,0.45);
  padding: 0.28rem 0.7rem; border-radius: var(--r-pill);
  margin-bottom: 0.9rem;
}
.ai-eyebrow::before { content: "✦"; font-size: 0.8rem; }

/* ---- Figures / screenshots ---- */
figure.screenshot { margin: 1.6rem 0; }
figure.screenshot img {
  max-width: 100%; border-radius: var(--r-md);
  border: 1px solid var(--border); display: block; box-shadow: var(--shadow-md);
}
figure.screenshot figcaption {
  font-size: 0.82rem; color: var(--ink-soft); margin-top: 0.6rem; text-align: center; font-style: italic;
}
.screenshot-missing {
  border: 2px dashed var(--teal); border-radius: var(--r-md);
  background: var(--teal-lt); color: var(--teal-dk);
  padding: 2.5rem 1rem; text-align: center; font-size: 0.9rem; font-weight: 500;
}
.screenshot-missing .sm-path {
  display: block; font-family: var(--font-mono); font-size: 0.78rem;
  color: var(--ink-mid); margin-top: 0.5rem;
}

/* ---- Cover / front matter banner ---- */
.manual-banner {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(89,197,197,0.35) 0%, rgba(89,197,197,0) 55%),
    linear-gradient(135deg, var(--navy) 0%, var(--teal-dk) 100%);
  color: #fff; padding: 3rem 3rem 2.75rem; border-radius: var(--r-lg); margin-bottom: 2.75rem;
  box-shadow: var(--shadow-md);
}
.manual-banner::after {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 0 0 40px rgba(255,255,255,0.05);
}
.manual-banner .banner-dot {
  width: 44px; height: 44px; border-radius: var(--r-pill);
  background: var(--teal); box-shadow: 0 0 0 8px rgba(89,197,197,0.22); margin-bottom: 1.2rem;
}
main.content .manual-banner h1 { color: #fff; margin: 0 0 0.5rem; font-size: 2.4rem; letter-spacing: -0.02em; }
main.content .manual-banner p { color: rgba(255,255,255,0.88); margin: 0; font-size: 1.05rem; max-width: 32rem; }
.manual-banner .meta {
  font-family: var(--font-mono); font-size: 0.8rem; margin-top: 1.3rem; opacity: 0.9;
  display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
}
.manual-banner .dl-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(255,255,255,0.16); color: #fff; text-decoration: none;
  padding: 0.35rem 0.85rem; border-radius: var(--r-pill);
  border: 1px solid rgba(255,255,255,0.28); font-size: 0.78rem;
  transition: background 0.15s ease;
}
.manual-banner .dl-pill:hover { background: rgba(255,255,255,0.26); }

/* ---- Confidential ribbon (Manual B) ---- */
.confidential-ribbon {
  background: #C8453B; color: #fff; text-align: center;
  font-weight: 700; font-size: 0.8rem; letter-spacing: 0.06em;
  padding: 0.5rem; text-transform: uppercase;
}

/* ---- Empty / placeholder state ---- */
.build-empty { text-align: center; padding: 4rem 1rem; color: var(--ink-soft); }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .rail { width: 100%; min-width: 0; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  main.content { padding: 1.75rem 1.35rem 4rem; }
  .doc-section.ai-feature { padding: 1.5rem 1.35rem; }
  .manual-banner { padding: 2rem 1.5rem; }
  .manual-banner h1 { font-size: 1.9rem; }
}
