/* ============================================================
   Documentation — docs layout on top of _shared/resource.css.
   Its own structure within the resources family: compact hero
   band with a live filter, then a sticky sidebar (scroll-spy)
   beside long-form handbook content. New interactions: "/" to
   focus the filter, live section filtering, copy-anchor links
   on headings. Accent = default library amber.
   ============================================================ */

/* ---------- hero band ---------- */
.docs-hero {
  position: relative;
  padding: 4.5rem 0 3.5rem;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.docs-hero-inner { position: relative; max-width: 760px; }
.docs-hero h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.3rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}
.docs-hero h1 em { font-style: normal; color: var(--rs-accent); }
.docs-hero .hero-sub { margin: 1.3rem 0 0; font-size: 1.06rem; }
.docs-hero-inner > * { animation: rise-in 0.9s var(--ease-out) both; }
.docs-hero-inner > *:nth-child(2) { animation-delay: 0.07s; }
.docs-hero-inner > *:nth-child(3) { animation-delay: 0.14s; }
.docs-hero-inner > *:nth-child(4) { animation-delay: 0.21s; }

/* filter input */
.docs-filter {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1.8rem;
  max-width: 460px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.docs-filter:focus-within {
  border-color: var(--rs-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rs-accent) 18%, transparent);
}
.docs-filter svg { width: 17px; height: 17px; flex: none; color: var(--text-faint); }
.docs-filter input {
  flex: 1;
  border: none;
  background: none;
  font-size: 0.96rem;
  color: var(--text);
}
.docs-filter input:focus-visible { outline: none; }
.docs-filter input::-webkit-search-cancel-button { -webkit-appearance: none; }
.docs-filter kbd {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0.1rem 0.5rem;
}

/* ---------- sidebar + content grid ---------- */
.docs-grid {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: clamp(2.5rem, 5vw, 4.5rem);
  align-items: start;
  padding: 3.5rem 0 4.5rem;
}
.docs-nav {
  position: sticky;
  top: calc(var(--nav-h) + 1.6rem);
}
.docs-nav-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.9rem;
}
.docs-nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
  border-left: 2px solid var(--line);
}
.docs-nav a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0.9rem;
  margin-left: -2px;
  border-left: 2px solid transparent;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.92rem;
  transition: color 0.2s, border-color 0.2s;
}
.docs-nav a .n {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  transition: color 0.2s;
}
.docs-nav a:hover { color: var(--text); }
.docs-nav li.active a {
  color: var(--text);
  font-weight: 600;
  border-left-color: var(--rs-accent);
}
.docs-nav li.active a .n { color: var(--rs-accent); }
.docs-nav li[hidden] { display: none; }
.docs-nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1.4rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--rs-accent);
  text-decoration: none;
}
.docs-nav-cta svg { width: 15px; height: 15px; transition: transform 0.2s var(--ease-out); }
.docs-nav-cta:hover svg { transform: translateX(4px); }

/* ---------- content ---------- */
.docs-content { max-width: none; margin: 0; }
.doc-section { scroll-margin-top: calc(var(--nav-h) + 1.5rem); }
.doc-section + .doc-section {
  margin-top: 3.2rem;
  padding-top: 2.6rem;
  border-top: 1px solid var(--line);
}
.doc-section > h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0 !important;
}
/* copy-anchor button, injected by docs.js */
.anchor-btn {
  background: none;
  border: none;
  padding: 0.2rem;
  cursor: pointer;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}
.doc-section > h2:hover .anchor-btn,
.anchor-btn:focus-visible { opacity: 1; }
.anchor-btn:hover { color: var(--rs-accent); }
.anchor-btn svg { width: 17px; height: 17px; display: block; }
.anchor-btn.copied { color: var(--olive); opacity: 1; }

/* glossary */
.glossary {
  margin: 1.3em 0 0;
  display: grid;
  gap: 1rem;
}
.glossary > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  transition: border-color 0.2s;
}
.glossary > div:hover { border-color: var(--rs-accent); }
.glossary dt {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--rs-accent);
  margin-bottom: 0.3rem;
}
.glossary dd { margin: 0; font-size: 0.95rem; color: var(--text-dim); }

/* filter empty state */
.docs-empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 0.9rem;
}
.docs-empty[hidden] { display: none; }
.docs-empty p { max-width: 44ch; }

/* filter match highlight on section titles */
.doc-section.dimmed { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  .docs-grid { grid-template-columns: 1fr; padding-top: 2.5rem; }
  .docs-nav {
    position: static;
    order: -1;
  }
  .docs-nav ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    border-left: none;
  }
  .docs-nav a {
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    margin-left: 0;
    font-size: 0.85rem;
  }
  .docs-nav li.active a {
    border-color: var(--rs-accent);
    box-shadow: inset 0 0 0 1px var(--rs-accent);
  }
  .docs-nav-cta { display: none; }
}
