/* ============================================================================
   zz_studio_export_cta.css — the Post studio sticky "Export →" CTA (plan stage
   C-6a; docs/design/new_content_screen.md §4 Sticky CTA; DS §1.5 pill CTA +
   §5 "Sticky CTA (mobil)"; map row B7 "Export trigger" -> Export CTA in
   docs/new_content/studio_control_map.md).

   Scope: #new-content-shell .sp-studio-export-cta (the id-less band that holds
   the SAME `workspace-open-export` button — same id, same click callback, same
   phase-gated `style` writer) + the scroll-clearance rules on the existing scroll
   surfaces (spec §4: "the scroll content gets bottom padding so the CTA
   never covers anything"), every one of them at 2-id specificity.

   UX 4.3 / decision D-63 (2026-09-15): the band is mounted in the studio topbar's
   actions cluster now (layout.py), not as the shell's last child. Owner report: on
   a phone the fixed band ate ~92 px of the first screen right above the bottom nav
   and the preview had to fit in what was left. At ≥641 NOTHING changes — the band is
   `position: fixed`, and no ancestor of the topbar establishes a containing block for
   fixed (no transform / filter / perspective / contain / will-change; an ancestor's
   `overflow: hidden` does not clip a fixed descendant), so it still paints at the
   viewport edges exactly as before. At ≤640 it turns `static` and the same button is
   a compact accent pill in the topbar row — the freed height goes to the preview
   stage through --sp-preview-height-reserve (assets/zz_studio_preview_scale.css).

   Geometry:
   * ≤767 (phones + the tablet band): fixed ABOVE the app's mobile bottom nav
     (layout.py `sp-bottom-nav`, styles.css:11323 — fixed, z 1200, ≤767),
     visible on the studio since Band S stage S-1a (decision S2 supersedes
     D5; it used to be hidden ≤640 and covered the CTA at 641–767 = finding
     E-9). The nav's height is not a CSS variable anywhere: 6+6 padding,
     5+5 link padding, 21 icon, 3 gap, 0.66rem text at Mantine's line-height
     (~17px), 1 border = 64px measured in Playwright (390×844 and 700×900,
     safe-area 0), + the safe-area inset — pinned here as --sp-bottom-nav-h.
     The nav's own scroll
     clearance is styles.css:11371 (`#app-page-container` padding-bottom at
     ≤767), so the clearance paddings below stay CTA-only. (Before S-1a the
     band sat on the retired B1 tool bar, `--sp-studio-mobile-bar-h` 61px.)
   * ≤640 (mobile): pill 44px (DS §3.1 touch ladder); the sheet panel and
     the canvas column get the band's height as extra bottom padding.
   * 641–1180: the page scrolls (panels stacked); fixed full-width bottom.
   * ≥1181 (desktop): the right inspector panel is a FIXED box at right:0
     whose width is the JS-measured --sp-workspace-side-panel-width
     (new_content_layout_editor.js, control map §C5); the band is fixed to
     the same box's bottom edge (never inside the panel — the panel is a JS
     measurement anchor). Pill 40px. The panel's stack gets the clearance.

   Hidden states (CSS only, the gates are untouched):
   * `_sync_workspace_phase_navigation` writes display:none on the button
     until the visual stage — the whole band hides with it (:has()).
   * while the data drawer is open the band hides (it would show through the
     drawer backdrop; the drawer is the entry stage on an empty studio).
   The export drawer (z 1000010) and the preset modal paint above the band.

   Cascade: this file sorts BEFORE zz_studio_header/look/output ("zz_studio_e"
   < "zz_studio_h") and AFTER zz_new_content.css; every override of an older
   band wins on ids (2), never on order; !important only where the older
   rule being overridden is !important (zz_new_content.css:1790 / :3416
   button metrics, the ≤640 preview-shell and tabs-panel paddings). Nothing
   in styles.css / zz_new_content.css is edited. Nothing here sets `display`
   on .sp-mob-* or .mantine-Tabs-* elements.
   ========================================================================== */

#new-content-shell {
  /* the band's own footprint (pill + paddings + the fade) = the clearance the
     scroll surfaces reserve; the app's bottom-nav height the band sits on
     at ≤767 (S-1a) */
  --sp-studio-cta-h: 40px;
  --sp-studio-cta-fade: 28px;
  --sp-studio-cta-pad-y: 10px;
  --sp-studio-cta-clearance: calc(var(--sp-studio-cta-h) + var(--sp-studio-cta-pad-y) * 2 + var(--sp-studio-cta-fade));
  --sp-bottom-nav-h: calc(64px + env(safe-area-inset-bottom, 0px));
}

#new-content-shell .sp-studio-export-cta {
  --cta-ui: "Instrument Sans", "Manrope", var(--bc-body);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50; /* above the desktop fixed panel (40); below drawers / modals */
  box-sizing: border-box;
  padding: calc(var(--sp-studio-cta-fade) + var(--sp-studio-cta-pad-y)) 16px var(--sp-studio-cta-pad-y);
  /* DS §5 Sticky CTA: the pill over a fade to the page ground */
  background: linear-gradient(to top, var(--sp-bg) 65%, transparent);
  /* the fade lets clicks through; only the pill is interactive */
  pointer-events: none;
}

/* the SAME button, DS §1.5 primary pill (accent / ink), full width.
   4.3 / D-63: the band lives in the topbar now, so the legacy `.sp-editor-topbar-export`
   ladders of zz_new_content.css — scoped to `.sp-builder-shell-topbar`, dormant while the
   band sat at the shell's end — match again. Two of them were not already answered by the
   declarations below and had to become `!important` here: the ≤720 icon-only treatment's
   `width: 34px !important` (:3334) and its `.mantine-Button-label { display: none !important }`
   (:3353), which would otherwise turn the 641–767 fixed bottom CTA into a blank 34px circle.
   Both answers are at 2-id specificity, on all widths; the rest of that ladder (height,
   min-width, padding, radius, font-size) already loses to the declarations below. */
#new-content-shell .sp-studio-export-cta #workspace-open-export.mantine-Button-root {
  display: inline-flex;
  width: 100% !important;
  height: var(--sp-studio-cta-h) !important;
  min-height: var(--sp-studio-cta-h) !important;
  min-width: 0 !important;
  padding-inline: 18px !important;
  border-radius: 999px !important;
  border: 0 !important;
  background: var(--bc-accent) !important;
  color: var(--bc-accent-ink) !important;
  font-family: var(--cta-ui);
  font-size: 14px !important;
  font-weight: 700 !important;
  letter-spacing: 0 !important;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--sp-accent) 26%, transparent);
  pointer-events: auto;
  transition: background-color 0.15s ease;
}

#new-content-shell .sp-studio-export-cta #workspace-open-export.mantine-Button-root:hover {
  background: var(--bc-accent-hover) !important;
  color: var(--bc-accent-ink) !important;
}

#new-content-shell .sp-studio-export-cta #workspace-open-export.mantine-Button-root:focus-visible {
  outline: 2px solid var(--bc-text);
  outline-offset: 2px;
}

/* the inner keeps Mantine's own centring flexbox — an earlier 4.3 draft set `display: block`
   here too and the label ended up in the pill's top-left corner on every width */
#new-content-shell .sp-studio-export-cta #workspace-open-export .mantine-Button-inner {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* the label only has to survive the ≤720 icon-only band's `display: none !important`
   (zz_new_content.css:3353), which the topbar mount of D-63 woke up — and it must come back
   as the FLEX box Mantine ships, not as a block: the label is stretched to the button's full
   30/40/44px height while its line-height is the font's 12px, so `display: block` parked the
   text at the top of the pill (caught at every width in tmp/shots/ux43_widths/zoom-*.png). */
#new-content-shell .sp-studio-export-cta #workspace-open-export .mantine-Button-label {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100%;
  white-space: nowrap;
}

/* phase gate: the button's callback-written display:none hides the band */
#new-content-shell .sp-studio-export-cta:has(> #workspace-open-export[style*="display: none"]) {
  display: none;
}

/* the data drawer (entry stage / "← Edit data" on non-explore posts) covers
   the studio with a translucent backdrop — no CTA under it */
#new-content-shell:has(#workspace-data-drawer.is-open) .sp-studio-export-cta {
  display: none;
}

/* ---- scroll clearance, desktop + tablet (spec §4) ------------------------ */
@media (min-width: 641px) {
  /* the inspector's scroll content (the ≤640 band zeroes this padding — the
     rule stays out of that band) */
  #new-content-shell #workspace-right-panel .sp-editor-panel-stack {
    padding-bottom: calc(16px + var(--sp-studio-cta-clearance));
  }
}

/* ---- desktop ≥1181: pinned to the fixed right panel's box ---------------- */
@media (min-width: 1181px) {
  #new-content-shell .sp-studio-export-cta {
    left: auto;
    right: 0;
    width: var(--sp-workspace-side-panel-width);
  }
}

/* ---- ≤767: above the app's bottom nav (S-1a; closes E-9) ----------------- */
@media (max-width: 767px) {
  #new-content-shell .sp-studio-export-cta {
    bottom: var(--sp-bottom-nav-h);
  }
}

/* ---- mobile ≤640: the pill rides IN the topbar (4.3 / D-63) --------------
   The band stops being a fixed bottom overlay and becomes a normal item of the
   topbar's `.sp-editor-topbar-actions` flex row, right after Save. The button
   keeps its id, its label and its phase gate — only the metrics shrink to the
   row's 30 px action ladder (Save is 34, undo/redo 26 at ≤640).
   Nothing below the canvas is reserved for the CTA any more: the ≤640 scroll
   clearances of C-6a are gone with the overlay, and the mobile shell's own
   `padding-bottom: 8px` on #builder-preview-shell (the ≤640 mobile-shell band)
   is what the canvas column keeps. */
@media (max-width: 640px) {
  #new-content-shell {
    --sp-studio-cta-h: 30px;
  }

  #new-content-shell .sp-studio-export-cta {
    position: static;
    flex: 0 0 auto;
    width: auto;
    padding: 0;
    background: none;
    pointer-events: auto;
  }

  #new-content-shell .sp-studio-export-cta #workspace-open-export.mantine-Button-root {
    width: auto !important;
    padding-inline: 11px !important;
    font-size: 12px !important;
    box-shadow: none;
  }

  /* the row's width budget: the accent pill takes ~73px the title used to have, so the
     one control whose icon already carries its whole meaning goes icon-only — the same
     treatment the ≤720 band (zz_new_content.css:3334) gives Save. "← Edit data" keeps its
     id, its `title` / `aria-label` and its callback; only the label is hidden. */
  #new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-data.mantine-Button-root {
    width: 34px !important;
    min-width: 34px !important;
    padding-inline: 0 !important;
    justify-content: center;
  }

  #new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-data .mantine-Button-label {
    display: none !important;
  }

  #new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-data .mantine-Button-section {
    margin: 0 !important;
  }
}
