/* API documentation page — standalone styling for the public site.
   The public shell ships a COMPILED Tailwind build (front.css) that only
   contains utilities already used elsewhere, so every layout class used here
   is defined in this file instead of relying on new Tailwind utilities. */

.api-docs-page .doc-hero {
  padding: 2.5rem 1.5rem 1.75rem;
  border-bottom: 1px solid #f3f4f6;
}

@media (min-width: 1024px) {
  .api-docs-page .doc-hero {
    padding: 3rem 4rem 2rem;
  }
}

.api-docs-page .doc-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 0.75rem;
}

.api-docs-page .doc-hero p {
  color: #4b5563;
  line-height: 1.65;
  margin: 0 0 1.25rem;
}

.api-docs-page .doc-hero-grid {
  display: grid;
  gap: 2rem;
  align-items: start;
}

@media (min-width: 1024px) {
  .api-docs-page .doc-hero-grid {
    grid-template-columns: minmax(0, 1fr) 22rem;
    gap: 3rem;
  }
}

.api-docs-page .doc-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.api-docs-page .doc-field + .doc-field {
  margin-top: 0.85rem;
}

.api-docs-page .doc-field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  margin: 0 0 0.35rem;
}

.api-docs-page .doc-field-row {
  display: flex;
  align-items: stretch;
}

.api-docs-page .doc-field-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-right: 0;
  border-radius: 0.75rem 0 0 0.75rem;
  background: #f9fafb;
  color: #374151;
  outline: none;
}

.api-docs-page .doc-field-row input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}

.api-docs-page .doc-field-row button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.85rem;
  border: 1px solid #e5e7eb;
  border-radius: 0 0.75rem 0.75rem 0;
  background: #ffffff;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.api-docs-page .doc-field-row button:hover {
  background: #f9fafb;
  color: #111827;
}

.api-docs-page .doc-meta-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
}

.api-docs-page .doc-inline-code {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  background: #f3f4f6;
  color: #be185d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82em;
}

.api-docs-page .doc-alert {
  margin: 3rem 1.5rem;
  padding: 1.5rem;
  border: 1px solid #fde68a;
  border-radius: 1rem;
  background: #fffbeb;
}

.api-docs-page .doc-alert h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #92400e;
}

.api-docs-page .doc-alert p {
  margin: 0;
  font-size: 0.875rem;
  color: #92400e;
}

.api-docs-page .doc-alert a {
  text-decoration: underline;
}

/* Layout: sidebar + content -------------------------------------------- */

/* The site shell card is `overflow-hidden` (rounded corners), and an
   overflow-clipping ancestor turns into the sticky scrollport — which kills
   position:sticky. Unclip here and round the footer's own bottom corners
   instead, so the rail can stick to the viewport. */
.api-docs-page .api-shell {
  overflow: visible;
}

.api-docs-page .api-shell > footer {
  border-radius: 0 0 1.5rem 1.5rem;
}

.api-docs-page .doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  padding: 2.5rem 1.5rem 3rem;
}

@media (min-width: 1024px) {
  .api-docs-page .doc-layout {
    grid-template-columns: 17rem minmax(0, 1fr);
    gap: 3rem;
    padding: 3rem 4rem 4rem;
  }
}

.api-docs-page .doc-sidebar {
  min-width: 0;
}

.api-docs-page .doc-toc-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  background: #ffffff;
  color: #111827;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

@media (min-width: 1024px) {
  .api-docs-page .doc-toc-toggle {
    display: none;
  }
}

.api-docs-page .doc-toc-panel {
  display: none;
  margin-top: 0.75rem;
}

.api-docs-page .doc-toc-panel.show {
  display: block;
}

/* Sticky rail on desktop: capped to the viewport with its own scroll. */
@media (min-width: 1024px) {
  .api-docs-page .doc-toc-panel,
  .api-docs-page .doc-toc-panel.show {
    display: block;
    margin-top: 0;
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 0.5rem;
    scrollbar-width: thin;
  }
}

.api-docs-page .doc-toc-filter {
  display: block;
  width: 100%;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.6rem;
  background: #f9fafb;
  font-size: 0.8125rem;
  color: #374151;
  outline: none;
}

.api-docs-page .doc-toc-filter:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}

.api-docs-page .doc-toc-hidden {
  display: none !important;
}

.api-docs-page .doc-content {
  min-width: 0;
}

/* Endpoint accordion nav ------------------------------------------------- */

.api-docs-page .doc-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.api-docs-page .doc-nav-group {
  border-bottom: 1px solid #f3f4f6;
}

.api-docs-page .doc-nav-group:last-child {
  border-bottom: 0;
}

.api-docs-page .doc-nav-summary {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.35rem;
  border-radius: 0.4rem;
  cursor: pointer;
  list-style: none;
  transition: background-color 0.15s ease-in-out;
}

.api-docs-page .doc-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.api-docs-page .doc-nav-summary::-webkit-details-marker {
  display: none;
}

.api-docs-page .doc-nav-summary:hover {
  background: #f9fafb;
}

.api-docs-page .doc-nav-summary:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
}

.api-docs-page .doc-nav-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
}

.api-docs-page .doc-nav-chevron {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  color: #9ca3af;
  transition: transform 0.15s ease-in-out;
}

.api-docs-page .doc-nav-group[open] > .doc-nav-summary .doc-nav-chevron {
  transform: rotate(180deg);
}

.api-docs-page a.doc-nav-summary {
  text-decoration: none;
  color: inherit;
}

.api-docs-page .doc-nav-flat.active {
  background: #eff6ff;
}

.api-docs-page .doc-nav-flat.active .doc-nav-label {
  color: #1d4ed8;
}

.api-docs-page .doc-nav-endpoint {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  padding-left: 0.1rem;
}

.api-docs-page .doc-nav-endpoint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-docs-page .doc-nav-method {
  display: inline-block;
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.5;
  color: #ffffff;
  background: #6b7280;
}

.api-docs-page .doc-nav-method--post {
  background: #2563eb;
}

.api-docs-page .doc-nav-method--get {
  background: #059669;
}

.api-docs-page .doc-nav-list,
.api-docs-page .doc-nav-sublist {
  list-style: none;
  margin: 0;
  padding: 0 0 0.35rem 0.6rem;
  border-left: 1px solid #e5e7eb;
  margin-left: 0.35rem;
}

.api-docs-page .doc-nav-sublist {
  padding-left: 0.75rem;
  margin-left: 0.5rem;
}

.api-docs-page .doc-nav-link {
  display: block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.35rem;
  color: #4b5563;
  font-size: 0.8rem;
  line-height: 1.35;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
}

.api-docs-page .doc-nav-link::-webkit-details-marker {
  display: none;
}

.api-docs-page .doc-nav-link:hover {
  background: #f3f4f6;
  color: #111827;
}

.api-docs-page .doc-nav-link.active {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.api-docs-page .doc-nav-link--child {
  font-size: 0.76rem;
  color: #6b7280;
}

.api-docs-page .doc-nav-link--parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-weight: 600;
  color: #374151;
}

.api-docs-page .doc-nav-link--parent::after {
  content: '';
  flex: 0 0 auto;
  width: 0.35rem;
  height: 0.35rem;
  border-right: 1.5px solid #9ca3af;
  border-bottom: 1.5px solid #9ca3af;
  transform: rotate(-45deg);
  transition: transform 0.15s ease-in-out;
}

.api-docs-page .doc-nav-sub[open] > .doc-nav-link--parent::after {
  transform: rotate(45deg);
}

/* Grouped content sections ---------------------------------------------- */

.api-docs-page .doc-section {
  padding-top: 0.5rem;
}

.api-docs-page .doc-section + .doc-section {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid #f3f4f6;
}

.api-docs-page .doc-section--endpoint {
  border-radius: 0.75rem;
}

.api-docs-page .doc-endpoint-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.api-docs-page .doc-endpoint-line code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: #374151;
  word-break: break-all;
}

.api-docs-page .doc-section-title {
  margin-top: 0;
}

.api-docs-page [id^='section-'] {
  scroll-margin-top: 1.5rem;
}

.api-docs-page .doc-body h2,
.api-docs-page .doc-body h3,
.api-docs-page .doc-body h4 {
  scroll-margin-top: 1.5rem;
}

/* Rendered markdown ------------------------------------------------------ */

.api-docs-page .doc-content h1:first-child {
  display: none; /* duplicate of the page hero title */
}

.api-docs-page .doc-body h2 {
  margin: 2.25rem 0 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #e5e7eb;
  font-size: 1.4rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.api-docs-page .doc-body h3 {
  margin: 1.75rem 0 0.6rem;
  font-size: 1.1rem;
}

.api-docs-page .doc-body h4 {
  margin: 1.35rem 0 0.5rem;
  font-size: 0.98rem;
}

.api-docs-page .doc-body p {
  margin: 0 0 0.9rem;
  color: #374151;
  line-height: 1.65;
}

.api-docs-page .doc-body ul,
.api-docs-page .doc-body ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
}

.api-docs-page .doc-body li {
  margin-bottom: 0.3rem;
  color: #374151;
  line-height: 1.6;
}

.api-docs-page .doc-body a {
  color: #1d4ed8;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

.api-docs-page .doc-body code {
  padding: 0.12rem 0.35rem;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #f9fafb;
  color: #be185d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82em;
  word-break: break-word;
}

.api-docs-page .doc-body pre {
  position: relative;
  margin: 0 0 1.1rem;
  padding: 0.95rem 1.1rem;
  border-radius: 0.75rem;
  background: #111827;
  color: #e5e7eb;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.55;
}

.api-docs-page .doc-body pre code {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  word-break: normal;
}

.api-docs-page .doc-copy-btn {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0.375rem;
  background: rgba(255, 255, 255, 0.1);
  color: #f3f4f6;
  font-size: 0.7rem;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.15s ease-in-out;
}

.api-docs-page .doc-body pre:hover .doc-copy-btn,
.api-docs-page .doc-copy-btn:focus {
  opacity: 1;
}

.api-docs-page .doc-table {
  width: 100%;
  margin: 0 0 1.15rem;
  border-collapse: collapse;
  font-size: 0.82rem;
  display: block;
  overflow-x: auto;
}

.api-docs-page .doc-table th,
.api-docs-page .doc-table td {
  padding: 0.55rem 0.7rem;
  border: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
}

.api-docs-page .doc-table th {
  background: #f9fafb;
  color: #111827;
  font-weight: 600;
  white-space: nowrap;
}

.api-docs-page .doc-table tbody tr:nth-child(even) {
  background: #fcfcfd;
}

/* Field names in reference tables must not break mid-token; the table block
   scrolls horizontally instead. */
.api-docs-page .doc-table code {
  white-space: nowrap;
}

.api-docs-page .doc-body blockquote {
  margin: 0 0 1.1rem;
  padding: 0.7rem 1rem;
  border-left: 3px solid #2563eb;
  border-radius: 0 0.5rem 0.5rem 0;
  background: #eff6ff;
  color: #1f2937;
}

.api-docs-page .doc-body blockquote p {
  margin: 0;
  color: inherit;
}

.api-docs-page .doc-body hr {
  margin: 1.75rem 0;
  border: 0;
  border-top: 1px solid #e5e7eb;
}

/* Copy toast ------------------------------------------------------------- */

#docToast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  padding: 0.55rem 0.9rem;
  border-radius: 0.5rem;
  background: #111827;
  color: #f9fafb;
  font-size: 0.8rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

#docToast.show {
  opacity: 1;
}

@media print {
  .api-docs-page .doc-sidebar,
  .api-docs-page .doc-copy-btn,
  #docToast {
    display: none !important;
  }
}