/* Story cutscenes. Shared by the game and the story theater, so it carries its own
   fonts and colors. The frame color tells you who is speaking. */
@font-face { font-family: "Dos"; src: url('/style/fonts/Perfect DOS VGA 437.ttf') format("truetype"); }
@font-face { font-family: "Arcade"; src: url('/style/fonts/JMH Cthulhumbus Arcade.otf') format("opentype"); }

.cutscene, .story-theater {
    --st-hull: #13152b; --st-hull-2: #1d2140; --st-edge: #3b4466; --st-steel: #a9b6c6; --st-ink: #e9eef7;
    --st-amber: #f7b52c; --st-cyan: #5ee6e8; --st-orange: #fa6400;
}
.cutscene *, .cutscene *::before, .cutscene *::after { box-sizing: border-box; }
.cutscene * {
    --st-cut: 12px;
    --st-chamfer: polygon(var(--st-cut) 0, calc(100% - var(--st-cut)) 0, 100% var(--st-cut), 100% calc(100% - var(--st-cut)),
                          calc(100% - var(--st-cut)) 100%, var(--st-cut) 100%, 0 calc(100% - var(--st-cut)), 0 var(--st-cut));
}

.cutscene[hidden] { display: none; }
.cutscene {
    --accent: var(--st-orange);
    position: fixed; inset: 0; z-index: 20; overflow: auto; overscroll-behavior: contain;
    display: grid; place-items: start center;
    padding: calc(14px + env(safe-area-inset-top, 0px)) calc(14px + env(safe-area-inset-right, 0px))
             calc(14px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
    background: rgba(8, 9, 22, .9); color: var(--st-ink); font: 16px/1.35 Dos, monospace;
    -webkit-user-select: none; user-select: none; outline: none;
}
@supports (backdrop-filter: blur(2px)) { .cutscene { background: rgba(8, 9, 22, .8); backdrop-filter: blur(3px); } }
.cutscene[data-speaker="ninja"] { --accent: #ff6b5e; }
.cutscene[data-speaker="zed"]   { --accent: #8cb8ff; }
.cutscene[data-speaker="jinx"]  { --accent: #c79bff; }
.cutscene[data-speaker="pluto"] { --accent: #7fdc8f; }
.cutscene[data-speaker="beans"] { --accent: #ffc65c; }
.cutscene[data-speaker="larry"] { --accent: #e040a0; }

.cutscene-stage {
    width: min(100%, 860px); margin-block: auto;
    display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "header" "frame" "box" "hint";
}
.cutscene-header { grid-area: header; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.cutscene-heading { margin: 0; font: 400 clamp(20px, 3vw, 28px)/1 Arcade, sans-serif; color: var(--st-amber); letter-spacing: 1px; }
.cutscene-location { margin: 0; color: var(--st-steel); }

.cutscene-frame {
    grid-area: frame; justify-self: center; width: min(100%, 72dvh);
    padding: 4px; background: var(--accent); --st-cut: 18px; clip-path: var(--st-chamfer);
    transition: background-color .2s;
}
.cutscene-portrait {
    display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover;
    background: var(--st-orange); image-rendering: pixelated; --st-cut: 15px; clip-path: var(--st-chamfer);
}

.cutscene-box {
    grid-area: box; position: relative; isolation: isolate; cursor: pointer;
    padding: 16px 18px 14px; --st-cut: 14px; clip-path: var(--st-chamfer);
}
.cutscene-box::before, .cutscene-box::after { content: ""; position: absolute; z-index: -1; clip-path: var(--st-chamfer); }
.cutscene-box::before { inset: 0; background: linear-gradient(var(--accent), var(--accent)) 0 0 / 100% 3px no-repeat, var(--st-edge); }
.cutscene-box::after { inset: 2px; background: var(--st-hull); }

.cutscene-dialogue { margin: 0 0 14px; min-height: calc(1em + 3 * 1.4em + 10px); }
.cutscene-speaker {
    display: inline-block; margin-bottom: 10px; padding: 5px 12px 4px;
    font: 400 20px/1 Arcade, sans-serif; letter-spacing: 1px; color: #14102a; background: var(--accent);
    --st-cut: 6px; clip-path: var(--st-chamfer);
}
.cutscene-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.cutscene-text { display: block; font-size: clamp(18px, 2.3vw, 22px); line-height: 1.4; text-wrap: pretty; }

.cutscene-controls { display: flex; align-items: center; gap: 8px; }
/* Line counter sits in the box's top-right corner so the buttons keep the whole row */
.cutscene-progress { position: absolute; top: 18px; right: 18px; color: var(--st-steel); font-size: 14px; white-space: nowrap; }
.cutscene [data-action="skip"] { margin-left: auto; }
.cutscene button { white-space: nowrap; }
.cutscene button, .story-theater nav a, .story-theater select {
    --b-edge: var(--st-edge); --b-fill: var(--st-hull-2); --b-ink: var(--st-ink);
    position: relative; isolation: isolate; min-height: 44px; padding: 10px 16px; border: 0;
    background: none; color: var(--b-ink); font: 16px/1 Dos, monospace; cursor: pointer; text-decoration: none;
}
.cutscene button { --st-cut: 8px; clip-path: var(--st-chamfer); }
.cutscene button::before, .cutscene button::after { content: ""; position: absolute; z-index: -1; clip-path: var(--st-chamfer); }
.cutscene button::before { inset: 0; background: var(--b-edge); }
.cutscene button::after { inset: 2px; background: var(--b-fill); }
.cutscene button:hover { --b-fill: #2a3060; }
.cutscene button:focus-visible { outline: none; --b-edge: #fff; }
.cutscene button:disabled { opacity: .35; cursor: default; }
.cutscene .cutscene-next { --b-edge: #ffe08a; --b-fill: var(--st-amber); --b-ink: #2a1600; min-width: 96px; }
.cutscene .cutscene-next:hover { --b-fill: #ffc84a; }
.cutscene .cutscene-next:focus-visible { --b-edge: #fff; }

.cutscene-hint { grid-area: hint; margin: 0; text-align: center; color: var(--st-steel); font-size: 14px; }
@media (pointer: coarse) { .cutscene-hint { display: none; } }

@media (max-width: 600px) {
    .cutscene-stage { gap: 10px; }
    .cutscene-box { padding: 12px 12px 10px; }
    .cutscene-speaker { font-size: 18px; margin-bottom: 8px; }
    .cutscene-controls { gap: 6px; }
    .cutscene button { padding: 10px 12px; }
}
/* Landscape phones: portrait beside the text box */
@media (max-height: 540px) and (min-width: 640px) {
    .cutscene-stage {
        width: min(100%, 1000px); gap: 10px 14px; align-items: center;
        grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
        grid-template-areas: "header header" "frame box";
    }
    .cutscene-frame { width: 100%; }
    .cutscene-hint { display: none; }
    .cutscene-dialogue { min-height: 0; }
}

/* ---- story theater page ---- */
.story-theater { margin: 0; min-height: 100vh; background: #0a0b1a; color: var(--st-ink); font-family: Dos, monospace; }
.story-theater nav {
    position: fixed; z-index: 30; top: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 10px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; background: var(--st-hull); border-bottom: 2px solid var(--st-edge);
}
.story-theater nav a { display: flex; align-items: center; white-space: nowrap; border: 2px solid var(--st-cyan); }
.story-theater select { border: 2px solid var(--st-edge); background: var(--st-hull-2); min-width: 0; max-width: 70%; }
.story-theater nav a:hover, .story-theater nav a:focus-visible, .story-theater select:focus-visible { border-color: #fff; outline: none; }
.story-theater .cutscene { padding-top: calc(76px + env(safe-area-inset-top, 0px)); }
@media (max-width: 600px) { .story-theater nav { justify-content: space-between; } }

@media (prefers-reduced-motion: reduce) { .cutscene-frame { transition: none; } }
