/**
 * Murmur Docs — Layout & Typography
 *
 * Depends on (loaded before this file):
 *   /css/reset.css
 *   /css/variables.css
 *   /css/layout.css       (provides .skip-link, .sr-only, :focus-visible, body)
 *   /css/components.css   (provides .btn, .theme-toggle, .nav-link, .logo-icon)
 *
 * All colors, fonts, spacing, and radii are consumed via CSS custom properties
 * defined in variables.css. Nothing is hardcoded here.
 */

/* ==========================================================================
   DOCS HEADER — fixed, full-width, 56 px tall
   ========================================================================== */

.docs-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
}

.docs-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 100%;
  padding: 0 var(--space-4);
  max-width: 100%;
}

.docs-header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: var(--text-base);
  color: var(--color-text);
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
}

.docs-header__logo:hover {
  color: var(--color-accent);
}

.docs-header__logo img {
  display: block;
}

/* Vertical divider after logo */
.docs-header__divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* "Documentation" label beside divider */
.docs-header__label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Center search bar — grows to fill available space */
.docs-header__search {
  flex: 1;
  max-width: 420px;
  margin: 0 auto;
  position: relative;
}

.docs-header__search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.docs-header__search input {
  width: 100%;
  height: 34px;
  padding: 0 var(--space-3) 0 2.1rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.docs-header__search input::placeholder {
  color: var(--color-text-secondary);
}

.docs-header__search input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

/* Right-side actions */
.docs-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  flex-shrink: 0;
}

.docs-header__back {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
  margin-left: auto;
}

.docs-header__back:hover {
  color: var(--color-accent);
  background: var(--color-accent-light);
}

/* Mobile sidebar toggle — hamburger, hidden on desktop */
.docs-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.docs-sidebar-toggle:hover {
  color: var(--color-text);
  background: var(--color-accent-light);
}

/* ==========================================================================
   ROOT LAYOUT
   ========================================================================== */

/* Offset for fixed header */
.docs-page {
  padding-top: 56px;
}

/* Two-column grid: sidebar | content */
.docs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 56px);
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.docs-sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
  background: var(--color-bg);
  padding: var(--space-3) 0 var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Subtle scrollbar on WebKit */
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.docs-sidebar::-webkit-scrollbar {
  width: 4px;
}

.docs-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

/* Search block pinned at top of sidebar */
.docs-search {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-bg);
  padding: var(--space-3) var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
}

.docs-search-wrap {
  position: relative;
}

.docs-search-wrap svg {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  pointer-events: none;
}

.docs-search input {
  width: 100%;
  height: 34px;
  padding: 0 var(--space-3) 0 2rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
}

.docs-search input::placeholder {
  color: var(--color-text-secondary);
}

.docs-search input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

/* ==========================================================================
   SIDEBAR NAVIGATION
   ========================================================================== */

.docs-nav {
  flex: 1;
  padding: 0 var(--space-2);
}

/* Category group */
.docs-nav details {
  /* Remove default disclosure triangle — we supply our own in summary */
  list-style: none;
}

.docs-nav details + details {
  margin-top: var(--space-1);
}

/* Category heading */
.docs-nav summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  user-select: none;
  /* Remove default WebKit marker */
}

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

.docs-nav summary:hover {
  color: var(--color-text);
  background: var(--color-bg-alt);
}

/* Chevron arrow indicator on summary */
.docs-nav summary::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
  margin-right: 2px;
}

.docs-nav details[open] > summary::after {
  transform: rotate(45deg);
}

/* Article link list inside a category */
.docs-nav details > ul {
  list-style: none;
  padding: 0;
  margin: var(--space-1) 0 var(--space-2) var(--space-3);
}

.docs-nav details > ul > li {
  margin: 1px 0;
}

/* Article link */
.docs-nav a {
  display: block;
  padding: 0.4rem var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  line-height: var(--lh-snug);
}

.docs-nav a:hover {
  color: var(--color-text);
  background: var(--color-accent-light);
}

/* Active / current page */
.docs-nav a.is-active {
  color: var(--color-accent);
  background: var(--color-accent-light);
  font-weight: var(--fw-medium);
}

/* Search results — flat list without category details */
.docs-nav--search-results .docs-search-heading {
  padding: 0.45rem var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
}

.docs-nav--search-results ul {
  list-style: none;
  padding: 0;
  margin: var(--space-1) 0;
}

.docs-nav--search-results li {
  margin: 1px 0;
}

.docs-nav--search-results a {
  display: block;
  padding: 0.4rem var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.docs-nav--search-results a:hover {
  color: var(--color-text);
  background: var(--color-accent-light);
}

.docs-nav--search-results .result-title {
  display: block;
  font-weight: var(--fw-medium);
  color: var(--color-text);
}

.docs-nav--search-results .result-summary {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: 1px;
  line-height: var(--lh-snug);
}

.docs-nav--no-results {
  padding: var(--space-3) var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-align: center;
}

/* ==========================================================================
   CONTENT AREA
   ========================================================================== */

.docs-content {
  min-width: 0; /* prevent grid blowout */
  padding: var(--space-5) var(--space-6);
}

.docs-article {
  max-width: 760px;
  margin: 0 auto;
}

/* ==========================================================================
   ARTICLE TYPOGRAPHY
   ========================================================================== */

.docs-article h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
  color: var(--color-text);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.docs-article h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  color: var(--color-text);
  margin-top: 2.5rem;
  margin-bottom: var(--space-3);
}

.docs-article h3 {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  color: var(--color-text);
  margin-top: 1.75rem;
  margin-bottom: var(--space-2);
}

.docs-article h4 {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.docs-article p {
  font-size: var(--text-base);
  line-height: var(--lh-relaxed);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.docs-article ul,
.docs-article ol {
  font-size: var(--text-base);
  line-height: var(--lh-relaxed);
  color: var(--color-text);
  margin-bottom: var(--space-3);
  padding-left: 1.5rem;
}

.docs-article ul {
  list-style: disc;
}

.docs-article ol {
  list-style: decimal;
}

.docs-article li {
  margin-bottom: 0.375rem;
}

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

/* Inline code */
.docs-article code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  color: var(--color-text);
}

/* Code block */
.docs-article pre {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  overflow-x: auto;
  margin-bottom: var(--space-3);
}

.docs-article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-sm);
  line-height: var(--lh-relaxed);
  border-radius: 0;
}

/* Links */
.docs-article a {
  color: var(--color-accent);
  text-decoration: none;
}

.docs-article a:hover {
  text-decoration: underline;
}

/* Images */
.docs-article img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  display: block;
  margin: var(--space-4) 0;
}

/* Blockquote / callout — mirrors .legal-highlight */
.docs-article blockquote {
  background: var(--color-bg-alt);
  border-left: 4px solid var(--color-accent);
  padding: var(--space-4);
  margin: var(--space-4) 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.docs-article blockquote p {
  margin-bottom: 0;
  color: var(--color-text);
}

/* Horizontal rule */
.docs-article hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

/* Tables */
.docs-article table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.docs-article th {
  background: var(--color-bg-alt);
  padding: 0.6rem var(--space-3);
  text-align: left;
  font-weight: var(--fw-semibold);
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text);
}

.docs-article td {
  padding: 0.6rem var(--space-3);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: top;
}

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

/* Strong / em */
.docs-article strong {
  font-weight: var(--fw-semibold);
}

/* ==========================================================================
   BREADCRUMB
   ========================================================================== */

.docs-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}

.docs-breadcrumb a {
  color: var(--color-accent);
  text-decoration: none;
}

.docs-breadcrumb a:hover {
  text-decoration: underline;
}

.docs-breadcrumb__sep {
  color: var(--color-border-strong);
  margin: 0 0.1rem;
  user-select: none;
}

.docs-breadcrumb__current {
  color: var(--color-text-secondary);
}

/* ==========================================================================
   PAGINATION
   ========================================================================== */

.docs-pagination {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-4);
  margin-top: var(--space-6);
  gap: var(--space-3);
}

.docs-pagination__prev,
.docs-pagination__next {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.docs-pagination__next {
  text-align: right;
}

.docs-pagination__label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
}

.docs-pagination a {
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.docs-pagination a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.docs-pagination__prev a::before {
  content: '\2190\00a0'; /* ← */
}

.docs-pagination__next a::after {
  content: '\00a0\2192'; /* → */
}

/* ==========================================================================
   DOCS LANDING PAGE (docs/index.html)
   ========================================================================== */

.docs-hero {
  text-align: center;
  padding: var(--space-7) var(--space-4) var(--space-5);
  max-width: 640px;
  margin: 0 auto;
}

.docs-hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.docs-hero p {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  line-height: var(--lh-relaxed);
  margin-bottom: var(--space-4);
}

/* Hero search bar */
.docs-hero-search {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
}

.docs-hero-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  pointer-events: none;
}

.docs-hero-search input {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-4) 0 2.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
}

.docs-hero-search input::placeholder {
  color: var(--color-text-secondary);
}

.docs-hero-search input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

/* Category grid */
.docs-grid-section {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--space-4) var(--space-7);
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-3);
}

/* Category card */
.docs-card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.docs-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.docs-card__icon {
  font-size: 1.5rem;
  line-height: 1;
}

.docs-card__title {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  line-height: var(--lh-snug);
}

.docs-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--lh-normal);
}

.docs-card__count {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: auto;
}

/* ==========================================================================
   MOBILE OVERLAY — rendered by docs-nav.js
   ========================================================================== */

.docs-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
  opacity: 0;
  animation: overlay-in var(--transition-fast) forwards;
}

@keyframes overlay-in {
  to { opacity: 1; }
}

/* ==========================================================================
   RESPONSIVE — mobile first breakpoint at 767px
   ========================================================================== */

@media (max-width: 767px) {

  /* Show mobile toggle, hide header search */
  .docs-sidebar-toggle {
    display: flex;
  }

  .docs-header__search {
    display: none;
  }

  .docs-header__label {
    display: none;
  }

  .docs-header__divider {
    display: none;
  }

  /* Single-column layout */
  .docs-layout {
    grid-template-columns: 1fr;
  }

  /* Sidebar becomes a fixed off-canvas drawer */
  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    height: 100dvh;
    z-index: 95;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    border-right: 1px solid var(--color-border);
    /* Override sticky to fixed so it can slide */
    padding-top: 56px; /* account for header */
  }

  .docs-sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  /* Content takes full width */
  .docs-content {
    padding: var(--space-4) var(--space-3);
  }

  /* Article headings scale down */
  .docs-article h1 {
    font-size: var(--text-3xl);
  }

  .docs-article h2 {
    font-size: var(--text-xl);
  }

  /* Hero heading */
  .docs-hero h1 {
    font-size: var(--text-3xl);
  }

  /* Pagination stacks on very small screens */
  .docs-pagination {
    flex-direction: column;
    align-items: flex-start;
  }

  .docs-pagination__next {
    text-align: left;
  }

  /* Grid min card width shrinks */
  .docs-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* ==========================================================================
   PRINT — hide chrome, full-width article
   ========================================================================== */

@media print {
  .docs-header,
  .docs-sidebar,
  .docs-sidebar-toggle,
  .docs-pagination,
  .docs-breadcrumb {
    display: none !important;
  }

  .docs-layout {
    display: block;
  }

  .docs-content {
    padding: 0;
  }

  .docs-article {
    max-width: 100%;
  }

  .docs-page {
    padding-top: 0;
  }
}
