/* ============================================================
   Hugo Book – Features page  (docs-style SPA layout)
   ============================================================ */

:root {
  --book-text: #1a1a1a;
  --book-text-muted: #555;
  --book-background: #fff;
  --book-border: #e5e5e5;
  --book-sidebar-bg: #f7f7f8;
  --book-sidebar-width: 240px;
  --book-active-gradient: linear-gradient(135deg, #2d79ff 0%, #4c9bff 100%);
  --book-active-bg: rgba(45, 121, 255, 0.08);
  --book-active-color: #1d6af5;
}

html[data-theme="dark"] {
  --book-text: #e4e4e7;
  --book-text-muted: #a1a1aa;
  --book-background: #111113;
  --book-border: #2a2a2e;
  --book-sidebar-bg: #18181b;
  --book-active-bg: rgba(77, 155, 255, 0.12);
  --book-active-color: #5fa8ff;
}

/* ── Full-height docs layout ────────────────────────────────── */
.docs-layout {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 70px); /* subtract approx header height */
  background: var(--book-background);
}

/* ── Mobile bar (hamburger + inline search) ──────────────────── */
.docs-mobilebar {
  display: none;
  align-items: center;
  position: sticky;
  top: 70px;
  z-index: 200;
  width: 100%;
  background: var(--book-sidebar-bg);
  border-bottom: 1px solid var(--book-border);
  gap: 0;
}

.docs-hamburger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  border-right: 1px solid var(--book-border);
  cursor: pointer;
  color: var(--book-text);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
}

.docs-hamburger svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Mobile search — inside the mobilebar */
.docs-search-mobile {
  flex: 1;
  min-width: 0;
  max-width: 100% !important;
  padding: 0.45rem 0.75rem;
}

.docs-search-mobile .docs-search-input {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none !important;
  padding-left: 0.25rem;
}

.docs-search-mobile .docs-search-input:focus {
  box-shadow: none !important;
  border: none;
}

.docs-search-mobile .docs-search-results {
  top: calc(100% + 2px);
  left: -1px;
  right: -1px;
  border-radius: 0 0 10px 10px;
}

/* Desktop: hide the mobile search */
.docs-search-mobile {
  display: none;
}

/* ── Overlay (mobile) ────────────────────────────────────────── */
.docs-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.docs-overlay.visible {
  opacity: 1;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.docs-sidebar {
  width: var(--book-sidebar-width);
  flex-shrink: 0;
  background: var(--book-sidebar-bg);
  border-right: 1px solid var(--book-border);
  position: sticky;
  top: 70px;
  height: calc(100vh - 70px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

.docs-sidebar-inner {
  padding: 1rem 0 2rem;
}

/* Sidebar search — only visible on mobile/small screens */
.docs-search-sidebar {
  display: none;
  margin: 0 0.75rem;
  max-width: calc(100% - 1.5rem) !important;
  min-width: 0 !important;
  box-sizing: border-box;
  overflow: hidden;
}

.docs-search-sidebar .docs-search-input {
  font-size: 0.875rem;
  padding: 0.55rem 2.2rem 0.55rem 0.85rem;
  border-radius: 7px;
}

.docs-search-sidebar .docs-search-label {
  right: 0.7rem;
}

.docs-search-sidebar .docs-search-icon {
  width: 15px;
  height: 15px;
}

.docs-search-sidebar .docs-search-results {
  border-radius: 8px;
}

/* Divider between search and nav */
.docs-sidebar-divider {
  display: none;
  height: 1px;
  background: var(--book-border);
  margin: 0.85rem 0.75rem 0.5rem;
}

@media (max-width: 860px) {
  .docs-search-sidebar {
    display: block;
  }
  .docs-sidebar-divider {
    display: block;
  }
}

/* ── Sidebar nav ─────────────────────────────────────────────── */
.docs-nav {
  display: flex;
  flex-direction: column;
}

/* Top-level standalone item */
.docs-nav-item--top {
  padding: 0 0.5rem 0.25rem;
}

.docs-nav-item--top .docs-nav-link {
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.88rem;
}

/* Group */
.docs-nav-group {
  padding: 0 0.5rem 0;
}

.docs-nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.45rem 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--book-text);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  border-radius: 6px;
  gap: 0.4rem;
  transition: background 0.15s ease;
}

.docs-nav-group-toggle:hover {
  background: var(--book-active-bg);
}

.docs-nav-group-toggle span {
  flex: 1;
}

.docs-nav-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--book-active-color);
  transition: transform 0.2s ease;
}

.docs-nav-group-toggle[aria-expanded="false"] .docs-nav-chevron {
  transform: rotate(-90deg);
}

/* Children list */
.docs-nav-children {
  list-style: none;
  padding: 0.1rem 0 0.25rem 0;
  margin: 0;
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}

.docs-nav-children.collapsed {
  max-height: 0;
  opacity: 0;
}

.docs-nav-children li {
  margin: 0;
}

/* Nav link (child item) */
.docs-nav-link {
  display: block;
  width: 100%;
  padding: 0.38rem 0.75rem 0.38rem 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--book-text-muted);
  font-size: 0.85rem;
  font-family: inherit;
  text-align: left;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.docs-nav-link:hover {
  color: var(--book-text);
  background: var(--book-active-bg);
}

.docs-nav-link--active {
  background: var(--book-active-gradient) !important;
  color: #fff !important;
}

/* ── Content area ────────────────────────────────────────────── */
.docs-content {
  flex: 1;
  min-width: 0;
  padding: 0.9rem 2.5rem 4rem;
  overflow-y: auto;
}

.docs-page {
  max-width: 75%;
}

@media (max-width: 1100px) {
  .docs-page {
    max-width: 100%;
  }
}

/* ── Topbar ──────────────────────────────────────────────────── */
.docs-topbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

/* Search row — always full height so breadcrumb never shifts */
.docs-topbar-search-row {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin-left: -0.75rem;
}

/* Panel — always visible */
.docs-search-inline-panel {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--book-border);
  border-radius: 10px;
  padding: 0.35rem 0.75rem;
  width: 450px;
  max-width: 50vw;
  box-sizing: border-box;
  background: var(--book-background);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

html[data-theme="dark"] .docs-search-inline-panel {
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

/* Input always visible */
.docs-search-inline-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.875rem;
  color: var(--book-text);
  font-family: inherit;
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
}

/* Icon-only state */
.docs-search-inline-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--book-text-muted);
  transition: color 0.15s ease;
}

.docs-search-inline-icon:hover {
  color: var(--book-active-color);
}

.docs-search-inline-icon svg {
  width: 17px;
  height: 17px;
}

html[data-theme="dark"] .docs-search-inline-panel {
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

.docs-search-inline-input::placeholder {
  color: var(--book-text-muted);
  opacity: 0.6;
}

.docs-search-inline-panel .docs-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  border-radius: 10px;
}

/* ── Search bar (sidebar/mobile only) ───────────────────────── */
.docs-search-wrap {
  position: relative;
  width: 100%;
}

.docs-search-label {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  pointer-events: none;
}

.docs-search-icon {
  width: 16px;
  height: 16px;
  color: var(--book-text-muted);
  opacity: 0.7;
}

.docs-search-input {
  width: 100%;
  padding: 0.3rem 2.2rem 0.3rem 0.85rem;
  line-height: 1.4;
  background: var(--book-sidebar-bg);
  border: 1px solid var(--book-border);
  border-radius: 8px;
  color: var(--book-text);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.docs-search-input::placeholder {
  color: var(--book-text-muted);
  opacity: 0.6;
}

.docs-search-input:focus {
  border-color: #2d79ff;
  box-shadow: 0 0 0 3px rgba(45, 121, 255, 0.12);
}

/* Search results dropdown */
.docs-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--book-background);
  border: 1px solid var(--book-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 400;
  overflow: hidden;
}

html[data-theme="dark"] .docs-search-results {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.docs-search-result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.12s ease;
}

.docs-search-result:hover {
  background: var(--book-active-bg);
}

.docs-search-result-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--book-text);
}

.docs-search-result-group {
  font-size: 0.78rem;
  color: var(--book-text-muted);
  white-space: nowrap;
}

.docs-search-empty {
  padding: 0.75rem 0.9rem;
  font-size: 0.85rem;
  color: var(--book-text-muted);
}

/* ── Breadcrumb ──────────────────────────────────────────────── */
.docs-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0;
  font-size: 0.85rem;
  color: var(--book-text-muted);
  flex-wrap: wrap;
}

.docs-breadcrumb-home {
  display: flex;
  align-items: center;
  color: var(--book-active-color);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.docs-breadcrumb-home:hover {
  opacity: 0.75;
}

.docs-breadcrumb-home svg {
  width: 15px;
  height: 15px;
}

.docs-breadcrumb-sep {
  font-size: 1rem;
  opacity: 0.5;
}

.docs-breadcrumb-current {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--book-text);
  font-weight: 500;
  flex-wrap: wrap;
}

/* Clickable group label in breadcrumb */
.docs-breadcrumb-group-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  font-weight: 400;
  color: var(--book-text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}

.docs-breadcrumb-group-btn:hover {
  color: var(--book-active-color);
}

/* ── Pages ───────────────────────────────────────────────────── */
.docs-page {
  display: none;
  animation: docsPageIn 0.18s ease;
}

.docs-page.active {
  display: block;
}

@keyframes docsPageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.docs-page h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--book-text);
  margin: 0 0 0.75rem;
  line-height: 1.2;
}

.docs-lead {
  font-size: 1.05rem;
  color: var(--book-text-muted);
  line-height: 1.65;
  margin-bottom: 1.5rem;
}

.docs-page p {
  font-size: 0.95rem;
  color: var(--book-text-muted);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.docs-page ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.5rem;
}

.docs-page li {
  position: relative;
  padding: 0.3rem 0 0.3rem 1.25rem;
  color: var(--book-text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.docs-page li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--book-text-muted);
  opacity: 0.5;
}

/* ── Overview grid ───────────────────────────────────────────── */
.docs-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.docs-overview-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.1rem 1.25rem;
  background: var(--book-sidebar-bg);
  border: 1px solid var(--book-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.docs-overview-card:hover {
  border-color: #2d79ff;
  box-shadow: 0 0 0 3px rgba(45, 121, 255, 0.08);
}

.docs-overview-card strong {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--book-text);
}

.docs-overview-card span {
  font-size: 0.82rem;
  color: var(--book-text-muted);
  line-height: 1.4;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 860px) {
  .docs-mobilebar {
    display: flex;
  }

  .docs-layout {
    flex-direction: column;
    min-height: unset;
  }

  /* Sidebar becomes a fixed overlay panel on mobile */
  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: min(var(--book-sidebar-width), 80vw);
    max-width: 80vw;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
    overflow-x: hidden;
  }

  .docs-sidebar-inner {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .docs-search-sidebar {
    max-width: calc(100% - 1.5rem) !important;
    width: calc(100% - 1.5rem);
  }

  .docs-search-sidebar .docs-search-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .docs-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }

  .docs-overlay {
    display: block;
    pointer-events: none;
  }

  .docs-overlay.visible {
    pointer-events: auto;
  }

  .docs-content {
    padding: 1.25rem 1.25rem 3rem;
  }

  /* Hide desktop inline search on mobile */
  .docs-topbar-search-row {
    display: none;
  }
  .docs-search-inline {
    display: none;
  }
  .docs-topbar-spacer {
    display: none;
  }

  .docs-topbar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .docs-search-mobile {
    display: flex;
  }

  .docs-overview-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

@media (max-width: 480px) {
  .docs-content {
    padding: 1rem 1rem 3rem;
  }

  .docs-page h1 {
    font-size: 1.5rem;
  }

  .docs-overview-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .docs-overview-card {
    padding: 0.9rem 1rem;
  }
}

/* ── Features-page-only overrides ───────────────────────────── */

/* Lock page scroll on desktop — only sidebar and content scroll */
@media (min-width: 861px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  .page {
    height: calc(100vh - 84px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .docs-layout {
    flex: 1;
    min-height: 0;
    height: 100%;
  }

  .docs-sidebar {
    height: 100%;
    top: 0;
    position: sticky;
  }

  .docs-content {
    height: 100%;
    overflow-y: auto;
  }
}

/* Align nav-brand to the left, flush with the sidebar */
@media (min-width: 861px) {
  .site-header .nav {
    max-width: none;
    margin: 0;
    padding-left: 0;
    padding-right: 16px;
  }

  .site-header .nav-brand {
    width: var(--book-sidebar-width);
    flex-shrink: 0;
    padding-left: 16px;
  }
}
