﻿/* Cast art (cast_art.js): the visual-novel stage (the place and the character
   in the stage column left of the tale, the strip on narrow screens), the
   character view, the pictures on the story cards and the faces in the
   Ledger. Kit tokens only (tests/test_style_budget.py). */

/* The kit's buttons and rows set their own display, which beats [hidden]. */
.cast-sprite[hidden], .cast-strip[hidden], .cast-strip__sprite[hidden],
#set-cast[hidden], #cast-owner-note[hidden] { display: none !important; }

/* ---------- the backdrop: the place, faint behind the Tale's text ---------- */
/* Two layers so one place can fade into the next. Inside the Tale panel,
   under its header, story and composer (which sit above it), dimmed and
   darkened at the foot so the prose stays readable: it is a mood, not a
   picture to look at. Page-wide until 2026-10-23, then in the character
   column, then here at Lucas's request. */
#app-view.sv-adventure .tale-panel { overflow: hidden; }
#app-view.sv-adventure .tale-panel > .cast-backdrop { position: absolute; inset: 0; z-index: 0; overflow: hidden;
  pointer-events: none; border-radius: inherit; }
#app-view.sv-adventure .tale-panel > :not(.cast-backdrop) { position: relative; z-index: 1; }
/* Since 2026-10-24 the place is shown, not hinted at (Lucas: "the Tale should
   be the current place the player is at"): brighter, only lightly veiled, with
   a darker foot under the composer so the prose still reads. */
.cast-backdrop__layer { position: absolute; inset: 0; background-position: center; background-size: cover;
  opacity: 0; filter: saturate(.9) brightness(.8); transition: opacity var(--sv-t-slow) var(--sv-ease); }
.cast-backdrop__layer::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(var(--sv-ground-rgb), .18) 0%, rgba(var(--sv-ground-rgb), .32) 55%, rgba(var(--sv-ground-rgb), .72) 100%); }
.cast-backdrop__layer.is-on { opacity: .95; }
/* Text over a picture (Lucas, 2026-10-24): the header, the tools row and the
   input row are solid grey so the picture shows only behind the prose, the
   prose sits on a dark strip, and a shadow keeps it legible on bright patches.
   The input row (.cmdbar) was left see-through until 2026-10-29. */
#app-view.sv-adventure .tale-panel > .panel-h,
#app-view.sv-adventure .tale-panel > .sv-tale-tools,
#app-view.sv-adventure .tale-panel > .cmdbar {
  background: linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .06)), rgb(var(--sv-ground-rgb)); }
/* Everything below the tools row is one solid band: the tools row casts a
   solid shadow from its own top down past the foot of the panel (which clips
   it), under Lichy's Suggestion and the input row, which paint after it. It
   fills the suggestion card's gutters, its folded "Ideas" row and whatever
   shows through a translucent card. A shadow, not a pseudo-element, because
   the phone tools row scrolls sideways (mobile.css) and would clip one. */
#app-view.sv-adventure .tale-panel > .sv-tale-tools {
  box-shadow: 0 100vh 0 100vh color-mix(in srgb, rgb(var(--sv-ground-rgb)) 92%, white); }
#app-view.sv-adventure .tale-panel > .story-body { background: rgba(var(--sv-ground-rgb), .5); }
#app-view.sv-adventure .tale-panel #story-log { text-shadow: 0 1px 2px rgba(var(--sv-ground-rgb), 1), 0 0 10px rgba(var(--sv-ground-rgb), .95), 0 0 24px rgba(var(--sv-ground-rgb), .8); }

/* ---------- the character: the stage column, the story cards, the phone strip ---------- */
/* Without a stage (off, sealed, or no adventure) the column is hidden and
   the Tale takes its width, as it has since 2026-10-23. */
#app-view.sv-adventure .mid { grid-template-columns: minmax(0, 1fr) clamp(270px, 22.2vw, 320px); }
#app-view.sv-adventure .chron-col { display: none; }
/* With the stage on (cast_art.js `has-stage`, every adventure since
   2026-10-24) the column is there: three columns, the character the moment
   is about standing left of the tale, and the column kept, empty, when
   nobody important is there. */
#app-view.sv-adventure.has-stage .mid { grid-template-columns: clamp(240px, 23vw, 400px) minmax(0, 1fr) clamp(270px, 22.2vw, 320px); }
#app-view.sv-adventure.has-stage .chron-col { display: block; position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#app-view.sv-adventure.has-stage .chron-col > :not(.cast-sprite):not(.cast-hide) { display: none; }
/* Hidden at will (cast_art.js `stage-hidden`, Lucas, 2026-10-29): the column
   folds to a rail that keeps only the button, and the Tale takes the width. */
#app-view.sv-adventure.has-stage .cast-hide { position: absolute; top: var(--sv-space-2); left: var(--sv-space-2); z-index: 3; }
#app-view.sv-adventure.has-stage.stage-hidden .mid { grid-template-columns: 44px minmax(0, 1fr) clamp(270px, 22.2vw, 320px); }
#app-view.sv-adventure.has-stage.stage-hidden .cast-sprite { display: none; }
/* The character is shown large, from the chest up, like a visual novel's
   close framing (Lucas, 2026-10-24): the sprite is scaled past the column's
   width, anchored at the top under the name, and the column clips the rest.
   The mask still fades the foot. */
/* Sized by the column's HEIGHT, so she is the same size relative to the
   screen everywhere (a width-based size left her tiny on tall screens): the
   picture is as tall as the column and a bit more, centred, the column clips
   the sides and the mask fades the foot. Her own charcoal ground shows as a
   rectangle on the black column: wanted (Lucas, 2026-10-24). */
#app-view.sv-adventure.has-stage .chron-col { background: rgb(var(--sv-ground-rgb)); }
#app-view.sv-adventure.has-stage .cast-sprite { align-items: flex-start; inset: var(--sv-space-7) 0 0; overflow: hidden; }
#app-view.sv-adventure.has-stage .cast-sprite__img,
#app-view.sv-adventure.has-stage .cast-sprite__video { width: auto; height: 118%; max-width: none; max-height: none; flex: none; object-fit: contain; object-position: top;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 62%, transparent 86%);
  mask-image: linear-gradient(180deg, #000 0%, #000 62%, transparent 86%); }
/* The mood's idle clip (cast_art.js setClip): two layers over the still,
   same geometry, one fading in as the other fades out. The still stays
   underneath as the poster and shows again when a mood has no clip. */
.cast-sprite__video { position: absolute; top: 0; left: 50%; transform: translateX(-50%); opacity: 0; pointer-events: none;
  transition: opacity var(--sv-t3) var(--sv-ease); }
.cast-sprite__video.is-on { opacity: 1; }
.cast-sprite:not(.has-clip) .cast-sprite__video { display: none; }
/* The loops are transparent (2026-10-29), so the still under them would show
   through as a second Mavi (Lucas, 2026-10-30: "multiple side animations
   playing on top of each other"): while a clip plays, the still is hidden,
   and it comes back the moment no clip is on. */
.cast-sprite.has-clip .cast-sprite__img, .cast-sprite.is-in.has-clip .cast-sprite__img { opacity: 0; }
@media (max-width: 960px) {
  /* The strip above the story carries her on narrow screens. One column in
     every state: without a stage (off, sealed) or with it hidden, the desktop
     columns above squeezed the Tale to ~120 px on a phone (2026-10-29). */
  #app-view.sv-adventure .mid, #app-view.sv-adventure.has-stage .mid,
  #app-view.sv-adventure.has-stage.stage-hidden .mid { grid-template-columns: minmax(0, 1fr); }
  #app-view.sv-adventure.has-stage .chron-col { display: none; }
}
#app-view.sv-adventure .cast-sprite { position: absolute; inset: var(--sv-space-6) 0 0; z-index: 1; margin: 0;
  display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
/* The sprite is drawn on a plain dark ground; the mask fades its edges and
   foot into the backdrop instead of showing a rectangle. */
.cast-sprite__img { display: block; width: 112%; max-width: 400px; max-height: 100%; object-fit: contain; object-position: bottom;
  opacity: 0; transform: translateY(10px); transition: opacity var(--sv-t3) var(--sv-ease), transform var(--sv-t3) var(--sv-ease);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 8%, #000 62%, transparent 92%),
                      linear-gradient(90deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(180deg, transparent 0%, #000 8%, #000 62%, transparent 92%),
              linear-gradient(90deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
  mask-composite: intersect; }
.cast-sprite.is-in .cast-sprite__img { opacity: 1; transform: none; }
/* The character opens the character view. Only the image takes the pointer;
   the rest of the column lets it through. The mask would clip a focus ring on
   the image, so focus shows on the name. */
.cast-sprite__img { pointer-events: auto; cursor: zoom-in; }
.cast-sprite__img:focus-visible { outline: none; }
.cast-sprite__img:focus-visible + .cast-sprite__name { outline: var(--sv-focus); outline-offset: 4px; }
/* Focusing the image would scroll a hidden-overflow box to show the foot the
   mask fades out; clip cannot scroll. The strip below clips for that reason. */
#app-view.sv-adventure .cast-sprite__name { position: absolute; top: 0; left: var(--sv-space-5); right: var(--sv-space-5); text-align: center;
  font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-17); letter-spacing: var(--sv-ls-label);
  color: var(--sv-violet-bright); text-wrap: balance; }
/* What a picture cost at the provider, top right of it: the stage character
   and the story cards (Lucas, 2026-10-23). Same pill as the story plates. */
.cast-sprite__cost, .scard-cost { position: absolute; z-index: 2; padding: 2px var(--sv-space-2);
  border: 1px solid var(--sv-line); border-radius: var(--sv-r); background: rgba(var(--sv-ground-rgb), .72);
  color: var(--sv-text); font-size: var(--sv-fs-11); line-height: 1.4; pointer-events: none; }
#app-view.sv-adventure .cast-sprite__cost { top: var(--sv-space-2); right: var(--sv-space-3); }
.cast-sprite__cost[hidden] { display: none; }
.scard-cost { top: var(--sv-space-3); right: var(--sv-space-3); }

/* The sound of the place (cast_art.js buildSound): a speaker in the Tale's
   tools row, lit while the ambience and music play. */
.cast-sound-wrap { display: inline-flex; align-items: center; gap: var(--sv-space-1); }
.cast-sound-wrap[hidden] { display: none; }
.cast-sound.is-on { color: var(--sv-violet-bright); }
.cast-sound__vol { width: 72px; margin: 0; }

/* ---------- the death screen (app.js showDeathScreen) ---------- */
/* A scenario pack's run that the game ended: the ending's name, the run's
   numbers in the middle, two ways out. Kept here with the pack's other
   visual-novel pieces. */
.death-screen { max-width: 440px; text-align: center; }
.death-screen .sv-modal__title { color: var(--sv-danger, var(--sv-text)); letter-spacing: var(--sv-ls-label); }
.death-screen__reason { margin: 0 0 var(--sv-space-4); font-family: var(--sv-font-display); font-size: var(--sv-fs-17); text-wrap: balance; }
.death-screen__stats { display: grid; gap: var(--sv-space-2); margin: 0 auto var(--sv-space-4); max-width: 300px; }
.death-screen__row { display: flex; justify-content: space-between; gap: var(--sv-space-4); padding: var(--sv-space-1) 0; border-bottom: 1px solid var(--sv-line); }
.death-screen__row dt { color: var(--sv-text-muted, var(--sv-text)); }
.death-screen__row dd { margin: 0; }
.death-screen__hint { margin: 0; }
.death-screen__foot { display: flex; justify-content: center; gap: var(--sv-space-3); flex-wrap: wrap; }

/* ---------- narrow screens: a strip above the story ---------- */
.cast-strip { display: none; }
@media (max-width: 960px) {
  #app-view.sv-adventure .cast-strip { display: block; position: relative; flex: 0 0 auto; height: clamp(150px, 28vh, 240px);
    overflow: hidden; overflow: clip; border-bottom: 1px solid var(--sv-line); transition: height var(--sv-t3) var(--sv-ease); }
  #app-view.sv-adventure .cast-strip.is-slim { height: 44px; }
  .cast-strip__bg { position: absolute; inset: 0; background-position: center; background-size: cover; filter: brightness(.72); }
  .cast-strip__bg::after { content: ""; position: absolute; inset: 0;
    background: linear-gradient(180deg, transparent 45%, rgba(var(--sv-ground-rgb), .85) 100%); }
  /* Head and shoulders: the sprite is taller than the strip and cropped at its foot. */
  .cast-strip__sprite { position: absolute; right: var(--sv-space-5); top: var(--sv-space-2); height: 190%; width: auto; max-width: 55%;
    object-fit: contain; object-position: top;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 18%, #000 82%, transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0%, #000 18%, #000 82%, transparent 100%); cursor: zoom-in; }
  .cast-strip__sprite:focus-visible { outline: none; }
  .cast-strip__sprite:focus-visible ~ .cast-strip__name { outline: var(--sv-focus); outline-offset: 2px; }
  .cast-strip__name { position: absolute; left: var(--sv-space-4); bottom: var(--sv-space-3); max-width: 55%; color: var(--sv-text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cast-strip__fold { position: absolute; left: var(--sv-space-2); top: var(--sv-space-2); }
  .cast-strip__fold .sv-icon { transition: transform var(--sv-t2) var(--sv-ease); }
  .cast-strip.is-slim .cast-strip__fold .sv-icon { transform: rotate(180deg); }
  .cast-strip.is-slim .cast-strip__sprite { display: none; }
  .cast-strip.is-slim .cast-strip__name { bottom: auto; top: 50%; left: calc(var(--sv-space-2) + 40px); transform: translateY(-50%); }
}

/* ---------- story cards ---------- */
/* A card with art shows it full bleed, its name over a fade at the foot. */
.scard.has-art .scard-front { overflow: hidden; justify-content: flex-end; }
.scard-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scard[data-aspect="person"] .scard-art, .scard[data-aspect="player"] .scard-art { object-position: center 12%; }
.scard.has-art .scard-front::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(var(--sv-ground-rgb), .6) 0%, transparent 24%, transparent 45%, rgba(var(--sv-ground-rgb), .9) 100%); }
.scard.has-art .scard-front .scard-aspect { position: absolute; top: var(--sv-space-3); left: var(--sv-space-3); z-index: 1; }
.scard.has-art .scard-front .scard-glyph { display: none; }
.scard.has-art .scard-front .scard-name { position: relative; z-index: 1; }
/* A turned card's front stays out of the way of the back's buttons: Chromium
   still hit-tests the raised name above. */
.scard.flipped .scard-front { pointer-events: none; }
.scard-draw { margin-top: auto; align-self: stretch; }
.card-tile.has-art { position: relative; padding-left: calc(64px + var(--sv-space-4) * 2) !important; min-height: 88px; }
.card-tile__art { position: absolute; left: var(--sv-space-3); top: var(--sv-space-3); width: 64px; height: 64px; object-fit: cover;
  object-position: center 12%; border: 1px solid var(--sv-line); }

/* ---------- the character view (cast_art.js openView) ---------- */
.cast-view { width: min(520px, 100%); }
.cast-view [hidden] { display: none !important; }
/* The whole sprite, letterboxed on the panel; a thumbnail per drawn expression
   below. On a short screen it gives up height so the thumbnails and the close
   button still fit without scrolling. */
.cast-view__img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; max-height: min(62vh, calc(100vh - 312px)); object-fit: contain;
  border-radius: var(--sv-r-card); background: var(--sv-panel-soft); }
/* Each thumbnail is as wide as its label ("Com medo" is longer than "Calm"),
   so the frame goes on the face, where the widths match. */
.cast-view__moods { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sv-space-3); margin-top: var(--sv-space-3); }
.cast-view__mood { flex: none; min-width: 64px; display: flex; flex-direction: column; align-items: center; gap: var(--sv-space-1);
  padding: 0; border: 0; border-radius: var(--sv-r); background: none; cursor: pointer; }
.cast-view__mood img { display: block; width: 64px; height: 64px; object-fit: cover; object-position: center 12%;
  border: 1px solid var(--sv-line); border-radius: var(--sv-r); transition: border-color var(--sv-t1) var(--sv-ease); }
.cast-view__mood .sv-label { white-space: nowrap; }
.cast-view__mood:hover img { border-color: var(--sv-line-hover); }
.cast-view__mood[aria-pressed="true"] img { border-color: var(--sv-rim); outline: 1px solid var(--sv-rim); outline-offset: 1px; }
.cast-view__mood[aria-pressed="true"] .sv-label { color: var(--sv-text); }
.cast-view__mood:focus-visible { outline: var(--sv-focus); outline-offset: 3px; }

/* ---------- the story card dialog (cast_art.js openCard) ---------- */
.cast-card { width: min(560px, 100%); }
.cast-card [hidden] { display: none !important; }
.cast-card__art { position: relative; }
.cast-card__img { display: block; width: 100%; height: auto; max-height: min(48vh, calc(100vh - 380px)); object-fit: contain;
  border-radius: var(--sv-r-card); background: var(--sv-panel-soft); }
.cast-card__cost { position: absolute; top: var(--sv-space-2); right: var(--sv-space-2); padding: 2px var(--sv-space-2);
  border: 1px solid var(--sv-line); border-radius: var(--sv-r); background: rgba(var(--sv-ground-rgb), .72);
  color: var(--sv-text); font-size: var(--sv-fs-11); line-height: 1.4; pointer-events: none; }
.cast-card__noart { margin: 0; padding: var(--sv-space-5); text-align: center; border: 1px dashed var(--sv-line); border-radius: var(--sv-r-card); }
.cast-card__actions { display: flex; flex-wrap: wrap; gap: var(--sv-space-2); margin-top: var(--sv-space-3); }
.cast-card__edit { display: grid; gap: var(--sv-space-2); margin-top: var(--sv-space-3); }
.cast-card__editbox { width: 100%; resize: vertical; }
.cast-card__text { margin: var(--sv-space-3) 0 0; white-space: pre-wrap; color: var(--sv-text-soft); max-height: 30vh; overflow: auto; }
.cast-card__err:empty { display: none; }
.cast-card__err { color: var(--sv-danger, var(--sv-text)); }
/* A character's moods on the card: a row per mood with its still, whether a
   clip is there, and import/export for both. */
.cast-card__moods { display: grid; gap: var(--sv-space-2); margin-top: var(--sv-space-4); padding-top: var(--sv-space-3); border-top: 1px solid var(--sv-line); }
.cast-card__moods-title { margin: 0 0 var(--sv-space-1); }
.cast-card__mood { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; gap: var(--sv-space-1) var(--sv-space-3); align-items: center; }
.cast-card__mood-thumb { grid-row: 1 / span 2; width: 40px; height: 40px; border: 1px solid var(--sv-line); border-radius: var(--sv-r); overflow: hidden; background: rgba(var(--sv-ground-rgb), .6); }
.cast-card__mood-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 12%; }
.cast-card__mood-name { grid-column: 2; }
.cast-card__mood-acts { grid-column: 2; display: flex; flex-wrap: wrap; gap: var(--sv-space-1); }

/* ---------- faces in the Ledger (app.js ledAvatar) ---------- */
/* A sprite or portrait in the avatar box, cropped to the face; the initial
   stays for everyone without one. */
#app-view.sv-adventure .led-avatar { width: 28px; height: 28px; flex: none; display: grid; place-items: center; box-sizing: border-box;
  border: 1px solid var(--sv-rim); border-radius: var(--sv-r); background: var(--sv-surface-primary); color: var(--sv-on-primary);
  font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-14); line-height: 1; }
#app-view.sv-adventure .sva-hero__avatar.has-face, #app-view.sv-adventure .led-avatar.has-face { overflow: hidden; background: var(--sv-panel-soft); }
.led-face { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 12%; }
