/* Site Builder — phones and touch, across the whole builder (loaded last)
   One layer of house rules for small screens and fingers, so every screen
   gets them without each one remembering:
   - nothing scrolls the page sideways, and text is never inflated by Safari
   - a header's title gives way (it truncates) before its buttons do
   - rows of controls wrap onto a second line instead of squeezing words into
     a column or running off the card
   - things you tap are at least 44px on a touch screen (40px where a row of
     them shares a narrow band), and nothing you need is hover-only
   - fields are 16px on touch, so iOS does not zoom the page on focus
   - sheets fit the screen and scroll inside it; fixed things clear the
     home indicator
   Component files keep their own phone rules; this only fills the gaps. */

/* ---- everywhere ---- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: clip; }
/* long words, links and keys break rather than push their box wider */
:is(p, li, dd, h1, h2, h3, h4, label) { overflow-wrap: break-word; }

/* a sheet never runs past the window: it scrolls inside (component sheets
   with a height of their own keep it — this adds no specificity) */
.modal:where(.modal-back > *) { max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain; }
.modal-actions { flex-wrap: wrap; }

/* ---- touch screens ---- */
@media (pointer: coarse) {
  /* 16px fields: anything smaller and iOS zooms the page in on focus */
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"]), select, textarea { font-size: 16px !important; }

  /* the full-window pages' headers (the tools, the brief, the launch page) */
  .home-head .btn.icon { min-width: 44px; min-height: 44px; justify-content: center; }
  .home-head .btn:not(.icon) { min-height: 44px; }
  .home-head .brand-home { display: flex; align-items: center; min-height: 44px; }
  /* the side menu's pages share its top row on a phone: 40px there */
  body.sb-shell .home-head .btn.icon { width: 40px; height: 40px; min-width: 40px; min-height: 40px; }
  body.sb-shell .home-head .btn:not(.icon) { min-height: 40px; }

  /* buttons on the pages and in sheets */
  :is(.home-main, .dev-main, .crm-main, .inv-main, .gsc-main, .care-shell, .gads-shell, .modal) .btn { min-height: 40px; }
  :is(.home-main, .dev-main, .crm-main, .inv-main, .gsc-main, .care-shell, .gads-shell, .modal) .btn.icon { min-width: 40px; justify-content: center; }
  .modal-actions .btn { min-height: 44px; }

  /* Widgets: the card's trash, a category's pencil and trash, Light / Dark */
  .wg-del { width: 40px; height: 40px; opacity: 1; }
  .wg-del svg { width: 17px; height: 17px; }
  .wg-cat-btn { width: 40px; height: 40px; opacity: 1; }
  .wg-cat-btn svg { width: 15px; height: 15px; }
  .wg-look button { min-height: 40px; padding: 0 18px; }
  .wg-catpick select { min-height: 40px; }
}

/* no hover on this screen: what shows on hover stays shown */
@media (hover: none) {
  .wg-del, .wg-cat-btn { opacity: 1; }
}

/* ---- phones ---- */
@media (max-width: 640px) {
  /* the header: the title truncates before a button is pushed off */
  .home-head { gap: 8px; }
  .home-head .brand { flex: 1 1 auto; min-width: 0; }
  .home-head .head-actions { flex: none; }
  .home-head .brand > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* the back arrow already says where it goes */
  .wg-crumb > span { display: none; }
  .wg-crumb { margin-left: 2px; }

  /* Widgets */
  .wg-bar { flex-wrap: wrap; }
  .wg-svc { padding: 14px 14px 16px; }
  .wg-svc-head { flex-wrap: wrap; row-gap: 10px; }
  .wg-svc-head h2 { flex: 1 1 auto; min-width: 0; }
  .wg-svc-head .wg-svc-n { flex: 0 1 auto; min-width: 0; }
  /* New category and New … widget: their own row, side by side */
  .wg-svc-head .wg-make { flex: 1 1 calc(50% - 6px); justify-content: center; text-align: center; min-height: 40px; }
  .wg-cat-head { flex-wrap: wrap; }
  .wg-gone-list li { flex-wrap: wrap; }

  /* fixed things clear the home indicator */
  .home-dock { right: 12px; bottom: max(12px, calc(env(safe-area-inset-bottom) + 8px)); }
}
