/* The documentation page (docs/specs/documentation.md). Builds on ../styles.css: the same
   colors, type and header, with a sidebar, screenshots and reference blocks. */

.wrap-wide { width: min(1320px, 100% - 2.5rem); margin-inline: auto; }
.brand-tag { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; color: var(--teal); background: color-mix(in srgb, var(--teal) 12%, transparent); border-radius: 999px; padding: 0.15rem 0.55rem; margin-left: 0.15rem; }
.top nav a[aria-current="page"] { color: var(--text); }

/* The opening */
.docs-hero {
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(2.5rem, 5vw, 3.5rem);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(50rem 24rem at 90% -20%, color-mix(in srgb, var(--mark) 24%, transparent), transparent 60%),
    radial-gradient(36rem 22rem at -5% 120%, color-mix(in srgb, var(--teal) 12%, transparent), transparent 60%);
}
.docs-hero h1 { font-size: clamp(2.2rem, 4.4vw, 3.4rem); }
.docs-hero h1 .line { display: inline-block; }
@media (min-width: 681px) { .docs-hero h1 .line { white-space: nowrap; } }
.hero-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr); gap: clamp(2rem, 5vw, 4rem); align-items: center; margin-bottom: 2.5rem; }
.hero-shots { position: relative; padding: 0 3.5rem 2.5rem 0; }
.hero-desk img, .hero-phone img { display: block; width: 100%; height: auto; }
.hero-desk { display: block; overflow: hidden; border-radius: 14px; border: 1px solid var(--line); background: var(--paper-2); padding-top: 1.5rem; box-shadow: var(--shadow-lg); position: relative; }
.hero-desk::before { content: ""; position: absolute; top: 0.5rem; left: 0.75rem; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: #ff5f57; box-shadow: 0.8rem 0 #febc2e, 1.6rem 0 #28c840; }
.hero-phone { position: absolute; right: 0; bottom: 0; width: 30%; overflow: hidden; border: 6px solid var(--ink); border-radius: 26px; background: var(--ink); box-shadow: var(--shadow-lg); }
.hero-phone img { border-radius: 20px; }
.docs-hero .lead { margin: 1rem 0 0; max-width: 40rem; }
.paths { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.paths a {
  display: flex; gap: 0.85rem; align-items: flex-start; height: 100%;
  padding: 1.1rem 1.15rem; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  color: var(--text); text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.paths a:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--teal) 40%, var(--line)); }
.paths strong { display: block; font-size: 1.02rem; margin-bottom: 0.15rem; }
.paths a > span:last-child > span { display: block; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.path-i { flex: none; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 12px; background: color-mix(in srgb, var(--mark) 45%, transparent); }
.path-i svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: var(--mark-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Sidebar and article */
.docs-grid { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); gap: clamp(2rem, 5vw, 5rem); align-items: start; padding: 2.5rem 0 5rem; }
.sidebar { position: sticky; top: 5.25rem; max-height: calc(100vh - 6.5rem); overflow-y: auto; scrollbar-width: thin; padding: 0.25rem 0.5rem 1rem 0; }
.toc ul { list-style: none; margin: 0 0 1.4rem; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; margin-left: -1px; padding: 0.3rem 0.85rem; border-left: 2px solid transparent; color: var(--muted); font-size: 0.93rem; line-height: 1.4; text-decoration: none; }
.toc a:hover { color: var(--text); border-left-color: color-mix(in srgb, var(--muted) 45%, transparent); }
.toc a.active { color: var(--text); font-weight: 650; border-left-color: var(--accent); background: linear-gradient(90deg, color-mix(in srgb, var(--mark) 22%, transparent), transparent); }
.toc-group { margin: 0 0 0.45rem; font-size: 0.74rem; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase; color: var(--teal); }
.toc-none { color: var(--muted); font-size: 0.92rem; }
.filter { position: relative; display: block; margin-bottom: 1.4rem; }
.filter svg { position: absolute; left: 0.7rem; top: 50%; width: 1rem; height: 1rem; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.filter input { width: 100%; font: inherit; font-size: 0.92rem; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem 0.75rem 0.5rem 2.1rem; }
.filter input::placeholder { color: var(--muted); }
.filter[hidden] { display: none; }
.sidebar-toggle { display: none; }

.doc { max-width: 52rem; min-width: 0; }
.doc section + section { margin-top: 4.5rem; padding-top: 3.5rem; border-top: 1px solid var(--line); }
.doc h2 { font-size: clamp(1.8rem, 3vw, 2.35rem); max-width: none; margin-bottom: 1rem; }
.doc h3 { font-size: 1.32rem; margin: 2.75rem 0 0.7rem; letter-spacing: -0.01em; }
.doc h2, .doc h3 { scroll-margin-top: 5.5rem; }
.doc p, .doc li { max-width: 46rem; }
.doc code { background: color-mix(in srgb, var(--muted) 12%, transparent); border-radius: 5px; padding: 0.08em 0.32em; font-size: 0.86em; }
.doc p code, .doc li code, .doc td code { white-space: nowrap; }
.doc kbd { font: inherit; font-size: 0.86em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0.02em 0.36em; white-space: nowrap; }
.doc pre code, .doc .tree code { background: none; padding: 0; font-size: inherit; }
.doc .terminal pre { font-size: 0.86rem; }
.doc .terminal { margin: 1.25rem 0 1.5rem; border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
@media (prefers-color-scheme: dark) {
  .doc .terminal, .doc .tree { background: #121a2b; border: 1px solid var(--line); }
}

/* Screenshots: a browser window or a phone, opening larger on a tap (D10) */
.shot { margin: 1.75rem 0 2rem; }
.shot .zoom {
  position: relative; display: block; overflow: hidden; cursor: zoom-in;
  border: 1px solid var(--line); border-radius: 14px; background: var(--paper-2);
  padding-top: 1.7rem; box-shadow: var(--shadow-lg);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.shot .zoom::before { content: ""; position: absolute; top: 0.6rem; left: 0.8rem; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #ff5f57; box-shadow: 0.9rem 0 #febc2e, 1.8rem 0 #28c840; }
.shot .zoom:hover { transform: translateY(-2px); }
.shot img { display: block; width: 100%; height: auto; }
.shot.phone .zoom { padding: 0; border: 7px solid var(--ink); border-radius: 30px; background: var(--ink); }
.shot.phone .zoom::before { display: none; }
.shot.phone img { border-radius: 23px; }
.shot figcaption { margin-top: 0.85rem; color: var(--muted); font-size: 0.9rem; line-height: 1.5; text-align: center; max-width: 40rem; margin-inline: auto; }
.shots.duo { display: grid; grid-template-columns: minmax(0, 1fr) 11.5rem; gap: 1.5rem; align-items: center; margin: 1.75rem 0 2rem; }
.shots.duo .shot { margin: 0; }
.split { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 2rem; align-items: center; margin: 1.75rem 0 2rem; }
.split .shot { margin: 0; }
.split:has(.shot:not(.phone)) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.split-title { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; margin-bottom: 0.5rem; }

/* Lists, notes and tables */
.facts { list-style: none; padding: 0; margin: 1.25rem 0 1.5rem; display: grid; gap: 0.7rem; }
.facts li { position: relative; padding-left: 1.35rem; }
.facts li::before { content: ""; position: absolute; left: 0.1rem; top: 0.62em; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--accent); }
.flow, .steps-list { list-style: none; padding: 0; margin: 1.25rem 0 1.5rem; counter-reset: n; display: grid; gap: 0.8rem; }
.flow li, .steps-list li { counter-increment: n; position: relative; padding-left: 2.6rem; min-height: 1.8rem; }
.flow li::before, .steps-list li::before { content: counter(n); position: absolute; left: 0; top: 0.05rem; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--mark); color: var(--mark-ink); font-size: 0.85rem; font-weight: 800; }
.steps-list .tag { margin: 0 0.35rem 0 0; vertical-align: 0.1em; font-size: 0.68rem; }

.callout { margin: 1.5rem 0; padding: 1rem 1.25rem; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--teal) 30%, transparent); border-left: 4px solid var(--teal); background: color-mix(in srgb, var(--teal) 8%, var(--card)); }
.callout.warn { border-color: color-mix(in srgb, var(--accent) 40%, transparent); border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--card)); }
.callout p { margin: 0; }
.callout p + p { margin-top: 0.35rem; }
.callout-title { font-weight: 700; }
.coming { color: var(--muted); font-size: 0.97rem; }
.coming .tag { margin: 0 0.4rem 0 0; vertical-align: 0.08em; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }

.table-wrap { margin: 1.5rem 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 0.96rem; }
th, td { text-align: left; vertical-align: top; padding: 0.8rem 1rem; border-top: 1px solid var(--line); }
thead th { border-top: 0; font-size: 0.76rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); background: var(--paper-2); }
tbody th { font-weight: 650; white-space: nowrap; }
.commands tbody th { white-space: normal; min-width: 13rem; }
td { color: var(--muted); }

.format-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; align-items: start; margin: 1.75rem 0; }
.format-split .facts { margin-top: 0; }
.doc .tree code { color: #fff; font-size: 0.86rem; }

/* The studio's screens, as tabs with JavaScript and one after another without */
.tabs { margin: 1.75rem 0; }
.tab-list { display: inline-flex; gap: 0.25rem; padding: 0.3rem; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line); margin-bottom: 0.5rem; }
.tab-list[hidden] { display: none; }
.tab-list button { font: inherit; font-weight: 650; font-size: 0.95rem; color: var(--muted); background: none; border: 0; border-radius: 999px; padding: 0.45rem 1.1rem; cursor: pointer; }
.tab-list button[aria-selected="true"] { color: var(--paper); background: var(--text); }
.tab-title { font-weight: 700; font-size: 1.05rem; margin: 1.5rem 0 0.35rem; }
.tabs.ready .tab-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tabs.ready .tab-panel[hidden] { display: none; }
.tabs.ready .tab-panel > p:first-of-type { margin-top: 1rem; }

details { margin: 0 0 0.75rem; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
summary { cursor: pointer; list-style: none; padding: 1rem 1.25rem; font-weight: 650; display: flex; justify-content: space-between; gap: 1rem; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; flex: none; font-size: 1.3rem; line-height: 1; color: var(--muted); }
details[open] summary::after { content: "–"; }
details p { margin: 0; padding: 0 1.25rem 1.1rem; color: var(--muted); }

/* A screenshot, larger */
.lightbox { width: min(1500px, 94vw); max-height: 92vh; padding: 0; border: 0; border-radius: 16px; background: var(--card); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); overflow: auto; }
.lightbox::backdrop { background: rgba(10, 14, 24, 0.72); backdrop-filter: blur(4px); }
.lightbox img { display: block; width: 100%; height: auto; }
.lightbox.tall { width: auto; }
.lightbox.tall img { width: auto; max-width: 94vw; max-height: 92vh; }
.lightbox form { position: sticky; top: 0; height: 0; display: flex; justify-content: flex-end; }
.lightbox-close { margin: 0.6rem; width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 0; font-size: 1.5rem; line-height: 1; color: #fff; background: rgba(10, 14, 24, 0.7); cursor: pointer; }

@media (max-width: 1100px) {
  .paths { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
  .hero-split { grid-template-columns: minmax(0, 1fr); }
  .hero-shots { max-width: 34rem; }
  .docs-grid { grid-template-columns: minmax(0, 1fr); padding-top: 1.5rem; }
  .sidebar { position: static; max-height: none; overflow: visible; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
  .toc { padding: 1.1rem 1.1rem 0.2rem; }
  .sidebar-toggle:not([hidden]) {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    font: inherit; font-weight: 650; color: var(--text); background: none; border: 0;
    padding: 0.9rem 1.1rem; cursor: pointer;
  }
  .sidebar-toggle svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .sidebar-toggle::after { content: "+"; margin-left: auto; font-size: 1.3rem; line-height: 1; color: var(--muted); }
  .sidebar-toggle[aria-expanded="true"]::after { content: "–"; }
  .sidebar-toggle[aria-expanded="false"] + .toc { display: none; }
  .sidebar-toggle[aria-expanded="true"] + .toc { border-top: 1px solid var(--line); }
  .format-split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .brand-tag { display: none; }
  .paths { grid-template-columns: minmax(0, 1fr); }
  .shots.duo, .split, .split:has(.shot:not(.phone)) { grid-template-columns: minmax(0, 1fr); }
  .shots.duo .shot.phone, .split .shot.phone { width: min(15rem, 70%); margin-inline: auto; }
  .shot .zoom { border-radius: 10px; padding-top: 1.2rem; }
  .shot .zoom::before { top: 0.4rem; left: 0.6rem; width: 0.4rem; height: 0.4rem; box-shadow: 0.65rem 0 #febc2e, 1.3rem 0 #28c840; }
  .tab-list { display: flex; }
  .tab-list button { flex: 1; padding-inline: 0.5rem; }
  tbody th { white-space: normal; }
  th, td { padding: 0.7rem 0.8rem; }
}
.toc-guides a[aria-current="page"] { color: var(--text); font-weight: 650; }

/* The sidebar, folded into a button once it has scrolled away on a phone (D22). docs.js
   moves it between the bar and the circle; the ring fills as the page is read. */
.toc-fold {
  position: fixed; z-index: 9; top: calc(var(--fold-edge, 0px) + 0.75rem); right: 1.25rem;
  display: grid; place-items: center; width: 2.9rem; height: 2.9rem; padding: 0;
  border: 0; border-radius: 1.45rem; overflow: hidden; cursor: pointer;
  font: inherit; font-weight: 650; color: var(--text); background: var(--card);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-lg);
}
.toc-fold[hidden] { display: none; }
.toc-fold:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.toc-fold-icon { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toc-fold-ring { position: absolute; inset: 0; width: 100%; height: 100%; rotate: -90deg; fill: none; stroke-width: 2.5; }
.toc-fold-ring circle { stroke: var(--line); }
.toc-fold-ring .read { stroke: var(--teal); stroke-linecap: round; stroke-dasharray: 100px; stroke-dashoffset: calc((1 - var(--read, 0)) * 100px); }
.toc-fold-label { position: absolute; left: 1.1rem; top: 50%; translate: 0 -50%; white-space: nowrap; opacity: 0; pointer-events: none; }
.toc-panel {
  position: fixed; inset: calc(var(--fold-edge, 0px) + 4.25rem) 1.25rem auto auto; margin: 0;
  width: min(21rem, 100vw - 2.5rem);
  max-height: calc(100vh - var(--fold-edge, 0px) - 5.5rem);
  max-height: calc(100dvh - var(--fold-edge, 0px) - 5.5rem);
  overflow-y: auto; overscroll-behavior: contain; padding: 0;
  border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: var(--card);
  box-shadow: var(--shadow-lg);
  transform-origin: calc(100% - 1.45rem) -1.5rem;
}
.toc-panel .toc { padding: 1.1rem 1.1rem 0.2rem; }
@media (prefers-reduced-motion: no-preference) {
  .toc-panel {
    opacity: 0; transform: scale(0.4);
    transition: opacity 0.2s ease, transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1),
      overlay 0.32s allow-discrete, display 0.32s allow-discrete;
  }
  .toc-panel:popover-open { opacity: 1; transform: none; }
  @starting-style { .toc-panel:popover-open { opacity: 0; transform: scale(0.4); } }
}

/* The API docs (D13, D14) */
.api-preview, .staff-only { margin: 1rem 0 0; max-width: 40rem; padding: 0.7rem 1rem; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-left: 4px solid var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--card)); }
.doc .api-op { margin-top: 2.75rem; padding-top: 0.25rem; border-top: 1px solid var(--line); }
.doc .api-op h3 { margin-top: 1.5rem; }
.doc .api-schema { margin-top: 2.25rem; padding-top: 0.25rem; border-top: 1px solid var(--line); }
.doc .api-schema h3 { margin-top: 1.5rem; }
.doc .api-schema h3 code { font-size: 0.9em; }
.doc .api-call { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; }
.doc .api-call code { white-space: normal; overflow-wrap: break-word; }
.api-method { font-size: 0.74rem; font-weight: 800; letter-spacing: 0.06em; padding: 0.15em 0.55em; border-radius: 6px; color: var(--paper); background: var(--teal); }
.api-facts { color: var(--muted); font-size: 0.93rem; }
.doc h4 { font-size: 0.98rem; margin: 1.5rem 0 0.4rem; }
.doc .api-op .table-wrap, .doc .api-schema .table-wrap { margin: 0.75rem 0 1rem; }

/* On a phone, an API table is stacked, a row at a time; docs.js gives it its roles and its
   cells their column's name (D23). */
@media (max-width: 680px) {
  .docs-api table.stacked, .docs-api .stacked :is(tbody, tr, th, td) { display: block; }
  .docs-api .stacked thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .docs-api .stacked tr { padding: 0.8rem 0.9rem 0.7rem; border-top: 1px solid var(--line); }
  .docs-api .stacked tbody tr:first-child { border-top: 0; }
  .docs-api .stacked :is(th, td) { padding: 0; border: 0; }
  .docs-api .stacked tbody th { margin-bottom: 0.3rem; }
  .docs-api .stacked td + td { margin-top: 0.3rem; }
  /* The label floats in the cell's padding, so a cell is as tall as its label. */
  .docs-api .stacked td[data-label] { display: flow-root; padding-left: 6.25rem; }
  .docs-api .stacked td[data-label]::before {
    content: attr(data-label); content: attr(data-label) / "";
    float: left; width: 5.75rem; margin-left: -6.25rem; padding-top: 0.45em;
    font-size: 0.68rem; font-weight: 750; line-height: 1.3; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  }
  .docs-api .stacked td:empty { display: none; }
  .docs-api .stacked code { white-space: normal; overflow-wrap: break-word; }
}
