/* public/assets/css/tf-0006-v7.css */
/* TF-0006 v7 (round 5): one bottom action area in the #chat image/video studio
   (#tf2create open over the chat page). Replaces v6 (tf-0006-chat-send.css/.js).
   Pure CSS, no script, no viewport math.
   Owner decisions 2026-12-02:
     - the dock stays visible on short (landscape) screens;
     - the chat composer stays visible in the FORM view too;
     - desktop Create stays in the page flow (as v7).
   Layout below 1100px (bottom dock):
     FORM (no #tf2cWork):  dock, then a compact composer just above the dock and
                           the + FAB, then Create fixed above the composer.
                           Landscape (>=560 wide, <=500 tall): Create and the
                           composer share one lane, side by side.
     WORK (#tf2cWork):     full composer just above the dock (as v7).
   Desktop: the composer is centered over the studio column in both views, and
   Create stays in flow, padded so that its end sits clear of the composer.
   Every rule is scoped to html.tf2.tf2c-on + body[data-tf-view="chat"], so the
   plain chat page, #tf2mv studios and Home are unchanged.
   Keyboard-up detection uses real focus on a text field INSIDE #tf2create only.
   Composer focus is ignored: chat.js focuses the composer on its own when #chat
   opens (focusCreateSurface, TFChat.focusComposer/prefill), so composer focus
   and body.tf-typing say nothing about a keyboard.
   Dock geometry mirrors tf2-redesign.css: 68px at max(18px,safe) in general,
   52px at max(6px,safe) with the + FAB 24px above the dock top under
   (orientation:landscape) and (max-height:500px) and (max-width:1099px).
   Without :has() the FORM layout applies in both views; the composer stays
   visible above the dock.
   Revert: remove this file's <link> from index.html. */

/* Declared on html (for .tfa11y-btn, a child of <html>) and on body, so
   --tf-composer-h resolves wherever chat.js sets it. */
html.tf2.tf2c-on,
html.tf2.tf2c-on body[data-tf-view="chat"]{
  /* dock = bottom max(18px,safe) + 68px tall (tf2-redesign.css:14,266) */
  --tf7-safe-b: max(18px, env(safe-area-inset-bottom, 0px));
  --tf7-dock-h: 68px;
  /* the lane starts this far above the dock top: 9px clear of the + FAB (raised 7px) */
  --tf7-fab-clear: 16px;
  --tf7-dock-top: calc(var(--tf7-safe-b) + var(--tf7-dock-h));
  --tf7-above-dock: calc(var(--tf7-dock-top) + var(--tf7-fab-clear));
  --tf7-side: calc(12px + max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)));
  --tf7-gap: 12px;
  --tf7-go-h: 52px;
  --tf7-go-w: clamp(160px, 30%, 240px);            /* landscape side-by-side Create */
  /* composer heights; the floors guard a stale or missing --tf-composer-h */
  --tf7-cmp-form: max(var(--tf-composer-h, 64px), 64px);   /* compact, ~68px */
  --tf7-cmp-work: max(var(--tf-composer-h, 96px), 96px);   /* full, ~95px */
  /* top of the fixed Create, measured from the viewport bottom (stacked form) */
  --tf7-go-top: calc(var(--tf7-above-dock) + var(--tf7-cmp-form) + var(--tf7-gap) + var(--tf7-go-h));
}
/* landscape dock (same query as tf2-redesign.css): 52px tall at max(6px,safe),
   + FAB 46px raised so its top is 24px above the dock top; lane clears it by 8px */
@media (orientation:landscape) and (max-height:500px) and (max-width:1099px){
  html.tf2.tf2c-on,
  html.tf2.tf2c-on body[data-tf-view="chat"]{
    --tf7-safe-b: max(6px, env(safe-area-inset-bottom, 0px));
    --tf7-dock-h: 52px;
    --tf7-fab-clear: 32px;
  }
}

/* ---- Composer: visible in both views while the studio is open ---- */
html.tf2.tf2c-on body[data-tf-view="chat"] .tf-composer{
  display: block;
  z-index: 10001; /* above the overlay (9999); never overlaps the dock (10000) */
  transform: none;
}
/* billing sheet open on top: no composer peeking over it */
html.tf2.tf2c-on.tf2bill-on body[data-tf-view="chat"] .tf-composer{
  display: none !important;
}

/* ---- Bottom dock (all widths below 1100px, any height) ---- */
@media (max-width:1099px){
  /* composer: one lane just above the dock and the + FAB, in both views */
  html.tf2.tf2c-on body[data-tf-view="chat"] .tf-composer{
    left: 0;
    right: 0;
    bottom: var(--tf7-above-dock);
    margin-inline: auto;
    width: min(720px, calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    padding-bottom: 10px;
    border: 1px solid rgba(125,107,255,.22);
    border-radius: 18px;
  }
  /* FORM: compact composer (no trust line, tight padding) to make room */
  html.tf2.tf2c-on body[data-tf-view="chat"]:not(:has(#tf2cWork)) .tf-composer{
    padding-top: 8px;
    padding-bottom: 8px;
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:not(:has(#tf2cWork)) .tf-composer-trust{
    display: none;
  }

  /* FORM: Create fixed just above the composer (fixed, not sticky; sticky
     cannot leave its parent block) */
  html.tf2.tf2c-on body[data-tf-view="chat"] #tf2create .tf2c-go{
    position: fixed;
    z-index: 3;
    left: 0;
    right: 0;
    bottom: calc(var(--tf7-above-dock) + var(--tf7-cmp-form) + var(--tf7-gap));
    margin-inline: auto;
    width: min(688px, calc(100% - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  }
  html.tf2.tf2c-on body[data-tf-view="chat"] #tf2create .tf2c-wrap{
    padding-bottom: calc(var(--tf7-go-top) + 32px);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"] #tf2create .tf2c-scroll{
    scroll-padding-bottom: calc(var(--tf7-go-top) + 24px);
  }
  /* scrim: content fades out above Create instead of showing between the bars.
     It lives in the overlay (9999), so it stays under the dock and the + FAB. */
  html.tf2.tf2c-on body[data-tf-view="chat"] #tf2create::after{
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--tf7-go-top) + 24px);
    background: linear-gradient(to top, var(--tf2-bg2, #0b0a14) calc(100% - 24px), transparent);
    pointer-events: none;
    z-index: 1;
  }
  html.tf2.tf2c-on body[data-tf-view="chat"] ~ .tfa11y-btn{
    bottom: calc(var(--tf7-go-top) + 16px);
  }

  /* WORK: the full composer is the lane */
  html.tf2.tf2c-on body[data-tf-view="chat"]:has(#tf2cWork) #tf2create .tf2c-wrap{
    padding-bottom: calc(var(--tf7-above-dock) + var(--tf7-cmp-work) + 20px);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:has(#tf2cWork) #tf2create .tf2c-scroll{
    scroll-padding-bottom: calc(var(--tf7-above-dock) + var(--tf7-cmp-work) + 12px);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:has(#tf2cWork) #tf2create::after{
    height: calc(var(--tf7-above-dock) + 8px); /* solid band under the composer, behind the dock */
    background: var(--tf2-bg2, #0b0a14);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:has(#tf2cWork) ~ .tfa11y-btn{
    bottom: calc(var(--tf7-above-dock) + var(--tf7-cmp-work) + 12px);
  }
}

/* ---- Dock is a centered pill (404px, 360px in landscape): a11y sits beside
   it, bottom-left (>=560px leaves >=78px free on the left) ---- */
@media (min-width:560px) and (max-width:1099px){
  html.tf2.tf2c-on body[data-tf-view="chat"] ~ .tfa11y-btn,
  html.tf2.tf2c-on body[data-tf-view="chat"]:has(#tf2cWork) ~ .tfa11y-btn{
    bottom: calc(var(--tf7-safe-b) + (var(--tf7-dock-h) - 44px) / 2); /* centered on the dock */
  }
}

/* ---- Landscape / short screens: FORM puts Create and the composer in one lane ---- */
@media (orientation:landscape) and (min-width:560px) and (max-width:1099px) and (max-height:500px){
  html.tf2.tf2c-on body[data-tf-view="chat"] #tf2create .tf2c-go{
    inset-inline: var(--tf7-side) auto;
    bottom: calc(var(--tf7-above-dock) + (var(--tf7-cmp-form) - var(--tf7-go-h)) / 2); /* centered on the compact composer */
    margin-inline: 0;
    width: var(--tf7-go-w);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:not(:has(#tf2cWork)) .tf-composer{
    inset-inline: calc(var(--tf7-side) + var(--tf7-go-w) + 10px) var(--tf7-side);
    margin-inline: 0;
    width: auto;
    max-width: none;
  }
  html.tf2.tf2c-on body[data-tf-view="chat"] #tf2create .tf2c-wrap{
    padding-bottom: calc(var(--tf7-above-dock) + var(--tf7-cmp-form) + 24px);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"] #tf2create .tf2c-scroll{
    scroll-padding-bottom: calc(var(--tf7-above-dock) + var(--tf7-cmp-form) + 16px);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"] #tf2create::after{
    height: calc(var(--tf7-above-dock) + var(--tf7-cmp-form) + 16px);
  }
}

/* keyboard up (touch, FORM): Create goes back into the flow and the composer
   spans the lane. Keyed ONLY on a text field inside #tf2create having focus;
   composer focus is ignored (chat.js auto-focuses it at boot). */
@media (pointer:coarse) and (max-width:1099px){
  html.tf2.tf2c-on body[data-tf-view="chat"]:not(:has(#tf2cWork)):has(#tf2create :is(textarea, input:not([type="checkbox"], [type="radio"], [type="button"], [type="submit"], [type="reset"], [type="file"], [type="range"], [type="color"], [type="hidden"]), [contenteditable="true"]):focus) #tf2create .tf2c-go{
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    margin-inline: 0;
    width: 100%;
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:not(:has(#tf2cWork)):has(#tf2create :is(textarea, input:not([type="checkbox"], [type="radio"], [type="button"], [type="submit"], [type="reset"], [type="file"], [type="range"], [type="color"], [type="hidden"]), [contenteditable="true"]):focus) #tf2create .tf2c-wrap{
    padding-bottom: calc(var(--tf7-above-dock) + var(--tf7-cmp-form) + 16px);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:not(:has(#tf2cWork)):has(#tf2create :is(textarea, input:not([type="checkbox"], [type="radio"], [type="button"], [type="submit"], [type="reset"], [type="file"], [type="range"], [type="color"], [type="hidden"]), [contenteditable="true"]):focus) #tf2create .tf2c-scroll{
    scroll-padding-bottom: calc(var(--tf7-above-dock) + var(--tf7-cmp-form) + 8px);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:not(:has(#tf2cWork)):has(#tf2create :is(textarea, input:not([type="checkbox"], [type="radio"], [type="button"], [type="submit"], [type="reset"], [type="file"], [type="range"], [type="color"], [type="hidden"]), [contenteditable="true"]):focus) #tf2create::after{
    display: none;
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:not(:has(#tf2cWork)):has(#tf2create :is(textarea, input:not([type="checkbox"], [type="radio"], [type="button"], [type="submit"], [type="reset"], [type="file"], [type="range"], [type="color"], [type="hidden"]), [contenteditable="true"]):focus) .tf-composer{
    left: 0;
    right: 0;
    margin-inline: auto;
    width: min(720px, calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    max-width: none;
  }
}

/* a11y button (touch): a11y.js and tf-0002-fabs.css (A5, !important) hide it
   on body.tf-typing, which chat.js's composer auto-focus sets at boot. Inside
   the studio, show it again unless a studio text field has focus. !important
   is needed to beat A5; this selector (2,9,4) outranks A5's strongest (1,3,3).
   Never while the billing sheet is open (html.tf2bill-on, body > #tf2bill,
   .tf2b-second): tf-0002 parks or hides a11y there and keeps control. */
@media (pointer:coarse){
  html.tf2.tf2c-on:not(.tf2bill-on, .tf2b-second):not(:has(body > #tf2bill, .tf2b-second)) body[data-tf-view="chat"].tf-typing:not(:has(#tf2create :is(textarea, input:not([type="checkbox"], [type="radio"], [type="button"], [type="submit"], [type="reset"], [type="file"], [type="range"], [type="color"], [type="hidden"]), [contenteditable="true"]):focus)) ~ .tfa11y-btn{
    display: flex !important; /* same display tf-0002-fabs.css uses for its parked a11y */
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:has(#tf2create :is(textarea, input:not([type="checkbox"], [type="radio"], [type="button"], [type="submit"], [type="reset"], [type="file"], [type="range"], [type="color"], [type="hidden"]), [contenteditable="true"]):focus) ~ .tfa11y-btn{
    display: none;
  }
}

/* ---- Desktop (dock = 252px sidebar on the inline-start side) ---- */
@media (min-width:1100px){
  /* both views: the composer is centered over the studio column, not the whole
     window. Logical insets follow the sidebar (left in LTR, right in RTL). */
  html.tf2.tf2c-on body[data-tf-view="chat"] .tf-composer{
    inset-inline-start: 252px;
    inset-inline-end: 0;
    bottom: 0;
    margin-inline: auto;
    width: min(760px, calc(100% - 252px - 32px));
  }
  /* Create stays in flow (as v7); its end and the last bubble scroll clear of the composer */
  html.tf2.tf2c-on body[data-tf-view="chat"] #tf2create .tf2c-wrap{
    padding-bottom: calc(var(--tf7-cmp-work) + 24px);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"] #tf2create .tf2c-scroll{
    scroll-padding-bottom: calc(var(--tf7-cmp-work) + 12px);
  }
  html.tf2.tf2c-on body[data-tf-view="chat"] ~ .tfa11y-btn{
    bottom: max(188px, calc(var(--tf7-cmp-work) + var(--tf7-go-h) + 40px));
  }
  html.tf2.tf2c-on body[data-tf-view="chat"]:has(#tf2cWork) ~ .tfa11y-btn{
    bottom: max(164px, calc(var(--tf7-cmp-work) + 16px));
  }
  /* LTR: the sidebar is on the left, so a11y moves just past it */
  html.tf2.tf2c-on:not([dir="rtl"]) body[data-tf-view="chat"] ~ .tfa11y-btn{
    left: calc(252px + 12px);
  }
}
