/* Docs layer on top of style.css. Colors, type and depth come from the shared
   amber-minimal theme and clay material; see apps/pecu/docs/design-system.md. */
.docs-page {
  --docs-header: 64px;
  --shiki-foreground: var(--dark-foreground);
  --shiki-background: var(--dark);
  --shiki-token-keyword: var(--primary);
  --shiki-token-constant: color-mix(in oklch, var(--chart-2) 70%, var(--dark-foreground));
  --shiki-token-string: color-mix(in oklch, var(--primary) 42%, var(--dark-foreground));
  --shiki-token-string-expression: color-mix(in oklch, var(--primary) 42%, var(--dark-foreground));
  --shiki-token-comment: var(--dark-muted-foreground);
  --shiki-token-function: var(--dark-foreground);
  --shiki-token-parameter: var(--dark-foreground);
  --shiki-token-punctuation: var(--dark-muted-foreground);
  --shiki-token-link: var(--primary);
  --shiki-token-inserted: var(--primary);
  --shiki-token-deleted: var(--dark-muted-foreground);
}
html:has(> .docs-page) { scroll-padding-top: calc(var(--docs-header) + 24px); }
.docs-page main { max-width: none; margin: 0; padding: 0; }
.docs-page :focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }
.docs-page main:focus { outline: none; }

/* Icons and small controls */
.docs-page .icon { flex: none; display: block; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; padding: 0; border: 0; border-radius: var(--clay-radius-control); background: none; color: var(--foreground); cursor: pointer; transition: background-color var(--fast) ease; }
.icon-button:hover { background: var(--muted); }

/* Header */
.docs-header { position: sticky; top: 0; z-index: 20; background: var(--background); border-bottom: 1px solid var(--border); }
.docs-header-inner { max-width: 1440px; height: var(--docs-header); margin: auto; padding: 0 24px; display: flex; align-items: center; gap: 28px; }
.docs-menu { display: none; }
.docs-brand { display: flex; align-items: baseline; gap: 8px; flex: none; }
.docs-brand > span { color: var(--border); font: 600 20px var(--font-mono); }
.docs-home { color: var(--foreground); font: 600 20px var(--font-mono); letter-spacing: -0.5px; text-decoration: none; }
.docs-home:hover { color: var(--accent-foreground); }
.product-switch { display: flex; gap: 4px; padding: 4px; border-radius: var(--clay-radius-pill); background: var(--muted); box-shadow: var(--clay-shadow-inset); }
.docs-page .product-switch a { min-height: 36px; padding: 0 16px; justify-content: center; border-radius: var(--clay-radius-pill); color: var(--muted-foreground); font-size: 14px; font-weight: 600; transition: color var(--fast) ease; }
.docs-page .product-switch a:hover { color: var(--foreground); }
.docs-page .product-switch a[aria-current] { background: var(--card); color: var(--foreground); box-shadow: var(--clay-shadow-sm); }
.docs-search-trigger { margin-left: auto; display: flex; align-items: center; gap: 10px; width: 260px; height: 40px; padding: 0 8px 0 14px; border: 1px solid var(--border); border-radius: var(--clay-radius-control); background: var(--card); color: var(--muted-foreground); box-shadow: var(--clay-shadow-inset); font: 500 14px var(--font-sans); cursor: pointer; transition: color var(--fast) ease; }
.docs-search-trigger:hover { color: var(--foreground); }
.docs-search-trigger kbd { margin-left: auto; min-width: 24px; padding: 2px 7px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--muted); color: var(--muted-foreground); font: 500 12px/1.5 var(--font-mono); text-align: center; }

/* Three-column layout: pages, article, outline */
.docs-layout { max-width: 1440px; margin: 0 auto; padding: 0 24px; display: grid; grid-template-columns: 248px minmax(0, 1fr) 216px; gap: 56px; }
.docs-layout.no-outline { grid-template-columns: 248px minmax(0, 1fr); }

/* Sidebar */
.docs-sidebar { position: sticky; top: var(--docs-header); align-self: start; height: calc(100dvh - var(--docs-header)); overflow-y: auto; overscroll-behavior: contain; padding: 28px 8px 40px 0; }
.drawer-head, .docs-sidebar > .product-switch, .docs-scrim { display: none; }
.docs-sidebar nav { display: block; }
.nav-group + .nav-group { margin-top: 24px; }
.docs-page .nav-group-title { margin: 0 0 6px; padding: 0 12px; color: var(--foreground); font-size: 13px; font-weight: 650; line-height: 1.4; }
.docs-sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.docs-page .docs-sidebar nav a { display: flex; min-height: 36px; padding: 7px 12px; border-radius: 10px; color: var(--muted-foreground); font-size: 14.5px; font-weight: 500; line-height: 1.4; transition: color var(--fast) ease, background-color var(--fast) ease; }
.docs-page .docs-sidebar nav a:hover { color: var(--foreground); background: var(--muted); }
.docs-page .docs-sidebar nav a[aria-current="page"] { color: var(--accent-foreground); background: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--primary) 32%, transparent); }
.nav-source { display: inline-flex; align-items: center; min-height: 44px; margin: 24px 12px 0; font-size: 14px; font-weight: 500; }

/* Article */
.docs-page .docs-main { min-width: 0; padding: 44px 0 72px; }
.docs-article { max-width: 760px; }
.docs-article h1 { margin: 0 0 14px; font-size: clamp(32px, 3.4vw, 42px); line-height: 1.08; letter-spacing: -0.035em; font-weight: 750; }
.docs-page .docs-lead { max-width: 64ch; margin: 0 0 40px; color: var(--muted-foreground); font-size: 18px; line-height: 1.6; }
.prose { color: var(--foreground); font-size: 16px; line-height: 1.72; overflow-wrap: break-word; }
.docs-page .prose p { margin: 0 0 18px; color: var(--foreground); font-size: 16px; line-height: 1.72; }
.prose h2 { margin: 56px 0 16px; font-size: 26px; line-height: 1.2; letter-spacing: -0.025em; font-weight: 700; scroll-margin-top: calc(var(--docs-header) + 24px); }
.prose h3 { margin: 36px 0 12px; font-size: 19px; line-height: 1.3; letter-spacing: -0.015em; font-weight: 650; scroll-margin-top: calc(var(--docs-header) + 24px); }
.prose > :first-child { margin-top: 0; }
.prose h2 + h3 { margin-top: 20px; }
.prose :is(h2, h3) code { font-size: 0.86em; }
.prose .anchor { margin-left: 10px; color: var(--muted-foreground); font-weight: 500; text-decoration: none; opacity: 0; transition: opacity var(--fast) ease; }
.prose .anchor:focus-visible { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .prose :is(h2, h3):hover .anchor { opacity: 1; }
}
.prose :is(ul, ol) { margin: 0 0 18px; padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose li > p { margin: 0; }
.prose li::marker { color: var(--muted-foreground); }
.prose a { font-weight: 500; }
.prose strong { font-weight: 650; }
.prose hr { margin: 40px 0; border: 0; border-top: 1px solid var(--border); }
.prose blockquote { margin: 24px 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--border); color: var(--muted-foreground); }
.prose code { font-size: 0.86em; overflow-wrap: break-word; }
.prose code.nowrap { white-space: nowrap; }

/* Code blocks: recessed terminal surface */
.code-block { position: relative; margin: 20px 0 24px; }
.code-block pre { margin: 0; padding: 18px 60px 18px 20px; overflow-x: auto; border-radius: var(--clay-radius-control); background: var(--dark); color: var(--dark-foreground); box-shadow: var(--clay-shadow-inset); font: 13.5px/1.7 var(--font-mono); tab-size: 2; }
.code-block pre code { display: block; padding: 0; border: 0; border-radius: 0; background: none; color: inherit; font: inherit; overflow-wrap: normal; white-space: pre; }
.copy-code { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--dark-border); border-radius: 10px; background: var(--dark-card); color: var(--dark-muted-foreground); cursor: pointer; transition: color var(--fast) ease, border-color var(--fast) ease; }
.copy-code::before { content: ""; position: absolute; inset: -4px; }
.copy-code:hover { color: var(--dark-foreground); border-color: var(--dark-muted-foreground); }
.copy-code .icon { grid-area: 1 / 1; width: 16px; height: 16px; transition: opacity var(--fast) var(--ease-out), transform var(--fast) var(--ease-out); }
.copy-code .icon-check { opacity: 0; transform: scale(0.9); color: var(--primary); }
.copy-code[data-copied] .icon-copy { opacity: 0; transform: scale(0.9); }
.copy-code[data-copied] .icon-check { opacity: 1; transform: none; }

/* Tables */
.table-wrap { margin: 20px 0 24px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--clay-radius-control); background: var(--card); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.55; }
.table-wrap :is(th, td) { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table-wrap th { background: var(--muted); font-size: 13px; font-weight: 650; white-space: nowrap; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td code { font-size: 0.9em; }
.table-wrap td:first-child { min-width: 140px; }

/* Callouts */
.callout { margin: 24px 0; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--clay-radius-control); background: var(--muted); }
.docs-page .callout p { margin: 0 0 8px; font-size: 15px; line-height: 1.65; }
.docs-page .callout p:last-child { margin-bottom: 0; }
.docs-page .callout-title { display: flex; align-items: center; gap: 8px; color: var(--foreground); font-size: 14px; font-weight: 650; }
.callout-title .icon { width: 16px; height: 16px; }
.callout-warning { background: var(--accent); border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); }
.docs-page .callout-warning .callout-title { color: var(--accent-foreground); }

/* Outline */
.docs-toc { position: sticky; top: var(--docs-header); align-self: start; max-height: calc(100dvh - var(--docs-header)); overflow-y: auto; padding: 48px 0 40px; }
.docs-toc nav, .toc-inline nav { display: block; }
.docs-toc ul, .toc-inline ul { list-style: none; margin: 0; padding: 0; }
.docs-toc ul { border-left: 1px solid var(--border); }
.docs-page .docs-toc a { display: block; min-height: 0; margin-left: -1px; padding: 5px 0 5px 14px; border-left: 2px solid transparent; color: var(--muted-foreground); font-size: 13.5px; font-weight: 500; line-height: 1.45; }
.docs-page .docs-toc .toc-h3 a { padding-left: 26px; font-size: 13px; }
.docs-page .docs-toc a:hover { color: var(--foreground); }
.docs-page .docs-toc a.is-active { color: var(--foreground); border-left-color: var(--primary); }
.toc-inline { display: none; margin: -16px 0 36px; border: 1px solid var(--border); border-radius: var(--clay-radius-control); background: var(--card); box-shadow: var(--clay-shadow-sm); }
.toc-inline summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 16px; font-size: 14px; font-weight: 600; list-style: none; cursor: pointer; }
.toc-inline summary::-webkit-details-marker { display: none; }
.toc-inline .icon-chevron { transition: transform 200ms var(--ease-out); }
.toc-inline[open] .icon-chevron { transform: rotate(180deg); }
.toc-inline nav { padding: 0 16px 12px; }
.docs-page .toc-inline a { display: flex; min-height: 40px; align-items: center; color: var(--muted-foreground); font-size: 14px; font-weight: 500; }
.docs-page .toc-inline .toc-h3 a { padding-left: 14px; }

/* Previous and next */
.docs-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--border); }
.pager-card { display: grid; align-content: start; gap: 6px; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--clay-radius-surface); background: var(--card); box-shadow: var(--clay-shadow-sm); color: var(--foreground); text-decoration: none; transition: transform var(--fast) var(--ease-out); }
.pager-next { grid-column: 2; justify-items: end; text-align: right; }
.pager-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted-foreground); font-size: 13px; font-weight: 500; }
.pager-label .icon { width: 15px; height: 15px; }
.pager-title { font-size: 16px; font-weight: 650; }
.pager-card:hover .pager-title { color: var(--accent-foreground); }
.pager-card:active { transform: translateY(1px); }

/* Footer */
.docs-page .docs-footer { display: block; padding: 0; border-top: 1px solid var(--border); background: var(--muted); }
.docs-footer-inner { max-width: 1440px; margin: auto; padding: 32px 24px 40px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 48px; }
.docs-page .docs-footer p { margin: 0; color: var(--muted-foreground); font-size: 13.5px; line-height: 1.65; }
.docs-footer strong { color: var(--foreground); }
.docs-footer nav { grid-column: 1 / -1; flex-wrap: wrap; gap: 0 24px; }
.docs-page .docs-footer nav a { color: var(--accent-foreground); font-size: 14px; }

/* Search */
.docs-search { width: min(640px, calc(100vw - 32px)); max-height: min(560px, calc(100dvh - 96px)); margin: 72px auto auto; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--clay-radius-surface); background: var(--background); color: var(--foreground); box-shadow: var(--clay-shadow); }
.docs-search[open] { display: flex; flex-direction: column; }
.docs-search::backdrop { background: color-mix(in oklch, var(--foreground) 28%, transparent); }
.search-field { display: flex; align-items: center; gap: 10px; padding: 0 6px 0 18px; border-bottom: 1px solid var(--border); color: var(--muted-foreground); }
.search-field input { flex: 1; min-width: 0; height: 58px; padding: 0; border: 0; outline: none; background: none; color: var(--foreground); font: 500 16px var(--font-sans); appearance: none; }
.search-field input::-webkit-search-cancel-button { appearance: none; }
.docs-page .search-field input:focus-visible { outline: none; }
.search-results { flex: 1; margin: 0; padding: 8px; overflow-y: auto; list-style: none; }
.search-results:empty { display: none; }
.search-results a { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; color: var(--foreground); text-decoration: none; }
.search-results [aria-selected="true"] a { background: var(--accent); }
.result-path { color: var(--muted-foreground); font-size: 12.5px; font-weight: 500; }
.result-title { font-size: 15px; font-weight: 600; }
.result-text { display: -webkit-box; overflow: hidden; color: var(--muted-foreground); font-size: 13.5px; line-height: 1.5; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-results mark { padding: 0 1px; border-radius: 3px; background: color-mix(in oklch, var(--primary) 34%, transparent); color: inherit; }
.docs-page .search-empty { margin: 0; padding: 18px 20px 22px; color: var(--muted-foreground); font-size: 14px; }
.docs-page .search-empty:empty { display: none; }

/* Landing */
.docs-page .docs-landing { max-width: 1120px; margin: 0 auto; padding: 48px 32px 72px; }
.docs-landing h1 { margin: 0 0 32px; font-size: clamp(36px, 5vw, 56px); line-height: 1.04; letter-spacing: -0.035em; font-weight: 750; }
.docs-tiles { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
.docs-tiles > .bento { grid-column: 1 / -1; }
.docs-tiles > .bento.aero { grid-column: span 7; }
.docs-tiles > .bento.evm { grid-column: span 5; }
.docs-tiles .evm .tile-visual { flex: 1; min-height: 180px; }
.docs-tiles .tile-copy { display: flex; flex-direction: column; min-width: 0; }
.docs-tile h2 { margin: 0 0 12px; font-size: 28px; line-height: 1.15; letter-spacing: -0.03em; }
.docs-tile .tile-copy h2 a { color: inherit; text-decoration: none; }
.docs-tile .tile-copy h2 a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
.docs-tile h2 small { display: block; margin-top: 6px; color: inherit; font-size: 15px; font-weight: 500; letter-spacing: 0; opacity: 0.8; }
.docs-page .docs-tile p { font-size: 15.5px; line-height: 1.6; }
.tile-links { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; margin: 24px 0 0; padding: 0; list-style: none; }
.tile-links a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; border-top: 1px solid var(--border); color: var(--foreground); font-size: 15px; font-weight: 600; text-decoration: none; }
.tile-links .icon { width: 16px; height: 16px; transition: transform var(--fast) var(--ease-out); }
.docs-tile.agent .tile-copy { padding: 8px 4px 4px 0; }
.docs-tile.agent :is(h2, .tile-links a) { color: var(--dark-foreground); }
.docs-tile.agent h2 small { color: var(--dark-muted-foreground); }
.docs-page .docs-tile.agent p { color: var(--dark-muted-foreground); }
.docs-tile.agent .tile-links a { border-color: var(--dark-border); }
.docs-tile.agent .tile-links a:hover { color: var(--primary); }
.docs-tile.aero :is(h2, .tile-links a) { color: var(--aero-blue-foreground); }
.docs-page .docs-tile.aero p { color: var(--aero-blue-foreground); }
.docs-tile.aero .tile-links a { border-color: color-mix(in oklch, var(--aero-blue-foreground) 28%, transparent); }
.docs-tile.aero .cmd { white-space: pre-wrap; }
.docs-tile.evm .tile-links a:hover { color: var(--accent-foreground); }
@media (hover: hover) and (pointer: fine) {
  .tile-links a:hover .icon { transform: translateX(2px); }
  .pager-card:hover { transform: translateY(-2px); }
}
.docs-missing p { max-width: 48ch; margin-bottom: 28px; font-size: 17px; }

@media (prefers-reduced-motion: reduce) {
  .copy-code .icon, .tile-links .icon, .toc-inline .icon-chevron { transition-property: opacity; }
  .copy-code .icon-check, .copy-code[data-copied] .icon-copy { transform: none; }
  .pager-card, .pager-card:active { transform: none; transition: none; }
}

/* Medium screens: the outline moves into the article */
@media (max-width: 1179px) {
  .docs-layout, .docs-layout.no-outline { grid-template-columns: 232px minmax(0, 1fr); gap: 44px; }
  .docs-toc { display: none; }
  .toc-inline { display: block; }
  .docs-search-trigger { width: 220px; }
}
@media (max-width: 999px) {
  .docs-tiles > .bento.aero, .docs-tiles > .bento.evm { grid-column: 1 / -1; }
  .docs-tiles > .bento.aero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; padding: 12px; }
  .docs-tiles > .bento.aero .tile-copy { padding: 12px 12px 12px 0; }
}

/* Small screens: pages move into a drawer */
@media (max-width: 899px) {
  .docs-header-inner { padding: 0 8px; gap: 4px; }
  .docs-menu { display: inline-flex; }
  .docs-header > .docs-header-inner > .product-switch { display: none; }
  .docs-search-trigger { width: 44px; height: 44px; margin-left: auto; padding: 0; justify-content: center; border-color: transparent; background: none; box-shadow: none; color: var(--foreground); }
  .docs-search-trigger :is(span, kbd) { display: none; }
  .docs-layout, .docs-layout.no-outline { display: block; padding: 0 20px; }
  .docs-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(320px, 86vw); height: 100dvh; padding: 8px 16px 32px; background: var(--background); box-shadow: var(--clay-shadow); visibility: hidden; transform: translateX(-100%); transition: transform 200ms var(--ease-in-out), visibility 0s linear 200ms; }
  .docs-sidebar.is-open { visibility: visible; transform: none; transition: transform 200ms var(--ease-in-out), visibility 0s; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; height: 56px; margin-bottom: 12px; padding-left: 4px; }
  .docs-sidebar > .product-switch { display: flex; margin-bottom: 24px; }
  .docs-page .docs-sidebar > .product-switch a { flex: 1; padding: 0 8px; }
  .docs-page .docs-sidebar nav a { min-height: 44px; align-items: center; }
  .docs-scrim { display: block; position: fixed; inset: 0; z-index: 30; background: color-mix(in oklch, var(--foreground) 28%, transparent); opacity: 0; visibility: hidden; transition: opacity 200ms var(--ease-in-out), visibility 0s linear 200ms; }
  .docs-scrim.is-open { opacity: 1; visibility: visible; transition: opacity 200ms var(--ease-in-out), visibility 0s; }
  .docs-page.nav-open { overflow: hidden; }
  .docs-page .docs-main { padding: 28px 0 56px; }
  .docs-page .docs-lead { margin-bottom: 32px; font-size: 17px; }
  .docs-pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: auto; }
  .docs-footer-inner { grid-template-columns: 1fr; padding: 28px 20px 36px; }
  .docs-page .docs-landing { padding: 32px 20px 56px; }
  .docs-landing h1 { margin-bottom: 24px; }
  .docs-tiles { gap: 16px; }
}
@media (max-width: 899px) and (prefers-reduced-motion: reduce) {
  .docs-sidebar, .docs-sidebar.is-open { transform: none; }
  .docs-sidebar { opacity: 0; transition: opacity 160ms ease, visibility 0s linear 160ms; }
  .docs-sidebar.is-open { opacity: 1; transition: opacity 160ms ease, visibility 0s; }
}
@media (max-width: 759px) {
  .docs-tiles > .bento.aero { display: flex; padding: 12px 12px 24px; }
  .docs-tiles > .bento.aero .tile-copy { padding: 0 12px; }
  .tile-links { grid-template-columns: 1fr; }
  .code-block { margin-left: -4px; margin-right: -4px; }
}
@media (max-width: 380px) {
  .docs-layout, .docs-layout.no-outline { padding: 0 16px; }
  .docs-page .docs-landing { padding-left: 16px; padding-right: 16px; }
}
@media (hover: none) {
  .docs-search-trigger kbd { display: none; }
}
