/* ==========================================================================
   IQ Design - TABLET AND PHONE FRIENDLY
   Loaded after every other style sheet. It only adds rules for touch screens and small
   windows, so desktop with a mouse looks exactly as before.

     - iPad / tablet: the top bar no longer runs off the right edge (buttons keep their icons).
     - iPhone / iPad: boxes use 16 px text, so Safari does not zoom the page when one is tapped.
     - Touch: buttons, chips and boxes are at least 44 px tall (Apple and Google guidance).
     - Tapping a button no longer waits for a double-tap zoom.
     - Windows and the Coach use the visible screen height, not the height behind the browser bars.

   Remove its <link> line in index.html to switch it off.
   ========================================================================== */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* no 300 ms double-tap-to-zoom wait on anything you tap */
button, a, summary, select, label, [data-act], .btn, .btn-icon, .seg-b, .chip, .mchip, .stage, .rm-tab,
.trace-tool, .elev-chip, .gd-launch, .linkbtn { touch-action: manipulation; }

/* ----- tablets: keep the top bar inside the screen ----- */
@media (max-width: 1000px) {
  .brand-tag, .savestate { display: none; }
  .topbar { gap: 10px; }
  .topbar-actions { gap: 6px; min-width: 0; }
}
@media (max-width: 860px) {
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn-sm { padding: 8px 10px; min-width: 44px; justify-content: center; }
}

/* ----- phones: five top-bar buttons at 44 px still fit beside the logo ----- */
@media (max-width: 560px) {
  .topbar { gap: 6px; }
  .topbar-actions { gap: 4px; }
  .wordmark { font-size: 17px; }
  .topbar-actions .btn-sm, .topbar-actions .btn-icon, .topbar-actions .gd-launch { min-width: 42px; padding-left: 8px; padding-right: 8px; }
}

/* ----- small phones (iPhone SE, 360 px Androids): the logo alone, so the buttons all fit ----- */
@media (max-width: 380px) {
  .brand .wordmark { display: none; }
  .topbar-job { display: none; }
}

/* never let the whole page wobble sideways on a small phone */
@media (max-width: 420px) { html, body { overflow-x: clip; } }

/* ----- touch screens (iPad, iPhone, Android) ----- */
@media (pointer: coarse) {
  .btn, .btn-sm, .btn-icon, .seg-b, .chip, .chip.sm, .mchip, .gd-launch, .elev-chip, .rm-tab, .trace-tool { min-height: 44px !important; }
  .mchip, .trace-tool { min-width: 44px; }
  .linkbtn, .todo-link, .adv-link { min-height: 44px !important; display: inline-flex; align-items: center; }
  input.field, select.field, textarea.field, .field input, .field select { min-height: 48px; }
  input[type="checkbox"], input[type="radio"] { min-width: 22px; min-height: 22px; }
  /* sliders: a thicker touch area */
  input[type="range"] { min-height: 44px; }
  /* a little more room between neighbouring buttons so a thumb hits the right one */
  .actions-row { gap: 10px; }
}

/* Safari zooms the page when a box with text under 16 px is tapped. Keep boxes at 16 px on touch screens and phones. */
@media (pointer: coarse), (max-width: 820px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
  select, textarea { font-size: 16px; }
}

/* ----- short screens: phones on their side ----- */
@media (max-height: 500px) and (orientation: landscape) {
  .rm-head { padding-top: 6px; padding-bottom: 6px; }
  .rm-bar { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .rm-bar .btn { min-height: 44px; }
}

/* ----- the Coach: use the screen you can actually see (iOS browser bars come and go) ----- */
@supports (height: 100dvh) {
  .cc-card { max-height: calc(100dvh - var(--cc-dock, 0px) - 28px); }
  .cc-panel { max-height: min(620px, calc(100dvh - var(--cc-dock, 0px) - 120px)); }
}

/* the notch and the home bar */
.topbar, .stepper { padding-left: max(var(--gutter, 16px), env(safe-area-inset-left)); padding-right: max(var(--gutter, 16px), env(safe-area-inset-right)); }

/* Sun & shade window: the buttons wrap two across on a phone, so three or four never run off the edge */
@media (max-width: 700px) {
  .ps-actions { grid-template-columns: 1fr 1fr; }
  .ps-tools button { flex: 1 1 calc(50% - 8px); }
}
