/* Shared CSS variables — single source of truth for landing site and docs.
 * Landing site: resolved by Vite CSS processing via @import.
 * Docs site: inlined by vite-plugin-docs during build via @import resolution. */

:root {
  --warm-indigo: #5d3fd3;
  --warm-amber: #ffb347;
  --charcoal: #1a1a2e;
  --off-white: #f8f9fb;
  --white: #ffffff;
  --gray-100: #f3f4f6;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --warm-indigo: #7b61e0;
    --charcoal: #e8e9ed;
    --off-white: #0f1117;
    --white: #1a1f2e;
    --gray-100: #1e2332;
    --gray-300: #2e3446;
    --gray-500: #8b95a5;
    --gray-700: #c8cdd5;
  }
}


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

/* --- Skip to content (accessibility) --- */
.skip-to-content {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  padding: 8px 16px;
  background: var(--warm-indigo);
  color: var(--white);
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
}

.skip-to-content:focus {
  left: 0;
}

/* --- Auth pending (hidden until JS runs) --- */
.auth-pending {
  visibility: hidden;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--charcoal);
  background: var(--off-white);
  line-height: 1.6;
}

/* --- Nav (shared with landing) --- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.logo-img {
  height: 32px;
  width: auto;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  color: var(--gray-700);
  text-decoration: none;
  font-size: 0.95rem;
}
.nav-link:hover {
  color: var(--warm-indigo);
}
.nav-link-active {
  color: var(--warm-indigo);
  font-weight: 600;
}

.btn {
  display: inline-block;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:hover {
  opacity: 0.9;
}
.btn-primary {
  background: var(--warm-indigo);
  color: var(--white);
}

/* --- Focus styles (accessibility) --- */
:focus-visible {
  outline: 2px solid var(--warm-indigo);
  outline-offset: 2px;
}

/* --- Docs layout --- */
.docs-layout {
  display: flex;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: calc(100vh - 180px);
}

/* --- Sidebar --- */
.docs-sidebar {
  width: 220px;
  min-width: 220px;
  padding: 24px 16px 24px 0;
  position: sticky;
  top: 0;
  height: fit-content;
  max-height: 100vh;
  overflow-y: auto;
}

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin: 20px 0 6px;
}

.sidebar-label:first-child {
  margin-top: 0;
}

.docs-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.docs-sidebar li a {
  display: block;
  padding: 4px 10px;
  font-size: 0.875rem;
  color: var(--gray-700);
  text-decoration: none;
  border-radius: 4px;
  transition:
    background 0.1s,
    color 0.1s;
}

.docs-sidebar li a:hover {
  background: var(--gray-100);
  color: var(--warm-indigo);
}

.docs-sidebar li a.active {
  background: rgba(93, 63, 211, 0.08);
  color: var(--warm-indigo);
  font-weight: 600;
}

.sidebar-toggle {
  display: none;
}

/* --- Content area --- */
.docs-content {
  flex: 1;
  min-width: 0;
  max-width: 720px;
  padding: 24px 0 64px 40px;
}

.docs-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.2;
}

.docs-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 40px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-300);
}

.docs-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 28px 0 8px;
}

.docs-content p {
  margin: 12px 0;
  font-size: 1rem;
  line-height: 1.7;
}

.docs-content ul,
.docs-content ol {
  margin: 12px 0;
  padding-left: 24px;
}

.docs-content li {
  margin: 6px 0;
  font-size: 1rem;
  line-height: 1.7;
}

.docs-content a {
  color: var(--warm-indigo);
  text-decoration: none;
}
.docs-content a:hover {
  text-decoration: underline;
}

.docs-content strong {
  font-weight: 600;
}

/* --- Code blocks --- */
.docs-content pre {
  margin: 16px 0;
  padding: 16px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  border: 1px solid var(--gray-300);
}

.docs-content code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.875em;
}

.docs-content :not(pre) > code {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* Shiki-generated code blocks — fallback background for blocks where Shiki's
 * inline styles failed to apply (syntax error catch branch in the plugin).
 * Normal Shiki blocks have inline background-color that takes precedence. */
.docs-content pre.shiki {
  background: var(--gray-100);
}

/* --- Heading anchors --- */
.heading-anchor {
  color: inherit;
  text-decoration: none;
}

.heading-anchor:hover {
  text-decoration: underline;
}

/* --- Tables --- */
.docs-content table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 0.925rem;
}

.docs-content th {
  text-align: left;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 2px solid var(--gray-300);
}

.docs-content td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
}

.docs-content tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.015);
}

/* --- Docs index page --- */
.docs-index-subtitle {
  color: var(--gray-500);
  font-size: 1.1rem;
  margin-bottom: 32px;
}

.docs-index-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.docs-index-card {
  display: block;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.docs-index-card:hover {
  border-color: var(--warm-indigo);
  box-shadow: 0 2px 8px rgba(93, 63, 211, 0.1);
}

.docs-index-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--charcoal);
  margin: 0 0 6px;
}

.docs-index-card p {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin: 0;
  line-height: 1.5;
}

/* --- Footer (shared with landing) --- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
  border-top: 1px solid var(--gray-300);
}

.logo-sm {
  height: 24px;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.9rem;
}
.footer-links a:hover {
  color: var(--warm-indigo);
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--gray-500);
}

/* --- Sidebar backdrop (mobile) --- */
.sidebar-backdrop {
  display: none;
}

/* --- Mobile --- */
@media (max-width: 768px) {
  .nav {
    padding: 12px 16px;
  }
  .nav-links {
    gap: 10px;
  }
  .nav-links .nav-link {
    display: none;
  }
  /* Show only the first nav link (Docs) on mobile; hides Sign in */
  .nav-links .nav-link:first-child {
    display: inline;
    font-size: 0.85rem;
  }
  .nav-links .btn {
    padding: 8px 16px;
    font-size: 0.85rem;
  }

  .docs-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--white);
    z-index: 100;
    padding: 24px;
    border-right: 1px solid var(--gray-300);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.1);
  }

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

  .sidebar-backdrop.visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
  }

  .sidebar-toggle {
    display: inline-block;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 6px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    margin-bottom: 16px;
    align-self: flex-start;
  }

  .docs-layout {
    flex-direction: column;
  }

  .docs-content {
    padding-left: 0;
  }

  .docs-index-grid {
    grid-template-columns: 1fr;
  }

  .footer {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

/* --- Dark mode (OS preference) ---
 * Variable overrides are in ../shared/variables.css (shared with landing site).
 * Only site-specific fixes below. */
@media (prefers-color-scheme: dark) {
  /* --white is now a dark surface; fix elements using it for text-on-color */
  .skip-to-content,
  .btn-primary {
    color: #f3f4f6;
  }

  .docs-sidebar li a.active {
    background: rgba(123, 97, 224, 0.15);
  }

  .docs-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
  }

  .docs-index-card:hover {
    box-shadow: 0 2px 8px rgba(123, 97, 224, 0.15);
  }

  /* Shiki dual-theme: swap to dark token colors */
  .shiki,
  .shiki span {
    color: var(--shiki-dark) !important;
    background-color: var(--shiki-dark-bg) !important;
    font-style: var(--shiki-dark-font-style) !important;
    font-weight: var(--shiki-dark-font-weight) !important;
    text-decoration: var(--shiki-dark-text-decoration) !important;
  }
}

@media (prefers-color-scheme: dark) and (max-width: 768px) {
  .docs-sidebar {
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.4);
  }

  .sidebar-backdrop.visible {
    background: rgba(0, 0, 0, 0.6);
  }
}

/* --- Prev/next pagination footer (#81) --- */

.docs-pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--gray-300);
}

.docs-pagination-prev,
.docs-pagination-next {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--gray-300);
  border-radius: 0.5rem;
  text-decoration: none;
  color: inherit;
  transition:
    border-color 0.15s,
    background-color 0.15s;
}

.docs-pagination-prev:hover,
.docs-pagination-next:hover {
  border-color: var(--warm-indigo);
  background-color: var(--gray-100);
}

.docs-pagination-next {
  text-align: right;
  grid-column: 2;
}

.docs-pagination-prev {
  grid-column: 1;
}

.docs-pagination-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
}

.docs-pagination-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--charcoal);
}

@media (max-width: 600px) {
  .docs-pagination {
    grid-template-columns: 1fr;
  }
  .docs-pagination-prev,
  .docs-pagination-next {
    grid-column: 1;
  }
  .docs-pagination-next {
    text-align: left;
  }
}

/* --gray-100 already flips dark in variables.css's
   prefers-color-scheme: dark block, so the hover background works
   in both modes without a dedicated rule. */

/* --- Pagefind search widget (#82) --- */

.docs-search {
  margin-bottom: 1.25rem;
  /* Pagefind's default UI sets its own widths; constrain just the
     outer padding so the input lines up with the sidebar links. */
}

/* Pagefind's default UI uses `--pagefind-ui-*` vars; tune them to match
   the docs theme so the search widget doesn't look like a foreign body. */
.docs-search .pagefind-ui {
  --pagefind-ui-font: inherit;
  --pagefind-ui-text: var(--charcoal);
  --pagefind-ui-background: var(--white);
  --pagefind-ui-border: var(--gray-300);
  --pagefind-ui-primary: var(--warm-indigo);
  --pagefind-ui-tag: var(--gray-500);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 0.5rem;
  --pagefind-ui-image-border-radius: 0.5rem;
}
