/* ═══════════════════════════════════════════════════════════════════════════
   ht-ipad.css — The Hive as an installed iPad app
   ═══════════════════════════════════════════════════════════════════════════

   Why this file exists and not edits inside galileo.css: that sheet is shared
   with /v1/ and /v3/, which are frozen copies of the commercial proposal. A
   change there changes those too. This file is loaded ONLY by /galileo/, so
   rolling the whole thing back is deleting one <link> line.

   Two blocks, on purpose:

   1. SAFE AREAS. Not gated by anything. env(safe-area-inset-*) resolves to 0px
      on a desktop browser, so these rules are inert everywhere except a device
      that actually has an inset.

   2. TOUCH. Gated behind @media (pointer: coarse) so a mouse never sees them.

      ⚠️ (pointer: coarse) does NOT fire in desktop Chrome. Reviewing this in a
      normal Chrome window will show NO change and that is not a bug. To see it:
      DevTools → device toolbar (⌘⇧M) → iPad Pro 11", which does set it — or the
      iPad simulator, which is the only thing that proves it.

   ── Everything below was measured on iPad Pro 11" (M5), iPadOS 26.5 ─────────
   Viewport, portrait ........ 834 × 1178 installed · 834 × 1078 in Safari
   Viewport, landscape ....... 1210 × 802 installed · 1210 × 702 in Safari
   safe-area-inset-bottom .... 20px, BOTH orientations, installed AND in Safari
   safe-area-inset top/left/right ... 0px. An iPad has no notch: there is no
      side inset in landscape and nothing hides under a camera. That premise is
      an iPhone premise.
   ═══════════════════════════════════════════════════════════════════════════ */


/* ═══ 1 · SAFE AREAS ═══════════════════════════════════════════════════════ */

/* MEASURED, landscape 1210×702: the sidebar is 224×702 with no bottom padding,
   and "Sign out" sits at y 672–696. The home indicator owns y 682–702. So 14 of
   the button's 24px are underneath it — you swipe home while trying to sign out.
   Same for the theme toggle beside it (673–695). */
.g-sidebar { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* The bottom bar is 64px + inset = 84px tall installed. galileo.css reserves 90px
   of scroll room, which left 6px of clearance. */
@media (max-width: 900px) {
  .g-main { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
}

/* The Print pill is fixed at top 18 / right 22. Zero inset on this iPad, so this
   changes nothing here — it is here so the day someone opens The Hive on a
   notched phone the button does not land under the status bar. */
.pr-btn {
  top: calc(18px + env(safe-area-inset-top, 0px));
  right: calc(22px + env(safe-area-inset-right, 0px));
}

/* Modals are centred with a fixed padding; on a device with insets the bottom of
   a tall modal (and its footer buttons) can end up under the home indicator. */
.ht-help-backdrop { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.gpay-mask        { padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
.hc-modal         { padding-bottom: calc(4vh + env(safe-area-inset-bottom, 0px)); }
#gPal             { padding-bottom: env(safe-area-inset-bottom, 0px); }


/* ═══ 2 · TOUCH ════════════════════════════════════════════════════════════ */

@media (pointer: coarse) {

  /* ── 2.1 · The primary navigation ──────────────────────────────────────────
     MEASURED, landscape: .g-nav-item is 199 × 23. Twenty-three pixels, stacked
     with no gap (Dashboard 117–140, Rooms 140–163, Conversations 163–186 …), so
     a miss does not do nothing — it opens the neighbouring module. In landscape
     the sidebar is the ONLY navigation, because .g-mobilebar is hidden above
     900px. The 23px comes from @media (max-height: 1024px) in galileo.css, which
     compacts the sidebar; the iPad is 702px tall in landscape, so it always fires.

     ⚠️ CONSEQUENCE, say it out loud: 25 items × 44px = 1.100px in a 702px column.
     The menu WILL scroll. .g-nav already has overflow-y:auto and a visible
     scrollbar, put there on purpose as a safety net, so nothing breaks — but the
     menu stops fitting on one screen. If Daniel prefers not to pay that, 36px is
     a real improvement that still fits. It is his call, not mine. */
  .g-nav-item,
  .g-nav-group { min-height: 44px; }

  /* MEASURED: 38 × 22 (theme) and 157 × 24 (Sign out). */
  .g-user-btn { min-height: 44px; }

  /* MEASURED: 199 × 38. */
  .g-search { min-height: 44px; }

  /* ══ Why !important appears from here down, and only from here down ═══════
     Found by measuring, not by reading: the first version of this file had no
     !important and the fields stayed at 14.08px on the device.

     galileo/index.html defines .hf-field, .ht-help-x, .ht-task-act, .hc-*,
     .gpay-* and the Follow-ups <summary> inside <style> blocks in the BODY.
     A <style> in the body comes after a <link> in the head, and a media query
     adds no specificity — so at an identical selector the page's own rule wins
     and this file loses silently. Raising specificity with a parent class does
     not work either: the same .hf-field markup lives under .hf-form in Forms and
     under #sgForm in Follow-ups.

     These are the 44px and 16px accessibility floors. They are supposed to win.
     Every rule WITHOUT !important below is one that has no competitor and was
     verified applying on the device.
     ═══════════════════════════════════════════════════════════════════════════ */

  /* ── 2.2 · Form fields ────────────────────────────────────────────────────
     MEASURED: every .hf-field control renders at 14.08px (0.88rem × 16). That is
     Forms (14 fields), Child's Records (3) and Follow-ups (5) — the three Live
     modules where a person types.

     ⚠️ Correcting the brief, with evidence: on iPad iOS does NOT zoom on focus.
     Measured with the software keyboard up on all three screens —
     visualViewport.scale stayed at 1 and the layout did not move. Auto-zoom on
     focus is iPhone behaviour. So 16px here is not about zoom on this device; it
     is legibility and it is the 44px target. It also means the same screens WILL
     zoom the day someone opens them on a phone, and this prevents that too. */
  .hf-field input:not([type=checkbox]),
  .hf-field select,
  .hf-field textarea,
  .g-list-search input,   /* MEASURED 214 × 37 at 14px — "Search conversations…" */
  .gpay-in,
  .hc-in,
  .hc-ta {
    font-size: 16px !important;
    min-height: 44px !important;
  }

  /* MEASURED: text inputs 366 × 43.81 and selects 366 × 42 — a fraction under.
     min-height above already fixes it; this keeps the text vertically centred
     once the box grows. */
  .hf-field select { padding-top: 0; padding-bottom: 0; }

  /* ── 2.3 · Checkboxes ─────────────────────────────────────────────────────
     MEASURED: 16 × 16 in Forms (photo consent, the five weekday boxes) and
     18 × 18 in Follow-ups.

     🔴 Follow-ups is the bad one. ht-hive.js builds each row as a <div>, not a
     <label> — deliberately, so the mailto:/tel: links inside do not trigger the
     checkbox. The side effect is that the 18 × 18 box is the ONLY thing that
     closes a follow-up, inside a row that is 752 × 71. */
  .hf-field input[type=checkbox],
  .hf-days input[type=checkbox],
  .hf-check input[type=checkbox],
  .g-task input[type=checkbox] {
    width: 24px !important; height: 24px !important; flex: none;
  }
  /* The label around each one becomes the target, so the word is tappable too. */
  .hf-days label,
  .hf-check label { min-height: 44px !important; }
  /* And the box itself gets a 44px reach without moving anything on screen. */
  .g-task input[type=checkbox] { position: relative; }
  .g-task input[type=checkbox]::after {
    content: ""; position: absolute; top: 50%; left: 50%;
    width: 44px; height: 44px; transform: translate(-50%, -50%);
  }

  /* ── 2.4 · The "?" help button ────────────────────────────────────────────
     MEASURED: 20 × 20, in the nine modules that have one (dash, rooms, conv,
     segui, contacts, forms, records, cal, roles). It sits right beside the LIVE
     tag, so growing the circle would push the header around. The circle keeps
     its size and only the reach grows. */
  .ht-help-btn { position: relative; }
  .ht-help-btn::after {
    content: ""; position: absolute; top: 50%; left: 50%;
    width: 44px; height: 44px; transform: translate(-50%, -50%);
  }

  /* ── 2.5 · Ways out of a modal ────────────────────────────────────────────
     These are the ✕ of every modal. On an iPad with no keyboard they are, with
     the backdrop, the only way out — so here they DO grow, they are not
     decoration. MEASURED: .ht-help-x 26 × 26, .hc-x 30 × 30, .gpay-x ~28 × 28. */
  .ht-help-x,
  .hc-x,
  .gpay-x {
    width: 44px !important; height: 44px !important;
    display: inline-flex !important; align-items: center; justify-content: center;
  }

  /* ── 2.6 · Everything else that was measured under 44 ─────────────────────
     .g-date-btn 160 × 41 · .g-btn-pill 720 × 43 · .ht-task-act 32 tall
     .pr-btn 81 × 35 · "+ Add a follow-up" summary 752 × 21 */
  .g-date-btn,
  .g-viewall,
  .g-btn-pill,
  .g-filter-btn,
  .pr-btn { min-height: 44px; }

  /* .ht-task-act declares min-height: 32px in a body <style>: needs to win. */
  .ht-task-act { min-height: 44px !important; }

  .ht-sg-new > summary,
  .ht-sg-rules > summary {
    min-height: 44px !important;
    display: flex !important; align-items: center;
  }

  /* MEASURED: the search results are 622 × 40 each, and they are how you jump
     between the 25 modules once the palette is open. */
  #gPalList button { min-height: 44px; }

  /* ── 2.7 · Controls added by ht-ipad (the <script> block) ─────────────────── */
  .ht-salida { min-height: 44px; min-width: 44px; }

  /* ── 2.8 · The three that were missed · MEASURED 3-sep ─────────────────────
     Found by sweeping all 25 views at 834×1194 with this block injected as
     plain CSS, then checking every tappable control against the list above.
     All three are plain boxes with no ::after to rescue them.

     ⚠️ What are NOT defects, written down so nobody "fixes" them again:
     `.ht-help-btn` is a 20×20 box but its ::after at inset -35px gives a real
     46×46 target; the `.g-task` and form checkboxes are wrapped by their
     <label>, which is already 44px tall. Measuring those by the visible box
     produces nine and fourteen false findings. */

  /* Range segments — 7d · 30d · 90d · Total. Measured 38×24, and there are 14
     of them across the app. The Dashboard ones matter most: it is the first
     screen that opens and the period switch is the first thing anyone taps. */
  .g-seg button { min-height: 44px; }

  /* The Family-messages widget. Measured 67×27. It is hidden in a real session
     by ocultarRestosDeDemo(), but it DOES show in the sales shortcut — which is
     what gets demonstrated on an iPad in front of a client. */
  .hc-btn { min-height: 44px; }

  /* Two pixels short, and it is the field where a role gets its name. */
  .roles-title-in { min-height: 44px; }

  /* ── 2.9 · The 16px floor, applied by SHAPE and not by name · 3-sep ────────
     MEASURED at 402×874: the Conversations composer (`#convDraft`) renders at
     13.12px. It is a bare <textarea> with no class, so the enumerated list in
     2.2 above walked straight past it — and it is the single most-used input in
     the product: it is what a teacher taps to answer a family.

     Below 16px, iPhone Safari zooms the page in on focus and leaves the person
     scrolled sideways mid-sentence. (The iPad does NOT do this — measured, its
     visualViewport.scale stayed at 1 — but the floor costs nothing there.)

     🔑 Why this rule is written by shape instead of by adding one more class:
     the enumerated list has now missed a field twice. Any text-entry control
     inside the app gets the floor, whatever it ends up being called. New
     fields are covered the day they are written, not the day someone notices. */
  .g-app input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="range"]):not([type="color"]):not([type="file"]),
  .g-app select,
  .g-app textarea,
  /* 12-nov-2026 · The dialogs hang from <body>, OUTSIDE .g-app, so the rule above never
     reached them: the "Choose PIN" field (0096) rendered at 11px / 17px tall in Safari.
     Same floor for every text-entry control inside any dialog. */
  .ht-help-backdrop input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="range"]):not([type="color"]):not([type="file"]),
  .ht-help-backdrop select,
  .ht-help-backdrop textarea {
    font-size: 16px !important;
  }
  .ht-help-backdrop input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="range"]):not([type="color"]):not([type="file"]),
  .ht-help-backdrop textarea {
    min-height: 44px;
  }
}


/* ═══ 3 · KEYBOARD ═════════════════════════════════════════════════════════

   MEASURED, portrait, software keyboard up: it takes 340px — visualViewport
   drops from 1078 to 738. Three screens tested (the Conversations composer, the
   Family-messages reply box, and Forms' "Printed name of signer"): iOS scrolled
   the focused field into view every time and never covered it.

   What DOES happen: .g-mobilebar is position:fixed;bottom:0, so iOS lifts it to
   sit on top of the keyboard — 46px of tab bar wedged between the field you are
   typing in and the keys. Screenshot-confirmed on both screens. While someone is
   typing that bar is useless, so it steps aside.

   The class is toggled by the ht-ipad script block on focusin/focusout. */
body.ht-teclado .g-mobilebar { display: none !important; }
body.ht-teclado .g-ribbon    { display: none; }


/* ═══ 4 · INSTALLED-APP CHROME ═════════════════════════════════════════════

   <html class="ht-standalone"> is set by the ht-ipad script when
   navigator.standalone is true.

   ⚠️ MEASURED and worth knowing before anyone writes CSS against it: inside a
   real installed web app on iPadOS 26.5, @media (display-mode: standalone) is
   FALSE and (display-mode: browser) is TRUE. navigator.standalone is the only
   thing that told the truth. Do not gate anything on display-mode here. */

/* Nothing is hidden by default in standalone. Rules live here when needed. */
.ht-standalone .ht-solo-navegador { display: none !important; }


/* ═══ 5 · PRINT ════════════════════════════════════════════════════════════
   Accounting prints (window.print() and the .pr-btn pill). Anything this file
   adds is app chrome and must not reach paper. */
@media print {
  .ht-salida { display: none !important; }
}
