/* Tidy Docs (/tidy/docs). Hand-written; the pages are generated by
   scripts/build_tidy_docs.py from content/tidy-docs/. Loads after tidy.css and uses its
   tokens and header/footer. Layout: left sidebar, article, "On this page" on wide screens. */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.docs-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 88px); border-bottom: 1px solid var(--line); }

/* Sidebar */
.docs-side { position: sticky; top: 88px; align-self: start; max-height: calc(100vh - 88px); overflow-y: auto; padding: 32px 24px 48px 40px; border-right: 1px solid var(--line); background: var(--paper); }
.docs-nav-toggle > summary { display: none; }
.docs-nav { display: flex; flex-direction: column; gap: 28px; }
.dn-section { display: flex; flex-direction: column; gap: 2px; }
.dn-title { margin: 0 0 8px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.dn-group { margin: 14px 0 4px; padding-left: 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.docs-nav a { display: block; padding: 7px 12px; border-radius: 8px; font-size: 15px; line-height: 1.35; color: var(--body); text-decoration: none; transition: background-color 120ms ease-out, color 120ms ease-out; }
.docs-nav a:hover { background: var(--white); color: var(--ink); }
.docs-nav a[aria-current="page"] { background: var(--accent-wash); color: var(--accent-hover); font-weight: 600; }

/* Search */
.docs-search { position: relative; margin-bottom: 28px; }
.docs-search input { width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); font: inherit; font-size: 15px; color: var(--ink); }
.docs-search input::placeholder { color: var(--muted); }
.docs-search input:focus { outline: 3px solid var(--accent-wash); border-color: var(--accent); }
#docs-search-results { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--white); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 20px 40px -24px rgba(24, 34, 38, 0.4); }
#docs-search-results a { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); }
#docs-search-results a:hover, #docs-search-results a:focus { background: var(--accent-wash-soft); }
#docs-search-results strong { font-size: 15px; font-weight: 600; }
#docs-search-results span { font-size: 12px; color: var(--muted); }
#docs-search-results .none { padding: 10px 12px; font-size: 14px; color: var(--muted); }

/* Main column */
.docs-main { display: grid; grid-template-columns: minmax(0, 760px) 220px; justify-content: center; gap: 64px; padding: 48px 56px 96px; background: var(--white); }
.docs-article { min-width: 0; }
.docs-crumbs { font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.docs-crumbs a { color: var(--muted); text-decoration: none; }
.docs-crumbs a:hover { color: var(--accent); text-decoration: underline; }
.docs-article h1 { font-size: 44px; line-height: 1.1; letter-spacing: -0.01em; }
.docs-lede { margin-top: 16px; font-size: 19px; line-height: 1.55; color: var(--body); }
.docs-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 8px; padding-bottom: 28px; border-bottom: 1px solid var(--line-soft); }
.dt-btn { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); font: inherit; font-size: 13px; font-weight: 500; color: var(--body); text-decoration: none; cursor: pointer; transition: border-color 120ms ease-out, color 120ms ease-out; }
.dt-btn:hover { border-color: var(--accent); color: var(--accent-hover); }
@media (pointer: coarse) { .dt-btn { min-height: 44px; } }

/* Prose */
.docs-body { font-size: 17px; line-height: 1.7; color: var(--body); }
.docs-body > * + * { margin-top: 18px; }
.docs-body h2 { margin-top: 48px; font-size: 28px; line-height: 1.2; color: var(--ink); scroll-margin-top: 104px; }
.docs-body h3 { margin-top: 32px; font-size: 21px; line-height: 1.3; color: var(--ink); scroll-margin-top: 104px; }
.docs-body h4 { margin-top: 24px; font-family: var(--sans); font-size: 17px; font-weight: 700; color: var(--ink); scroll-margin-top: 104px; }
.docs-body h2:first-child { margin-top: 32px; }
.docs-body .anchor { float: left; margin-left: -1.1em; width: 1.1em; color: var(--line); text-decoration: none; opacity: 0; transition: opacity 120ms ease-out; }
.docs-body h2:hover .anchor, .docs-body h3:hover .anchor, .docs-body h4:hover .anchor, .docs-body .anchor:focus-visible { opacity: 1; }
.docs-body strong { color: var(--ink); font-weight: 600; }
.docs-body ul, .docs-body ol { padding-left: 24px; }
.docs-body li + li { margin-top: 8px; }
.docs-body li > ul, .docs-body li > ol { margin-top: 8px; }
.docs-body ol > li::marker { font-weight: 600; color: var(--accent); }
.docs-body code { font-family: var(--mono); font-size: 0.86em; padding: 2px 6px; border-radius: 6px; background: var(--paper); border: 1px solid var(--line-soft); color: var(--ink); overflow-wrap: anywhere; }
.docs-body pre { margin-top: 20px; padding: 18px 20px; border-radius: 10px; background: var(--slate-deep); overflow-x: auto; }
.docs-body pre code { padding: 0; border: 0; background: none; color: var(--on-slate); font-size: 14px; line-height: 1.6; overflow-wrap: normal; }
.docs-body kbd { font-family: var(--mono); font-size: 0.82em; padding: 2px 7px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--white); color: var(--ink); }
.docs-body hr { border: 0; border-top: 1px solid var(--line-soft); margin: 40px 0; }
.docs-body a { text-underline-offset: 3px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.docs-body table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
.docs-body th { text-align: left; padding: 12px 16px; background: var(--paper); color: var(--ink); font-weight: 600; border-bottom: 1px solid var(--line); }
.docs-body td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.docs-body tr:last-child td { border-bottom: 0; }

.callout { padding: 16px 20px; border-radius: 10px; border: 1px solid var(--line); border-left-width: 4px; background: var(--paper); font-size: 16px; }
.callout > * + * { margin-top: 8px; }
.callout-label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.callout-tip { border-left-color: var(--accent); background: var(--accent-wash-soft); }
.callout-tip .callout-label { color: var(--accent); }
.callout-warning { border-left-color: #B45309; background: #FFFBEB; }
.callout-warning .callout-label { color: #92400E; }
.callout-agent { border-left-color: var(--slate); background: #F1F4F5; }
.callout-plan { border-left-color: #6D28D9; background: #F5F3FF; }
.callout-plan .callout-label { color: #5B21B6; }

/* Cards on the introduction page */
.docs-body .cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.docs-body .cards li { margin: 0; }

/* Pager */
.docs-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--line-soft); }
.docs-pager a { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; transition: border-color 120ms ease-out; }
.docs-pager a:hover { border-color: var(--accent); }
.docs-pager span { font-size: 13px; color: var(--muted); }
.docs-pager strong { font-size: 16px; color: var(--ink); }
.pg-next { grid-column: 2; text-align: right; }

/* On this page */
.docs-toc { position: sticky; top: 120px; align-self: start; max-height: calc(100vh - 140px); overflow-y: auto; font-size: 14px; }
.toc-title { font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.docs-toc ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; border-left: 1px solid var(--line); }
.docs-toc a { display: block; padding: 4px 0 4px 14px; color: var(--body); text-decoration: none; line-height: 1.4; }
.docs-toc a:hover { color: var(--accent); }
.docs-toc .toc-l3 a { padding-left: 28px; font-size: 13px; color: var(--muted); }

@media (max-width: 1279px) {
  .docs-main { grid-template-columns: minmax(0, 760px); padding: 40px 48px 88px; }
  .docs-toc { display: none; }
}
@media (max-width: 1023px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); }
  .docs-side { position: static; max-height: none; overflow: visible; padding: 16px var(--gutter); border-right: 0; border-bottom: 1px solid var(--line); }
  .docs-search { margin-bottom: 12px; }
  .docs-nav-toggle > summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); font-weight: 600; cursor: pointer; list-style: none; }
  .docs-nav-toggle > summary::-webkit-details-marker { display: none; }
  .docs-nav-toggle > summary::after { content: "+"; font-size: 20px; color: var(--muted); }
  .docs-nav-toggle[open] > summary::after { content: "\2212"; }
  .docs-nav-toggle[open] .docs-nav { margin-top: 20px; }
  .docs-main { padding: 32px var(--gutter) 72px; }
  .docs-article h1 { font-size: 36px; }
}
@media (max-width: 639px) {
  .docs-article h1 { font-size: 30px; }
  .docs-lede { font-size: 17px; }
  .docs-body { font-size: 16px; }
  .docs-body h2 { font-size: 24px; }
  .docs-body .cards, .docs-pager { grid-template-columns: minmax(0, 1fr); }
  .pg-next { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) { .docs-nav a, .dt-btn, .docs-pager a, .docs-body .anchor { transition: none; } }
