/* Dice & Dominion — Story mode cut scenes (client/js/cutscene.js): letterbox, speech box, tail, emotes, controls. */
@import url('https://fonts.googleapis.com/css2?family=Jersey+15&display=swap');

.cs-root { --cs-paper: #e4dfd2; --cs-paper2: #c9c2b0; --cs-ink: #2b2420; --cs-rim: #3d342d; --cs-name: #8e1d16; --cs-bar: clamp(30px, 7vh, 64px);
  position: fixed; inset: 0; z-index: 9000; opacity: 0; transition: opacity .25s ease; cursor: pointer; user-select: none; -webkit-user-select: none; font-family: 'Jersey 15', 'Pixelify Sans', monospace; }
.cs-root.on { opacity: 1; }
.cs-dialogue { background: radial-gradient(ellipse at 50% 60%, rgba(30, 22, 40, .55), rgba(6, 4, 10, .82)); }
.hidden.cs-box, .cs-root .hidden { display: none !important; }

/* letterbox */
.cs-bar { position: fixed; left: 0; right: 0; height: var(--cs-bar); background: #050407; transition: transform .35s ease; z-index: 1; }
.cs-bar-top { top: 0; transform: translateY(-100%); box-shadow: 0 2px 0 rgba(255, 255, 255, .04); }
.cs-bar-bot { bottom: 0; transform: translateY(100%); }
.cs-root.on .cs-bar { transform: none; }
.cs-tint { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s ease; }
.cs-tint.on { opacity: 1; }
.cs-flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 4; }

/* the speech box */
.cs-box { position: fixed; left: 50%; transform: translateX(-50%); z-index: 3; width: min(780px, calc(100vw - 16px)); box-sizing: border-box;
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; padding: 10px 12px 12px 18px;
  background: linear-gradient(180deg, #efebe1 0%, var(--cs-paper) 30%, var(--cs-paper2) 100%);
  border: 3px solid var(--cs-rim); border-radius: 16px;
  box-shadow: inset 0 0 0 2px #faf7ef, inset 0 -4px 0 2px #a8a08c, inset 0 3px 0 2px #fffdf6, 0 8px 22px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .35);
  animation: csPop .18s ease-out; }
.cs-box.at-top { top: calc(var(--cs-bar) + 10px); }
.cs-box.at-bot { bottom: calc(var(--cs-bar) + 10px); }
.cs-root.cs-dialogue .cs-box.at-bot { bottom: calc(var(--cs-bar) + 7vh); }
@keyframes csPop { from { transform: translateX(-50%) scale(.96); opacity: .3; } }
.cs-main { min-width: 0; }
.cs-name { color: var(--cs-name); font-size: 27px; line-height: 1; letter-spacing: .02em; margin: 2px 0 5px; text-shadow: 0 1px 0 rgba(255, 255, 255, .7); }
.cs-sub { color: #6a5a4e; font-size: 17px; letter-spacing: 0; margin-left: 6px; }
.cs-text { color: var(--cs-ink); font-size: 24px; line-height: 1.12; min-height: calc(3 * 1.12em); white-space: pre-wrap; overflow-wrap: anywhere; text-shadow: 0 1px 0 rgba(255, 255, 255, .45); }
.cs-more { position: absolute; right: 128px; bottom: 6px; color: var(--cs-name); font-size: 14px; opacity: 0; }
.cs-more.on { opacity: 1; animation: csBlink 1s steps(2) infinite; }
@keyframes csBlink { 50% { opacity: .15; } }
/* the portrait, framed on the right */
.cs-face { width: 152px; height: 152px; padding: 4px; box-sizing: border-box; border-radius: 6px; background: linear-gradient(135deg, #8a6a3a, #4a3622);
  box-shadow: inset 0 0 0 2px #e8cf8c, inset 0 0 0 4px #3a2a1a, 0 2px 0 rgba(0, 0, 0, .35); align-self: center; }
.cs-face img { width: 100%; height: 100%; display: block; image-rendering: pixelated; border-radius: 2px; }
.cs-box.mood-angry .cs-face { background: linear-gradient(135deg, #b8321e, #5a140c); box-shadow: inset 0 0 0 2px #ffb08a, inset 0 0 0 4px #3a0e08, 0 0 10px rgba(220, 40, 20, .55); }
.cs-box.mood-sad .cs-face { background: linear-gradient(135deg, #4a6a9a, #22324a); box-shadow: inset 0 0 0 2px #b8d0f0, inset 0 0 0 4px #141e2e, 0 2px 0 rgba(0, 0, 0, .35); }
.cs-box.mood-smug .cs-face { background: linear-gradient(135deg, #c8a040, #6a4a14); box-shadow: inset 0 0 0 2px #fff0b0, inset 0 0 0 4px #3a2a0a, 0 0 8px rgba(240, 200, 80, .45); }
.cs-box.mood-shock .cs-face { background: linear-gradient(135deg, #e0e0f0, #7a7a98); }
.cs-box.mood-angry .cs-name { color: #b0120a; }
.cs-shake { animation: csShake .38s linear; }
@keyframes csShake { 10%, 50%, 90% { transform: translateX(calc(-50% - 5px)); } 30%, 70% { transform: translateX(calc(-50% + 5px)); } }
/* narrator: centered, no portrait, italic */
.cs-box.cs-narr { grid-template-columns: 1fr; text-align: center; padding: 14px 22px; background: linear-gradient(180deg, #d9d4c8, #b9b2a2); width: min(640px, calc(100vw - 16px)); }
.cs-box.cs-narr.at-top, .cs-box.cs-narr.at-bot { top: 50%; bottom: auto; transform: translate(-50%, -50%); animation: none; }
.cs-box.cs-narr .cs-name, .cs-box.cs-narr .cs-face { display: none; }
.cs-box.cs-narr .cs-text { font-style: italic; color: #3a3028; min-height: 0; transform: skewX(-6deg); }
.cs-box.cs-narr .cs-more { right: 12px; }
/* the tail (an SVG over the whole screen, joined to the box edge) */
.cs-tailsvg { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 3; overflow: visible; }
.cs-tail-fill { fill: #cfc8b7; }
.cs-tail-line { fill: none; stroke: var(--cs-rim); stroke-width: 3; stroke-linejoin: round; }
/* emotes over heads */
.cs-emotes { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.cs-emote { position: fixed; transform: translate(-50%, -100%); min-width: 30px; padding: 2px 8px 4px; text-align: center; font-size: 24px; line-height: 1; color: #b0120a;
  background: #fbf6ea; border: 3px solid var(--cs-rim); border-radius: 12px; box-shadow: 0 3px 0 rgba(0, 0, 0, .35); animation: csEmote 1.5s ease-out forwards; }
.cs-emote::after { content: ''; position: absolute; left: 50%; bottom: -9px; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--cs-rim); }
@keyframes csEmote { 0% { transform: translate(-50%, -60%) scale(.3); opacity: 0; } 14% { transform: translate(-50%, -110%) scale(1.15); opacity: 1; } 24% { transform: translate(-50%, -100%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -120%); } }
/* controls in the bottom bar */
.cs-ctrl { position: fixed; left: 0; right: 0; bottom: 0; height: var(--cs-bar); z-index: 5; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 0 10px; box-sizing: border-box;
  color: #d8ccb0; font-size: 19px; cursor: default; }
.cs-title { position: absolute; left: 14px; color: #8e7a5a; font-size: 17px; letter-spacing: .06em; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-keys { color: #7a6e5a; font-size: 15px; margin-left: 4px; }
.cs-auto { color: #8a7e68; font-size: 15px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.cs-auto input { accent-color: #8e1d16; }
.cs-btn { font: inherit; font-size: 18px; color: #f3ead2; background: linear-gradient(180deg, #4a3e34, #2a221c); border: 2px solid #8a7458; border-radius: 8px; padding: 2px 12px 4px; cursor: pointer; }
.cs-btn:hover { border-color: #e8cf8c; color: #fff; }
.cs-skipall { border-color: #b0402a; background: linear-gradient(180deg, #6a2418, #3a120a); }
.cs-wait { position: fixed; left: 50%; bottom: calc(var(--cs-bar) + 16px); transform: translateX(-50%); z-index: 3; max-width: calc(100vw - 24px); box-sizing: border-box;
  padding: 8px 16px 10px; border-radius: 12px; border: 3px solid var(--cs-rim); background: linear-gradient(180deg, #e4dfd2, #c2bba9); color: var(--cs-ink); font-size: 21px; text-align: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); }

/* the battle HUD steps aside while a scene plays */
body.cs-active .battle > :not(.b-center), body.cs-active #b-center > :not(canvas), body.cs-active .dbh-hud, body.cs-active .castflow, body.cs-active #b-tip { visibility: hidden !important; }

@media (max-width: 560px) {
  .cs-box { grid-template-columns: 1fr auto; gap: 8px; padding: 8px 8px 10px 12px; border-radius: 13px; }
  .cs-name { font-size: 22px; }
  .cs-sub { display: block; margin: 1px 0 0; font-size: 15px; }
  .cs-text { font-size: 20px; }
  .cs-face { width: 80px; height: 80px; padding: 4px; }
  .cs-more { right: 90px; }
  .cs-title, .cs-keys, .cs-auto { display: none; }
  .cs-ctrl { gap: 8px; font-size: 17px; }
  .cs-btn { font-size: 16px; padding: 2px 9px 3px; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-root, .cs-bar { transition: none; }
  .cs-box, .cs-shake, .cs-emote, .cs-more.on { animation: none !important; }
}

/* ▼ over the speaker on the field */
.cs-caret { position: fixed; z-index: 4; transform: translate(-50%, -100%); color: #ffd84a; font: 400 18px/1 'Jersey 15', monospace; text-shadow: 0 2px 0 #1a1220, 0 0 6px rgba(0,0,0,.6); pointer-events: none; animation: cs-caret .7s steps(2) infinite; }
.cs-caret.hidden { display: none; }
@keyframes cs-caret { 50% { margin-top: -4px; } }
@media (prefers-reduced-motion: reduce) { .cs-caret { animation: none; } }
