/* ============================================================================
   zz_studio_header.css — the Post studio header (plan stage C-1a).

   Scope: #new-content-shell .sp-builder-shell-topbar ONLY. Structure per
   docs/design/new_content_screen.md §2 + decisions C7 and S2
   (docs/design/builder_v6_decisions.md): "STEP 3 OF 3 · DESIGN" mono eyebrow ·
   "Post studio" phase label · dataset breadcrumb · ← Edit data · undo/redo ·
   Save. (C-6a: the Export button left the bar — it is the sticky CTA,
   assets/zz_studio_export_cta.css; the preset trigger is a LOOK-card row,
   zz_studio_look.css.) Values come from the --bc-* chrome tokens
   (assets/new_content.css) so the C-1b retune flows through; the DS fonts are
   header-local until a --bc-* type token exists.

   Cascade: this file sorts after zz_new_content.css ("zz_s" > "zz_n"), so it
   wins every equal-specificity tie against the older topbar bands — the
   density ladder (≤1780 / ≤1520 / ≤1330) and the ≤640 mobile hide-list are
   re-tuned here, never edited in place. Nothing in styles.css is touched.

   Hidden-first retirements (C7): the platform select and the Zones switch are
   display:none here; the components stay mounted (callbacks Input them).
   NOT touched (later stages): #preview-controls (C-2), the inspector Tabs
   and the mobile bottom-bar shell (C-6b/c).

   Band S stage S-1 (decision S2, docs/design/builder_v6_decisions.md,
   2026-09-05): the global app header is visible on the studio again, so this
   topbar is a SUB-ROW under it. The C-1 logo lockup was a duplicate brand —
   hidden in S-1a, deleted with its rules in S-1b (the older lockup rules in
   zz_new_content.css :5000–5035 / :5133 / :5328 are dead now — D-3 list).
   Row = [STEP 3 OF 3 · DESIGN][Post studio][/ breadcrumb] … [← Edit data]
   [↶] [↷] [Save]; on ≤640 the eyebrow stacks over the dataset name.
   ========================================================================== */

#new-content-shell .sp-builder-shell-topbar {
  --sh-display: "Bricolage Grotesque", "Archivo", var(--bc-body);
  --sh-ui: "Instrument Sans", "Manrope", var(--bc-body);
  --sh-mono: "Space Mono", var(--bc-num);
  --sh-control-h: 30px;
  /* DS §1.1: tool surfaces carry an opaque in-flow header on the page ground
     with a hairline below — no panel tint, no shadow. */
  background: var(--bc-bg) !important;
  border-bottom: 1px solid var(--bc-border) !important;
  box-shadow: none !important;
  padding: 6px 16px !important;
  min-height: 46px;
}

/* ---- left cluster: step eyebrow · phase · breadcrumb ---------------------- */

#new-content-shell .sp-builder-shell-heading-inline {
  gap: 12px !important;
  min-height: 32px;
}

/* "STEP 3 OF 3 · DESIGN" (S-1b, decision S2; 1.7 / D-16: 3 of 3): the DS §5 mono CAPS label in
   lime (§1.3 — the step-label idiom the entry screen shares). Plain span,
   no id. */
#new-content-shell .sp-studio-step-eyebrow {
  flex: 0 0 auto;
  font-family: var(--sh-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--bc-select);
  white-space: nowrap;
}

/* Phase label "Post studio" (spec §2: display font), separated from the
   eyebrow by the hairline. The R3 dot ::before is retired. */
#new-content-shell .sp-builder-brand {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding-left: 12px;
  border-left: 1px solid var(--bc-border);
  font-family: var(--sh-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--bc-text2);
  white-space: nowrap;
}

#new-content-shell .sp-builder-brand::before {
  content: none;
}

#new-content-shell .sp-builder-brand:hover {
  color: var(--bc-text2);
}

#new-content-shell .sp-builder-breadcrumb-name {
  font-family: var(--sh-ui);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--bc-text2);
  max-width: 260px;
}

#new-content-shell .sp-builder-breadcrumb-name:not(:empty)::before {
  content: "/";
  margin-right: 8px;
  color: var(--bc-faint);
}

/* ← Edit data (A5b, origin-aware — untouched wiring): DS ghost pill. */
#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-data.mantine-Button-root {
  height: var(--sh-control-h) !important;
  min-height: var(--sh-control-h) !important;
  padding-inline: 12px 14px !important;
  border-radius: 999px !important;
  background: transparent !important;
  border: 1px solid var(--bc-border) !important;
  color: var(--bc-text) !important;
  font-family: var(--sh-ui);
  font-size: 12.5px !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}

#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-data.mantine-Button-root:hover {
  border-color: var(--bc-accent) !important;
  color: var(--bc-text) !important;
}

#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-data .mantine-Button-section {
  margin-inline-end: 6px !important;
  color: var(--bc-text2);
}

/* ---- right cluster: status dot · undo/redo · Save (Export = sticky CTA since C-6a) */

#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-actions {
  gap: 6px !important;
  /* stacking root for the Save toast: below ~1500px the #preview-controls row
     wraps UNDER this cluster and painted over the toast (elementFromPoint hit
     #preview-edit-row); a positioned cluster with its own z-index paints above
     the non-positioned grid rows. Fixed drawers/sheets sit far above (≥1000).
     UX 4.3 / D-63 (2026-09-15): the Export CTA band (`.sp-studio-export-cta`,
     `position: fixed; z-index: 50`) is a child of this cluster now, so its
     z-index is resolved INSIDE this stacking context — at 20 the band fell
     under the fixed right inspector panel (zz_new_content.css:1483, z 40) it
     is pinned to the bottom of, and the pill was painted over by the panel's
     cards (verified with elementsFromPoint). 60 puts the cluster — and with it
     the band — back above that panel, which is the C-6a order; the cluster and
     the panel never overlap geometrically (the topbar is above the panel's
     top), and the drawers / modals / fullscreen shell are unaffected (≥1000). */
  position: relative;
  z-index: 60;
}

/* Hidden-first retirement (C7): platform select + Zones. Mounted, invisible. */
#new-content-shell .sp-editor-topbar-platform,
#new-content-shell .sp-editor-topbar-zones {
  display: none !important;
}

/* Undo / redo: compact ghost icons (C7 amendment). */
#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-undo.mantine-ActionIcon-root,
#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-redo.mantine-ActionIcon-root {
  width: 28px !important;
  min-width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  border-radius: 999px !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--bc-text2) !important;
  box-shadow: none !important;
}

#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-undo.mantine-ActionIcon-root:hover:not(:disabled):not([data-disabled]),
#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-redo.mantine-ActionIcon-root:hover:not(:disabled):not([data-disabled]) {
  background: var(--bc-raised) !important;
  border-color: var(--bc-border) !important;
  color: var(--bc-text) !important;
}

#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-undo.mantine-ActionIcon-root:disabled,
#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-undo.mantine-ActionIcon-root[data-disabled],
#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-redo.mantine-ActionIcon-root:disabled,
#new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-redo.mantine-ActionIcon-root[data-disabled] {
  background: transparent !important;
  color: var(--bc-faint) !important;
  opacity: 1;
}

/* Save (C7: kept). Secondary ghost pill — the sticky Export CTA
   (zz_studio_export_cta.css, C-6a) is the one primary. */
#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.mantine-Button-root {
  position: relative;
  /* Mantine's Button root clips its box (overflow:hidden for the loader
     overlay) — the feedback toast below is a ::after OUTSIDE the box. */
  overflow: visible !important;
  height: var(--sh-control-h) !important;
  min-height: var(--sh-control-h) !important;
  min-width: 0 !important;
  padding-inline: 12px 14px !important;
  border-radius: 999px !important;
  background: transparent !important;
  border: 1px solid var(--bc-border) !important;
  color: var(--bc-text) !important;
  font-family: var(--sh-ui);
  font-size: 12.5px !important;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  box-shadow: none !important;
  transition: border-color 0.15s ease, color 0.15s ease;
}

#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.mantine-Button-root:hover {
  border-color: var(--bc-accent) !important;
}

#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile .mantine-Button-section {
  margin-inline-end: 6px !important;
  color: var(--bc-text2);
}

/* Save feedback (the C7-note fix, page.py mirror): result state on the button
   + the message as a small toast under it. `data-save-feedback` is written by
   the clientside mirror; empty = resting. */
#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.is-saved.mantine-Button-root {
  border-color: var(--bc-good) !important;
  color: var(--bc-good) !important;
}

#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.is-saved .mantine-Button-section {
  color: var(--bc-good);
}

#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.is-save-error.mantine-Button-root {
  border-color: var(--bc-warn) !important;
  color: var(--bc-warn) !important;
}

#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.is-save-error .mantine-Button-section {
  color: var(--bc-warn);
}

/* informational Alerts (blue "Defaults applied…", yellow "already exists…"):
   neutral state, the toast carries the message */
#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.is-save-note.mantine-Button-root {
  border-color: var(--bc-text2) !important;
  color: var(--bc-text) !important;
}

#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.is-save-note[data-save-feedback]:not([data-save-feedback=""])::after {
  border-color: var(--bc-border);
}

#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile[data-save-feedback]:not([data-save-feedback=""])::after {
  content: attr(data-save-feedback);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: max-content;
  max-width: min(360px, 84vw);
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--bc-raised);
  border: 1px solid var(--bc-good);
  color: var(--bc-text);
  font-family: var(--sh-ui);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

#new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.is-save-error[data-save-feedback]:not([data-save-feedback=""])::after {
  border-color: var(--bc-warn);
}

/* Animation-freshness dot: keep, mono meta look. */
#new-content-shell .sp-builder-anim-status {
  font-family: var(--sh-mono);
  font-size: 10px;
}

/* ---- density ladder (re-tuned: the platform/zones cluster left the bar) --- */
/* ≤1780: nothing to shed on the left since S-1b (the wordmark is gone) — the
   phase label stays (zz_new_content.css :5134 hides .sp-builder-brand here;
   overridden), with its separator after the eyebrow. */
@media (min-width: 1181px) and (max-width: 1780px) {
  #new-content-shell .sp-builder-brand {
    display: inline-flex;
  }
}

/* ≤1520: the breadcrumb goes (as before). */
@media (min-width: 1181px) and (max-width: 1520px) {
  #new-content-shell .sp-builder-breadcrumb-name {
    display: none;
  }
}

/* ---- ≤720 (zz_new_content.css icon-only band): keep the pills round ------ */
@media (max-width: 720px) {
  #new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.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-preview-save-profile .mantine-Button-section {
    margin: 0 !important;
  }
}

/* ---- mobile ≤640 (spec §2, mobile-first) -------------------------------- */
/* Two rows: full-width step / dataset label, then Edit data + Boxes + actions.
   Flatten the primary wrapper into the grid so its heading and Edit data
   button can share rows with the existing controls without moving any IDs.
   "Post studio" stays hidden here by the B2 band (zz_new_content.css :5329,
   !important) — the eyebrow announces the phase. Save is icon-only and
   VISIBLE (the B2 band hid it — C7 keeps it in the header). */
@media (max-width: 640px) {
  #new-content-shell .sp-builder-shell-topbar {
    padding: 6px 12px !important;
  }

  #new-content-shell .sp-builder-shell-topbar-inner {
    grid-template-areas: "heading heading heading" "data controls actions" !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    column-gap: 4px !important;
    row-gap: 4px !important;
  }

  #new-content-shell .sp-builder-shell-topbar-primary {
    display: contents !important;
  }

  #new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-data {
    grid-area: data;
  }

  #new-content-shell .sp-builder-shell-topbar #preview-controls {
    grid-area: controls;
    justify-self: start;
  }

  #new-content-shell .sp-builder-shell-topbar #preview-controls .sp-preview-boxes-toggle .mantine-Switch-body {
    margin-right: 0;
  }

  #new-content-shell .sp-builder-shell-topbar #preview-controls .sp-preview-boxes-toggle .mantine-Switch-label {
    padding-left: 5px;
    font-size: 11px !important;
  }

  #new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-actions {
    width: max-content !important;
    justify-self: end;
  }

  #new-content-shell .sp-builder-shell-heading-inline {
    grid-area: heading;
    justify-self: stretch;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto;
    column-gap: 8px !important;
    row-gap: 0 !important;
    min-height: 16px;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0 !important;
  }

  #new-content-shell .sp-studio-step-eyebrow {
    grid-row: 1;
    grid-column: 1;
    font-size: 9px;
    line-height: 1.2;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #new-content-shell .sp-builder-breadcrumb-name {
    grid-row: 1;
    grid-column: 2;
    max-width: none;
    min-width: 0;
    font-size: 11px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The column gap separates the compact labels. */
  #new-content-shell .sp-builder-breadcrumb-name:not(:empty)::before {
    content: none;
  }

  /* An empty breadcrumb (nothing loaded) takes no space. */
  #new-content-shell .sp-builder-breadcrumb-name:empty {
    display: none;
  }

  /* Keep room for Edit data and Boxes on the controls row. */
  #new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-actions {
    gap: 4px !important;
  }

  #new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-data.mantine-Button-root {
    padding-inline: 7px 9px !important;
  }

  #new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-undo.mantine-ActionIcon-root,
  #new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-redo.mantine-ActionIcon-root {
    width: 26px !important;
    min-width: 26px !important;
  }

  #new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile.mantine-Button-root {
    display: inline-flex !important;
  }

  #new-content-shell .sp-builder-shell-topbar .sp-editor-topbar-actions > :is(div, .sp-tip):has(#btn-profile-save-topbar) {
    display: flex !important;
  }

  #new-content-shell .sp-builder-shell-topbar .sp-preview-save-profile[data-save-feedback]:not([data-save-feedback=""])::after {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* ---- C1: studio-only tweaks for `.sp-tip` ----------------------------------
   The bubble itself is defined once, app-wide, in zz_site_chrome.css (it is used by
   the header avatar too). Only the two studio specifics live here. Why the class
   exists at all: a `dmc.Tooltip` type carries the static `dashChildrenUpdate`
   property, so dash-renderer runs `determineChangedProps` — a scan of the whole
   `layoutHashes` table — for it on EVERY store update. Measured 2026-09-06 on a
   deeplink load: removing the nine flagged components on this route moved the graph
   from 41.8 s to 28.9 s, cut main-thread time from 25.7 s to 20.0 s and made every
   edit repaint 20-27 % faster, with an identical number of requests.
   See docs/new_content/perf_graph_load_options.md, option C1. */
#new-content-shell .sp-tip::after {
  /* Above the preview shell that starts right below the bar (its stack reaches 240
     in zz_new_content.css); Mantine used a portal for the same reason. */
  z-index: 250;
}

/* The Save button keeps its own `::after` (save feedback) on the BUTTON; the tooltip
   lives on the wrapper, so the two never collide. While feedback is showing, the
   tooltip stays out of the way. */
#new-content-shell .sp-tip:has(.sp-preview-save-profile[data-save-feedback]:not([data-save-feedback=""]))::after {
  opacity: 0 !important;
}
