/* LinkSIM documentation shell — premium responsive docs */

@import url("https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;500;600;700&family=Source+Serif+4:opsz,wght@8..60,600;8..60,700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --docs-sidebar-w: 280px;
  --docs-topbar-h: 56px;
  --docs-max: 820px;
}

html {
  scroll-behavior: smooth;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.docs-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--ls-font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ls-text);
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(21, 112, 239, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(240, 180, 41, 0.08), transparent 50%),
    var(--ls-background);
}

[data-theme="dark"] body.docs-body,
html[data-theme="dark"] body.docs-body {
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(28, 210, 252, 0.1), transparent 55%),
    radial-gradient(ellipse 50% 35% at 0% 100%, rgba(26, 124, 255, 0.08), transparent 50%),
    var(--ls-background);
}

a {
  color: var(--ls-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--ls-cyan, #1cd2fc);
}

/* —— Topbar —— */
.docs-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--docs-topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--ls-surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ls-border);
}

.docs-menu-btn,
.docs-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--ls-border);
  border-radius: 10px;
  background: var(--ls-elevated, var(--ls-surface));
  color: var(--ls-text);
  cursor: pointer;
}

.docs-menu-btn {
  display: none;
}

.docs-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.docs-brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.docs-brand span.product {
  font-family: var(--ls-font-display);
  font-size: 1.15rem;
}

.docs-search-wrap {
  flex: 1;
  max-width: 420px;
  margin-left: auto;
  position: relative;
}

.docs-search {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--ls-border);
  border-radius: 10px;
  background: var(--ls-background);
  color: var(--ls-text);
  font: inherit;
}

.docs-search:focus {
  outline: 2px solid var(--ls-focus-ring);
  outline-offset: 1px;
}

.docs-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  opacity: 0.55;
  pointer-events: none;
}

.docs-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow: auto;
  background: var(--ls-elevated, var(--ls-surface));
  border: 1px solid var(--ls-border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(5, 13, 26, 0.18);
  z-index: 50;
}

.docs-search-results.open {
  display: block;
}

.docs-search-results a {
  display: block;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--ls-text);
  border-bottom: 1px solid var(--ls-border);
}

.docs-search-results a:last-child {
  border-bottom: none;
}

.docs-search-results a:hover,
.docs-search-results a[aria-selected="true"] {
  background: var(--ls-primary-muted);
}

.docs-search-results .meta {
  display: block;
  font-size: 0.8rem;
  color: var(--ls-muted);
  margin-top: 2px;
}

.docs-search-empty {
  padding: 14px;
  color: var(--ls-muted);
  font-size: 0.9rem;
}

.docs-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.docs-version-pill {
  display: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ls-secondary-muted);
  color: var(--ls-gold, var(--ls-secondary));
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* —— Layout —— */
.docs-shell {
  display: flex;
  min-height: calc(100vh - var(--docs-topbar-h));
}

.docs-sidebar {
  position: sticky;
  top: var(--docs-topbar-h);
  align-self: flex-start;
  width: var(--docs-sidebar-w);
  height: calc(100vh - var(--docs-topbar-h));
  overflow-y: auto;
  padding: 20px 14px 40px;
  border-right: 1px solid var(--ls-border);
  background: color-mix(in srgb, var(--ls-surface) 70%, transparent);
  flex-shrink: 0;
}

.docs-sidebar-group {
  margin-bottom: 18px;
}

.docs-sidebar-group h2 {
  margin: 0 0 8px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ls-muted);
}

.docs-sidebar a {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ls-text);
  font-size: 0.92rem;
  font-weight: 500;
}

.docs-sidebar a:hover {
  background: var(--ls-primary-muted);
}

.docs-sidebar a.active {
  background: var(--ls-primary-muted);
  color: var(--ls-primary);
  font-weight: 650;
}

.docs-main {
  flex: 1;
  min-width: 0;
  padding: 32px 28px 96px;
}

.docs-article {
  max-width: var(--docs-max);
  margin: 0 auto;
}

.docs-article > h1:first-child,
.docs-article .docs-page-title {
  font-family: var(--ls-font-display);
  font-size: clamp(1.85rem, 3.5vw, 2.45rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 10px;
}

.docs-lead {
  color: var(--ls-muted);
  font-size: 1.08rem;
  max-width: 42rem;
  margin: 0 0 1.5rem;
}

.docs-article h2 {
  font-family: var(--ls-font-display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  margin: 2.4rem 0 0.75rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--ls-border);
  scroll-margin-top: calc(var(--docs-topbar-h) + 12px);
}

.docs-article h3 {
  font-size: 1.08rem;
  margin: 1.5rem 0 0.5rem;
  scroll-margin-top: calc(var(--docs-topbar-h) + 12px);
}

.docs-article h4 {
  font-size: 0.98rem;
  margin: 1.2rem 0 0.4rem;
}

.docs-article p {
  margin: 0 0 1rem;
}

.docs-article ul,
.docs-article ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.docs-article li {
  margin: 0.35rem 0;
}

.docs-article li > ul,
.docs-article li > ol {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.docs-crumb {
  font-size: 0.85rem;
  color: var(--ls-muted);
  margin-bottom: 12px;
}

.docs-crumb a {
  color: var(--ls-muted);
  text-decoration: none;
}

.docs-crumb a:hover {
  color: var(--ls-primary);
}

.docs-footer-meta {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ls-border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--ls-muted);
}

/* —— Code —— */
.docs-article code,
.docs-article kbd {
  font-family: var(--ls-font-mono);
  font-size: 0.86em;
  padding: 0.12em 0.35em;
  border-radius: 5px;
  background: var(--ls-primary-muted);
}

.docs-pre-wrap {
  position: relative;
  margin: 0 0 1.25rem;
}

.docs-article pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--ls-font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  background: var(--ls-navy-deep, #050d1a);
  color: #e8eef5;
  border: 1px solid var(--ls-border);
  border-radius: var(--ls-radius-card);
}

[data-theme="light"] .docs-article pre {
  background: #0b1b2b;
  color: #e8eef5;
}

.docs-article pre code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

.docs-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid rgba(232, 238, 245, 0.2);
  border-radius: 6px;
  background: rgba(15, 39, 68, 0.85);
  color: #e8eef5;
  cursor: pointer;
}

.docs-copy-btn:hover {
  background: rgba(26, 124, 255, 0.45);
}

.docs-copy-btn.copied {
  color: var(--ls-success);
}

/* —— Tables —— */
.docs-article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 0 0 1.25rem;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--ls-border);
}

.docs-article th,
.docs-article td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--ls-border);
}

.docs-article th {
  background: var(--ls-surface);
  font-weight: 650;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.docs-article tr:last-child td {
  border-bottom: none;
}

.docs-article tbody tr:hover td {
  background: color-mix(in srgb, var(--ls-primary-muted) 45%, transparent);
}

.docs-table-scroll {
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.docs-table-scroll table {
  margin-bottom: 0;
}

/* —— Callouts —— */
.callout,
.warning,
.success,
.info {
  margin: 1rem 0 1.25rem;
  padding: 14px 16px;
  border-radius: 0 12px 12px 0;
  border-left: 3px solid;
  background: var(--ls-surface);
}

.callout {
  border-left-color: var(--ls-secondary);
  background: var(--ls-secondary-muted);
}

.info {
  border-left-color: var(--ls-info);
  background: var(--ls-primary-muted);
}

.warning {
  border-left-color: var(--ls-warning);
  background: color-mix(in srgb, var(--ls-warning) 12%, var(--ls-surface));
}

.success {
  border-left-color: var(--ls-success);
  background: color-mix(in srgb, var(--ls-success) 12%, var(--ls-surface));
}

.callout strong,
.warning strong,
.success strong,
.info strong {
  display: block;
  margin-bottom: 4px;
}

.callout > :last-child,
.warning > :last-child,
.success > :last-child,
.info > :last-child {
  margin-bottom: 0;
}

/* —— Diagrams —— */
.docs-diagram {
  margin: 1.25rem 0;
  padding: 20px;
  background: var(--ls-surface);
  border: 1px solid var(--ls-border);
  border-radius: var(--ls-radius-card);
  overflow-x: auto;
}

.docs-diagram svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.docs-diagram figcaption {
  margin-top: 12px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ls-muted);
}

/* —— Cards / grid (index) —— */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 1.5rem 0;
}

.docs-card {
  display: block;
  padding: 16px 18px;
  background: var(--ls-surface);
  border: 1px solid var(--ls-border);
  border-radius: var(--ls-radius-card);
  text-decoration: none;
  color: inherit;
  transition:
    border-color var(--ls-motion-fast) var(--ls-easing-standard),
    transform var(--ls-motion-fast) var(--ls-easing-standard);
}

.docs-card:hover {
  border-color: var(--ls-primary);
  transform: translateY(-1px);
  color: inherit;
}

.docs-card strong {
  display: block;
  font-size: 0.98rem;
}

.docs-card span {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--ls-muted);
  font-weight: 400;
}

.docs-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--ls-surface);
  border: 1px solid var(--ls-border);
  border-radius: var(--ls-radius-card);
}

.docs-check input {
  margin-top: 4px;
}

.muted {
  color: var(--ls-muted);
}

/* Brand swatches */
.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin: 1rem 0 1.5rem;
}

.swatch {
  border-radius: var(--ls-radius-card);
  overflow: hidden;
  border: 1px solid var(--ls-border);
  background: var(--ls-surface);
}

.swatch .chip {
  height: 56px;
}

.swatch p {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.8rem;
}

.mark {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  box-shadow: 0 8px 24px rgba(5, 13, 26, 0.12);
  display: block;
  margin-bottom: 12px;
}

.docs-toc {
  margin: 0 0 1.5rem;
  padding: 14px 16px;
  background: var(--ls-surface);
  border: 1px solid var(--ls-border);
  border-radius: 12px;
}

.docs-toc strong {
  display: block;
  margin-bottom: 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ls-muted);
}

.docs-toc a {
  display: block;
  padding: 3px 0;
  text-decoration: none;
  font-size: 0.92rem;
}

/* —— Mobile nav overlay —— */
.docs-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  background: var(--ls-overlay);
}

.docs-backdrop.open {
  display: block;
}

@media (max-width: 960px) {
  .docs-menu-btn {
    display: inline-flex;
  }

  .docs-version-pill {
    display: none;
  }

  .docs-sidebar {
    position: fixed;
    top: var(--docs-topbar-h);
    left: 0;
    z-index: 38;
    transform: translateX(-105%);
    transition: transform var(--ls-motion-normal) var(--ls-easing-standard);
    box-shadow: 8px 0 32px rgba(5, 13, 26, 0.2);
    background: var(--ls-surface);
  }

  .docs-sidebar.open {
    transform: translateX(0);
  }

  .docs-main {
    padding: 24px 18px 80px;
  }

  .docs-search-wrap {
    max-width: none;
  }
}

@media (min-width: 1100px) {
  .docs-version-pill {
    display: inline-block;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .docs-card,
  .docs-sidebar {
    transition: none;
  }
}
