/* ===========================================================================
   BIRODALMAK — FORGATÓKÖNYVEK ÉS KAMPÁNY   (css/scenario.css)
   TULAJDONOS: „Forgatókönyvek és kampány" agent.

   Két hatókör:
     1. `#modalCard[data-screen="scenarios|objectives|scenarioResult"]`
        — a három modális képernyő (a screens.css közös vázára épül).
     2. `#scenPanel` — a lebegő CÉLKITŰZÉS-PANEL játék közben.

   A lapot a `js/ui/scenario_screen.js` tölti be, ha az index.html még nem
   tette. Az index.html-ben a helye a <link> sorok VÉGÉN.
   =========================================================================== */

/* ─────────────────────── közös apróságok ─────────────────────── */

#modalCard .scen-dim { color: var(--text-dim); font-size: 11.5px; }

#modalCard .scen-bar {
  display: block; position: relative; height: 7px; border-radius: 7px; overflow: hidden;
  background: rgba(0, 0, 0, .34); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .5);
}
#modalCard .scen-bar > i {
  position: absolute; inset: 0 auto 0 0; border-radius: 7px;
  background: linear-gradient(90deg, #7fbf5f, #a8d97f); transition: width .3s ease;
}
#modalCard .scen-bar.gold > i { background: linear-gradient(90deg, var(--gold), var(--gold-2)); }

#modalCard .scen-stars { letter-spacing: 1px; font-size: 13px; color: rgba(255, 255, 255, .28); }
#modalCard .scen-stars .scs.on { color: var(--gold-2); text-shadow: 0 0 8px rgba(240, 210, 144, .45); }

#modalCard .sd-h {
  font-family: Cinzel, serif; font-size: 12px; letter-spacing: .5px;
  margin: 13px 0 5px; color: var(--gold-2);
}
#modalCard .sd-list { margin: 0; padding: 0; list-style: none; font-size: 12px; line-height: 1.5; }
#modalCard .sd-list li { display: flex; gap: 7px; align-items: flex-start; padding: 2px 0; }
/* CSAK a sor-eleji jelölő kap fix szélességet — a `:first-child` nélkül a
   csillag-lista MINDEN spanjét 15 px-re nyomta (mérve: eltűntek a csillagok). */
#modalCard .sd-list li > span:first-child { flex: 0 0 15px; opacity: .85; }
#modalCard .sd-fail li > span:first-child { color: var(--bad); }
#modalCard .sd-brief li > span:first-child { color: var(--gold); }
#modalCard .sd-stars li > span:first-child { flex: 0 0 auto; }
#modalCard .sd-stars li b { flex: 0 0 54px; text-align: right; font-variant-numeric: tabular-nums; }
#modalCard .scen-detail-empty { padding: 22px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ─────────────────────── 1. VÁLASZTÓ KÉPERNYŐ ─────────────────────── */

#modalCard .scen-wrap { min-width: min(880px, 92vw); }

#modalCard .scen-camp {
  background: rgba(0, 0, 0, .22); border: 1px solid var(--sc-edge, rgba(255, 255, 255, .1));
  border-radius: 9px; padding: 8px 11px; margin-bottom: 10px;
}
#modalCard .scen-camp-h {
  display: flex; align-items: baseline; gap: 9px; margin-bottom: 6px;
}
#modalCard .scen-camp-h b { font-family: Cinzel, serif; font-size: 13px; }
#modalCard .scen-camp-h > span { margin-left: auto; }

#modalCard .scen-grid {
  display: grid; grid-template-columns: minmax(280px, 1fr) minmax(300px, 1.15fr); gap: 12px;
}
#modalCard .scen-list { display: flex; flex-direction: column; gap: 6px; align-content: start; }

#modalCard .scen-card {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 10px;
  background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .08);
  transition: .15s; color: inherit;
}
#modalCard .scen-card:hover { background: rgba(217, 180, 95, .13); border-color: var(--line); }
#modalCard .scen-card.on {
  background: linear-gradient(120deg, rgba(217, 180, 95, .20), rgba(217, 180, 95, .07));
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(217, 180, 95, .25), 0 6px 18px rgba(0, 0, 0, .35);
}
#modalCard .scen-card.locked { opacity: .5; filter: grayscale(.5); cursor: not-allowed; }
#modalCard .scen-card .sc-no {
  flex: 0 0 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700; background: rgba(0, 0, 0, .4); color: var(--gold-2);
}
#modalCard .scen-card .sc-ic { flex: 0 0 26px; font-size: 22px; text-align: center; }
#modalCard .scen-card .sc-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#modalCard .scen-card .sc-txt b { font-family: Cinzel, serif; font-size: 13px; }
#modalCard .scen-card .sc-txt i {
  font-style: normal; font-size: 11.5px; color: var(--text-dim); line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis;
}
#modalCard .scen-card .sc-txt em { font-style: normal; font-size: 10px; opacity: .55; margin-top: 1px; }
#modalCard .scen-card .sc-right {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
}
#modalCard .scen-card .sc-tag {
  font-size: 9.5px; letter-spacing: .4px; text-transform: uppercase;
  padding: 1px 7px; border-radius: 999px; background: rgba(0, 0, 0, .35); color: var(--text-dim);
}
#modalCard .scen-card .sc-new { font-size: 10px; }

#modalCard .scen-side {
  background: rgba(0, 0, 0, .2); border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 10px; padding: 11px 13px; max-height: 62vh; overflow-y: auto;
}
#modalCard .sd-head { display: flex; align-items: center; gap: 10px; }
#modalCard .sd-head .sd-ic { font-size: 27px; }
#modalCard .sd-head .sd-t { flex: 1; display: flex; flex-direction: column; }
#modalCard .sd-head .sd-t b { font-family: Cinzel, serif; font-size: 16px; }
#modalCard .sd-head .sd-t i { font-style: normal; font-size: 11px; color: var(--text-dim); }
#modalCard .sd-head .sd-medal { font-size: 22px; }
#modalCard .sd-desc { font-size: 12.5px; line-height: 1.55; margin: 9px 0 0; color: var(--text); opacity: .92; }

#modalCard .sd-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; font-size: 11.5px;
}
#modalCard .sd-grid > div {
  display: flex; justify-content: space-between; gap: 6px;
  padding: 3px 0; border-top: 1px solid rgba(255, 255, 255, .06);
}
#modalCard .sd-grid > div.sd-wide { grid-column: 1 / -1; }
#modalCard .sd-grid span { color: var(--text-dim); }
#modalCard .sd-stars li { align-items: center; gap: 8px; }

#modalCard .sd-best {
  margin-top: 11px; padding: 7px 9px; border-radius: 8px;
  background: rgba(0, 0, 0, .28); font-size: 12px;
}
#modalCard .sd-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
#modalCard .sd-actions .mbtn { flex: 1; min-height: 38px; }
/* Az „Indulhat" gomb a görgethető oldalsáv ALJÁRA ragad — hosszú leírásnál is
   egy kattintásra elérhető marad. */
#modalCard .scen-side .sd-actions {
  position: sticky; bottom: -12px; margin: 12px -13px -11px; padding: 9px 13px;
  background: linear-gradient(180deg, rgba(11, 16, 23, 0), rgba(11, 16, 23, .92) 32%);
  backdrop-filter: blur(4px);
}
#modalCard .scen-danger { border-color: rgba(226, 106, 106, .45) !important; color: #ffbdbd; }

#modalCard .scen-foot {
  display: flex; align-items: center; gap: 10px; margin-top: 11px;
  padding-top: 9px; border-top: 1px solid rgba(255, 255, 255, .07);
}
#modalCard .scen-foot .scen-reset { margin-left: auto; font-size: 11px; padding: 5px 10px; min-height: 0; }

/* ─────────────────────── 2. CÉLKITŰZÉS-KÉPERNYŐ ─────────────────────── */

#modalCard .scen-obj-wrap { min-width: min(680px, 92vw); }
#modalCard .so-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
#modalCard .so-head .so-ic { font-size: 28px; }
#modalCard .so-head .so-t { flex: 1; display: flex; flex-direction: column; }
#modalCard .so-head .so-t b { font-family: Cinzel, serif; font-size: 16px; }
#modalCard .so-head .so-t i { font-style: normal; font-size: 11.5px; color: var(--text-dim); }
#modalCard .so-head .so-turn { text-align: right; }
#modalCard .so-head .so-turn b { font-family: Cinzel, serif; font-size: 20px; color: var(--gold-2); }
#modalCard .so-head .so-turn i { display: block; font-style: normal; font-size: 10.5px; color: var(--text-dim); }
#modalCard .so-desc { font-size: 12.5px; line-height: 1.55; margin: 9px 0 0; opacity: .9; }

#modalCard .so-objs { display: flex; flex-direction: column; gap: 5px; }
#modalCard .so-obj {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 9px;
  background: rgba(0, 0, 0, .22); border: 1px solid rgba(255, 255, 255, .07);
}
#modalCard .so-obj.done { border-color: rgba(111, 209, 138, .45); background: rgba(111, 209, 138, .10); }
#modalCard .so-obj .so-o-ic { flex: 0 0 22px; font-size: 16px; text-align: center; }
#modalCard .so-obj.done .so-o-ic { color: var(--good); }
#modalCard .so-obj .so-o-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#modalCard .so-obj .so-o-t b { font-size: 12.5px; }
#modalCard .so-obj .so-o-t i { font-style: normal; font-size: 11px; color: var(--text-dim); }
#modalCard .so-obj .so-o-bar { flex: 0 0 110px; }

#modalCard .so-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px;
  margin-top: 12px; font-size: 11.5px;
}
#modalCard .so-stats > div {
  background: rgba(0, 0, 0, .24); border-radius: 8px; padding: 6px 9px;
  display: flex; flex-direction: column;
}
#modalCard .so-stats > div.so-wide { grid-column: 1 / -1; }
#modalCard .so-stats span { color: var(--text-dim); font-size: 10.5px; }
#modalCard .so-stats b { font-family: Cinzel, serif; font-size: 15px; }

/* ─────────────────────── 3. EREDMÉNY-KÉPERNYŐ ─────────────────────── */

#modalCard .scen-res { min-width: min(560px, 92vw); text-align: center; }
#modalCard .scen-res .sr-top { padding: 8px 0 14px; }
#modalCard .scen-res .sr-ic { font-size: 52px; line-height: 1; }
#modalCard .scen-res h3 { font-family: Cinzel, serif; font-size: 24px; margin: 8px 0 4px; }
#modalCard .scen-res.win h3 { color: var(--gold-2); text-shadow: 0 0 18px rgba(240, 210, 144, .35); }
#modalCard .scen-res.lose h3 { color: var(--bad); }
#modalCard .scen-res .sr-top p { font-size: 12.5px; color: var(--text-dim); margin: 0 auto; max-width: 46ch; line-height: 1.5; }
#modalCard .scen-res .sr-stars { margin-top: 11px; font-size: 30px; letter-spacing: 5px; }
#modalCard .scen-res .sr-medal { font-size: 13px; margin-top: 3px; color: var(--gold-2); font-family: Cinzel, serif; }
#modalCard .scen-res .sr-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 7px; margin-bottom: 6px;
}
#modalCard .scen-res .sr-grid > div {
  background: rgba(0, 0, 0, .26); border-radius: 8px; padding: 7px; display: flex; flex-direction: column;
}
#modalCard .scen-res .sr-grid span { font-size: 10.5px; color: var(--text-dim); }
#modalCard .scen-res .sr-grid b { font-family: Cinzel, serif; font-size: 17px; }
#modalCard .scen-res .so-objs { text-align: left; }
#modalCard .scen-res .sr-rec { margin-top: 11px; font-size: 12px; }

/* ─────────────────────── 4. LEBEGŐ CÉLKITŰZÉS-PANEL ─────────────────────── */

#scenPanel {
  position: fixed; left: 12px; top: 66px; width: 300px; z-index: 41;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l, 12px);
  box-shadow: var(--shadow); backdrop-filter: blur(8px); overflow: hidden;
  font-size: 12px; animation: scenIn .3s ease-out;
}
@keyframes scenIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
#scenPanel.hidden { display: none !important; }
#scenPanel.urgent { border-color: rgba(226, 106, 106, .6); box-shadow: 0 0 22px rgba(226, 106, 106, .25); }

#scenPanel .sp2-head {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px;
  background: rgba(255, 255, 255, .05); border-bottom: 1px solid rgba(255, 255, 255, .07);
}
#scenPanel.folded .sp2-head { border-bottom: none; }
#scenPanel .sp2-ic { font-size: 19px; }
#scenPanel .sp2-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
#scenPanel .sp2-t b { font-family: Cinzel, serif; font-size: 13px; }
#scenPanel .sp2-t i { font-style: normal; font-size: 10.5px; color: var(--text-dim); }
#scenPanel .sp2-t i em { font-style: normal; color: var(--gold-2); font-weight: 700; }
#scenPanel.urgent .sp2-t i em { color: #ff9c9c; }
#scenPanel .sp2-fold {
  flex: 0 0 24px; height: 24px; border-radius: 6px; color: var(--text-dim);
  display: grid; place-items: center; font-size: 12px;
}
#scenPanel .sp2-fold:hover { background: rgba(217, 180, 95, .2); color: var(--text); }
#scenPanel.folded .sp2-body { display: none; }
#scenPanel .sp2-body { padding: 7px 9px 9px; display: flex; flex-direction: column; gap: 6px; }

#scenPanel .sp2-obj { display: grid; grid-template-columns: 20px 1fr; gap: 3px 7px; align-items: center; }
#scenPanel .sp2-o-ic { grid-row: span 2; font-size: 15px; text-align: center; }
#scenPanel .sp2-obj.done .sp2-o-ic { color: var(--good); }
#scenPanel .sp2-o-t { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
#scenPanel .sp2-o-t b { font-size: 11.5px; font-weight: 600; }
#scenPanel .sp2-o-t i { font-style: normal; font-size: 10.5px; color: var(--text-dim); }
#scenPanel .sp2-obj.done .sp2-o-t b { color: var(--good); }
#scenPanel .scen-bar {
  display: block; position: relative; height: 5px; border-radius: 5px; overflow: hidden;
  background: rgba(0, 0, 0, .4); grid-column: 2;
}
#scenPanel .scen-bar > i {
  position: absolute; inset: 0 auto 0 0; border-radius: 5px;
  background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .3s ease;
}
#scenPanel .sp2-obj.done .scen-bar > i { background: linear-gradient(90deg, #4f9f6a, #7fbf8f); }
#scenPanel .sp2-more {
  margin-top: 2px; padding: 5px 0; border-radius: 7px; font-size: 11px; color: var(--text-dim);
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08);
}
#scenPanel .sp2-more:hover { background: rgba(217, 180, 95, .18); color: var(--text); }

/* A toastok ne bújjanak a panel alá — CSAK forgatókönyv-módban tolunk rajtuk.
   A pontos értéket a scenario_screen.js írja a `--scen-toast-top` változóba. */
body.scen-on #toasts { top: var(--scen-toast-top, 300px); }

/* ─────────────────────── mobil ─────────────────────── */

@media (max-width: 900px) {
  #modalCard .scen-grid { grid-template-columns: 1fr; }
  #modalCard .scen-side { max-height: none; }
  #modalCard .sd-grid { grid-template-columns: 1fr; }
  #scenPanel { left: 8px; right: 8px; width: auto; top: calc(var(--topbar-h, 58px) + 6px); }
  #scenPanel .sp2-body { max-height: 34vh; overflow-y: auto; }
  body.scen-on #toasts { top: var(--scen-toast-top, 260px); }
}

@media (max-width: 640px) {
  #modalCard .so-obj .so-o-bar { display: none; }
  #modalCard .scen-card .sc-txt em { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #scenPanel { animation: none; }
  #modalCard .scen-bar > i, #scenPanel .scen-bar > i { transition: none; }
}
