/* 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-check, .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-check { white-space: normal; }
.hb-bar > .hb-dropzone { padding: var(--hb-s2) var(--hb-s3); cursor: pointer; }
.hb-bar > .pg-note { font-family: var(--hb-body); font-size: 13px; color: var(--hb-ink-2); flex: 1 1 100%; margin: 0; max-width: var(--hb-measure); }

/* a fold inside the bar takes a full row and stacks its controls */
.hb-bar > .hb-fold { flex: 1 1 100%; min-width: 0; margin: 0; }
.hb-bar > .hb-fold > div { display: flex; flex-wrap: wrap; gap: var(--hb-s2); align-items: center; }
.hb-bar > .hb-fold > div > .hb-btn, .hb-bar > .hb-fold > div > .hb-dropzone { flex: 1 1 100%; width: auto; min-width: 0; }
.hb-bar > .hb-fold > div > .hb-dropzone { padding: var(--hb-s2) var(--hb-s3); cursor: pointer; }

/* viewport: a three.js scene orbits with one finger and zooms with two;
   the 2d face lets the page scroll */
.hb-viewport:not(.is-orbit) > canvas { touch-action: pan-y pinch-zoom; }
.hb-viewport > hb-avatar-host { display: block; width: 100%; height: 100%; }

/* 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-what a.hb-link { 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-check { flex: 0 1 auto; }
  .hb-bar > .hb-dropzone { flex: 1 1 320px; }
  .pg-pages > .hb-row { flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: var(--hb-s3); }
  .pg-pages a { min-width: 13ch; }
  .pg-pages span { flex: 1 1 320px; }
}
@media (min-width: 641px) {
  .hb-bar > .hb-fold > div > .hb-btn { flex: 0 1 auto; }
  .hb-bar > .hb-fold > div > .hb-dropzone { flex: 1 1 320px; }
  .hb-bar > .hb-fold > div > .hb-ctl.is-wide { flex: 1 1 300px; }
}

/* pg-side: a page with a long control set puts it in a column beside the
   view from 1024 px, so the view stays whole on a 1280 by 720 screen */
@media (min-width: 1024px) {
  body.hb.pg-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); grid-template-rows: auto auto 1fr auto; align-items: start; }
  body.pg-side > .hb-header, body.pg-side > .pg-foot { grid-column: 1 / -1; }
  body.pg-side > .pg-top { grid-column: 1; grid-row: 2; }
  body.pg-side > .pg-main { grid-column: 1; grid-row: 3; }
  body.pg-side > .hb-bar { grid-column: 2; grid-row: 2 / 4; align-self: stretch; align-content: flex-start; padding: var(--hb-s4) var(--hb-s4) var(--hb-s4) var(--hb-s3); border-bottom: 0; }
  body.pg-side > .hb-bar > *, body.pg-side > .hb-bar > .hb-ctl, body.pg-side .hb-bar > .hb-fold > div > * { flex: 1 1 100%; }
  body.pg-side .hb-ctl > .hb-range { flex: 1 1 auto; width: auto; }
}
@media (min-width: 641px) and (pointer: fine) {
  .pg-pages a, .hb-header h1 a, .pg-what a.hb-link { min-height: 0; line-height: inherit; }
}
