/* PUI documentation site. Layout: header row, collapsible side navigation, raised content panel with an
   "On this page" column. Colors and sizes come from tokens only. */
/* Inter Tight (Google Fonts), the closest free match to Helvetica Now Display, for large text only
   (page titles, section headings, page descriptions); the rest of the UI uses Geist. */
:root {
  --font-display: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --frame: var(--muted);
  --panel: var(--background);
}
.dark { --frame: var(--background); --panel: var(--card); }

html { background: var(--frame); }
body { background: var(--frame); font-family: var(--font-sans); font-size: 14px; line-height: 20px; margin: 0; }
a { color: var(--primary); text-underline-offset: 3px; }
a.pui-btn:not(.pui-btn--link) { text-decoration: none; }
code { font-family: var(--font-mono); font-size: 13px; }
svg { flex-shrink: 0; }
.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; }
:where(a, button, input, summary, select, [tabindex="0"]):focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.skip-link { position: absolute; left: 16px; top: -48px; z-index: 30; padding: 8px 12px; border-radius: var(--radius-md);
  background: var(--primary); color: var(--primary-foreground); font-weight: 500; text-decoration: none; }
.skip-link:focus { top: 8px; }

/* ---------- frame */
.frame { max-width: 1440px; margin: 0 auto; padding: 0 12px 12px; box-sizing: border-box; }
.site-header { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr minmax(0, 420px) 1fr; align-items: center;
  gap: 12px; height: 60px; background: var(--frame); padding: 0 4px; }
.brand { display: inline-flex; align-items: center; gap: 10px; justify-self: start; color: var(--foreground); text-decoration: none;
  font: 800 18px/1 var(--font-sans); letter-spacing: -0.02em; }
.brand-mark { width: 22px; height: 22px; border-radius: var(--radius-md); background: var(--primary);
  box-shadow: inset 6px -6px 0 0 var(--accent-foreground); }
.header-links { display: flex; align-items: center; gap: 4px; justify-self: end; }
.header-links a { color: var(--foreground); text-decoration: none; font-weight: 500; padding: 8px 10px; border-radius: var(--radius-md); }
.header-links a:hover { background: var(--accent); color: var(--accent-foreground); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--foreground); cursor: pointer; }
.icon-btn:hover { background: var(--accent); color: var(--accent-foreground); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn svg, .search-icon svg, .pui-btn svg, .llm-options svg { width: 16px; height: 16px; fill: currentColor; }
.menu-btn { display: none; }

/* ---------- search */
.search { position: relative; width: 100%; }
.search-icon { position: absolute; left: 12px; top: 10px; color: var(--muted-foreground); display: flex; }
.search input { box-sizing: border-box; width: 100%; height: 36px; padding: 0 12px 0 36px; border: 1px solid var(--input); border-radius: var(--radius-full);
  background: var(--panel); color: var(--foreground); font: 400 14px/20px var(--font-sans); }
.search input::placeholder { color: var(--muted-foreground); }
.search input:hover { border-color: var(--primary); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: var(--popover); color: var(--popover-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 6px; }
.search-results ul { list-style: none; margin: 0; padding: 0; }
.search-results a { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: var(--radius-md); color: var(--foreground); text-decoration: none; }
.search-results a:hover, .search-results a:focus-visible { background: var(--accent); color: var(--accent-foreground); }
.hit-group { color: var(--muted-foreground); font-size: 13px; }
.hit-empty { padding: 8px 10px; color: var(--muted-foreground); }

/* ---------- layout */
.nav-section + .nav-section { margin-top: 24px; }
.nav-heading { margin: 0 0 4px; padding: 0 12px; font: 600 12px/16px var(--font-sans); color: var(--muted-foreground); }
.nav-section ul { list-style: none; margin: 0; padding: 0; }
.nav-section a { display: block; padding: 7px 12px; border-radius: var(--radius-md); color: var(--foreground); text-decoration: none; }
.nav-section a:hover { background: var(--accent); color: var(--accent-foreground); }
.nav-section a[aria-current="page"] { background: var(--panel); color: var(--foreground); font-weight: 600; box-shadow: var(--shadow-sm); }
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 12px; align-items: start; }
.sidebar { position: sticky; top: 60px; max-height: calc(100vh - 72px); overflow-y: auto; padding: 8px 4px 24px; box-sizing: border-box; }

.panel { background: var(--panel); border-radius: var(--radius-xl); box-shadow: var(--shadow-md); padding: 40px; min-width: 0; outline: none; }
/* On larger screens the panel scrolls inside itself, so its rounded corners stay in view under the header */
@media (min-width: 861px) {
  body { height: 100vh; overflow: hidden; }
  .panel { height: calc(100vh - 72px); box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain; scroll-padding-top: 24px; }
}
.panel-grid { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 40px; align-items: start; }
.article { max-width: 768px; width: 100%; margin: 0 auto; min-width: 0; font-size: 16px; line-height: 26px; }

/* ---------- page head */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-head h1 { margin: 0; font: 700 52px/1.05 var(--font-display); letter-spacing: -0.02em; color: var(--foreground); text-wrap: balance; }
.page-description { font: 400 20px/28px var(--font-display); color: var(--muted-foreground); margin: 12px 0 0; max-width: 640px; }
.llm-menu { position: relative; display: flex; align-items: center; gap: 2px; flex-shrink: 0; margin-top: 8px; }
.llm-options { position: absolute; right: 0; top: 40px; z-index: 10; list-style: none; margin: 0; padding: 6px; min-width: 200px;
  background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.llm-options a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: var(--radius-md);
  color: var(--foreground); text-decoration: none; font-size: 14px; }
.llm-options a:hover, .llm-options a:focus-visible { background: var(--accent); color: var(--accent-foreground); }

/* ---------- content */
.article > section { margin-top: 48px; }
.article h2 { font: 700 28px/34px var(--font-display); letter-spacing: -0.01em; margin: 0 0 16px; color: var(--foreground); scroll-margin-top: 24px; text-wrap: balance; }
.article h3 { font: 600 18px/26px var(--font-sans); margin: 32px 0 8px; scroll-margin-top: 24px; }
.article p, .article ul, .article ol { margin: 0 0 16px; }
.article li + li { margin-top: 6px; }
.article :not(pre) > code { background: var(--muted); padding: 2px 6px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; }
.article pre { background: var(--muted); padding: 16px; border-radius: var(--radius-lg); overflow-x: auto; font-size: 13px; line-height: 20px; margin: 0 0 16px; }
.article section > table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; display: block; overflow-x: auto; }
.article section > table th, .article section > table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.article section > table th { font-weight: 600; }
.cta { margin-top: 24px; padding: 0; }

/* ---------- interactive example: preview + controls, generated code below */
.vx { margin-top: 24px; background: var(--frame); border-radius: var(--radius-xl); padding: 24px; display: grid;
  grid-template-columns: minmax(0, 1fr) 220px; grid-template-areas: "example controls" "code controls"; gap: 24px; font-size: 14px; line-height: 20px; }
.vx-mount { display: contents; }
.vx-preview { grid-area: example; min-height: 200px; display: flex; align-items: center; justify-content: center; padding: 32px 24px;
  background: var(--panel); border-radius: var(--radius-lg); min-width: 0; }
.vx-controls { grid-area: controls; display: grid; grid-auto-rows: min-content; gap: 16px; }
.vx-control { display: grid; gap: 6px; }
.vx-control--inline { display: flex; align-items: center; gap: 8px; }
.vx-label { font: 500 13px/16px var(--font-mono); color: var(--foreground); }
.vx-control .pui-input, .vx-control select { background: var(--panel); }
.vx-code { grid-area: code; min-width: 0; background: var(--panel); border-radius: var(--radius-lg); overflow: hidden; }
.vx-code-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 16px; border-bottom: 1px solid var(--border);
  color: var(--muted-foreground); font-size: 13px; }
.article .vx-code pre { margin: 0; border-radius: 0; background: transparent; }
.example-frame { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--panel); font-size: 14px; line-height: 20px; overflow-x: auto; }
.example-frame .pui-stage { padding: 32px 24px; }
.example-frame p, .vx-preview p { margin: 0; }
details.code { margin-top: 12px; }
details.code summary { cursor: pointer; color: var(--muted-foreground); font-size: 14px; }
.anatomy { border: 1px solid var(--border); }

/* ---------- prop tables: name, type, default, description underneath */
.prop-table { margin-bottom: 8px; }
.prop-table table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.prop-table th[scope="col"] { text-align: left; font-weight: 600; padding: 8px; border-bottom: 1px solid var(--border); }
.prop-row th, .prop-row td { text-align: left; padding: 12px 8px 4px; vertical-align: top; font-weight: 400; border: 0; }
.prop-desc td { padding: 0 8px 12px; color: var(--muted-foreground); border-bottom: 1px solid var(--border); }
.prop-name { color: var(--primary); }
.prop-type { white-space: normal; word-break: break-word; }
.required { margin-left: 8px; font-size: 12px; font-weight: 500; color: var(--warning); }

/* ---------- "On this page" */
.toc { position: sticky; top: 0; font-size: 14px; line-height: 20px; }
.toc-title { font: 600 13px/16px var(--font-sans); color: var(--muted-foreground); margin: 0 0 8px; }
.toc ul { list-style: none; margin: 0 0 24px; padding: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 4px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted-foreground); text-decoration: none; }
.toc a:hover { color: var(--foreground); }
.toc a[aria-current] { color: var(--foreground); border-left-color: var(--primary); font-weight: 500; }

/* ---------- foundations */
.copy-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.copy-row > div { min-width: 0; }
.copy-row code { word-break: break-all; font-size: 13px; }
.copy-label { font-size: 14px; font-weight: 500; }
.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.tokens-table td { vertical-align: middle; }
.tok { font-weight: 600; }
.usage { color: var(--muted-foreground); font-size: 13px; line-height: 18px; max-width: 520px; }
.swatch { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-md); background: var(--background); color: var(--foreground); border: 1px solid var(--border); white-space: nowrap; }
.chip { width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--border); flex-shrink: 0; }
.type-list { display: flex; flex-direction: column; }
.type-row { display: grid; gap: 6px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.type-meta { display: flex; gap: 12px; color: var(--muted-foreground); font-size: 13px; }
.type-sample { overflow-wrap: anywhere; }
.space-list { display: flex; flex-direction: column; gap: 10px; }
.space-row { display: grid; grid-template-columns: 90px 56px 48px minmax(0, 1fr); align-items: center; gap: 12px; font-size: 14px; }
.bar { height: 16px; background: var(--primary); border-radius: var(--radius-sm); }
.val { color: var(--muted-foreground); font-family: var(--font-mono); font-size: 13px; }
.demo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; font-size: 14px; }
.demo-tile { display: flex; flex-direction: column; gap: 6px; }
.radius-box { width: 72px; height: 72px; background: var(--accent); border: 2px solid var(--primary); }
.shadow-box { width: 100%; height: 72px; background: var(--card); border-radius: var(--radius-lg); border: 1px solid var(--border); }

/* ---------- footer, inside the panel */
.site-footer { margin-top: 64px; padding-top: 16px; border-top: 1px solid var(--border); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 20px;
  color: var(--muted-foreground); font-size: 12px; line-height: 18px; }
.site-footer a { color: var(--muted-foreground); }

/* ---------- smaller screens */
@media (max-width: 1100px) {
  .panel-grid { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .frame { padding: 0; }
  .site-header { grid-template-columns: auto auto minmax(0, 1fr) auto; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .menu-btn { display: inline-grid; }
  .header-links a { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar { display: none; position: static; max-height: none; padding: 8px 12px 16px; background: var(--frame); }
  .sidebar.open { display: block; }
  .panel { border-radius: 0; box-shadow: none; padding: 24px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left)); }
  .page-head { flex-direction: column; }
  .page-head h1 { font-size: 40px; }
  .page-description { font-size: 18px; line-height: 26px; }
  .vx { grid-template-columns: minmax(0, 1fr); grid-template-areas: "example" "controls" "code"; padding: 12px; gap: 12px; }
  .vx-controls { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-top: 1px solid var(--border); padding-top: 12px; }
  .space-row { grid-template-columns: 80px 48px minmax(0, 1fr); }
  .space-row .usage { grid-column: 1 / -1; }
  .site-footer ul { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
