/* ============================================================================
   zz_studio_data_scope.css — the inspector's DATA card (UX coherence program,
   backlog row 4.3, decision D-62; 2026-09-15).

   Owner report: on a classic full-HD desktop the studio preview is too big —
   the play bar falls off the screen. Measured on 1920×1080 (tmp/ux_4_3/probe.py,
   `ux43_before`): `#preview-action-panel` was 120 px tall above the stage and the
   transport bar started at y = 1039 of a 1080 viewport. The SHOWING / Edit filter
   row is a CONTROL, not canvas chrome, so it moves where every other control
   already lives: the right panel.

   "Regroup, don't rename" (docs/new_content/high_risk_rules.md): `preview-data-toolbar`
   and the `filter-collapse` → `filter-step-wrapper` → `filter-card` chain move WHOLE
   out of `#preview-surface` into `_data_scope_card` (layout.py, the v6
   `_studio_group_card` grammar — the `_chart_choice_card` precedent from 1.3b).
   Every id, prop, writer and reader is the pre-move one; no new id, no callback,
   no store, no allow_duplicate. The card is `config-card`'s FIRST card, directly above
   the read-only CHART card, so the inspector reads DATA · CHART · TEXT · OUTPUT · LOOK ·
   FINE-TUNING. The base card chrome (`.sp-studio-card*`) comes from zz_studio_output.css,
   unchanged.

   What this file owns:
   * the DATA card's own layout — the SHOWING row stacks over its action cluster
     in a ~484 px panel instead of sitting in one wide grid row;
   * `#filter-card`: the inline `maxWidth` / `margin` the stage-width writer
     (callbacks/preview_shell.py `_sync_viewport_styles_values`) still writes for
     it is neutralised HERE rather than by editing that callback (no contract
     change) — hence the two `!important`, the only way CSS beats an inline style;
   * what is LEFT above the canvas: `#preview-action-panel` now holds the C-6b
     chart-type chip row alone. When that strip is not drawn — an explore-born
     post (zz_studio_chart_choice.css:82) or before the visual stage (the
     wrapper's callback-written `display: none`) — the panel would be an empty
     bordered band, so it is hidden at ≥641; when it IS drawn the strip loses the
     separator it carried for the SHOWING row below it.
   * ≤640: the card is hidden, exactly as the SHOWING row was there before the
     move (zz_new_content.css:5206 hid the whole `#preview-action-panel`,
     zz_studio_canvas_toolbar.css:324 kept the row hidden when the chip band
     re-showed the panel). Phones keep the canvas column they had.

   Cascade: "zz_studio_d" sorts after zz_new_content.css, zz_studio_canvas_toolbar.css
   ("…_ca") and zz_studio_chart_choice.css ("…_ch"), and before zz_studio_export_cta.css
   ("…_e") and the ≤640 mobile-shell band ("…_m") — every override below either carries more
   ids/classes than the rule it replaces or wins an equal-specificity tie on order.
   `!important` only against an inline style or an `!important` rule. Scope:
   `#new-content-shell`. Nothing in styles.css / zz_new_content.css is edited.
   ========================================================================== */

/* ---- the card in the panel ---------------------------------------------- */
#new-content-shell .sp-studio-card--data-scope {
  margin-bottom: 12px;
}

/* the SHOWING summary over its actions: two rows in a narrow panel, not the
   wide `minmax(0, 1fr) max-content` grid the canvas band used
   (zz_new_content.css:2982 — no !important on the template, this wins on
   2 ids + 2 classes) */
#new-content-shell .sp-studio-card--data-scope #preview-data-toolbar.sp-preview-action-grid {
  grid-template-columns: minmax(0, 1fr);
  row-gap: 10px !important;
}

#new-content-shell .sp-studio-card--data-scope #preview-data-toolbar.sp-preview-action-grid > .sp-preview-visible-data {
  width: 100% !important;
  min-width: 0 !important;
}

#new-content-shell .sp-studio-card--data-scope #preview-data-toolbar.sp-preview-action-grid > .sp-preview-secondary-actions {
  width: 100% !important;
  flex-wrap: wrap !important;
  justify-content: flex-start !important;
}

/* the chips row may run long (12 entities max): let it wrap inside the card
   instead of pushing the panel wider */
#new-content-shell .sp-studio-card--data-scope .sp-filter-chips-row {
  flex-wrap: wrap;
}

/* the "Filters" Collapse: the stage-width inline style written by
   `_sync_viewport_styles_values` (filter-card.style: maxWidth = the stage's
   build width, margin 0 auto) is canvas geometry — in the panel the card is
   simply full width. Inline styles can only be beaten with !important. */
#new-content-shell .sp-studio-card--data-scope #filter-card {
  max-width: none !important;
  margin: 0 !important;
}

#new-content-shell .sp-studio-card--data-scope #filter-collapse:not([style*="height: 0"]) {
  margin-top: 4px;
}

/* ---- what is left above the canvas (≥641) -------------------------------- */
@media (min-width: 641px) {
  /* an explore-born post hides the chip strip (zz_studio_chart_choice.css:82) and
     so does the pre-visual-stage gate — either way the panel is empty now */
  #new-content-shell:has(#studio-chart-choice.is-explore) #preview-action-panel,
  #new-content-shell #preview-action-panel:has(> .sp-studio-canvas-toolbar > #visual-type-step-wrapper[style*="display: none"]) {
    display: none;
  }

  /* the strip was separated from the SHOWING row below it; nothing follows it now */
  #new-content-shell #preview-action-panel > .sp-studio-canvas-toolbar {
    padding-bottom: 2px;
    margin-bottom: 0;
    border-bottom: 0;
  }
}

/* ---- ≤640: the card stays off the phone, as the SHOWING row was ---------- */
@media (max-width: 640px) {
  #new-content-shell .sp-studio-card--data-scope {
    display: none;
  }

  /* UX 4.4 (2026-09-15): the ≥641 collapse above, mirrored for the explore-born
     post on the phone. zz_new_content.css hides #preview-action-panel at ≤640 and
     zz_studio_canvas_toolbar.css re-shows it while the chip wrapper is not
     callback-hidden — which it is not here: the strip is hidden by the SHELL rule
     in zz_studio_chart_choice.css ("an empty block once the strip is hidden"). So
     the panel survives as a 0-height block that still spends one #preview-surface
     gap above the canvas. This file sorts after both; !important answers theirs.
     The pre-visual-stage gate needs no twin — there the wrapper IS inline-hidden,
     so the re-show never fires. The panel's own class is carried only to match that
     re-show's specificity (3 ids + 2 classes, the [style*=] in its :not counts) —
     measured without it the re-show still won and the empty panel kept its gap. */
  #new-content-shell:has(#studio-chart-choice.is-explore) #preview-action-panel.sp-preview-action-panel {
    display: none !important;
  }
}
