/* Preview chrome only. Every component style still comes from the package
 * stylesheet; the few restated values below exist because the package keys
 * sizing off the host's `any-pointer: coarse`, and a simulated touch device
 * has to present a touch specimen inside a pointer host. */

@font-face {
  font-family: "Hanken Grotesk";
  src: url("./fonts/hanken-grotesk-400-800-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
/* Metric-matched fallback. Hanken Grotesk is materially narrower than the
 * desktop sans the browser picks when it is absent (measured at 100px: Hanken
 * 2590 units, Arial 2562.7, DejaVu 2917.2). Until the real face arrives every
 * line is laid out against the fallback, so the swap re-wraps the document and
 * pushes everything below it down ~20px — a visible CLS spike at first paint.
 * Resizing the local face to Hanken's advance width turns that swap into a
 * repaint.
 *
 * DejaVu is the point: it is what `sans-serif` actually resolves to on this
 * platform, so it is the face the unstyled first frame already uses, and 91.5%
 * reproduces Hanken's line breaks across the whole static list (0 mismatched
 * sections, 0px total height delta — Arial-based fallbacks still re-wrap one
 * paragraph). The ascent/descent overrides match Hanken's own box (1.0 / 0.3
 * em); they matter only if line-height is ever left at `normal`. */
@font-face {
  font-family: "Hanken Grotesk Fallback";
  src: local("DejaVu Sans");
  size-adjust: 91.5%;
  ascent-override: 100%;
  descent-override: 30%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

body {
  --kprev-pad: 24px;
  margin: 0;
  min-height: 100vh;
  padding: var(--kprev-pad);
  box-sizing: border-box;
  background: var(--kl-surface, #fbfbfa);
  color: var(--kl-text, #37352f);
  font-family: "Hanken Grotesk", "Hanken Grotesk Fallback", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  overflow-x: hidden;
}

.kprev-bar { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; max-width: 1440px; margin-inline: auto; }
.kprev-bar h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.025em; margin: 0; }
.kprev-title { margin-right: auto; min-width: 0; }
.kprev-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
/* WCAG 2.2 2.5.8: the hit area is the control, not the glyph. The anchors sit in
 * a wrapping row, so a 24px min-height plus the row gap clears the pointer
 * floor, and 44px on touch, without moving the text baseline. */
.kprev-links a { color: var(--kl-accent); text-underline-offset: 3px; display: inline-flex; align-items: center; min-height: 24px; }
@media (any-pointer: coarse) { .kprev-links a { min-height: 44px; } }
.kprev-links a:focus-visible,
.kpattern-example [tabindex="0"]:focus-visible { outline: 2px solid var(--kl-accent); outline-offset: -2px; }
.kprev-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; max-width: 100%; }
/* A one-option track (phone) must not stretch to the bar's width, but a wide
 * track must shrink and scroll itself rather than push the page sideways. */
.kprev-controls .kseg-track { flex: 0 1 auto; min-width: 0; }

.kprev-note {
  margin: 8px 0 10px;
  font-size: 12px;
  color: var(--kl-muted, #6a6967);
  font-variant-numeric: tabular-nums;
}
.kprev-bar + .kprev-note { max-width: 1440px; margin-inline: auto; }
.kprev-static { max-width: 900px; margin-inline: auto; }
.kprev-static section { padding-block: 12px; border-top: 1px solid var(--kl-border); }
.kprev-static h2 { margin: 0; }
.kprev-static a { color: var(--kl-accent); }
/* --- First paint: the static shell the module replaces ---------------------
 * The shell is real content, not a placeholder, so it must occupy the same
 * geometry the live document will. It reuses the live chrome's own classes and
 * order (.kprev-bar > .kprev-title > h1 + .kprev-links), so the header cannot
 * move when React takes over — the swap changes the bar's children, not its
 * box. Only the two controls and the device frame really are pending until
 * React mounts, so those are the only things drawn as placeholders.
 *
 * The stage wrapper is deliberately NOT clipped or fixed-height: the static
 * content below it is the indexable page, and it stays fully visible and its
 * natural height. Nothing follows the stage, so the frame's later height does
 * not move any element — which is why reserving the frame's height here would
 * buy nothing and cost a 3 kB block of guesswork.
 */
.kprev-skel {
  display: none;
  border-radius: 8px;
  background: var(--kl-sunken, #f3f2ef);
  box-shadow: inset 0 0 0 1px var(--kl-border, #e6e6e3);
}
/* A placeholder is only honest if something is actually coming. Without
 * JavaScript these two tracks never resolve, so they are hidden and the shell
 * is simply a static page; with JavaScript the head script below reveals them
 * before paint, so they are present in the first frame that has a bundle. */
.kprev-js .kprev-skel { display: block; }
/* Heights are the live track heights, not guesses: a .kseg-track-sm is
 * --kseg-h + 6px of padding, and the coarse row raises --kseg-h to 44px. A
 * wrong height here is exactly the vertical jump this is meant to prevent. */
.kprev-skel-theme { flex: 0 0 101px; height: 34px; }
/* The device track's width is the count of views the tier allows: one on a
 * phone (83), three on an iPad (247), four on a fine pointer (347). Matching it
 * keeps the pending row the same shape as the real one, so the swap does not
 * visibly reflow the bar horizontally either. */
.kprev-skel-device { flex: 0 0 347px; height: 34px; min-width: 0; max-width: 100%; }
@media (any-pointer: coarse) {
  .kprev-skel-theme, .kprev-skel-device { height: 50px; }
  .kprev-skel-device { flex-basis: 247px; }
}
@media (any-pointer: coarse) and (max-width: 599px) {
  .kprev-skel-device { flex-basis: 83px; }
}
/* One row, like the live control row: wrapping would add a second line and push
 * the note and stage down. */
.kprev-controls-pending { gap: 8px; flex-wrap: nowrap; }
/* The loading line only makes sense while a bundle is coming. Without one the
 * static list below is the whole page, so the note says that instead. */
.kprev-note-nojs { display: block; }
.kprev-js .kprev-note-nojs { display: none; }
.kprev-js .kprev-note-pending .kprev-note-js { display: block; }
.kprev-note-pending .kprev-note-js { display: none; }
/* Full-bleed like the live stage, but sized by its content and never clipped.
 * It inherits .kprev-stage's margin-inline and width, so those are not repeated
 * here. Padding goes on the inner block, not this one: padding on a content-box
 * element would widen the stage past the live one. `flow-root` contains the
 * first paragraph's top margin instead of letting it collapse out and shift the
 * whole stage down by the difference. */
.kprev-stage-pending { display: flow-root; overflow: visible; height: auto; }
.kprev-stage-pending .kprev-static {
  padding: 0 var(--kprev-pad) 24px;
  max-width: calc(900px + 2 * var(--kprev-pad));
}

/* The stage holds the height the frame occupies, so the document never gets a
 * scrollbar from the frame's own 1440px width. It runs to the window edge
 * (full-bleed) so a frame the size of the screen fits exactly; a touch frame
 * is never scaled, so if it is still wider the stage pans, not the page. */
.kprev-stage {
  overflow: hidden;
  overflow: clip;
  margin-inline: calc(-1 * var(--kprev-pad));
  width: calc(100% + 2 * var(--kprev-pad));
}
.kprev-stage[data-fit="pan"] { overflow: auto; overscroll-behavior-x: contain; }
/* Drawn inside, so the frame's own CSS width is its full footprint and a
 * 1180px frame fits a 1180px window. */
.kprev-frame {
  margin-inline: auto;
  transform-origin: top left;
  outline: 1px solid var(--kl-border, #e6e6e3);
  outline-offset: -1px;
  border-radius: 8px;
  overflow: hidden;
  overflow: clip;
  box-shadow: 0 18px 40px -28px rgb(0 0 0 / 45%);
}
.kprev-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  padding: 24px;
  background: var(--kl-sunken, #f3f2ef);
  color: var(--kl-text, #37352f);
  font-size: 14px;
  line-height: 1.4;
  container-type: inline-size;
}
.kprev-screen:focus-visible { outline: 2px solid var(--kl-accent, #1a66b3); outline-offset: -2px; }

.kprev-catalog { max-width: 1320px; margin-inline: auto; }
.kprev-group + .kprev-group { margin-top: 24px; }
.kprev-group > h2 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
/* Each section reflows independently in the device frame. */
.kprev-specimen {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 16px;
  align-items: start;
}
.kprev-specimen > section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--kl-border);
  border-radius: 14px;
  background: var(--kl-raised);
}

.kprev-specimen h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 650;
  color: var(--kl-text);
}
.kprev-specimen :is(.row, .kprev-badge-sizes) + h3 { margin-top: 16px; }
.kprev-badge-sizes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 10px 12px;
}
.kprev-badge-sample { display: grid; justify-items: start; gap: 4px; color: var(--kl-text-2); font-size: 12px; }
.kprev-badge-example { min-height: 28px; display: flex; align-items: center; }
.kprev-specimen .kinput-group { max-width: 100%; }
.kprev-guide { margin-bottom: 14px; color: var(--kl-text-2); }
.kprev-guide p { margin: 0 0 6px; }
.kprev-guide summary { color: var(--kl-accent); cursor: pointer; font-weight: 600; }
.kprev-guide summary:focus-visible { outline: 2px solid var(--kl-accent); outline-offset: 2px; }
.kprev-guide details[open] > :not(summary) { margin-block: 8px; }
.kprev-guide pre {
  padding: 8px;
  border-radius: 8px;
  background: var(--kl-sunken);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.kprev-guide code { font: 12px/1.5 var(--kl-font-mono); }
.kprev-guide ul { padding-inline-start: 20px; }
.kprev-guide li + li { margin-top: 6px; }
.kprev-guide a { color: var(--kl-accent); }
.kprev-composer-states {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 10px;
}
.kprev-composer-states > * { min-width: 0; }
.kprev-state-name { display: block; margin: 0 0 5px; font-size: 12px; color: var(--kl-text-2); }
.kprev-screen .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
/* The showcase trigger sits near its card's leading edge, including in the
 * narrow device frames. Grow inward from that edge instead of across it. */
.kprev-screen .kmenu-popover { --kmenu-left: anchor(left); }
.kprev-screen .kprev-long-labels .row { flex-direction: column; align-items: flex-start; }
.kprev-long-labels .kbtn { line-height: 1.3; padding-block: 6px; }
.kprev-long-labels .kbadge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.kprev-long-labels .kbadge-code { padding-inline: 6px; text-align: left; }
.kpattern-guide p { max-width: 72ch; }
.kpattern-example { margin-top: 18px; scroll-margin-top: 12px; }
.kpattern-example h3 { margin: 0; font-size: 16px; }
.kpattern-example > p { margin: 4px 0 10px; color: var(--kl-text-2); }
.kpattern-shell,
.kpattern-gate-review {
  display: grid;
  min-width: 0;
  border: 1px solid var(--kl-border);
  border-radius: 14px;
  background: var(--kl-raised);
}
.kpattern-nav {
  display: flex;
  justify-content: space-between;
  padding: 4px;
  grid-row: 2;
  border-top: 1px solid var(--kl-border);
}
.kpattern-nav .kbtn {
  min-width: 0;
  min-height: 44px;
  flex: 1 1 0;
  padding: 4px;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}
.kpattern-nav svg { flex-shrink: 0; }
.kpattern-nav .kbtn[aria-current] { background: var(--kl-selected); color: var(--kl-text); }
.kpattern-page,
.kpattern-transcript,
.kpattern-details { min-width: 0; padding: 16px; }
.kpattern-example h4 { margin: 0; font-size: 18px; }
.kpattern-example h5 { margin: 0; font-size: 14px; }
.kpattern-dashboard { display: grid; gap: 14px; margin-top: 10px; }
.kpattern-line { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--kl-border); }
.kpattern-line a { color: var(--kl-accent); }
.kpattern-board {
  --lane-width: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--lane-width);
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}
.kpattern-lane-picker { margin: 12px 0; }
.kpattern-lane { min-width: 0; padding: 12px; border: 1px solid var(--kl-border); }
.kpattern-lane:not([data-active="true"]) { display: none; }
.kpattern-gates {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-x: auto;
  min-width: 0;
  border-bottom: 1px solid var(--kl-border);
}
.kpattern-gates li { flex: 1 0 62px; display: grid; gap: 2px; padding: 6px; border-radius: 8px; }
.kpattern-gates li[aria-current] { background: var(--kl-selected); }
.kpattern-gates span { font-size: 12px; color: var(--kl-text-2); }
.kpattern-history { max-height: 224px; overflow-y: auto; padding-left: 24px; overscroll-behavior: contain; }
.kpattern-history li { padding-block: 6px; border-bottom: 1px solid var(--kl-border); }
.kpattern-history p { margin: 3px 0 0; }
.kpattern-details { display: none; }
[data-preview-device="phone"] .kpattern-run-sheet.ksheet { width: min(100%, 390px); }
.kpattern-layouts { display: grid; gap: 8px; margin-block: 10px; }
.kpattern-layouts div { padding: 10px 12px; border: 1px solid var(--kl-border); border-radius: 8px; }
.kpattern-layouts dt { font-weight: 650; }
.kpattern-layouts dd { margin: 4px 0 0; color: var(--kl-text-2); }
.kprev-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@container (min-width: 600px) {
  .kpattern-nav {
    grid-row: auto;
    flex-direction: column;
    justify-content: flex-start;
    border-top: 0;
    border-right: 1px solid var(--kl-border);
  }
  .kpattern-nav .kbtn { flex: 0 0 auto; }
  .kpattern-nav .kbtn > span { display: none; }
  .kpattern-shell { grid-template-columns: 56px minmax(0, 1fr); }
  .kpattern-board { --lane-width: 310px; gap: 8px; }
  .kpattern-lane-picker { display: none; }
  .kpattern-lane:not([data-active="true"]) { display: block; }
  .kpattern-layouts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (min-width: 1000px) {
  .kpattern-board { --lane-width: 330px; }
  .kpattern-dashboard { grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; }
  .kpattern-gate-review { grid-template-columns: 152px minmax(0, 1fr); }
  .kpattern-gates { flex-direction: column; border-bottom: 0; border-right: 1px solid var(--kl-border); }
  .kpattern-gates li { flex: 0 0 auto; }
  .kpattern-run-sheet.ksheet {
    inset: 0 0 0 auto;
    height: 100%;
    max-height: none;
    width: min(340px, 100%);
    margin: 0;
    border-radius: 22px 0 0 22px;
    animation: none;
  }
}
@container (min-width: 1300px) {
  .kpattern-board { --lane-width: 340px; }
  .kpattern-shell { grid-template-columns: 180px minmax(0, 1fr); }
  .kpattern-nav .kbtn { flex-direction: row; justify-content: flex-start; gap: 8px; padding: 6px 12px; font-size: 14px; }
  .kpattern-nav .kbtn > span { display: inline; }
  .kpattern-gate-review { grid-template-columns: 152px minmax(0, 1fr) 240px; }
  .kpattern-details { display: block; border-left: 1px solid var(--kl-border); }
  .kpattern-details-trigger.kbtn { display: none; }
}

#app:empty::after {
  content: "bundle missing — run node preview/build-fixture.mjs";
  display: block;
  padding: 12px;
  border: 1px solid #bc3b37;
  border-radius: 6px;
  color: #bc3b37;
  font-weight: 600;
}

@container (min-width: 1248px) {
  .kprev-basics .kprev-specimen {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.15fr) minmax(0, 1fr);
  }
  .kprev-composer { grid-column: span 2; }
}
@container (min-width: 616px) and (max-width: 947px) {
  .kprev-composer { grid-column: span 2; }
}
@container (max-width: 480px) {
  .kprev-specimen { gap: 12px; }
  .kprev-specimen > section { padding: 12px; }
}

/* Touch specimen: the package's own touch sizes, restated for the simulated
 * frame. Values mirror styles.css @media (any-pointer: coarse); the host may
 * have raised them too, and these win by being the frame's own. */
[data-preview-pointer="coarse"] .kbtn { --kbtn-h: 44px; --kbtn-r: 10px; }
[data-preview-pointer="coarse"] .kbtn.kbtn-sm { --kbtn-h: 36px; --kbtn-r: 6px; }
[data-preview-pointer="coarse"] .kbtn.kbtn-lg { --kbtn-h: 48px; }
[data-preview-pointer="coarse"] .kbtn.kbtn-icon { --kbtn-w: 44px; }
[data-preview-pointer="coarse"] .kbtn.kbtn-icon-sm { --kbtn-h: 36px; --kbtn-w: 36px; --kbtn-r: 6px; }
[data-preview-pointer="coarse"] .kbadge:is(.kbadge-status, .kbadge-count):not(.kbadge-sm, .kbadge-md, .kbadge-xl) {
  --kbadge-fs: 12.5px;
}
[data-preview-pointer="coarse"] .kseg-seg,
[data-preview-pointer="coarse"] .kseg-seg-sm { --kseg-h: 44px; }
/* sm/icon-sm keep their visual box; pad the hit area to 44px like the sheet. */
[data-preview-pointer="coarse"] .kbtn.kbtn-sm,
[data-preview-pointer="coarse"] .kbtn.kbtn-icon-sm { position: relative; }
[data-preview-pointer="coarse"] .kbtn.kbtn-sm::after,
[data-preview-pointer="coarse"] .kbtn.kbtn-icon-sm::after {
  content: "";
  position: absolute;
  inset: calc((var(--kbtn-h) - 44px) / 2);
}

@media (max-width: 480px) { body { --kprev-pad: 14px; } }
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  ::view-transition-old(root), ::view-transition-new(root) {
    animation-duration: 160ms;
  }
}
