/* Documentation Shell — dedicated operational surface
   Copyright (c) 2026 Evident Technologies LLC. All rights reserved.
*/

/* ── Surface Isolation ───────────────────────────────────────────────────── */

body[data-site-surface="docs"] {
  --docs-viewport-height: 100vh;
  --docs-shell-offset: var(--site-header-height, 5.5rem);
  --docs-shell-height: calc(var(--docs-viewport-height) - var(--docs-shell-offset));
  --docs-bg: #f3f6fb;
  --docs-panel-bg: #fff;
  --docs-panel-muted: #f8fbff;
  --docs-border: #d6dfec;
  --docs-border-strong: #b5c6e4;
  --docs-text: #0f172a;
  --docs-text-muted: #334155;
  --docs-link: #1d4ed8;
  --docs-link-hover: #1e3a8a;
  --docs-focus: #1d4ed8;

  background: var(--docs-bg);
}

@supports (height: 100dvh) {
  body[data-site-surface="docs"] {
    --docs-viewport-height: 100dvh;
  }
}

body[data-site-surface="docs"] .site-footer {
  display: none;
}

body[data-site-surface="docs"] .site-header,
body[data-site-surface="docs"] .site-header__menu {
  border-color: #d2ddec;
  background: #f3f6fb;
}

body[data-site-surface="docs"] .site-header__link,
body[data-site-surface="docs"] .site-header__btn--ghost {
  color: #1e293b;
}

body[data-site-surface="docs"] .site-header__link:hover,
body[data-site-surface="docs"] .site-header__link:focus-visible,
body[data-site-surface="docs"] .site-header__btn--ghost:hover,
body[data-site-surface="docs"] .site-header__btn--ghost:focus-visible {
  color: #0f172a;
  background: #e2e8f0;
  border-color: #94a3b8;
}

#main.docs-shell {
  inline-size: 100%;
  max-inline-size: none;
  margin: 0;
  padding: 0;
  min-block-size: var(--docs-shell-height);
  block-size: var(--docs-shell-height);
  overflow: clip;
  background: var(--docs-bg);
}

/* ── Shell Architecture ──────────────────────────────────────────────────── */

.docs-layout {
  display: flex;
  align-items: stretch;
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 100%;
}

.docs-sidebar {
  flex: 0 0 clamp(16rem, 22vw, 21rem);
  min-inline-size: 15rem;
  max-inline-size: 23rem;
  position: sticky;
  top: 0;
  block-size: 100%;
  padding: 1.5rem 1.25rem 2rem;
  border-inline-end: 1px solid var(--docs-border);
  background: var(--docs-panel-bg);
  box-shadow: 1px 0 8px rgb(2 6 23 / 6%);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.docs-content {
  flex: 1 1 auto;
  min-width: 0;
  inline-size: auto;
  block-size: 100%;
  padding: 2.25rem 3rem 3rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block-start: 1rem;
}

/* ── Sidebar Navigation ──────────────────────────────────────────────────── */

.docs-nav {
  display: grid;
  gap: 1.25rem;
  min-width: 0;
}

.docs-nav__group {
  min-width: 0;
}

.docs-nav__heading {
  display: block;
  margin-block-end: 0.6rem;
  padding-block-end: 0.4rem;
  border-block-end: 1px solid var(--docs-border);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--docs-text-muted);
}

.docs-nav__link {
  display: block;
  margin-block: 0.15rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  background: transparent;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--docs-text);
  text-decoration: none;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
  overflow-wrap: anywhere;
}

.docs-nav__link:hover {
  background: #e9f1ff;
  border-color: #c9dbff;
  color: #1e3a8a;
}

.docs-nav__link.active {
  background: #dce9ff;
  border-color: #9fbbf9;
  color: #1e3a8a;
  font-weight: 600;
}

.docs-nav__link:focus-visible {
  outline: 2px solid var(--docs-focus);
  outline-offset: 2px;
}

.docs-nav__link[data-tier-guest][hidden],
.docs-nav__link[data-tier-starter][hidden],
.docs-nav__link[data-tier-core][hidden],
.docs-nav__link[data-tier-complete][hidden] {
  display: none;
}

/* ── Hero and Sections ───────────────────────────────────────────────────── */

.docs-hero,
.docs-section,
.docs-cta {
  scroll-margin-block-start: 1rem;
}

.docs-hero {
  margin-block-end: 2.6rem;
  padding: 2.25rem;
  border: 1px solid var(--docs-border);
  border-radius: 0.95rem;
  background: var(--docs-panel-bg);
  box-shadow: 0 2px 10px rgb(15 23 42 / 6%);
}

.docs-hero__label {
  display: inline-block;
  margin-block-end: 0.8rem;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--docs-link);
}

.docs-hero__title,
.docs-section__title {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-inline-size: 28ch;
  margin: 0;
  color: var(--docs-text);
  text-wrap: balance;
}

.docs-hero__title {
  font-size: clamp(1.65rem, 2.8vw, 2.45rem);
  line-height: 1.15;
}

.docs-hero__subtitle {
  max-inline-size: 68ch;
  margin: 0.9rem 0 1.5rem;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--docs-text-muted);
  text-wrap: pretty;
}

.docs-hero__actions,
.docs-cta__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.docs-section {
  margin-block-end: 2.8rem;
}

.docs-section__title {
  font-size: clamp(1.25rem, 1.7vw, 1.62rem);
  font-weight: 700;
  margin-block-end: 0.45rem;
}

.docs-section__subtitle {
  margin: 0 0 1.4rem;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--docs-text-muted);
}

.docs-heading-anchor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 1.1rem;
  block-size: 1.1rem;
  border-radius: 0.25rem;
  color: var(--docs-link);
  font-size: 0.82rem;
  text-decoration: none;
  opacity: 0;
}

.docs-hero__title:hover .docs-heading-anchor,
.docs-hero__title:focus-within .docs-heading-anchor,
.docs-section__title:hover .docs-heading-anchor,
.docs-section__title:focus-within .docs-heading-anchor {
  opacity: 1;
}

.docs-heading-anchor:focus-visible {
  opacity: 1;
  outline: 2px solid var(--docs-focus);
  outline-offset: 2px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.docs-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.66rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

.docs-button--primary {
  background: #1d4ed8;
  color: #fff;
}

.docs-button--primary:hover {
  background: #1e3a8a;
  color: #fff;
}

.docs-button--secondary {
  border-color: var(--docs-border-strong);
  background: #fff;
  color: var(--docs-text);
}

.docs-button--secondary:hover {
  border-color: #8ea9df;
  background: #edf4ff;
}

.docs-button:focus-visible {
  outline: 2px solid var(--docs-focus);
  outline-offset: 2px;
}

/* ── Quickstart Steps ────────────────────────────────────────────────────── */

.docs-steps {
  display: grid;
  gap: 1.3rem;
}

.docs-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.docs-step__number {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 2.35rem;
  block-size: 2.35rem;
  border-radius: 999px;
  background: #1d4ed8;
  color: #fff;
  font-size: 1.03rem;
  font-weight: 700;
}

.docs-step__content {
  min-width: 0;
}

.docs-step__content h3 {
  margin: 0 0 0.4rem;
  font-size: 1.14rem;
  font-weight: 650;
  color: var(--docs-text);
}

.docs-step__content p {
  margin: 0 0 0.75rem;
  color: var(--docs-text-muted);
  line-height: 1.6;
}

.docs-step__tier-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

/* ── Tokens and Inline Badges ────────────────────────────────────────────── */

.docs-tier-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.docs-tier-badge--guest {
  background: #e5e7eb;
  color: #374151;
}

.docs-tier-badge--starter {
  background: #dcfce7;
  color: #166534;
}

.docs-tier-badge--core {
  background: #fef3c7;
  color: #92400e;
}

.docs-tier-badge--complete {
  background: #e0e7ff;
  color: #3730a3;
}

/* ── Grids, Cards, Panels ───────────────────────────────────────────────── */

.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.docs-card {
  min-width: 0;
  padding: 1.2rem;
  border: 1px solid var(--docs-border);
  border-radius: 0.75rem;
  background: var(--docs-panel-bg);
}

.docs-card h3 {
  margin: 0 0 0.45rem;
  color: var(--docs-text);
  font-size: 1.02rem;
}

.docs-card p {
  margin: 0;
  color: var(--docs-text-muted);
  line-height: 1.58;
}

.docs-panel {
  padding: 1.2rem;
  border-radius: 0.65rem;
  border-inline-start: 4px solid #1d4ed8;
  border-block: 1px solid var(--docs-border);
  border-inline-end: 1px solid var(--docs-border);
  background: var(--docs-panel-muted);
}

.docs-panel--note {
  border-inline-start-color: #a16207;
  background: #fef3c7;
}

.docs-panel p {
  margin: 0;
  color: var(--docs-text);
  line-height: 1.6;
}

.docs-list {
  margin: 0.8rem 0 0;
  padding-inline-start: 1.35rem;
}

.docs-list li {
  margin-block-end: 0.4rem;
  color: var(--docs-text-muted);
  line-height: 1.6;
}

.docs-note {
  margin-block-start: 0.8rem;
  color: var(--docs-text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* ── Tables and Code Overflow ────────────────────────────────────────────── */

.docs-table-wrap {
  max-inline-size: 100%;
  overflow: auto hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--docs-border);
  border-radius: 0.65rem;
  background: var(--docs-panel-bg);
}

.docs-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.docs-table th,
.docs-table td {
  padding: 0.7rem 0.9rem;
  border-block-end: 1px solid var(--docs-border);
  text-align: left;
}

.docs-table th {
  color: var(--docs-text);
  font-weight: 650;
}

.docs-table td {
  color: var(--docs-text-muted);
  vertical-align: top;
}

.docs-content pre {
  max-inline-size: 100%;
  overflow: auto hidden;
  overscroll-behavior-x: contain;
  border: 1px solid var(--docs-border);
  border-radius: 0.5rem;
  padding: 0.8rem;
  background: #f1f5f9;
}

.docs-content code {
  overflow-wrap: anywhere;
}

.docs-content :not(pre) > code,
.docs-table td code {
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  background: #e2e8f0;
  color: #0f172a;
}

/* ── CTA ─────────────────────────────────────────────────────────────────── */

.docs-cta {
  margin-block-end: 2rem;
  padding: 2rem;
  border: 1px solid var(--docs-border);
  border-radius: 0.9rem;
  background: var(--docs-panel-muted);
}

.docs-cta h2 {
  margin: 0 0 0.55rem;
  font-size: clamp(1.2rem, 1.8vw, 1.55rem);
  color: var(--docs-text);
}

.docs-cta p {
  margin: 0 0 1.1rem;
  color: var(--docs-text-muted);
  line-height: 1.55;
}

/* ── Links ───────────────────────────────────────────────────────────────── */

.docs-content a:not(.docs-button) {
  color: var(--docs-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.docs-content a:not(.docs-button):hover {
  color: var(--docs-link-hover);
}

/* ── Responsive & Zoom Resilience ───────────────────────────────────────── */

@media (width <= 1200px) {
  .docs-content {
    padding-inline: 2rem;
  }
}

@media (width <= 1024px) {
  #main.docs-shell {
    block-size: var(--docs-shell-height);
  }

  .docs-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 40%) minmax(0, 1fr);
  }

  .docs-sidebar {
    max-inline-size: none;
    min-inline-size: 0;
    border-inline-end: none;
    border-block-end: 1px solid var(--docs-border);
    box-shadow: 0 1px 8px rgb(2 6 23 / 6%);
  }

  .docs-content {
    min-block-size: 0;
    padding: 1.4rem 1.2rem 2.2rem;
  }

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

@media (width <= 700px) {
  .docs-hero {
    padding: 1.4rem;
  }

  .docs-hero__actions,
  .docs-cta__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .docs-step {
    gap: 0.7rem;
  }

  .docs-step__number {
    inline-size: 2rem;
    block-size: 2rem;
    font-size: 0.95rem;
  }
}

@media (width <= 1024px) and (orientation: landscape) {
  .docs-layout {
    grid-template-rows: minmax(0, 48%) minmax(0, 1fr);
  }
}

/* ── Dark Scheme ─────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  body[data-site-surface="docs"] {
    --docs-bg: #0b1220;
    --docs-panel-bg: #111827;
    --docs-panel-muted: #0f172a;
    --docs-border: #2b3a52;
    --docs-border-strong: #425577;
    --docs-text: #f8fafc;
    --docs-text-muted: #cbd5e1;
    --docs-link: #93c5fd;
    --docs-link-hover: #bfdbfe;
    --docs-focus: #93c5fd;
  }

  .docs-sidebar {
    box-shadow: 1px 0 8px rgb(0 0 0 / 25%);
  }

  .docs-nav__link:hover {
    background: #17233a;
    border-color: #2f4368;
  }

  .docs-nav__link.active {
    background: #1d2f4f;
    border-color: #3f5f98;
    color: #e2e8f0;
  }

  .docs-panel--note {
    background: #3b2f12;
    border-inline-start-color: #f59e0b;
  }

  .docs-content :not(pre) > code,
  .docs-table td code {
    background: #1f2937;
    color: #f8fafc;
  }

  .docs-content pre {
    background: #0f172a;
  }

  .docs-button--secondary {
    background: #111827;
    color: #f8fafc;
  }

  .docs-button--secondary:hover {
    background: #17233a;
    border-color: #4d648d;
  }

  body[data-site-surface="docs"] .site-header,
  body[data-site-surface="docs"] .site-header__menu {
    border-color: #334155;
    background: #0f172a;
  }

  body[data-site-surface="docs"] .site-header__link,
  body[data-site-surface="docs"] .site-header__btn--ghost {
    color: #e2e8f0;
  }

  body[data-site-surface="docs"] .site-header__link:hover,
  body[data-site-surface="docs"] .site-header__link:focus-visible,
  body[data-site-surface="docs"] .site-header__btn--ghost:hover,
  body[data-site-surface="docs"] .site-header__btn--ghost:focus-visible {
    color: #f8fafc;
    background: #1e293b;
    border-color: #64748b;
  }
}

/* ── Forced Colors / High Contrast ──────────────────────────────────────── */

@media (forced-colors: active) {
  body[data-site-surface="docs"] .site-header,
  body[data-site-surface="docs"] .site-header__menu {
    forced-color-adjust: none;
    color: CanvasText;
    background: Canvas;
    border-color: CanvasText;
  }

  body[data-site-surface="docs"] .site-header__link,
  body[data-site-surface="docs"] .site-header__btn {
    forced-color-adjust: none;
    color: CanvasText;
    background: Canvas;
    border-color: CanvasText;
  }

  body[data-site-surface="docs"] .site-header__link:focus-visible,
  body[data-site-surface="docs"] .site-header__btn:focus-visible,
  body[data-site-surface="docs"] .site-header__link:hover,
  body[data-site-surface="docs"] .site-header__btn:hover {
    color: HighlightText;
    background: Highlight;
    border-color: Highlight;
  }

  .docs-sidebar,
  .docs-hero,
  .docs-card,
  .docs-panel,
  .docs-table-wrap,
  .docs-cta {
    border: 1px solid CanvasText;
    box-shadow: none;
  }

  .docs-nav__link {
    forced-color-adjust: none;
    border: 1px solid transparent;
    color: CanvasText;
    background: Canvas;
  }

  .docs-nav__link.active,
  .docs-nav__link:hover,
  .docs-nav__link:focus-visible {
    forced-color-adjust: none;
    border-color: Highlight;
    color: HighlightText;
    background: Highlight;
  }

  .docs-hero__label,
  .docs-tier-badge {
    forced-color-adjust: none;
    color: CanvasText;
    background: Canvas;
    border: 1px solid CanvasText;
  }

  .docs-heading-anchor {
    opacity: 1;
  }
}

/* ── Motion Safety ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .docs-nav__link,
  .docs-button {
    transition: none;
  }
}
