/* ═══════════════════════════════════════════════════════════════════
   PORTAL IFRAME EMBED — layout overrides (styles/embed.css)

   Loaded LAST by BOTH index.html and tutorial.html. It must live in its own
   file rather than app.css: the tutorial page does not load app.css, and
   duplicating these rules into hfg-tutorial-v2.css guarantees drift.

   Every rule here is gated on html.framed, which scripts/app.js and
   scripts/tutorial.js set in their init():

       if (window.self !== window.top) document.documentElement.classList.add('framed');

   Without that line every rule below is DEAD CSS. It is set inside init(),
   which auth.js runs BEFORE signalRendered(), so the corrected framed layout
   is what the first rvo-height message measures.

   Why any of this is needed — the portal frames each tool as:
       <iframe src=… scrolling="no" style="height:{rvo-height}px">
   so (1) there is no local viewport — the portal page is the only scroll
   surface, and (2) the frame's height comes from the tool's OWN rvo-height
   message, which makes 100vh self-referential: inside the frame 100vh IS the
   height we last reported.
   ═══════════════════════════════════════════════════════════════════ */

/* ── 1. THE VIEWPORT-HEIGHT RATCHET ──────────────────────────────────
   A min-height:100vh on a CHILD of <body> that has a sibling above it (the
   nav) makes the frame grow forever:

       reported = nav + max(content, 100vh) = nav + H
       portal sets frame = nav + H   ⇒   100vh becomes nav + H
       reported = nav + (nav + H)    ⇒   ResizeObserver fires ⇒ repeat

   Every pass adds the nav's height. Symptom: dead space below the report
   that keeps growing, on the results page only.

   Fix by OVERRIDING the phantom height, never by capping the posted height —
   a numeric cap clips a legitimately tall report (two letter pages ≈ 2300px)
   and hides the real bug. */
html.framed body{min-height:0;}                 /* hfg-tool-shell.css:66  */
html.framed #pg2{min-height:0;}                 /* hfg-tool-shell.css:284 — the ratchet */
html.framed #tut-app{min-height:0;}             /* hfg-tutorial-v2.css:31 — the tutorial's own */
/* Mobile live screen. Stable today (mv-mode hides .site-nav, so there is no
   sibling adding height above these), but 100vh is still wrong framed — the
   dark shell should be as tall as its content, not as tall as the frame we
   just sized to its content. Precautionary and cheap. */
html.framed #mv .mapp.dk{min-height:0;}         /* hfg-tool-shell.css:189 */
html.framed #mv .sub{min-height:0;}             /* hfg-tool-shell.css:193 */

/* ── 2. position:fixed / sticky DO NOT WORK FRAMED ───────────────────
   sticky has no scroll viewport to stick to, so it is simply inert. fixed
   resolves against the iframe viewport, which EQUALS the full content height,
   so a bottom:0 bar pins to the bottom of the entire tall frame instead of
   floating over the reader. Flatten both into normal flow.

   SPECIFICITY TRAP: #tut-app .site-nav is (1,1,0) and BEATS a bare
   html.framed .site-nav at (0,2,0). The ID has to be repeated or the
   override silently does nothing. */
html.framed .site-nav{position:static;}             /* hfg-tool-shell.css:71  */
html.framed #tut-app .site-nav{position:static;}    /* hfg-tutorial-v2.css:36 — ID repeated */
html.framed #tut-app .tut-ctrl{position:static;box-shadow:none;border-top:1px solid var(--iv-line);}
/* …and drop the padding that only existed to reserve space for that fixed
   bar. Prev/Next now sit in flow directly under the step content, which is a
   better embedded experience than faking sticky and removes the need to
   scroll to reach them. */
html.framed #tut-app{padding-bottom:24px;}          /* was 104px */

/* NOT flattened, deliberately:
     · #authGate (auth.css)  — a full-bleed overlay; while it is showing the
       app is hidden, so content height IS the gate and inset:0 is correct.
     · #mv .shov (shell:535) — the mobile share overlay is *meant* to cover
       the screen; flattening it would break the sheet, and the portal
       workspace is a desktop surface. */

/* ── 3. SCROLL-TO-TOP ON A VIEW SWITCH ──────────────────────────────
   window.scrollTo is a silent no-op framed (a cross-origin child cannot
   scroll its parent), so the JS focuses the new view's heading instead:
   moving focus is a user-agent action and the UA scrolls every ancestor
   scroll container — across the iframe boundary — to reveal the target.

   Suppress the ring only for the non-keyboard case, so a real keyboard user
   keeps their focus indicator. */
#pg1Heading:focus:not(:focus-visible),
#pg2Heading:focus:not(:focus-visible),
#tut-app .tut-shead:focus:not(:focus-visible),
#tutStepHeading:focus:not(:focus-visible){outline:none;}
