/* ============================================================
   Muse — documentation layout (/info, /privacy, /terms, /acknowledgements)

   Loaded AFTER styles.css, which supplies the tokens, @font-face, header,
   footer and buttons. This file only adds the documentation layout on top:
   a sticky tree, a prose column, and the search results panel.

   The one thing to know: styles.css positions .site-header absolutely so it
   floats over the homepage hero. There is no hero here, so it is re-anchored
   to the normal flow below.
   ============================================================ */

:root {
  --docs-nav:  260px;                    /* tree column */
  --docs-gap:  clamp(32px, 5vw, 72px);   /* tree → prose */
  /* The header scrolls away with the page now, so nothing sticky needs to clear
     it. Kept as a token because the tree, the topic scroll-margins and the
     mobile bar all measure off it. */
  --docs-top:  0px;
}

/* ───────── Header ─────────
   Nothing is overridden. styles.css positions it `absolute`, floating over the
   page, and that is kept here so the header is pixel-identical to the homepage
   — same glass pills, same padding, same 34px mark, same place on screen.

   Because it is out of flow, the page title must clear it the way the hero's
   headline does: `.docs` carries the hero's own top padding (see below), which
   is what puts the h1 on the same line as the homepage headline. An earlier
   pass set this header `position: static`, which pushed every h1 down by the
   header's full 118px height. Don't do that. */

/* .btn-guide and .docs-footer live in styles.css — the homepage uses them too. */

/* keyboard users get a real way past the tree */
.skip-link {
  position: absolute; left: 50%; top: 8px; transform: translate(-50%, -200%);
  z-index: 200; background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 100px; font-size: 13px;
  transition: transform .2s var(--ease);
}
.skip-link:focus { transform: translate(-50%, 0); }

/* ───────── Page frame ───────── */
.docs {
  max-width: var(--wrap);
  margin: 0 auto;
  /* Top padding is the HERO's, verbatim (styles.css `.hero`), so the h1 lands on
     the same line as the homepage headline instead of below the floating
     header. Change it there and here together. */
  padding: clamp(100px, 13vh, 138px) var(--gut) clamp(72px, 9vw, 120px);
  display: grid;
  grid-template-columns: var(--docs-nav) minmax(0, 1fr);
  /* column-gap only: `gap` also applies between the title row and the columns
     below it, which stacked on the title's own margin and opened a ~110px hole. */
  column-gap: var(--docs-gap);
  row-gap: 0;
  align-items: start;
}
/* The legal pages are a single prose column, no tree. It is capped for
   readability but starts at the SAME gutter as the homepage and /info — not
   centred, which floated it 164px in and made every legal page look like a
   different site. */
.docs.docs-solo {
  grid-template-columns: minmax(0, 72ch);
}

.docs-title {
  grid-column: 1 / -1;
  margin-bottom: clamp(20px, 3vw, 36px);
}
/* Bricolage Grotesque, like .hero-lede and .feat-head h2 on the homepage. Instrument
   Serif is a declared token that the site does not actually use anywhere —
   don't reach for it here either. */
.docs-title h1 {
  font-family: var(--fat);
  font-weight: 800;
  font-stretch: 100%;
  font-optical-sizing: auto;
  font-size: clamp(34px, 4.6vw, 52px);
  line-height: 1.07;
  letter-spacing: -0.015em;
}
.docs-title p {
  margin-top: 10px;
  max-width: 56ch;
  color: var(--ink-soft);
  font-size: clamp(15px, 1.5vw, 17px);
}

/* ───────── Tree column ───────── */
.docs-aside {
  position: sticky;
  top: calc(var(--docs-top) + 20px);
  max-height: calc(100vh - var(--docs-top) - 40px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.docs-search { position: relative; flex: none; }
.docs-search input {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 300;
  color: var(--ink);
  background: rgba(10, 10, 10, .04);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 34px 10px 34px;
  outline: none;
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
.docs-search input::placeholder { color: var(--ink-faint); }
/* type="search" draws its own clear button in WebKit, which sat beside ours and
   read as two X's. Ours stays: it is styled with the page and is keyboard-
   reachable with a real label. */
.docs-search input::-webkit-search-cancel-button,
.docs-search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.docs-search input:focus {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 6px 20px -12px rgba(0, 0, 0, .4);
}
.docs-search .icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); pointer-events: none; display: grid;
}
.docs-search .clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: 0; background: none; cursor: pointer;
  color: var(--ink-faint); border-radius: 6px; display: none;
  align-items: center; justify-content: center; font-size: 15px; line-height: 1;
}
.docs-search.has-query .clear { display: flex; }
.docs-search .clear:hover { color: var(--ink); background: rgba(10, 10, 10, .06); }

/* results panel — overlays the tree rather than pushing it */
.docs-results {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 6px);
  max-height: min(58vh, 460px); overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .3);
  padding: 6px;
  display: none;
}
.docs-results.is-open { display: block; }
.docs-results li { list-style: none; }
.docs-results a {
  display: block;
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
}
.docs-results a:hover,
.docs-results a.is-active { background: rgba(10, 10, 10, .05); }
.docs-results .r-crumb {
  display: block;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.docs-results .r-title {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-top: 1px;
}
.docs-results .r-snip {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.docs-results mark {
  background: rgba(255, 214, 0, .38);
  color: inherit;
  border-radius: 2px;
}
.docs-results .r-empty {
  padding: 14px 11px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

/* the tree itself */
.docs-tree { overflow-y: auto; flex: 1; min-height: 0; padding-bottom: 8px; }
.docs-tree ul { list-style: none; }
.docs-tree > ul > li + li { margin-top: 22px; }
.docs-tree .t-group {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 7px;
}
.docs-tree a {
  display: block;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-soft);
  padding: 4px 10px;
  margin-left: -10px;
  border-radius: 7px;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.docs-tree a:hover { color: var(--ink); background: rgba(10, 10, 10, .04); }
.docs-tree a[aria-current="page"] {
  color: var(--ink);
  font-weight: 500;
  background: rgba(10, 10, 10, .06);
}

/* mobile-only disclosure button */
.docs-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
  background: rgba(10, 10, 10, .04);
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
.docs-toggle .chev { transition: transform .25s var(--ease); color: var(--ink-faint); }
.docs-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* ───────── Prose column ───────── */
.docs-body { min-width: 0; }

.docs-group + .docs-group { margin-top: clamp(56px, 7vw, 88px); }
.docs-group > h2 {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.topic { padding: 30px 0; border-bottom: 1px solid var(--line-2); scroll-margin-top: calc(var(--docs-top) + 24px); }
.topic:last-child { border-bottom: 0; }
.topic > h3 {
  font-family: var(--fat);
  font-weight: 800;
  font-stretch: 100%;
  font-optical-sizing: auto;
  /* smaller than the homepage's 38px h2 — there are 31 of these, and Bricolage
     Grotesque at section-header size would shout down the prose it labels */
  font-size: clamp(21px, 2.2vw, 26px);
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin-bottom: 12px;
}
.topic p {
  max-width: 68ch;
  font-size: 15px;
  line-height: 1.68;
  color: var(--ink-soft);
}
.topic p + p { margin-top: 12px; }
.topic p strong { color: var(--ink); font-weight: 500; }
.topic a:not(.btn-appstore) {
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  transition: border-color .2s var(--ease);
}
.topic a:not(.btn-appstore):hover { border-color: var(--ink); }
.topic ul {
  max-width: 68ch;
  margin: 12px 0 0 0;
  padding-left: 18px;
}
.topic li {
  font-size: 15px;
  line-height: 1.62;
  color: var(--ink-soft);
  margin-top: 6px;
}

/* the four-part shape: prose, Where, Keys, Note */
.meta {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 4px 14px;
  max-width: 68ch;
  align-items: baseline;
}
.meta dt {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 3px;
}
/* Each dd is its own grid item, so a dt followed by three dds put the 2nd and
   3rd back in column 1 and they wrapped under the label. Pin every dd to the
   value column. */
.meta dd { grid-column: 2; font-size: 14px; line-height: 1.6; color: var(--ink-soft); }
.meta dd + dd { margin-top: 2px; }

/* menu paths and shortcut names */
.path, kbd {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink);
  background: rgba(10, 10, 10, .05);
  border-radius: 5px;
  padding: 2px 6px;
  white-space: nowrap;
}
kbd { font-weight: 500; }

.note {
  margin-top: 16px;
  max-width: 68ch;
  padding: 12px 16px;
  border-left: 2px solid var(--line);
  background: rgba(10, 10, 10, .025);
  border-radius: 0 8px 8px 0;
}
.note p { font-size: 13.5px; line-height: 1.6; }

/* the all-shortcuts table */
.keytable { width: 100%; max-width: 68ch; border-collapse: collapse; margin-top: 16px; }
.keytable caption {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 18px 0 6px;
}
.keytable td {
  padding: 7px 0;
  font-size: 14px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line-2);
  vertical-align: baseline;
}
.keytable td:first-child { width: 108px; white-space: nowrap; padding-right: 14px; }
.keytable tr:last-child td { border-bottom: 0; }

/* search jump target */
@keyframes docsFlash {
  from { background: rgba(255, 214, 0, .30); }
  to   { background: transparent; }
}
.topic.flash { animation: docsFlash 1.4s var(--ease); border-radius: 8px; }

/* ───────── Mobile ───────── */
@media (max-width: 900px) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-top: 20px;
  }
  .docs-aside {
    position: sticky;
    top: var(--docs-top);
    max-height: none;
    z-index: 40;
    background: var(--bg);
    padding: 12px 0 14px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line-2);
    gap: 10px;
  }
  .docs-toggle { display: flex; }
  /* Collapsed by default on mobile; the button owns the state. Using a button
     rather than <details> because the tree is two levels deep and needs to keep
     its group headings — and because UA <details> styling is the one thing that
     still differs enough between browsers to bite. */
  .docs-tree {
    display: none;
    max-height: 62vh;
    margin-top: 4px;
    padding: 4px 0 8px;
  }
  .docs-tree.is-open { display: block; }
  .docs-results { max-height: 52vh; }
  .topic { scroll-margin-top: 150px; }
  .meta { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .meta dt { padding-top: 8px; }
  .meta dd { grid-column: 1; }   /* single column here, so undo the desktop pin */
  .keytable td:first-child { width: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .topic.flash { animation: none; }
  .docs-toggle .chev { transition: none; }
}
