/* =========================================================================
   Amua Docs — layout + content styling. Loads AFTER styles.css (reuses
   tokens, nav, footer, buttons). Light + dark via :root[data-theme].
   ========================================================================= */

.docs-body {
  --docs-accent: var(--blue);
  --docs-accent-soft: rgba(77, 121, 217, 0.10);
  --docs-accent-line: rgba(77, 121, 217, 0.30);
  --docs-sidebar-w: 266px;
  --docs-otp-w: 236px;
  --docs-nav-offset: 152px;       /* content/sticky top: clears the floating nav pill + breathing room */
  --docs-mobile-offset: 104px;    /* smaller nav pill on mobile */
  --docs-measure: 820px;
  background: var(--paper);
}
:root[data-theme="dark"] .docs-body {
  --docs-accent: #8fb0f2;
  --docs-accent-soft: rgba(143, 176, 242, 0.12);
  --docs-accent-line: rgba(143, 176, 242, 0.34);
}

/* ---------------- shell / columns ---------------- */
.docs-shell {
  max-width: 1460px;
  margin: 0 auto;
  padding: var(--docs-nav-offset) 32px 64px;
  display: grid;
  grid-template-columns: var(--docs-sidebar-w) minmax(0, 1fr);
  gap: 44px;
  align-items: start;
}
.docs-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--docs-otp-w);
  gap: 56px;
  align-items: start;
  min-width: 0;
}

/* ---------------- left sidebar ---------------- */
.docs-sidebar {
  position: sticky;
  top: var(--docs-nav-offset);
  align-self: start;
  max-height: calc(100vh - var(--docs-nav-offset) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.docs-sidebar-inner { padding-right: 10px; }
.docs-sb-home {
  display: block;
  font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-soft);
  padding: 2px 0 14px;
  text-decoration: none;
}
.docs-sb-home:hover { color: var(--docs-accent); }

.docs-nav { display: flex; flex-direction: column; gap: 2px; }
.docs-nav-top { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.docs-nav-group { display: flex; flex-direction: column; }
.docs-nav-grouphd {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--ink-soft);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 16px 6px 7px; text-align: left;
}
.docs-nav-caret { transition: transform 0.18s ease; opacity: 0.7; flex: 0 0 auto; }
.docs-nav-group:not(.is-open) .docs-nav-caret { transform: rotate(0deg); }
.docs-nav-group.is-open .docs-nav-caret { transform: rotate(90deg); }
.docs-nav-items { display: flex; flex-direction: column; gap: 2px; }
.docs-nav-group:not(.is-open) .docs-nav-items { display: none; }

.docs-nav-link {
  display: block;
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background 0.14s ease, color 0.14s ease;
}
.docs-nav-link:hover { background: var(--mist); color: var(--ink); }
.docs-nav-link.is-child {
  margin-left: 12px;
  padding-left: 14px;
  border-left: 1.5px solid var(--line-strong);
  border-radius: 0 9px 9px 0;
  font-size: 13.8px;
}
.docs-nav-link.is-active {
  background: var(--docs-accent-soft);
  color: var(--docs-accent);
  font-weight: 600;
}
.docs-nav-link.is-child.is-active { border-left-color: var(--docs-accent); }

/* collapsible parent (items with sub-sections, e.g. Best Practices, Permissions) */
.docs-nav-item--parent { display: flex; flex-direction: column; }
.docs-nav-row { display: flex; align-items: stretch; gap: 2px; }
.docs-nav-row .docs-nav-link { flex: 1 1 auto; min-width: 0; }
.docs-nav-subtoggle {
  flex: 0 0 auto; display: grid; place-items: center; width: 30px;
  border: 0; background: none; cursor: pointer; color: var(--ink-soft);
  border-radius: 8px; padding: 0;
}
.docs-nav-subtoggle:hover { background: var(--mist); color: var(--ink); }
.docs-nav-subtoggle .docs-nav-caret { transition: transform 0.18s ease; opacity: 0.8; }
.docs-nav-item--parent.is-open .docs-nav-subtoggle .docs-nav-caret { transform: rotate(90deg); }
.docs-nav-children { display: none; flex-direction: column; gap: 2px; margin-top: 2px; }
.docs-nav-item--parent.is-open .docs-nav-children { display: flex; }

/* label-only parent (e.g. Permissions): the whole row is a toggle, no page to land on */
.docs-nav-labelrow {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 7px 12px; border-radius: 9px;
  font: inherit; font-size: 14.5px; line-height: 1.35;
  color: var(--ink-soft); text-align: left;
}
.docs-nav-labelrow:hover { background: var(--mist); color: var(--ink); }
.docs-nav-labeltext { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- article ---------------- */
.docs-article { min-width: 0; max-width: var(--docs-measure); }
.docs-crumb {
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--docs-accent); text-transform: uppercase; margin-bottom: 12px;
}
.docs-title {
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.08; letter-spacing: -0.02em; font-weight: 700;
  color: var(--ink); margin: 0 0 14px;
}
.docs-lede {
  font-size: 18px; line-height: 1.55; color: var(--ink-soft);
  margin: 0 0 8px; max-width: 70ch;
}

/* content rhythm */
.docs-content { color: var(--ink); font-size: 16px; line-height: 1.72; }
.docs-content > :first-child { margin-top: 20px; }
.docs-content p { margin: 0 0 18px; max-width: 74ch; }
.docs-content ul, .docs-content ol { margin: 0 0 18px; padding-left: 24px; max-width: 74ch; }
.docs-content li { margin: 6px 0; }
.docs-content li > ul, .docs-content li > ol { margin: 6px 0; }
.docs-content a {
  color: var(--docs-accent); text-decoration: none;
  border-bottom: 1px solid var(--docs-accent-line);
  transition: border-color 0.14s ease;
}
.docs-content a:hover { border-bottom-color: var(--docs-accent); }
.docs-content strong { font-weight: 700; color: var(--ink); }
.docs-content hr { border: 0; height: 1px; background: var(--line); margin: 34px 0; }

/* headings */
.docs-content h2, .docs-content h3, .docs-content h4 {
  color: var(--ink); scroll-margin-top: calc(var(--docs-nav-offset) + 8px);
  position: relative; letter-spacing: -0.01em;
}
.docs-content h2 { font-size: 25px; font-weight: 700; line-height: 1.25; margin: 42px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.docs-content h3 { font-size: 20px; font-weight: 700; line-height: 1.3; margin: 34px 0 12px; }
.docs-content h4 { font-size: 17px; font-weight: 700; margin: 26px 0 10px; }
.docs-anchor {
  position: absolute; left: -22px; top: 0; width: 22px;
  color: var(--docs-accent); opacity: 0; text-decoration: none; border: 0 !important;
  font-weight: 400; text-align: center;
  transition: opacity 0.14s ease;
}
.docs-content h2:hover .docs-anchor,
.docs-content h3:hover .docs-anchor,
.docs-content h4:hover .docs-anchor { opacity: 0.55; }
.docs-anchor:hover { opacity: 1 !important; }

/* inline code */
.docs-content code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.88em; background: var(--mist);
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px;
}
.docs-content pre {
  background: var(--mist); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; overflow-x: auto; margin: 0 0 20px; font-size: 14px; line-height: 1.6;
}
.docs-content pre code { background: none; border: 0; padding: 0; }

/* blockquote */
.docs-content blockquote {
  margin: 0 0 20px; padding: 2px 18px; border-left: 3px solid var(--line-strong);
  color: var(--ink-soft);
}

/* highlight marks */
.docs-mark { background: rgba(255, 214, 102, 0.42); color: inherit; padding: 1px 3px; border-radius: 4px; }
.docs-mark--warning { background: rgba(255, 196, 73, 0.42); }
.docs-mark--danger  { background: rgba(240, 120, 120, 0.34); }
.docs-mark--success { background: rgba(120, 200, 140, 0.34); }
.docs-mark--info    { background: var(--docs-accent-soft); }
:root[data-theme="dark"] .docs-mark { background: rgba(255, 210, 110, 0.22); }

/* ---------------- callouts (hints) ---------------- */
.docs-callout {
  display: flex; gap: 13px; align-items: flex-start;
  background: var(--docs-accent-soft);
  border: 1px solid var(--docs-accent-line);
  border-radius: 14px; padding: 15px 17px; margin: 0 0 22px;
}
.docs-callout-ic {
  flex: 0 0 auto; width: 21px; height: 21px; border-radius: 50%;
  display: grid; place-items: center; margin-top: 1px;
  background: var(--docs-accent); color: #fff;
  font-size: 12px; font-weight: 700; font-style: normal;
}
.docs-callout-body { min-width: 0; }
.docs-callout-body > :last-child { margin-bottom: 0 !important; }
.docs-callout-body p { margin: 0 0 8px; }
.docs-callout--warning { background: rgba(255, 196, 73, 0.12); border-color: rgba(255, 196, 73, 0.4); }
.docs-callout--warning .docs-callout-ic { background: #e0a33a; }
.docs-callout--danger { background: rgba(240, 120, 120, 0.1); border-color: rgba(240, 120, 120, 0.35); }
.docs-callout--danger .docs-callout-ic { background: #d75d5d; }
.docs-callout--success { background: rgba(120, 200, 140, 0.1); border-color: rgba(120, 200, 140, 0.35); }
.docs-callout--success .docs-callout-ic { background: #4ea96b; }

/* ---------------- figures / images ---------------- */
.docs-content figure { margin: 0 0 24px; }
.docs-content figure img,
.docs-content img {
  display: block; max-width: 100%; height: auto; max-height: 440px;
  margin-left: auto; margin-right: auto;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--mist); cursor: zoom-in;
}
/* images with an explicit width (small/portrait shots) keep their true aspect — no height cap */
.docs-content img[width] { max-height: none; height: auto; }
.docs-content figcaption {
  margin-top: 9px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.5;
}
.docs-fig-align { margin: 0 0 24px; }
.docs-fig-align--left { text-align: left; }
.docs-fig-align--center { text-align: center; }
.docs-fig-align--right { text-align: right; }
.docs-fig-align figure { display: inline-block; margin: 0; }

/* columns: side-by-side pairs sit at equal width + equal height */
.docs-cols { display: flex; gap: 16px; margin: 0 0 24px; align-items: stretch; }
.docs-cols .docs-col { min-width: 0; flex: 1 1 0 !important; }
.docs-cols .docs-col > :last-child { margin-bottom: 0; }
.docs-cols figure { margin: 0; height: 100%; }
.docs-cols .docs-col figure img {
  width: 100%; height: 320px; max-height: 320px;
  object-fit: cover; object-position: top center;
}
@media (max-width: 640px) {
  .docs-cols { flex-direction: column; gap: 14px; }
  .docs-cols .docs-col figure img { height: auto; max-height: 420px; object-fit: contain; }
}

/* video embeds */
.docs-video { margin: 0 0 24px; }
.docs-video video {
  display: block; width: 100%; max-height: 560px; border-radius: 14px;
  border: 1px solid var(--line); background: #000;
}
.docs-embed a { word-break: break-word; }

/* ---------------- tables ---------------- */
.docs-table-wrap {
  overflow-x: auto; margin: 0 0 24px; border: 1px solid var(--line);
  border-radius: 12px; -webkit-overflow-scrolling: touch;
}
.docs-content table {
  border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.5;
  min-width: max-content;
}
.docs-content th, .docs-content td {
  text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line); vertical-align: top;
}
.docs-content th:last-child, .docs-content td:last-child { border-right: 0; }
.docs-content thead th {
  background: var(--mist); font-weight: 700; color: var(--ink);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.docs-content tbody tr:last-child td { border-bottom: 0; }
.docs-content tbody tr:hover td { background: var(--mist); }
.docs-content table del, .docs-content table s { color: var(--ink-soft); }
/* sticky first column (large permission matrices) */
.docs-content table.docs-sticky-col th:first-child,
.docs-content table.docs-sticky-col td:first-child {
  position: sticky; left: 0; z-index: 2; background: var(--paper);
  border-right: 1px solid var(--line-strong);
}
.docs-content table.docs-sticky-col thead th:first-child { z-index: 3; background: var(--mist); }

/* ---------------- prev / next ---------------- */
.docs-prevnext {
  display: flex; gap: 16px; margin: 48px 0 0; padding-top: 28px;
  border-top: 1px solid var(--line);
}
.docs-pn {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px;
  text-decoration: none; transition: border-color 0.15s ease, background 0.15s ease;
}
.docs-pn--empty { border: 0; background: none; pointer-events: none; }
.docs-pn:not(.docs-pn--empty):hover { border-color: var(--docs-accent); background: var(--docs-accent-soft); }
.docs-pn--next { text-align: right; align-items: flex-end; }
.docs-pn-dir { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.docs-pn-title { font-size: 15.5px; color: var(--ink); font-weight: 600; }
.docs-pn:hover .docs-pn-title { color: var(--docs-accent); }

/* ---------------- help / community ---------------- */
.docs-help { margin-top: 40px; }
.docs-help-row {
  display: flex; align-items: center; justify-content: space-between; gap: 22px; flex-wrap: wrap;
  background: var(--mist); border: 1px solid var(--line);
  border-radius: 16px; padding: 20px 22px;
}
.docs-help-row h3 { margin: 0 0 4px; font-size: 16px; color: var(--ink); font-weight: 700; }
.docs-help-row p { margin: 0; font-size: 14px; color: var(--ink-soft); max-width: 46ch; }
.docs-help-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.docs-help-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 100px; font-size: 14px; font-weight: 600;
  text-decoration: none; border: 1px solid var(--line-strong); color: var(--ink);
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.docs-help-btn:hover { border-color: var(--docs-accent); color: var(--docs-accent); transform: translateY(-1px); }
.docs-help-btn--tg { background: #2aabee; border-color: #2aabee; color: #fff; }
.docs-help-btn--tg:hover { background: #1f97d4; border-color: #1f97d4; color: #fff; }

/* ---------------- on this page (right rail) ---------------- */
.docs-onthispage {
  position: sticky; top: var(--docs-nav-offset); align-self: start;
  max-height: calc(100vh - var(--docs-nav-offset) - 24px); overflow-y: auto;
  scrollbar-width: thin; font-size: 13.5px;
}
.docs-otp-head {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 12px;
}
.docs-otp-nav { display: flex; flex-direction: column; border-left: 1.5px solid var(--line); }
.docs-otp-link {
  display: block; padding: 6px 0 6px 14px; margin-left: -1.5px;
  border-left: 1.5px solid transparent;
  color: var(--ink-soft); text-decoration: none; line-height: 1.4;
  transition: color 0.14s ease, border-color 0.14s ease;
}
.docs-otp-link:hover { color: var(--ink); }
.docs-otp-link.lvl-3 { padding-left: 26px; font-size: 13px; }
.docs-otp-link.is-active { color: var(--docs-accent); border-left-color: var(--docs-accent); font-weight: 600; }

/* ---------------- mobile menu button + scrim ---------------- */
.docs-sidebar-toggle {
  display: none; align-items: center; gap: 8px;
  position: sticky; top: var(--docs-nav-offset); z-index: 40;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 100px; padding: 9px 16px; font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; box-shadow: 0 6px 20px rgba(10,11,13,0.08);
}
.docs-sidebar-scrim {
  position: fixed; inset: 0; background: rgba(10,11,13,0.42); z-index: 110;
  opacity: 0; transition: opacity 0.2s ease;
}

/* ---------------- responsive ---------------- */
@media (max-width: 1180px) {
  .docs-main { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .docs-onthispage { display: none; }
  .docs-article { max-width: none; }
}
@media (max-width: 920px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); gap: 0; padding: var(--docs-mobile-offset) 20px 56px; }
  .docs-sidebar-toggle { display: inline-flex; margin-bottom: 18px; top: var(--docs-mobile-offset); }
  .docs-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 120;
    width: 300px; max-width: 86vw; max-height: none;
    background: var(--paper); border-right: 1px solid var(--line);
    padding: 90px 18px 24px; transform: translateX(-104%);
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 0 24px 60px rgba(10,11,13,0.25);
  }
  .docs-shell.sidebar-open .docs-sidebar { transform: translateX(0); }
  .docs-shell.sidebar-open .docs-sidebar-scrim { display: block; }
  .docs-title { font-size: clamp(27px, 7vw, 34px); }
}
@media (max-width: 920px) {
  .docs-sidebar-scrim[hidden] { display: none; }
}
@media (max-width: 560px) {
  .docs-prevnext { flex-direction: column; }
  .docs-pn--empty { display: none; }
  .docs-pn--next { text-align: left; align-items: flex-start; }
  .docs-help-row { flex-direction: column; align-items: flex-start; }
}

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  .docs-nav-items, .docs-sidebar, .docs-nav-caret, .docs-pn, .docs-help-btn { transition: none; }
}
