/* adventure-cost.css: the admin's full-screen Adventure cost view
   (adventure-cost.js), a layer opened through SVModal. Type, buttons, badges,
   cards and the table come from kit.css and the shared svx-stat / svx-table
   classes of admin.css; this file places them and draws the two marks the kit
   does not have, the split bar and the fit meter. Classes are svac-*. Sizes,
   radii, motion and layers use the kit tokens (tests/test_style_budget.py),
   and every surface, line and text colour is a token, so the screen follows
   both Reverie moods. */

.svac-shell {
  position: fixed; inset: 0; z-index: calc(var(--sv-z-screen) + var(--sv-layer, 0) * 2);
  box-sizing: border-box; isolation: isolate; color: var(--sv-text); font-family: var(--sv-font-body);
  -webkit-font-smoothing: antialiased; overscroll-behavior: contain;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--sv-bg) radial-gradient(ellipse 90% 70% at 50% -10%, var(--sv-violet-ground), var(--sv-bg) 70%) no-repeat;
  /* The four parts of a turn's cost, one fixed colour each: story, memory,
     art, other. Moonlight steps here, Morning haze steps below. Checked with
     the dataviz palette validator against each mood's ground, all pairs,
     because a part at zero draws nothing and any two can end up side by side.
     "Other" is a neutral on purpose. Text inside a part is white in both moods. */
  --svac-c-story: #9085e9; --svac-c-memory: #d95926; --svac-c-art: #199e70; --svac-c-other: #6b6a65;
  --svac-on-fill: #ffffff;
  /* Good, careful and bad as text: the status colour pulled toward the text
     colour, so it stays readable on a light ground and on a dark one. */
  --svac-good: color-mix(in srgb, var(--sv-success) 60%, var(--sv-text));
  --svac-warn: color-mix(in srgb, var(--sv-warning) 55%, var(--sv-text));
  --svac-bad: color-mix(in srgb, var(--sv-danger) 70%, var(--sv-text));
}
html[data-sv-theme=reverie] .svac-shell { --svac-c-story: #6250d6; --svac-c-memory: #eb6834; --svac-c-art: #1baf7a; }
.svac-shell.hidden { display: none; }
.svac-root { height: 100%; min-height: 0; display: flex; flex-direction: column; }

/* ---- the bar: the way out, the title, what the adventure runs on, the turns counted ---- */
.svac-top { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: var(--sv-space-2) var(--sv-space-3); min-width: 0;
  padding: var(--sv-space-3) var(--sv-space-5); border-bottom: 1px solid var(--sv-line); background: var(--sv-surface-overlay); }
.svac-back { flex: none; }
.svac-top__title { display: flex; flex-direction: column; min-width: 0; margin-right: var(--sv-space-2); }
.svac-title { white-space: nowrap; }
.svac-adv { max-width: 44ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svac-adv:empty { display: none; }
.svac-chips { display: flex; flex-wrap: wrap; gap: var(--sv-space-2); min-width: 0; }
.svac-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.svac-top__end { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sv-space-2); margin-left: auto; }
.svac-window { flex: none; }

/* ---- the body: one scrolling column of sections ---- */
.svac-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sv-space-5) var(--sv-space-5) var(--sv-space-7);
  transition: opacity var(--sv-t1) var(--sv-ease); }
.svac-body:focus-visible { outline: var(--sv-focus); outline-offset: -2px; }
.svac-body.is-loading { opacity: .55; pointer-events: none; }   /* a refetch keeps the last render */
.svac-inner { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--sv-space-6); }
.svac-section { display: flex; flex-direction: column; gap: var(--sv-space-3); min-width: 0; }
.svac-h, .svac-h4, .svac-sub, .svac-note, .svac-state, .svac-how, .svac-error { margin: 0; }
.svac-sub, .svac-note, .svac-how, .svac-state { max-width: 88ch; line-height: 1.5; }
.svac-state { padding: var(--sv-space-5) 0; }
.svac-notes { margin: 0; padding-left: 1.2em; max-width: 88ch; line-height: 1.5; display: flex; flex-direction: column; gap: var(--sv-space-1); }

/* ---- stat tiles (svx-stat from admin.css) ---- */
.svac-shell .svac-tiles { margin: 0; }
.svac-exact { color: var(--sv-text-muted); line-height: 1.35; }
.svac-tile--good .svx-stat__v { color: var(--svac-good); }
.svac-tile--warn .svx-stat__v { color: var(--svac-warn); }

/* ---- the split bar: one whole, each part as wide as its share ---- */
.svac-split { display: flex; gap: 2px; height: 28px; }
.svac-seg { flex-grow: var(--svac-g, 0); flex-shrink: 1; flex-basis: 0%; min-width: 3px; display: flex; align-items: center;
  border-radius: 2px; color: var(--svac-on-fill); font-size: var(--sv-fs-12); font-weight: 600; white-space: nowrap; }
.svac-seg > span { padding: 0 var(--sv-space-2); }
.svac-seg--story, .svac-key--story { background: var(--svac-c-story); }
.svac-seg--text, .svac-key--text { background: var(--svac-c-story); }   /* story and background calls, not split */
.svac-seg--memory, .svac-key--memory { background: var(--svac-c-memory); }
.svac-seg--art, .svac-key--art { background: var(--svac-c-art); }
.svac-seg--other, .svac-key--other { background: var(--svac-c-other); }
.svac-legend { display: flex; flex-wrap: wrap; gap: var(--sv-space-1) var(--sv-space-4); font-size: var(--sv-fs-12); color: var(--sv-text-muted); }
.svac-legend__it { display: inline-flex; align-items: center; }
.svac-key { display: inline-block; flex: none; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }

/* ---- tables (svx-table from admin.css) in a frame that scrolls sideways with a bar you can see ---- */
.svac-grid { overflow-x: auto; scrollbar-width: thin; border: 1px solid var(--sv-line); border-radius: var(--sv-r); background: var(--sv-surface-card); }
.svac-grid .svx-table { width: 100%; }
/* A long heading (the Portuguese ones) wraps onto a second line before the table grows past its frame. */
.svac-grid .svx-table th { white-space: normal; vertical-align: bottom; }
.svac-grid .svx-table th, .svac-grid .svx-table td { padding-left: var(--sv-space-3); padding-right: var(--sv-space-3); }
.svac-grid .svx-table td { max-width: 420px; }
.svac-grid .svx-table th.svx-num, .svac-grid .svx-table td.svx-num { text-align: right; font-variant-numeric: tabular-nums; }
.svac-grid .svx-table td.sv-data { font-size: var(--sv-fs-14); color: var(--sv-text-soft); }
.svac-grid .svx-table td .sv-hint, .svac-grid .svx-table td .sv-data { font-size: var(--sv-fs-12); }
.svac-tag { vertical-align: 1px; }

/* ---- one card per model ---- */
.svac-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: var(--sv-space-4); align-items: start; }
.svac-card { display: flex; flex-direction: column; gap: var(--sv-space-3); min-width: 0; }
.svac-card.is-now { border-color: var(--sv-rim); }
.svac-card__head { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sv-space-2); min-width: 0; }
.svac-card__name { overflow-wrap: anywhere; }
.svac-badges { display: flex; flex-wrap: wrap; gap: var(--sv-space-1); }
.svac-slug { color: var(--sv-text-dim); overflow-wrap: anywhere; }
.svac-host, .svac-alt { margin: 0; line-height: 1.45; overflow-wrap: anywhere; }
.svac-host { font-size: var(--sv-fs-14); color: var(--sv-text-soft); }
.svac-host--none { color: var(--svac-warn); }
.svac-role { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sv-space-2); min-width: 0;
  padding: var(--sv-space-3); border: 1px solid var(--sv-line-soft); border-radius: var(--sv-r); background: var(--sv-surface-field); }
.svac-fig { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--sv-space-1) var(--sv-space-2); }
.svac-fig__v { font-family: var(--sv-font-mono); font-size: var(--sv-fs-19); line-height: 1.15; color: var(--sv-text); }
.svac-fig__v--big { font-size: var(--sv-fs-24); }
.svac-cmp { align-self: center; display: inline-flex; align-items: center; min-height: 22px; padding: 0 var(--sv-space-2); white-space: nowrap;
  border: 1px solid var(--sv-line-2); border-radius: var(--sv-r-pill); font-size: var(--sv-fs-12); font-weight: 600; color: var(--sv-text-muted); }
.svac-cmp--good { color: var(--svac-good); border-color: color-mix(in srgb, var(--svac-good) 45%, transparent); }
.svac-cmp--warn { color: var(--svac-warn); border-color: color-mix(in srgb, var(--svac-warn) 45%, transparent); }
.svac-break { display: flex; flex-wrap: wrap; gap: var(--sv-space-2) var(--sv-space-4); margin: 0; }
.svac-break > div { display: flex; flex-direction: column; gap: 2px; }
.svac-break dd { margin: 0; font-size: var(--sv-fs-14); color: var(--sv-text-soft); }
.svac-pays { font-size: var(--sv-fs-14); line-height: 1.4; color: var(--sv-text-soft); }

/* ---- the fit meter: the average prompt against the model's context ---- */
.svac-fit { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sv-space-1); min-width: 0; }
.svac-meter { align-self: stretch; display: block; height: 8px; overflow: hidden; border-radius: var(--sv-r-pill);
  color: var(--sv-violet); background: color-mix(in srgb, currentColor 20%, transparent); }
.svac-meter > span { display: block; width: var(--svac-fill, 0%); min-width: 2px; max-width: 100%; height: 100%; border-radius: var(--sv-r-pill); background: currentColor; }
.svac-meter--tight { color: var(--sv-warning); }
.svac-meter--over { color: var(--sv-danger); }
.svac-fit__line { font-size: var(--sv-fs-14); color: var(--sv-text-soft); overflow-wrap: anywhere; }
.svac-fit__mark { font-size: var(--sv-fs-14); font-weight: 600; }
.svac-fit__mark--tight { color: var(--svac-warn); }
.svac-fit__mark--over { color: var(--svac-bad); }

/* ---- narrower screens: the bar wraps and everything stacks ---- */
@media (max-width: 900px) {
  .svac-top__end { margin-left: 0; }
}
@media (max-width: 720px) {
  .svac-top { padding: var(--sv-space-2) var(--sv-space-4); }
  .svac-top__title { flex: 1 1 0%; }
  .svac-chips, .svac-top__end { flex-basis: 100%; }
  .svac-body { padding: var(--sv-space-4) var(--sv-space-4) var(--sv-space-6); }
  .svac-inner { gap: var(--sv-space-5); }
  .svac-refresh { margin-left: auto; }
}
