/* premiere.css — THE PREMIERE MODAL (`sn-premiere`), one result + edit surface for every tool.
 *
 * Loaded LAST in studio-live.html, after studio-system.css, so this component never has to fight the
 * cascade with !important. It owns its own .snp-* namespace for the same reason.
 *
 * THE LAYOUT RULE, which is the whole fix for "stuff gets cut off":
 *   the MEDIA yields, the CHROME never does.
 * The first version had it backwards — the stage was `flex: 0 0 auto` with the media capped at 62vh, so
 * on a normal laptop (~800px tall ⇒ 88vh = 704px) the stage claimed ~500px and the title, the action bar
 * and the thumb strip were pushed past the bottom of a panel with `overflow: hidden`. Not scrolled —
 * clipped. Now the stage is `flex: 1 1 auto; min-height: 0` and shrinks to whatever is left; the head
 * (title + actions) is `flex: 0 0 auto` and is always on screen; only `.snp-scroll` scrolls.
 *
 * Everything is a --sn-* token. The only literal is #000 behind letterboxed FILM, which is film-frame
 * black and not a theme colour.
 */

/* The screen-reader announcer (A8): present, addressable, never visible. */
.sn-live {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.sn-premiere-scrim {
  position: fixed; inset: 0; z-index: 1400;
  background: var(--sn-scrim);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; transition: opacity var(--sn-t-micro) var(--sn-ease-out);
}
.sn-premiere-scrim.in { opacity: 1; }

.sn-premiere {
  position: fixed; z-index: 1401;
  top: 50%; left: 50%;
  width: min(1080px, 92vw);
  max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--sn-surface);
  border: 1px solid var(--sn-hairline-strong);
  border-radius: var(--sn-r-card);
  box-shadow: var(--sn-elev-3);
  overflow: hidden;
  opacity: 0; transform: translate(-50%, -50%) scale(.98);
  transition: opacity var(--sn-t-micro) var(--sn-ease-out), transform var(--sn-t-micro) var(--sn-ease-out);
}
.sn-premiere.in { opacity: 1; transform: translate(-50%, -50%) scale(1); }

body.has-premiere { overflow: hidden; }

/* ---- media stage: the part that YIELDS -----------------------------------------------------------
 * minmax(0, …) on BOTH axes. An implicit `auto` track sizes to the media's max-content — a 1280px clip
 * forced a 1280px track (pushing the close button off a mobile sheet) and its full height (clipping the
 * action bar on a short laptop).
 */
.snp-stage {
  position: relative;
  background: #000;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
  place-items: center;
  flex: 1 1 auto; min-height: 96px;
  overflow: hidden;
}
.snp-stage > video,
.snp-stage > img {
  display: block;
  max-width: 100%; max-height: 100%;
  width: auto; height: auto; object-fit: contain;
}
/* Film black is right behind FILM. Behind a still it reads as two broken bars; the theme's deepest
   ground (which is dark in BOTH themes — it is the documented "cinematic floor") reads as a mount. */
.snp-stage[data-kind="image"],
.snp-stage[data-kind="audio"] { background: var(--sn-bg-deep); }

.snp-3d { width: 100%; height: 100%; min-height: 240px; background: var(--sn-bg-deep); }
.snp-3d-load { display: grid; place-items: center; height: 100%; min-height: 240px; color: var(--sn-ink-3); font: var(--sn-ui) / 1.5 var(--sn-sans); padding: var(--sn-4); text-align: center; }

.snp-audio { width: 100%; padding: var(--sn-5); display: flex; flex-direction: column; align-items: center; gap: var(--sn-4); }
.snp-audio-art { width: 112px; height: 112px; border-radius: var(--sn-r-media); background: var(--sn-bg-raised); display: grid; place-items: center; overflow: hidden; }
.snp-audio-art img { width: 100%; height: 100%; object-fit: cover; }
.snp-audio-art .sn-ic { width: 36px; height: 36px; color: var(--sn-ink-3); }
.snp-audio audio { width: 100%; max-width: 520px; }

/* ---- the mask overlay: the money gate, drawn ------------------------------------------------------
 * A tinted region ON the deliverable, showing exactly which pixels are about to change, before anything
 * generation-priced runs. The mask is white-on-black, so it drives a CSS mask over a flat accent wash:
 * white shows the tint, black is fully transparent. `pointer-events: none` — it is a statement about the
 * media, not a control, and it must never swallow a click meant for the player.
 */
.snp-overlay {
  position: absolute; z-index: 1; pointer-events: none;
  background: var(--sn-accent);
  opacity: .42;
  -webkit-mask-image: var(--snp-mask); mask-image: var(--snp-mask);
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  animation: snp-mask-in var(--sn-t-micro) var(--sn-ease-out);
}
@keyframes snp-mask-in { from { opacity: 0; } to { opacity: .42; } }
@media (prefers-reduced-motion: reduce) { .snp-overlay { animation: none; } }

/* stage overlays */
.snp-nav, .snp-fs {
  position: absolute; z-index: 2;
  width: 36px; height: 36px; display: grid; place-items: center;
  border: none; border-radius: var(--sn-r-pill);
  background: var(--sn-glass-strong); color: var(--sn-on-media);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  cursor: pointer; opacity: 0;
  transition: opacity var(--sn-t-hover) var(--sn-ease), background var(--sn-t-hover) var(--sn-ease);
}
.snp-stage:hover .snp-nav, .snp-stage:hover .snp-fs,
.snp-nav:focus-visible, .snp-fs:focus-visible { opacity: 1; }
.snp-nav:hover, .snp-fs:hover { background: var(--sn-glass-solid); }
.snp-prev { left: var(--sn-3); top: 50%; transform: translateY(-50%); }
.snp-next { right: var(--sn-3); top: 50%; transform: translateY(-50%); }
.snp-fs { right: var(--sn-3); bottom: var(--sn-3); }
.snp-nav .sn-ic, .snp-fs .sn-ic { width: 18px; height: 18px; }

/* ---- the chrome: the part that NEVER yields ------------------------------------------------------ */
.snp-side {
  flex: 0 0 auto;
  display: flex; flex-direction: column;
  /* The chrome takes only what it needs. Capping it well under half the panel keeps the DELIVERABLE the
     biggest thing on screen — it is the hero — and the cap lifts only while the edit rail is open. */
  min-height: 0; max-height: 46vh;
  border-top: 1px solid var(--sn-hairline);
}
/* Title + actions are pinned. If anything has to scroll it is the block below them, never the CTA. */
.snp-head {
  flex: 0 0 auto;
  display: flex; flex-direction: column; gap: var(--sn-3);
  padding: var(--sn-4) var(--sn-4) var(--sn-3);
}
.snp-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: var(--sn-3);
  padding: 0 var(--sn-4) var(--sn-4);
}
.snp-scroll > * { flex: 0 0 auto; }
.snp-scroll:empty { display: none; }
/* The rail needs more room than the closed state — but not so much that the clip you are editing shrinks
   to a stamp. You have to be able to SEE the thing you are changing. */
.sn-premiere.rail-open .snp-side { max-height: 58vh; }

.snp-titlerow { display: flex; align-items: flex-start; gap: var(--sn-3); }
.snp-titlewrap { flex: 1 1 auto; min-width: 0; }
.snp-title {
  display: block; width: 100%;
  font: 600 var(--sn-h4) / 1.25 var(--sn-serif);
  color: var(--sn-ink);
  background: none; border: 1px solid transparent; border-radius: var(--sn-r-input);
  padding: var(--sn-1) var(--sn-2); margin: 0 0 0 calc(-1 * var(--sn-2));
  text-overflow: ellipsis;
  transition: background var(--sn-t-hover) var(--sn-ease), border-color var(--sn-t-hover) var(--sn-ease);
}
.snp-title:hover { border-color: var(--sn-hairline); }
.snp-title:focus { outline: none; background: var(--sn-bg-raised); border-color: var(--sn-accent); }
.snp-title.is-static { border-color: transparent; overflow: hidden; white-space: nowrap; }
.snp-x { flex: 0 0 auto; }

.snp-chips { display: flex; flex-wrap: wrap; gap: var(--sn-2); margin-top: var(--sn-1); }
.snp-chip {
  font: var(--sn-overline) / 1 var(--sn-mono);
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--sn-ink-2); background: var(--sn-bg-raised);
  border-radius: var(--sn-r-pill); padding: 5px var(--sn-2);
}
.snp-chip.is-quiet { background: none; color: var(--sn-ink-3); padding-left: 0; }

.snp-note { margin: 0; font: var(--sn-meta) / 1.5 var(--sn-sans); color: var(--sn-ink-2); }

.snp-acts { display: flex; align-items: center; gap: var(--sn-2); flex-wrap: wrap; }
.snp-grow { flex: 1; }
.snp-dlgroup { display: flex; gap: var(--sn-2); flex-wrap: wrap; }

.snp-count { font: var(--sn-overline) / 1 var(--sn-mono); color: var(--sn-ink-3); letter-spacing: .04em; }

/* ---- sibling strip ------------------------------------------------------------------------------ */
.snp-strip { display: flex; gap: var(--sn-2); overflow-x: auto; padding-bottom: var(--sn-1); }
.snp-thumb {
  flex: 0 0 auto; width: 108px;
  display: flex; flex-direction: column; gap: var(--sn-1);
  padding: 0; border: none; background: none; cursor: pointer; text-align: left; font: inherit;
}
.snp-thumb img, .snp-thumb-ph {
  display: block; width: 108px; height: 61px;
  object-fit: cover; border-radius: var(--sn-r-input);
  background: var(--sn-bg-raised);
  border: 2px solid transparent;
  transition: border-color var(--sn-t-hover) var(--sn-ease);
}
.snp-thumb-ph { display: grid; place-items: center; color: var(--sn-ink-3); font: var(--sn-meta) var(--sn-mono); }
.snp-thumb.is-on img, .snp-thumb.is-on .snp-thumb-ph { border-color: var(--sn-accent); }
.snp-thumb:hover img, .snp-thumb:hover .snp-thumb-ph { border-color: var(--sn-hairline-strong); }
.snp-thumb-l {
  font: var(--sn-overline) / 1.3 var(--sn-sans); color: var(--sn-ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.snp-thumb.is-on .snp-thumb-l { color: var(--sn-ink-2); }

/* ---- versions: free, non-destructive, and visibly so --------------------------------------------- */
.snp-versions { display: flex; align-items: center; gap: var(--sn-2); flex-wrap: wrap; }
.snp-vk { font: var(--sn-overline) / 1 var(--sn-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--sn-ink-3); }
.snp-vchip {
  appearance: none; cursor: pointer; font: var(--sn-meta) / 1 var(--sn-sans);
  padding: 6px var(--sn-3); border-radius: var(--sn-r-pill);
  border: 1px solid var(--sn-hairline); background: var(--sn-bg); color: var(--sn-ink-2);
  transition: border-color var(--sn-t-hover) var(--sn-ease), color var(--sn-t-hover) var(--sn-ease);
}
.snp-vchip:hover { border-color: var(--sn-hairline-strong); color: var(--sn-ink); }
.snp-vchip.is-on { border-color: var(--sn-accent); color: var(--sn-ink); }
.snp-compare {
  appearance: none; cursor: pointer; font: var(--sn-meta) / 1 var(--sn-sans);
  padding: 6px var(--sn-3); border-radius: var(--sn-r-pill);
  border: 1px dashed var(--sn-hairline-strong); background: none; color: var(--sn-ink-2);
}
.snp-compare.is-held { border-style: solid; border-color: var(--sn-accent); color: var(--sn-ink); }
.snp-vnote { font: var(--sn-overline) / 1.4 var(--sn-sans); color: var(--sn-ink-3); }

/* ---- the edit rail -------------------------------------------------------------------------------
 * `[hidden]` is only a UA rule (`display: none`), so ANY author `display` declaration silently beats it
 * — the rail rendered permanently open and the Edit button appeared to do nothing. Author-level [hidden]
 * rules, first, for every element here that sets its own display.
 */
.snp-rail[hidden], .snp-editor[hidden] { display: none; }
.snp-rail {
  border-top: 1px solid var(--sn-hairline);
  padding-top: var(--sn-3);
  display: flex; flex-direction: column; gap: var(--sn-3);
}
.snp-rail-lead { margin: 0; font: var(--sn-meta) / 1.5 var(--sn-sans); color: var(--sn-ink-2); }
.snp-rail-note { margin: 0; font: var(--sn-overline) / 1.5 var(--sn-sans); color: var(--sn-ink-3); }
.snp-routes { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sn-2); }
/* Every route is a SWITCH, and it reads as one at a glance: off by default, with the track visibly to
   the left. The point is that a customer can SEE that nothing is armed, rather than being told so. */
.snp-route {
  appearance: none; cursor: pointer; text-align: left; font: inherit;
  display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: var(--sn-3);
  padding: var(--sn-3);
  border: 1px solid var(--sn-hairline); border-radius: var(--sn-r-input);
  background: var(--sn-bg);
  transition: border-color var(--sn-t-hover) var(--sn-ease), background var(--sn-t-hover) var(--sn-ease);
}
.snp-route:hover { border-color: var(--sn-hairline-strong); background: var(--sn-bg-raised); }
.snp-route[aria-checked="true"] { border-color: var(--sn-accent); background: var(--sn-bg-raised); }
.snp-route-sw {
  width: 34px; height: 20px; flex: 0 0 auto; margin-top: 1px;
  border-radius: var(--sn-r-pill);
  background: var(--sn-hairline-strong);
  position: relative;
  transition: background var(--sn-t-hover) var(--sn-ease);
}
.snp-route-sw::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--sn-surface);
  transition: transform var(--sn-t-hover) var(--sn-ease-out);
}
.snp-route[aria-checked="true"] .snp-route-sw { background: var(--sn-accent); }
.snp-route[aria-checked="true"] .snp-route-sw::after { transform: translateX(14px); }
.snp-route-tx { display: grid; gap: 2px; min-width: 0; }
.snp-route-l { font: 600 var(--sn-ui) / 1.3 var(--sn-sans); color: var(--sn-ink); }
.snp-route-b { font: var(--sn-overline) / 1.4 var(--sn-sans); color: var(--sn-ink-3); }
.snp-route-p { font: var(--sn-overline) / 1 var(--sn-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--sn-ink-2); white-space: nowrap; }
.snp-route-p.is-free { color: var(--sn-success); }

/* The standing promise. Permanent, in the rail, in the customer's own words — not a tooltip they have
   to go looking for, and not a claim that only exists in a commit message. */
.snp-rail-guarantee {
  margin: 0; display: flex; align-items: flex-start; gap: var(--sn-2);
  font: var(--sn-meta) / 1.5 var(--sn-sans); color: var(--sn-ink-2);
}
.snp-rail-guarantee .sn-ic { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 2px; color: var(--sn-success); }

.snp-editor { display: flex; flex-direction: column; gap: var(--sn-2); }
.snp-editor.is-busy { opacity: .6; pointer-events: none; }
.snp-editor textarea, .snp-editor input[type="text"] {
  width: 100%; font: var(--sn-ui) / 1.5 var(--sn-sans); color: var(--sn-ink);
  background: var(--sn-bg); border: 1px solid var(--sn-hairline); border-radius: var(--sn-r-input);
  padding: var(--sn-2) var(--sn-3); resize: vertical;
}
.snp-editor textarea:focus, .snp-editor input[type="text"]:focus { outline: none; border-color: var(--sn-accent); }
.snp-editor label { display: grid; gap: var(--sn-1); font: var(--sn-meta) / 1.4 var(--sn-sans); color: var(--sn-ink-2); }
.snp-editor .snp-ed-row { display: flex; align-items: center; gap: var(--sn-2); flex-wrap: wrap; }
.snp-styles { display: flex; gap: var(--sn-2); flex-wrap: wrap; }
.snp-style {
  appearance: none; cursor: pointer; font: var(--sn-meta) / 1 var(--sn-sans);
  padding: 6px var(--sn-3); border-radius: var(--sn-r-pill);
  border: 1px solid var(--sn-hairline); background: var(--sn-bg); color: var(--sn-ink-2);
}
.snp-style.is-on { border-color: var(--sn-accent); color: var(--sn-ink); }
.snp-err { margin: 0; font: var(--sn-meta) / 1.5 var(--sn-sans); color: var(--sn-error); }

/* ---- details: a disclosure, not a destination ---------------------------------------------------- */
.snp-details { border-top: 1px solid var(--sn-hairline); padding-top: var(--sn-3); }
.snp-details > summary { cursor: pointer; font: 600 var(--sn-meta) / 1.4 var(--sn-sans); color: var(--sn-ink-2); }
.snp-details > summary:hover { color: var(--sn-ink); }
.snp-dl-rows { margin: var(--sn-3) 0 0; display: grid; gap: var(--sn-2); }
.snp-dl-rows > div { display: flex; gap: var(--sn-3); font: var(--sn-meta) / 1.4 var(--sn-sans); }
.snp-dl-rows dt { flex: 0 0 96px; color: var(--sn-ink-3); margin: 0; }
.snp-dl-rows dd { margin: 0; color: var(--sn-ink-2); min-width: 0; word-break: break-word; }

/* Portaled to <body> with position:fixed — inside the panel it was clipped by `overflow: hidden`. */
.snp-menu { position: fixed; z-index: 1402; min-width: 200px; }

/* ---- PORTRAIT: media left, chrome in a right column ---------------------------------------------- */
@media (min-width: 720px) {
  .sn-premiere.is-portrait { flex-direction: row; align-items: stretch; }
  .sn-premiere.is-portrait .snp-stage { flex: 1 1 auto; min-width: 0; }
  .sn-premiere.is-portrait .snp-side {
    flex: 0 0 380px; width: 380px; max-height: none;
    border-top: none; border-left: 1px solid var(--sn-hairline);
  }
  /* The title has a 380px column here; a long address must wrap rather than truncate mid-word. */
  .sn-premiere.is-portrait .snp-title { font-size: var(--sn-body-lg); }
}

/* ---- MOBILE: a full-screen sheet from the bottom -------------------------------------------------- */
@media (max-width: 719px) {
  .sn-premiere {
    top: auto; left: 0; bottom: 0;
    width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh;
    border-radius: 0; border: none;
    transform: translate(0, 100%);
    transition: transform var(--sn-t-panel) var(--sn-ease-out), opacity var(--sn-t-micro) var(--sn-ease-out);
  }
  .sn-premiere.in { transform: translate(0, 0); }
  .snp-side { max-height: 58vh; }
  /* No hover on a phone: paging and fullscreen are always visible. */
  .snp-nav, .snp-fs { opacity: 1; }
  .snp-routes { grid-template-columns: 1fr; }
}

/* On a SHORT viewport the media gives up more ground so the chrome keeps its room. */
@media (max-height: 720px) {
  .snp-side { max-height: 68vh; }
  .snp-audio-art { width: 72px; height: 72px; }
}

/* Reduced motion always designs the still state. */
@media (prefers-reduced-motion: reduce) {
  .sn-premiere, .sn-premiere-scrim { transition: none; }
  .sn-premiere { transform: translate(-50%, -50%) scale(1); }
  @media (max-width: 719px) { .sn-premiere { transform: none; } }
}
