/* ==========================================================================
   StudentHPC — Portal / documentation shell
   CU Boulder Alpine + ReadTheDocs lineage: sticky left sidebar, dense and
   highly readable centre column, right-hand "on this page" rail.
   Depends on: tokens.css, base.css, components.css, site.css
   ========================================================================== */

/* ==========================================================================
   DOCS TOP BAR — replaces the marketing masthead inside the portal.
   Quick actions only: search, system status, sign in.
   ========================================================================== */
.docs-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--surface);
  border-bottom: 1px solid var(--border-base);
  height: var(--topbar-h);
}
.docs-topbar__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  height: 100%;
  padding-inline: var(--sp-6);
  max-width: none;   /* the portal is full-bleed, unlike the landing page */
}
.docs-topbar__brand { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }
.docs-topbar__divider { width: 1px; height: 22px; background: var(--border-base); flex-shrink: 0; }
.docs-topbar__section {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  white-space: nowrap;
}
.docs-topbar__spacer { flex: 1; }
.docs-topbar__actions { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }

/* Search — presentational only; wire to your own index. */
.docs-search { position: relative; width: min(340px, 34vw); }
.docs-search__input {
  width: 100%;
  font-size: var(--fs-sm);
  padding: 0.5rem var(--sp-3) 0.5rem var(--sp-8);
  background: var(--surface-subtle);
  border: 1px solid var(--border-base);
  border-radius: var(--r-1);
  color: var(--text);
}
.docs-search__input::placeholder { color: var(--text-muted); }
.docs-search__input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--blue-100);
}
.docs-search__icon {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.docs-search__kbd {
  position: absolute;
  right: var(--sp-2);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Status pill in the docs bar sits on white, so it needs the light treatment. */
.docs-status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  color: var(--status-ok-fg);
  background: var(--status-ok-bg);
  border: 1px solid var(--status-ok-bd);
  border-radius: var(--r-1);
  padding: 0.3125rem var(--sp-3);
  text-decoration: none;
  white-space: nowrap;
}
.docs-status:hover { color: var(--status-ok-fg); border-color: var(--status-ok-dot); }

/* ==========================================================================
   SHELL — sidebar | content | toc
   ========================================================================== */
.docs-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  align-items: start;
  min-height: calc(100vh - var(--topbar-h));
}

/* --------------------------------------------------------------------------
   SIDEBAR
   -------------------------------------------------------------------------- */
.docs-sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface-invert);
  border-right: 1px solid var(--border-invert);
  padding: var(--sp-6) 0 var(--sp-12);
  scrollbar-width: thin;
  scrollbar-color: var(--slate-600) transparent;
}
.docs-sidebar::-webkit-scrollbar { width: 8px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--slate-600); border-radius: var(--r-1); }
.docs-sidebar::-webkit-scrollbar-track { background: transparent; }

.docs-sidebar__cluster {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: 0 var(--sp-5) var(--sp-6);
  padding: var(--sp-3) var(--sp-4);
  background: var(--slate-900);
  border: 1px solid var(--border-invert);
  border-radius: var(--r-1);
}
.docs-sidebar__cluster-name {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: var(--fw-mono-strong);
  color: var(--white);
}
.docs-sidebar__cluster-meta {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--slate-300);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
}

.docs-nav__group { margin-bottom: var(--sp-6); }
.docs-nav__title {
  font-size: var(--fs-3xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--text-invert-muted);
  padding: 0 var(--sp-5);
  margin-bottom: var(--sp-2);
}
.docs-nav__list { display: flex; flex-direction: column; }
.docs-nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-on-invert);
  text-decoration: none;
  padding: 0.4375rem var(--sp-5);
  border-left: 2px solid transparent;
  transition: color var(--motion-fast) var(--ease), background-color var(--motion-fast) var(--ease);
}
.docs-nav__link:hover { color: var(--white); background: rgba(255, 255, 255, 0.045); text-decoration: none; }
.docs-nav__link[aria-current='page'] {
  color: var(--white);
  background: rgba(255, 255, 255, 0.07);
  border-left-color: var(--pine-400);
  font-weight: var(--fw-medium);
}
/* Sub-items — one level only. Deeper nesting belongs in the page TOC. */
.docs-nav__link--sub { padding-left: var(--sp-8); font-size: var(--fs-xs); color: var(--text-invert-muted); }
.docs-nav__link--sub:hover { color: var(--white); }

.docs-nav__tag {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--text-invert-muted);
  border: 1px solid var(--slate-600);
  border-radius: var(--r-1);
  padding: 1px 5px;
  flex-shrink: 0;
}

.docs-sidebar__foot {
  margin: var(--sp-8) var(--sp-5) 0;
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border-invert);
  font-size: var(--fs-xs);
  color: var(--text-invert-muted);
  line-height: var(--lh-relaxed);
}
.docs-sidebar__foot a { color: var(--blue-300); }
.docs-sidebar__foot a:hover { color: var(--white); }

/* --------------------------------------------------------------------------
   CONTENT
   -------------------------------------------------------------------------- */
.docs-main {
  min-width: 0;
  padding: var(--sp-8) var(--sp-12) var(--sp-24);
  background: var(--surface);
}
.docs-header { padding-bottom: var(--sp-6); margin-bottom: var(--sp-8); border-bottom: 1px solid var(--border-hair); }
.docs-header__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-4); margin-top: var(--sp-4); }
.docs-title { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing: var(--ls-display); margin-top: var(--sp-3); }
.docs-subtitle { font-size: var(--fs-lg); color: var(--text-secondary); line-height: var(--lh-relaxed); margin-top: var(--sp-4); max-width: var(--w-prose); }

/* --------------------------------------------------------------------------
   PROSE — the reading surface. 17px / 1.7 over a hard 72ch measure.
   The old site set body copy at 14px; documentation read at that size is
   where "information dense" turns into "unreadable".
   -------------------------------------------------------------------------- */
.prose { max-width: var(--w-prose); font-size: var(--fs-md); line-height: var(--lh-relaxed); color: var(--text); }
.prose > * + * { margin-top: var(--sp-5); }

.prose h2 {
  font-size: var(--fs-2xl);
  margin-top: var(--sp-12);
  padding-top: var(--sp-2);
  scroll-margin-top: calc(var(--topbar-h) + var(--sp-4));
}
.prose h3 {
  font-size: var(--fs-xl);
  margin-top: var(--sp-10);
  scroll-margin-top: calc(var(--topbar-h) + var(--sp-4));
}
.prose h4 { font-size: var(--fs-lg); margin-top: var(--sp-8); }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: var(--sp-4); }

.prose ul, .prose ol { padding-left: var(--sp-6); }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: var(--sp-2); }
.prose li::marker { color: var(--text-muted); }

.prose dl { display: grid; gap: var(--sp-3); }
.prose dt { font-weight: var(--fw-mono-strong); font-family: var(--font-mono); font-size: var(--fs-sm); }
.prose dd { color: var(--text-secondary); font-size: var(--fs-base); padding-left: var(--sp-4); border-left: 2px solid var(--border-hair); }

.prose blockquote {
  border-left: 3px solid var(--border-base);
  padding-left: var(--sp-5);
  color: var(--text-secondary);
  font-style: italic;
}

.prose .table-scroll, .prose .code-block, .prose .callout { max-width: 100%; }
.prose img { border: 1px solid var(--border-base); border-radius: var(--r-2); }

/* Anchor link revealed on heading hover — standard docs affordance. */
.heading-anchor {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: var(--sp-2);
  opacity: 0;
  font-weight: var(--fw-regular);
  transition: opacity var(--motion-fast) var(--ease);
}
h2:hover .heading-anchor, h3:hover .heading-anchor,
.heading-anchor:focus-visible { opacity: 1; }

/* --------------------------------------------------------------------------
   TOC — "on this page"
   -------------------------------------------------------------------------- */
.docs-toc {
  position: sticky;
  top: var(--topbar-h);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: var(--sp-8) var(--sp-5) var(--sp-12) 0;
  font-size: var(--fs-sm);
}
.docs-toc__title {
  font-size: var(--fs-3xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  padding-left: var(--sp-4);
}
.docs-toc__list { display: flex; flex-direction: column; border-left: 1px solid var(--border-base); }
.docs-toc__list a {
  display: block;
  padding: var(--sp-2) var(--sp-4);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}
.docs-toc__list a:hover { color: var(--text); text-decoration: none; }
.docs-toc__list a[aria-current='true'] {
  color: var(--text-brand);
  font-weight: var(--fw-semibold);
  border-left-color: var(--border-brand);
}
.docs-toc__list a.is-sub { padding-left: var(--sp-8); }

/* --------------------------------------------------------------------------
   PAGE FOOTER — prev/next
   -------------------------------------------------------------------------- */
.docs-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-top: var(--sp-16);
  padding-top: var(--sp-8);
  border-top: 1px solid var(--border-hair);
  max-width: var(--w-prose);
}
.docs-pager__link {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border-base);
  border-radius: var(--r-2);
  text-decoration: none;
  transition: border-color var(--motion-fast) var(--ease), background-color var(--motion-fast) var(--ease);
}
.docs-pager__link:hover { border-color: var(--border-brand); background: var(--surface-inset); text-decoration: none; }
.docs-pager__link--next { text-align: right; }
.docs-pager__dir { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-caps); color: var(--text-muted); font-weight: var(--fw-semibold); }
.docs-pager__title { font-size: var(--fs-base); font-weight: var(--fw-semibold); color: var(--text-link); }

.docs-updated {
  margin-top: var(--sp-8);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  max-width: var(--w-prose);
}

/* --------------------------------------------------------------------------
   Sidebar drawer (narrow viewports)
   -------------------------------------------------------------------------- */
.sidebar-toggle { display: none; }
.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 16, 0.55);
  z-index: var(--z-drawer);
}

@media (max-width: 1280px) {
  .docs-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .docs-toc { display: none; }
  .docs-main { padding-inline: var(--sp-10); }
}

@media (max-width: 900px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar-toggle { display: inline-flex; }
  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 84vw);
    height: 100vh;
    z-index: calc(var(--z-drawer) + 1);
    transform: translateX(-102%);
    transition: transform var(--motion-base) var(--ease);
    padding-top: var(--sp-5);
  }
  .docs-sidebar.is-open { transform: translateX(0); }
  .docs-main { padding: var(--sp-6) var(--sp-5) var(--sp-16); }
  .docs-title { font-size: var(--fs-2xl); }
  .docs-search { display: none; }
}

@media (max-width: 600px) {
  .docs-pager { grid-template-columns: 1fr; }
  .docs-topbar__section { display: none; }
}

/* --------------------------------------------------------------------------
   Narrow top bar
   At 390px the brand, status pill and sign-in button together overflow the
   viewport, pushing the button off-screen entirely. Drop the verbose halves
   rather than letting the row scroll: the status pill keeps its dot (still a
   link to the status page) and the button keeps its verb.
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .docs-topbar__inner { gap: var(--sp-3); padding-inline: var(--sp-4); }
  .docs-topbar__brand .wordmark__name { font-size: var(--fs-base); }
  .docs-status .is-long { display: none; }
  .docs-status { padding-inline: var(--sp-2); }
  .docs-topbar__actions .is-long { display: none; }
  .docs-topbar__divider { display: none; }
}
@media (max-width: 420px) {
  .docs-status { display: none; }   /* reachable from the sidebar footer */
}

/* Policy links in the sidebar foot — the portal has no page footer, so this
   is the only place a docs reader can reach terms/privacy/cookie settings. */
.docs-sidebar__foot p + p { margin-top: var(--sp-3); }
.docs-sidebar__policy { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: baseline; }

/* The sidebar nav is a real <ul role="list"> now, so the anchor is one level
   deeper than the flex container. Keep it filling the row. */
.docs-nav__list > li { display: block; }
