/* Layout glue for the example pages, mobile first: the base is a 360 px
   phone, wider layouts come in at min-width. The look is the hackbuild-ui
   class layer (shared/hb/hackbuild.css, loaded before this file); this
   file only places things and adds no colour, face or token of its own. */
.hb-header h1 a { color: inherit; text-decoration: none; display: inline-block; min-height: 44px; line-height: 44px; }
.hb-header h1 { overflow-wrap: anywhere; }
body.hb { display: flex; flex-direction: column; min-height: 100vh; }
.pg-top { padding-top: var(--hb-s3); padding-bottom: var(--hb-s4); width: 100%; }
.pg-top:not(:has(.hb-viewport)) { padding-bottom: 0; }
.pg-main { padding-top: var(--hb-s3); padding-bottom: var(--hb-s5); display: flex; flex-direction: column; width: 100%; }
.pg-main > * { min-width: 0; }
.pg-what { max-width: var(--hb-measure); color: var(--hb-ink-2); margin: 0 0 var(--hb-s3); }
.pg-foot { width: 100%; padding-bottom: max(var(--hb-s6), env(safe-area-inset-bottom)); }
.pg-foot p { font-family: var(--hb-utility); font-size: 11px; color: var(--hb-ink-3); margin: 0; border-top: 1px dashed rgba(26, 26, 26, .25); padding-top: var(--hb-s3); }

/* controls row: every control takes its own row on a phone */
.hb-bar > .hb-btn, .hb-bar > .hb-input, .hb-bar > .hb-select, .hb-bar > .hb-dropzone { flex: 1 1 100%; width: auto; min-width: 0; }
.hb-bar .hb-btn { white-space: normal; text-align: left; }
.hb-bar > .hb-dropzone { padding: var(--hb-s2) var(--hb-s3); }
.hb-bar > .pg-note { font-family: var(--hb-utility); font-size: 11px; color: var(--hb-ink-3); flex: 1 1 100%; }
.hb-bar > .pg-note[hidden] { display: none; }

/* viewport: the scene orbits with a finger, other canvases let the page scroll */
.hb-viewport:not(.is-orbit) > canvas { touch-action: pan-y pinch-zoom; }
.hb-inset-media { --hb-inset-ratio: 16 / 9; }
.hb-inset-media > canvas { object-fit: contain; background: var(--hb-void); }

/* page output: pre blocks, the chat reply, the element grid */
.pg-main pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.pg-out { margin: 0 0 var(--hb-s3); }
.pg-out .pg-reply { max-width: 100%; align-self: stretch; }
.pg-out .hb-msg-text { min-height: 6em; }
.pg-grid { display: grid; gap: var(--hb-s4); grid-template-columns: minmax(0, 1fr); margin: 0 0 var(--hb-s4); }
.pg-grid > .hb-panel { min-width: 0; }
.hb h2.hb-panel-hd-inst.pg-sub { margin-top: var(--hb-s4); }
.pg-scroll { max-height: 420px; overflow: auto; }

/* index list: page name over its line */
.pg-pages { list-style: none; margin: 0 0 var(--hb-s4); padding: 0; }
.pg-pages > .hb-row { cursor: default; flex-direction: column; align-items: flex-start; gap: var(--hb-s1); }
.pg-pages a { font-weight: 700; color: var(--hb-ink); display: inline-block; min-height: 44px; line-height: 44px; }
.pg-pages span { font-family: var(--hb-body); font-size: 13px; color: var(--hb-ink-2); }

@media (min-width: 641px) {
  /* the toolbar goes back under the header on a wider screen */
  .hb-bar { order: -1; }
  .hb-header { order: -2; }
  .pg-top { padding-top: var(--hb-s4); }
  .pg-main { padding-top: var(--hb-s4); }
  .hb-bar > .hb-btn, .hb-bar > .hb-select { flex: 0 1 auto; }
  .hb-bar > .hb-input { flex: 1 1 260px; }
  .hb-bar > .hb-dropzone { flex: 1 1 320px; }
  .hb-bar > .pg-note { flex: 0 1 auto; }
  .pg-grid { gap: var(--hb-s5); grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); margin-bottom: var(--hb-s5); }
  .pg-wide { grid-column: 1 / -1; }
  .pg-pages > .hb-row { flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: var(--hb-s3); }
  .pg-pages a { min-width: 9ch; }
  .pg-pages span { flex: 1 1 320px; }
}
@media (min-width: 641px) and (pointer: fine) {
  .pg-pages a, .hb-header h1 a { min-height: 0; line-height: inherit; }
}
