/* The dochouse panel: an in-SPA docs reader. Two columns — a sticky
 * section rail and the article (.docs-article, styled in docs.css).
 * dochouse.js fetches /docs fragments and fills both. Tokens from
 * themes/labrador.css; no hex literals. */

.dochouse {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  /* A little breathing room so the masthead / rail don't crash into the
     topbar on load. */
  padding-top: 16px;
}

/* The first heading of a freshly-swapped article shouldn't crash into
   the topbar on a deep-link load. */
.dochouse-article > :first-child,
.docs-article > :first-child {
  margin-top: 0;
}

/* --- section rail ------------------------------------------------------ */
.dochouse-rail {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px;
  background: linear-gradient(180deg, var(--surface-drawer-top), var(--surface-drawer-bot));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.02) inset,
    0 8px 24px -18px rgba(0, 0, 0, 0.7);
}

.dochouse-rail-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 6px 10px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
/* The little house-of-docs glyph — CSS, not an emoji asset. A stacked
   "book spine" mark in the brand gold. */
/* The little house-of-docs glyph — CSS, not an emoji asset. Banded
   purple -> cyan -> green as a nod to the Code Puppy wordmark we're
   riffing on. Blocky on purpose. */
.dochouse-rail-ico {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  flex: 0 0 auto;
  background: linear-gradient(
    180deg,
    #b3a8f0 0%,
    #b3a8f0 33%,
    #7ef0f5 33%,
    #7ef0f5 66%,
    #8ee6a0 66%,
    #8ee6a0 100%
  );
  box-shadow: 0 0 10px rgba(126, 240, 245, 0.35);
}

.dochouse-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dochouse-nav-item {
  position: relative;
  padding: 7px 11px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.35;
  transition:
    background 0.13s ease,
    color 0.13s ease;
}
.dochouse-nav-item:hover {
  background: rgba(var(--slate-rgb), 0.16);
  color: var(--text);
}
.dochouse-nav-item.current {
  background: rgba(var(--accent-rgb), 0.13);
  color: var(--accent-bright);
  font-weight: 600;
}
/* A slim gold marker on the current item, drawn as a pseudo so it can
   sit flush inside the rounded pill without a hard border seam. */
.dochouse-nav-item.current::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: var(--accent);
}

/* Skeleton bars shown before the first fetch resolves. */
.dochouse-nav-skel {
  height: 32px;
  border-radius: 8px;
  background: rgba(var(--slate-rgb), 0.12);
  opacity: 0.6;
}

/* --- expandable sub-nav ------------------------------------------------ */
/* A top-level entry that owns children. The parent is itself a real doc
   link; its children live in .dochouse-nav-sub, collapsed until the
   group is .open (parent or a child is the current page). */
.dochouse-nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* A small disclosure caret on the parent, rotating when open. */
.dochouse-nav-parent {
  position: relative;
  padding-right: 26px;
}
.dochouse-nav-parent::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-70%) rotate(-45deg);
  opacity: 0.5;
  transition:
    transform 0.18s ease,
    opacity 0.13s ease;
}
.dochouse-nav-parent:hover::after {
  opacity: 0.9;
}
.dochouse-nav-group.open .dochouse-nav-parent::after {
  transform: translateY(-30%) rotate(45deg);
  opacity: 0.9;
}

/* The child list: indented, with a vertical connector rail. Collapsed to
   zero height until the group opens. */
.dochouse-nav-sub {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  margin: 1px 0 3px 15px;
  padding-left: 11px;
  border-left: 1px solid var(--line);
  transition: grid-template-rows 0.2s ease;
}
.dochouse-nav-group.open .dochouse-nav-sub {
  grid-template-rows: 1fr;
}
.dochouse-nav-sub > * {
  min-height: 0; /* let the 0fr row actually collapse */
}
.dochouse-nav-child {
  position: relative;
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
  transition:
    background 0.13s ease,
    color 0.13s ease;
}
.dochouse-nav-child:hover {
  background: rgba(var(--slate-rgb), 0.16);
  color: var(--text);
}
.dochouse-nav-child.current {
  background: rgba(var(--accent-rgb), 0.13);
  color: var(--accent-bright);
  font-weight: 600;
}
/* Nudge the connector rail's accent to the current child so the tree
   reads as "you are here" without a heavy marker. */
.dochouse-nav-child.current::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 100%;
  background: var(--accent);
}

.dochouse-rail-foot {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-soft);
}
.dochouse-rail-foot code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(var(--accent-rgb), 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent);
}

/* --- article column ---------------------------------------------------- */
.dochouse-main {
  min-width: 0;
}

/* ASCII masthead — the Code Puppy wordmark riff. Banded purple -> cyan ->
   green via background-clip text so the glyphs carry the lineage gradient.
   Scrolls horizontally on narrow screens rather than wrapping (wrapping
   box-drawing art is a war crime). */
.dochouse-banner {
  margin: 0 0 2px;
  font-family: var(--font-mono);
  font-size: clamp(5px, 1.05vw, 11px);
  line-height: 1.15;
  font-weight: 700;
  white-space: pre;
  overflow-x: auto;
  background: linear-gradient(180deg, #b3a8f0 0%, #7ef0f5 52%, #8ee6a0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.dochouse-banner-sub {
  margin: 0 0 22px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.dochouse-loading {
  color: var(--text-soft);
  font-size: 14px;
}

/* --- narrow screens: rail collapses above the article ------------------ */
@media (max-width: 760px) {
  .dochouse {
    grid-template-columns: 1fr;
    gap: 18px;
  }
dochouse-rail {
    position: static;
  }
  /* Keep the nav vertical on narrow screens so nested groups stay
     legible (a wrapping row breaks the parent/child indentation). */
  .dochouse-nav {
    flex-direction: column;
  }
}
