/* Explore ranking inside the shared editor shell (plan 2.1, 2026-10-28).
 * The host carries `data-kind` (the compare kind); while it is "ranking" the line
 * stage gives way to the ranking card, which assets/ranking_stage.js pins to the stage
 * wrap's box. Nothing here changes the card's own geometry. */

/* The chart stage, its overlays and the playback bar belong to the line document. */
#editor-workspace-root[data-kind="ranking"] #editor-retail-graph-stage,
#editor-workspace-root[data-kind="ranking"] #editor-canvas-column .sp-transport-bar { display: none; }
#editor-workspace-root[data-kind="ranking"] .sp-preview-stage-wrap { height: var(--rs-stage-h, 0px); min-height: 0; }

/* Bar: Title, Subtitle, Chart and Data. Canvas, Time label, Annotations and More have no
   ranking meaning; Background returns with the ranking theme panel (plan 2.3). */
#editor-workspace-root[data-kind="ranking"] .sp-editor-category:is([data-group="canvas"], [data-group="time-label"],
  [data-group="annotations"], [data-group="more"]) { display: none; }
/* Chart offers only its Type (the way back to a line chart). */
#editor-workspace-root[data-kind="ranking"] #editor-panel-chart .sp-editor-subtab:not([data-subtab="type"]) { display: none; }

/* The card lives under the host: the host passes pointer events through to it except on the
   editor's own chrome. */
#editor-workspace-root[data-kind="ranking"][data-mode="design"].is-placed { background: transparent; pointer-events: none; }
#editor-workspace-root[data-kind="ranking"] :is(#editor-tools, .sp-editor-sheet-head, dialog) { pointer-events: auto; }

body:where([data-sp-has~="editor-ranking-design-placed"]):not(#sp-s):not(.sp-s):not(.sp-s):not(.sp-s):not(.sp-s) #cmp-visual {
  position: fixed; z-index: 4; left: var(--rs-left, 0); top: var(--rs-top, 0); width: var(--rs-width, 0);
  min-height: 0; padding: 0; margin: 0; display: block;
}
body:where([data-sp-has~="editor-ranking-design-placed"]):not(#sp-s):not(.sp-s):not(.sp-s):not(.sp-s):not(.sp-s) #cmp-visual .cmp-ranking[data-ranking-post] {
  width: 100%; max-width: none;
}
/* The Design accordion, publish controls and CTA of the browse page give way to the shell
   (the header keeps its kind chips, format and actions exactly as for a line chart). */
body:where([data-sp-has~="editor-ranking-design-placed"]):not(#sp-s):not(.sp-s):not(.sp-s):not(.sp-s):not(.sp-s)
  #compare-shell.sp-data-shell :is(.cmp-visual-actions, .cmp-cta-wrap, #cmp-legend) { display: none; }

/* Explore browse of a ranking is the bare list page: the host is rendered but shows nothing, so the
   header Export can open its modal dialog (top layer, unaffected by the ancestor's size or clipping). */
#editor-workspace-root[data-kind="ranking"]:not([data-mode="design"]) {
  position: fixed; left: 0; top: 0; width: 0; height: 0; overflow: hidden; visibility: hidden; pointer-events: none;
}
#editor-workspace-root[data-kind="ranking"]:not([data-mode="design"]) dialog { visibility: visible; pointer-events: auto; }
/* TEMPORARY (removed with private Save for rankings, plan step 4): saving would store a line document
   without the ranking, so the header Save stays hidden until a ranking project can be reopened. */
body:where([data-sp-has~="explore-ranking-preview-list"]):not(#sp-s):not(.sp-s):not(.sp-s) #compare-shell #cmp-workspace-save { display: none !important; }

/* Title and Subtitle (plan 2.2): the ranking card's text field replaces the line section's
   controls. Both are mounted; only Text exists for a ranking (no style, color or position). */
.sp-editor-line-only { display: contents; }
.sp-editor-ranking-only { display: none; }
#editor-workspace-root[data-kind="ranking"] .sp-editor-line-only { display: none; }
#editor-workspace-root[data-kind="ranking"] .sp-editor-ranking-only { display: flex; flex-direction: column; gap: 6px; }
#editor-workspace-root[data-kind="ranking"] :is(#editor-panel-title, #editor-panel-subtitle) .sp-editor-subtab:not([data-subtab="text"]) { display: none; }
.sp-editor-ranking-reset {
  align-self: flex-start; min-height: 44px; padding: 0 4px; border: 0; background: none; cursor: pointer;
  font: 500 13px/1 var(--sp-font-ui); color: var(--sp-text-2);
}
.sp-editor-ranking-reset:hover { color: var(--sp-text); }
/* No history for a ranking in delivery 1 (plan 4.3 decides it later). */
#editor-workspace-root[data-kind="ranking"] :is(#editor-undo, #editor-redo) { display: none; }
/* The keyboard composer shows only the subtab row and the focused field (102 px). */
#editor-workspace-root[data-keyboard="true"] .sp-editor-ranking-reset { display: none; }

/* Ranking look controls (plan 2.3): theme thumbnails, portraits switch and title layouts. The card's
   attributes are the state; assets/editor_ranking_text.js mirrors them into `aria-pressed`. */
.sp-editor-ranking-look { flex-direction: column; gap: 8px; }
/* F-14: `display: flex` only while the host shows a ranking. As a bare class rule it outranked
   `.sp-editor-ranking-only { display: none }` and leaked the Theme / Portraits block into Line and Bar. */
#editor-workspace-root[data-kind="ranking"] .sp-editor-ranking-look { display: flex; }
.sp-editor-ranking-segment { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--sp-border); border-radius: 10px; background: var(--sp-surface); }
.sp-editor-workspace button.sp-editor-ranking-choice {
  flex: 1 1 0; min-width: 0; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 4px 6px; border: 0; border-radius: 8px; background: transparent; color: var(--sp-text-2); font: 500 12px/1.2 var(--sp-font-ui);
}
.sp-editor-workspace button.sp-editor-ranking-choice[aria-pressed="true"] { background: var(--sp-chrome); color: var(--sp-text); box-shadow: inset 0 0 0 1px var(--sp-accent); }
.sp-ranking-layout-glyph { display: block; width: 26px; height: 14px; background: linear-gradient(currentColor, currentColor) 0 0 / 100% 3px no-repeat, linear-gradient(currentColor, currentColor) 0 8px / 60% 2px no-repeat; opacity: .8; }
.sp-ranking-layout-glyph[data-layout="centered"] { background-position: 50% 0, 50% 8px; }
.sp-ranking-layout-glyph[data-layout="compact"] { background-size: 70% 2px, 45% 2px; background-position: 0 2px, 0 8px; }
.sp-ranking-themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sp-editor-workspace button.sp-ranking-theme {
  display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 1px solid var(--sp-border); border-radius: 10px;
  background: var(--sp-surface); color: var(--sp-text-2); font: 500 12px/1.2 var(--sp-font-ui); text-align: left;
}
.sp-editor-workspace button.sp-ranking-theme[aria-pressed="true"] { border-color: var(--sp-accent); color: var(--sp-text); box-shadow: 0 0 0 1px var(--sp-accent); }
.sp-ranking-theme-sheet { display: flex; flex-direction: column; gap: 5px; height: 58px; padding: 8px; border-radius: 6px; background: var(--ranking-bg); }
.sp-ranking-theme-title { display: block; width: 54%; height: 5px; margin-bottom: 3px; border-radius: 2px; background: var(--ranking-text); }
.sp-ranking-theme-bar { display: block; width: var(--bar); height: 4px; border-radius: 2px; background: var(--ranking-fill); }
.sp-ranking-theme-bar:first-of-type { background: var(--ranking-leader); }
.sp-ranking-theme-label { padding: 0 2px; }
/* A tap on the card's title or subtitle opens that category: show which one is selected. The
   selector stays under #cmp-visual so the PNG export's clone never carries it. */
body:where([data-sp-has~="editor-ranking-design-title"]):not(#sp-s):not(.sp-s):not(.sp-s):not(.sp-s):not(.sp-s) #cmp-visual .cmp-ranking-title > span,
body:where([data-sp-has~="editor-ranking-design-subtitle"]):not(#sp-s):not(.sp-s):not(.sp-s):not(.sp-s):not(.sp-s) #cmp-visual .cmp-ranking-context {
  outline: 2px solid var(--sp-accent); outline-offset: 3px; border-radius: 2px;
}
body:where([data-sp-has~="editor-ranking-design"]):not(#sp-s):not(.sp-s):not(.sp-s):not(.sp-s) #cmp-visual :is(.cmp-ranking-title, .cmp-ranking-context) { cursor: pointer; }
#editor-workspace-root[data-keyboard="true"] .sp-editor-ranking-look { display: none; }
/* Export dialog (plan 3.1): a ranking exports a PNG and publishes, so its block replaces the video form. */
.sp-export-ranking { display: none; }
#editor-workspace-root[data-kind="ranking"] #editor-export-content { display: none; }
#editor-workspace-root[data-kind="ranking"] .sp-export-ranking { display: flex; flex-direction: column; gap: 14px; }
#editor-export .sp-export-ranking .sp-editor-ranking-segment { margin-top: -6px; }
#editor-export .sp-export-ranking .sp-export-submit { width: 100%; }
#editor-export .sp-export-ranking .sp-export-submit.sp-export-secondary {
  background: transparent; color: var(--sp-text-primary); border: 1px solid var(--sp-border-soft);
}
#editor-export .sp-export-ranking .sp-export-submit.sp-export-secondary:hover { background: var(--sp-surface-soft); }
#editor-export .sp-export-ranking .sp-export-submit:disabled { opacity: .5; cursor: wait; }
#editor-ranking-export-result { color: var(--sp-text-muted); font-size: 14px; line-height: 1.5; }
#editor-ranking-export-result:empty { display: none; }
#editor-ranking-export-result a { color: var(--sp-accent); }
/* Phone browse restyles the same dialog (zzzzzzzzzz_explore_export.css, body.sp-explore-final) with rules
   that outrank the ones above: restate the hidden video form, the secondary button and the result there. */
@media (max-width: 599px), (max-width: 767px) and (max-aspect-ratio: 10/13) {
  body.sp-explore-final:where([data-sp-has~="app"]):not(#sp-s) #editor-workspace-root[data-kind="ranking"] #editor-export #editor-export-content { display: none; }
  body.sp-explore-final:where([data-sp-has~="app"]):not(#sp-s) #editor-export .sp-export-ranking { display: block; }
  body.sp-explore-final:where([data-sp-has~="app"]):not(#sp-s) #editor-export .sp-export-ranking .sp-export-submit.sp-export-secondary {
    margin-top: 8px; background: transparent; color: #f2efe9; border: 1px solid #3a3c45 !important;
  }
  body.sp-explore-final:where([data-sp-has~="app"]):not(#sp-s) #editor-export #editor-ranking-export-result { margin-top: 12px; color: #b8b4ac; font: 400 13px/1.4 var(--sp-font-ui); }
  body.sp-explore-final:where([data-sp-has~="app"]):not(#sp-s) #editor-export #editor-ranking-export-result a { color: var(--sp-accent); }
}
/* Muted studio colours every row by identity instead of one fill (the first three of its row palette). */
.sp-ranking-theme[data-ranking-theme="muted-studio"] .sp-ranking-theme-bar:nth-of-type(1) { background: #92b09e; }
.sp-ranking-theme[data-ranking-theme="muted-studio"] .sp-ranking-theme-bar:nth-of-type(2) { background: #c4b877; }
.sp-ranking-theme[data-ranking-theme="muted-studio"] .sp-ranking-theme-bar:nth-of-type(3) { background: #8f9fbc; }
/* Broadcast (looks pilot) gives every row its own team or player colour; the thumbnail shows three samples. */
.sp-ranking-theme[data-ranking-theme="broadcast"] .sp-ranking-theme-bar:nth-of-type(1) { background: #8d5fd3; }
.sp-ranking-theme[data-ranking-theme="broadcast"] .sp-ranking-theme-bar:nth-of-type(2) { background: #2e9e57; }
.sp-ranking-theme[data-ranking-theme="broadcast"] .sp-ranking-theme-bar:nth-of-type(3) { background: #22b5a6; }
/* Home looks: square bars as on the card; Home bold a thicker bar, Home soft a soft fill. */
.sp-ranking-theme[data-ranking-theme^="home"] .sp-ranking-theme-sheet { border-radius: 2px; }
.sp-ranking-theme[data-ranking-theme^="home"] :is(.sp-ranking-theme-title, .sp-ranking-theme-bar) { border-radius: 0; }
.sp-ranking-theme[data-ranking-theme="home-bold"] .sp-ranking-theme-bar { height: 6px; }
.sp-ranking-theme[data-ranking-theme="home-soft"] .sp-ranking-theme-bar { height: 7px; background: color-mix(in srgb, #F1EEE7 18%, transparent); }

/* Explore browse on a phone: the bare list is the fixed 4:5 sheet scaled uniformly to the room above the
   control dock (assets/ranking_stage.js measures it); never cropped under the dock. */
@media (max-width: 599px), (max-width: 767px) and (max-aspect-ratio: 10/13) {
  body.sp-explore-final #compare-shell.sp-data-shell #cmp-visual .cmp-ranking[data-ranking-post] { width: min(100%, var(--rs-browse-width, 100%)); }
}
