/* AirForge Pro: sticky rules for both shells (contract G.3).
   Page headers, tab rows, section headers and table column headers stay in view while the page scrolls.
   Everything is offset by the real height of the strip (--pro-h) and of the product's own top bar.

   Variables (set by frame.css and frame.js, usable by other Pro stylesheets):
     --pro-h        height of the strip (0px on phones, where the strip scrolls away)
     --pro-top      y where page content starts under the strip and the product's own top bar
     --pro-phead-h  height of the sticky page header of the open screen (0px when it is not sticky)
     --pro-tabs-h   height of the sticky tab row of the open screen (0px when there is none)
     --pro-stick    y just under the sticky page header and tab row: where the next sticky thing may sit   */

html.pro{--pro-stick:calc(var(--pro-top,0px) + var(--pro-phead-h,0px) + var(--pro-tabs-h,0px))}

/* =====================================================================================================
   PART 1. AirForge new console
   ===================================================================================================== */

/* the status bars above the top bar (free trial, offline grace, licence) scroll away with the page: they must pass
   UNDER the strip, not over it (their own z-index is 80) */
html.pro-ctx-airforge .afbar{z-index:1}
/* the console's own top bar sits under the strip */
html.pro-ctx-airforge .top{top:calc(env(safe-area-inset-top,0px) + var(--pro-h,0px))}
/* DJ header bar: the DJ pages are drawn at 88% (zoom), so the offset is divided by the same factor */
html.pro-ctx-airforge .djh{top:calc((env(safe-area-inset-top,0px) + var(--pro-h,0px)) / .88)}

@media (min-width:861px){
  /* left rail: starts under both bars and fills the rest of the window */
  html.pro-ctx-airforge .rail,
  html.pro-ctx-airforge body.onairview .rail{top:calc(env(safe-area-inset-top,0px) + var(--pro-top)); height:calc(100vh - var(--pro-top))}
}
/* On Air screen: one fixed-height board. It gives the strip's height back so the page still fits the window. */
html.pro-ctx-airforge .ax{height:calc(100vh - 78px - 16px - var(--pro-h,0px))}
@media (max-width:900px){html.pro-ctx-airforge .ax{height:auto}}

/* page header and tab row of every console screen. From 600 px wide: tablets and half-screen windows too
   (only phones and very short windows let the header scroll away, there is no room to hold it there). */
@media (min-width:600px) and (min-height:560px){
  html.pro-ctx-airforge .work-in > .phead{position:sticky; top:var(--pro-top); z-index:9; background:var(--bg);
    padding:10px 0 9px; margin:-10px 0 -9px}
  html.pro-ctx-airforge .work-in > .tabs{position:sticky; top:calc(var(--pro-top) + var(--pro-phead-h,0px)); z-index:8; background:var(--bg);
    padding-top:9px; margin-top:-9px}
}

/* things that already stuck under the top bar: now under the page header and tab row */
html.pro-ctx-airforge .selbar,
html.pro-ctx-airforge .stickybar{top:calc(var(--pro-stick) + 6px)}
/* clock editor: its "Items in the hour" header carries its own offset inline (--wcsStick = bottom of the top bar) */
html.pro-ctx-airforge .card > div[style*="--wcsStick"]{top:var(--pro-stick)!important}
/* Feature map: heading row sticks to the page, under the page header */
@media (min-width:900px){
  html.pro-ctx-airforge table.fm th{top:calc(env(safe-area-inset-top,0px) + var(--pro-stick))}
}

/* section headers: the header of a card stays in view while the card's content scrolls past */
@media (min-width:600px) and (min-height:560px){
  html.pro-ctx-airforge .work-in > .card > .card-h,
  html.pro-ctx-airforge .work-in > :not(.ax):not(.card) > .card > .card-h{position:sticky; top:var(--pro-stick); z-index:5;
    background:var(--panel); border-radius:10px 10px 0 0}
}

/* table column headers: a long table scrolls inside its own box and its headings stay on top (the Library pattern).
   Not the Library itself (owned by library.css), not the On Air running order and not the Feature map (own rules). */
html.pro-ctx-airforge .tw:not(.libtw):has(> table:not(.fm):not(.aqt)){max-height:max(300px,calc(100vh - var(--pro-stick) - 28px)); overflow:auto}
html.pro-ctx-airforge .tw:not(.libtw) > table:not(.fm):not(.aqt) > thead th,
html.pro-ctx-airforge .tw:not(.libtw) > table:not(.fm):not(.aqt):not(:has(> thead)) > tbody > tr:first-child > th{position:sticky; top:0; z-index:2;
  background:var(--panel2); box-shadow:inset 0 -1px 0 var(--line)}

/* =====================================================================================================
   PART 2. WebForge console (new shell, classic, basic)
   ===================================================================================================== */

/* the page is one screen tall in WebForge's own sheet; the strip must be able to stick for the whole scroll */
html.pro-ctx-webforge body{height:auto; min-height:100%}

/* new shell */
html.pro-ctx-webforge .wf-top{top:var(--pro-h,0px)}
@media (min-width:901px){
  html.pro-ctx-webforge .wf-rail{top:calc(var(--pro-h,0px) + var(--pro-wftop-h,50px)); height:calc(100vh - var(--pro-h,0px) - var(--pro-wftop-h,50px))}
}
@media (min-width:600px) and (min-height:560px){
  html.pro-ctx-webforge .wf-in > .wf-head{position:sticky; top:var(--pro-top); z-index:30; background:var(--bg);
    padding:10px 0 9px; margin:-10px 0 -9px}
  html.pro-ctx-webforge .wf-in > .wf-tabs{position:sticky; top:calc(var(--pro-top) + var(--pro-phead-h,0px)); z-index:29; background:var(--bg);
    padding-top:9px; margin-top:-9px}
  /* section headers of the console's own cards */
  html.pro-ctx-webforge .wf-in > .wf-card > .h{position:sticky; top:var(--pro-stick); z-index:6; background:var(--bg2); border-radius:10px 10px 0 0}
}
/* classic console: header and tab bar */
html.pro-ctx-webforge .admin-header{top:var(--pro-h,0px)}
html.pro-ctx-webforge .admin-tabs{top:calc(var(--pro-h,0px) + var(--pro-wftop-h,53px))}

/* table column headers */
html.pro-ctx-webforge .tbl-wrap{max-height:max(300px,calc(100vh - var(--pro-stick) - 28px)); overflow:auto}
html.pro-ctx-webforge .tbl-wrap > table > thead th,
html.pro-ctx-webforge .tbl-wrap > table:not(:has(> thead)) > tbody > tr:first-child > th{position:sticky; top:0; z-index:2; background:var(--bg3)}
html.pro-ctx-webforge table.wf-moved th{position:sticky; top:var(--pro-stick); z-index:2}
