/* ==========================================================================
   docs.css — CrazyToad documentation layer.
   Loaded AFTER /index.css on every /docs/ page. Colors come only from the
   theme CSS variables (--text, --text-2, --accent, --elevated, --border, …)
   so the whole docs section recolors with the 50-theme system. No hardcoded
   colors — everything must survive a live theme swap.
   ========================================================================== */

/* --- Shell: sidebar / main / on-this-page rail ---------------------------- */
.docs-page .docs-shell {
  max-width: 1400px;
  margin: 0 auto;
  /* Clear the 64px fixed nav: without this the crumbs (desktop) and the mobile
     "Docs menu" disclosure button render *under* the bar — on mobile the button
     was fully obscured and un-tappable (it's the only route to the sidebar nav). */
  padding: calc(64px + clamp(1rem, 2.5vw, 1.6rem)) clamp(1.1rem, 4vw, 2.4rem) 4rem;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 200px;
  gap: clamp(1.6rem, 3vw, 2.8rem);
  align-items: start;
}

/* --- Left sidebar --------------------------------------------------------- */
.docs-side {
  position: sticky;
  top: 84px;
  align-self: start;
}
.docs-menu-btn {
  display: none;
  width: 100%;
  font-family: var(--fm);
  font-size: .8rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: .7rem 1rem;
  cursor: pointer;
}
.docs-menu-btn::after { content: ' ▾'; color: var(--accent-readable); }
.docs-side.is-open .docs-menu-btn::after { content: ' ▴'; }
.docs-side-inner {
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  padding-right: .4rem;
}
.docs-tree { display: flex; flex-direction: column; gap: 1.3rem; }
.docs-cat-h {
  font-family: var(--fm);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .55rem;
  padding-left: .2rem;
}
.docs-tree ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.docs-tree a {
  display: block;
  color: var(--text-2);
  text-decoration: none;
  font-size: .9rem;
  line-height: 1.35;
  padding: .42rem .7rem;
  border-radius: var(--r-sm);
  border-left: 2px solid transparent;
  transition: color .15s, background .15s, border-color .15s;
}
.docs-tree a:hover { color: var(--text); background: rgb(var(--accent-rgb) / 0.06); }
.docs-tree a.active {
  color: var(--accent-readable);
  background: rgb(var(--accent-rgb) / 0.1);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* --- Main column ---------------------------------------------------------- */
.docs-main { min-width: 0; }
.docs-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  font-family: var(--fm);
  font-size: .74rem;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 1.4rem;
}
.docs-crumbs a { color: var(--text-2); text-decoration: none; }
.docs-crumbs a:hover { color: var(--accent-readable); }
.docs-crumbs .sep { color: var(--border); }
.docs-crumbs b { color: var(--text); font-weight: 600; }

/* --- Article typography --------------------------------------------------- */
.docs-article { max-width: 46rem; }
.docs-article h1, .docs-article h2, .docs-article h3 { text-wrap: balance; }

/* Facts strip — the page's vitals as compact chips right under the lede
   (replaces the boxy "at a glance" list; scannable in one sweep). */
.docs-facts {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin: 0 0 1.9rem; padding: 0; list-style: none;
}
.docs-facts li {
  display: inline-flex; align-items: baseline; gap: .45rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--elevated); padding: .38rem .85rem;
  font-size: .8rem; color: var(--text-2); margin: 0;
}
.docs-facts b {
  font-family: var(--fm); font-size: .64rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--accent-readable);
}

/* Step timeline — numbered rail for procedures; reads top-to-bottom at a glance. */
.docs-steps { list-style: none; margin: 1.2rem 0 1.6rem; padding: 0; }
.docs-steps > li {
  position: relative; padding: 0 0 1.15rem 2.6rem; margin: 0;
}
.docs-steps > li::before {
  content: counter(docs-step); counter-increment: docs-step;
  position: absolute; left: 0; top: -1px;
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-contrast);
  font-family: var(--fm); font-size: .7rem; font-weight: 700;
}
.docs-steps > li::after {
  content: ''; position: absolute; left: 12.5px; top: 29px; bottom: 3px;
  width: 1px; background: var(--border);
}
.docs-steps > li:last-child { padding-bottom: .2rem; }
.docs-steps > li:last-child::after { display: none; }
.docs-steps { counter-reset: docs-step; }
.docs-steps b:first-child { color: var(--text); }

/* Bullets get a quiet accent dash instead of the browser disc (content lists
   only — facts/steps/related/glance have their own treatments). */
.docs-article ul:not(.docs-facts):not(.docs-steps):not(.docs-related ul):not(.docs-glance ul) { list-style: none; padding-left: .2rem; }
.docs-article ul:not(.docs-facts):not(.docs-steps):not(.docs-related ul):not(.docs-glance ul) > li {
  position: relative; padding-left: 1.15rem;
}
.docs-article ul:not(.docs-facts):not(.docs-steps):not(.docs-related ul):not(.docs-glance ul) > li::before {
  content: ''; position: absolute; left: 0; top: .68em;
  width: .55rem; height: 2px; border-radius: 2px; background: var(--accent);
}

/* Heading anchors — hover a section title to grab its link. */
.docs-article h2[id] { position: relative; }
.docs-article h2[id] .h-anchor {
  position: absolute; left: -1.3rem; top: 0; bottom: 0;
  display: flex; align-items: center;
  color: var(--muted); text-decoration: none; border: none;
  font-family: var(--fm); font-size: .9em;
  opacity: 0; transition: opacity .15s;
}
.docs-article h2[id] .h-anchor::before { content: '#'; }
.docs-article h2[id]:hover .h-anchor, .docs-article h2[id] .h-anchor:focus-visible { opacity: 1; }
/* Kicker = the docs eyebrow: mono label with the small leading accent rule
   (mirrors index.css's .eyebrow). Base class (not a child combinator) so the
   docs-home hero kicker is styled too. */
.docs-kicker {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  font-family: var(--fm);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent-readable);
  margin-bottom: .7rem;
}
.docs-article h1 {
  font-size: clamp(1.9rem, 3.2vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.05;
  margin: 0 0 1rem;
  color: var(--text);
}
.docs-article .lede {
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--text-2);
  margin: 0 0 1.6rem;
}
.docs-article h2 {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.25;
  color: var(--text);
  margin: 2.6rem 0 .9rem;
  padding-top: .4rem;
  scroll-margin-top: 90px;
}
.docs-article h3 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
  margin: 1.8rem 0 .6rem;
  scroll-margin-top: 90px;
}
.docs-article p { color: var(--text-2); line-height: 1.7; margin: 0 0 1rem; }
.docs-article ul, .docs-article ol { color: var(--text-2); line-height: 1.7; margin: 0 0 1rem; padding-left: 1.3rem; }
.docs-article li { margin: .3rem 0; }
.docs-article li b, .docs-article p b { color: var(--text); }
/* :not(.btn) — buttons inside articles keep .btn-primary's --accent-contrast
   text; without it this rule painted accent-on-accent (unreadable, all themes). */
.docs-article a:not(.btn) { color: var(--accent-readable); text-decoration: none; border-bottom: 1px solid rgb(var(--accent-rgb) / 0.28); }
.docs-article a:not(.btn):hover { border-bottom-color: var(--accent); }
.docs-article code {
  font-family: var(--fm);
  background: var(--void);
  color: var(--accent-readable);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: .84em;
  overflow-wrap: anywhere;
}
.docs-article .frame { margin: 1.4rem 0; }
.docs-article .docs-shot-note {
  font-family: var(--fm);
  font-size: .74rem;
  color: var(--muted);
  margin: -.7rem 0 1.6rem;
}
.docs-article .guide-mini-grid { margin: 1.2rem 0 1.6rem; }
.docs-article .guide-mini-grid + .docs-callout { margin-top: 0; }
/* No orphan cards in the narrow article column: exactly four cards → 2×2;
   3n+1 counts (7, 10, …) → the last card widens into a full summary row. */
.docs-article .guide-mini-grid:has(> div:nth-child(4):last-child) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.docs-article .guide-mini-grid:not(:has(> div:nth-child(4):last-child)) > div:nth-child(3n+1):last-child:not(:first-child) {
  grid-column: 1 / -1;
}

/* --- "At a glance" box ---------------------------------------------------- */
.docs-glance {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--elevated);
  padding: 1.1rem 1.3rem;
  margin: 0 0 1.8rem;
}
.docs-glance h2 {
  font-family: var(--fm);
  font-size: .72rem !important;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .7rem !important;
  padding: 0 !important;
}
.docs-glance ul { margin: 0; padding-left: 1.1rem; }
.docs-glance li { color: var(--text-2); }

/* --- Callouts (tip / note / warn) ----------------------------------------- */
.docs-callout {
  display: flex;
  gap: .8rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  background: rgb(var(--accent-rgb) / 0.05);
  padding: .95rem 1.15rem;
  margin: 1.4rem 0;
  color: var(--text-2);
  font-size: .92rem;
  line-height: 1.6;
}
.docs-callout b { color: var(--text); }
.docs-callout code { background: var(--void); }
.docs-callout .docs-callout-ico {
  flex: 0 0 auto;
  font-family: var(--fm);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-readable);
  padding-top: .1rem;
}
.docs-callout--note { border-left-color: var(--text-2); background: rgb(var(--void-rgb) / 0.3); }
.docs-callout--note .docs-callout-ico { color: var(--text-2); }
.docs-callout--warn { border-left-color: var(--gold); background: rgb(var(--accent-rgb) / 0.04); }
.docs-callout--warn .docs-callout-ico { color: var(--gold-readable); }

/* --- Term grids inside docs — definition rows, not card boxes -------------- */
.docs-article .guide-mini-grid {
  display: block; margin: 1.2rem 0 1.6rem;
  border-top: 1px solid var(--border-soft);
}
.docs-article .guide-mini-grid > div {
  display: grid; grid-template-columns: minmax(120px, 170px) 1fr;
  gap: 1rem; align-items: baseline;
  min-height: 0; padding: .6rem .2rem;
  border: none; border-bottom: 1px solid var(--border-soft);
  border-radius: 0; background: none;
}
.docs-article .guide-mini-grid b { font-size: .9rem; }
.docs-article .guide-mini-grid span { font-size: .86rem; }
@media (max-width: 560px) {
  .docs-article .guide-mini-grid > div { grid-template-columns: 1fr; gap: .15rem; }
}

/* --- Related block — one quiet line of links, no pills --------------------- */
.docs-related {
  margin: 2.6rem 0 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border-soft);
  display: flex; flex-wrap: wrap; align-items: baseline;
}
.docs-related-h {
  font-family: var(--fm);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 1rem;
}
.docs-related ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: baseline; row-gap: .4rem; }
.docs-related li { display: flex; align-items: baseline; }
.docs-related li + li::before { content: '·'; color: var(--muted); margin: 0 .7rem; }
.docs-related a {
  font-size: .88rem;
  color: var(--accent-readable);
  text-decoration: none;
  border-bottom: 1px solid rgb(var(--accent-rgb) / 0.28);
  transition: border-color .15s;
}
.docs-related a:hover { border-bottom-color: var(--accent); }

/* --- Prev / next — plain directional links, no cards ----------------------- */
.docs-pagenav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.8rem 0 0;
}
.docs-pagenav a {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  text-decoration: none;
}
.docs-pagenav a.docs-next { text-align: right; align-items: flex-end; margin-left: auto; }
.docs-pagenav span {
  font-family: var(--fm);
  font-size: .64rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.docs-pagenav b { color: var(--accent-readable); font-size: .96rem; }
.docs-pagenav a:hover b { text-decoration: underline; text-underline-offset: 3px; }
.docs-pagenav a.docs-prev b::before { content: '← '; }
.docs-pagenav a.docs-next b::after { content: ' →'; }
.docs-pagenav .docs-pagenav-empty { display: none; }

/* --- On-this-page rail ---------------------------------------------------- */
.docs-toc {
  position: sticky;
  top: 84px;
  align-self: start;
  font-size: .84rem;
}
.docs-toc-h {
  font-family: var(--fm);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .7rem;
}
.docs-toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; border-left: 1px solid var(--border); }
.docs-toc a {
  display: block;
  color: var(--text-2);
  text-decoration: none;
  padding: .3rem .8rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  line-height: 1.35;
}
.docs-toc a:hover { color: var(--text); }
.docs-toc a.active { color: var(--accent-readable); border-left-color: var(--accent); }

/* --- Docs home (hub) ------------------------------------------------------ */
.docs-home-hero { margin: 0 0 2.4rem; }
.docs-home-hero .docs-kicker { color: var(--accent-readable); }
.docs-home-hero h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.03; color: var(--text); margin: .6rem 0 1rem; }
.docs-home-hero .lede { font-size: 1.12rem; color: var(--text-2); line-height: 1.6; max-width: 44rem; }
/* Guide index — a print-style table of contents. Mono page numbers,
   link-coloured titles, dotted leaders running to an always-visible arrow:
   unmistakably navigation, zero boxes. */
.docs-index { margin: 1.2rem 0 2.4rem; counter-reset: docs-toc-n; }
.docs-index-group {
  font-family: var(--fm); font-size: .66rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
  margin: 1.7rem 0 .5rem;
}
.docs-index-group:first-child { margin-top: 0; }
.docs-index-row {
  display: grid; grid-template-columns: 2rem auto 1fr auto;
  grid-template-areas: 'num title leader arrow' '. desc desc desc';
  align-items: baseline; column-gap: .6rem; row-gap: .15rem;
  padding: .55rem .4rem .6rem .2rem; margin: 0 -.4rem 0 -.2rem;
  border-radius: 8px; text-decoration: none;
  transition: background .15s;
}
.docs-index-row::before {
  grid-area: num; counter-increment: docs-toc-n;
  content: counter(docs-toc-n, decimal-leading-zero);
  font-family: var(--fm); font-size: .72rem; color: var(--muted);
}
.docs-index-row b {
  grid-area: title; color: var(--accent-readable);
  font-size: .98rem; font-weight: 600; letter-spacing: -.01em; white-space: nowrap;
}
.docs-index-row i {
  grid-area: leader; display: block; align-self: center; height: 1px;
  background-image: linear-gradient(90deg, var(--border) 1.5px, transparent 1.5px);
  background-size: 6px 1px; background-repeat: repeat-x; background-position: 0 50%;
  min-width: 2rem; margin: 0 .2rem;
}
.docs-index-row::after {
  grid-area: arrow; content: '→'; font-family: var(--fm);
  color: var(--muted); transition: color .15s, transform .18s var(--spring);
}
.docs-index-row span { grid-area: desc; color: var(--text-2); font-size: .84rem; line-height: 1.5; }
.docs-index-row:hover { background: rgb(var(--accent-rgb) / 0.06); }
.docs-index-row:hover b { text-decoration: underline; text-underline-offset: 3px; }
.docs-index-row:hover::after { color: var(--accent-readable); transform: translateX(3px); }
@media (max-width: 700px) {
  .docs-index-row { grid-template-columns: 2rem 1fr auto; grid-template-areas: 'num title arrow' '. desc desc'; }
  .docs-index-row i { display: none; }
  .docs-index-row b { white-space: normal; }
}

.docs-cat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
  margin: 1.2rem 0 2.4rem;
}
.docs-cat-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--elevated);
  padding: 1.2rem 1.3rem;
  text-decoration: none;
  transition: border-color .15s, background .15s, transform .15s;
}
.docs-cat-card:hover { border-color: var(--accent); background: var(--elevated2); transform: translateY(-3px); }
.docs-cat-card h3 { color: var(--text); margin: 0 0 .4rem; font-size: 1.05rem; }
.docs-cat-card p { color: var(--text-2); margin: 0; font-size: .88rem; line-height: 1.55; }
.docs-popular {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: .6rem 0 2.4rem;
}
.docs-popular a {
  font-size: .88rem;
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .45rem 1rem;
  transition: color .15s, border-color .15s;
}
.docs-popular a:hover { color: var(--accent-readable); border-color: var(--accent); }
.docs-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: linear-gradient(180deg, transparent, rgb(var(--accent-rgb) / 0.05));
  padding: 1.5rem 1.6rem;
  margin: 1rem 0 0;
}
.docs-cta p { margin: 0; color: var(--text-2); flex: 1 1 16rem; }
.docs-cta b { color: var(--text); }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 1100px) {
  .docs-page .docs-shell { grid-template-columns: 240px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 900px) {
  .docs-page .docs-shell { grid-template-columns: 1fr; gap: 1.2rem; }
  .docs-side { position: static; top: 0; }
  .docs-menu-btn { display: block; }
  .docs-side-inner {
    display: none;
    max-height: none;
    margin-top: .7rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 1rem;
    background: var(--elevated);
  }
  .docs-side.is-open .docs-side-inner { display: block; }
  .docs-article { max-width: none; }
}
@media (max-width: 560px) {
  .docs-pagenav { grid-template-columns: 1fr; }
  .docs-article .guide-mini-grid:has(> div:nth-child(4):last-child) { grid-template-columns: 1fr; }
}

/* --- Ticket mock (docs/tickets.html) -------------------------------------- */
.docs-ticket-mock { display: flex; flex-direction: column; gap: .6rem; padding: 1.4rem; background: var(--elevated); }
.docs-ticket-row { display: flex; align-items: center; gap: .9rem; padding: .85rem 1rem; background: var(--elevated2); border: 1px solid var(--border); border-radius: 12px; }
.docs-ticket-tag { flex: 0 0 auto; font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--border); }
.docs-ticket-tag--bug { color: var(--danger); border-color: rgb(var(--accent-rgb) / 0.20); }
.docs-ticket-tag--feat { color: var(--accent-readable); border-color: rgb(var(--accent-rgb) / 0.30); }
.docs-ticket-title { flex: 1 1 auto; color: var(--text); font-size: .92rem; }
.docs-ticket-state { flex: 0 0 auto; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.docs-ticket-state--open { color: var(--accent-readable); }
.docs-ticket-state--progress { color: var(--gold-readable); }
.docs-ticket-state--done { color: var(--muted); }
@media (max-width: 560px) { .docs-ticket-row { flex-wrap: wrap; gap: .5rem; } .docs-ticket-title { flex-basis: 100%; order: 3; } }
