/* Property of Sistema THEAD. All rights reserved. */
/* Story-mode-only styling. Loaded alongside index.css on editor.html.
   All rules scope themselves under [data-editor-mode="story"] on body
   so robot-mode visuals stay untouched. */

/* Hide the Bluetooth pair button + robot-info chip in story mode —
   there's no robot to pair. The new Story Manager button lives next
   to them and stays visible. */
body[data-editor-mode="story"] .robot-actions {
    display: none;
}

/* The Story Manager button replaces the robot icon at the top of the
   editor in story mode. Sized to match the other top-bar buttons. */
.story-manager-btn {
    background-color: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}
.story-manager-btn[hidden] { display: none; }
.story-manager-btn img {
    height: 50px;
    width: auto;
}
.story-manager-btn:active img { transform: scale(0.95); }

/* When the camera is active, the top bar is hidden — but the .bluetooth
   container is positioned absolutely outside it. Keep the manager
   button out of the way during scanning so it doesn't overlap the
   camera UI. */
body.camera-active .story-manager-btn { display: none; }

/* Desktop-landscape: index.css gives #btn-blt and .settings a a circular
   white pill 80x80 with shadow. Mirror those rules so the story-manager
   button takes the same slot visually. */
body[data-editor-mode="story"].screen-desktop.screen-landscape .top-bar #btn-story-manager {
    width: 80px;
    height: 80px;
    border: var(--round-control-outline);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background: #ffffff;
}
body[data-editor-mode="story"].screen-desktop.screen-landscape .top-bar #btn-story-manager img {
    width: 75%;
    height: 75%;
    object-fit: contain;
}

/* Scanned-block tray checker pattern moved to
   apps/client/public/assets/styles/index/50-camera-active.css — it now
   applies in both story and robot modes (2026-05-21). */

/* The repurposed Send button. Visually identical to robot mode — same
   green flag — but clicking it opens the story player popup. */
body[data-editor-mode="story"] .story-send-button {
    background-color: #6BB04F;
}

/* -----------------------------------------------------------------
   Stage popup
   ----------------------------------------------------------------- */

.swal-story-stage-popup,
.swal-story-picker-popup {
    border-radius: 18px !important;
    padding: 18px 18px 22px !important;
}

.story-stage {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.story-stage-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.story-stage-btn {
    appearance: none;
    border: 2px solid #0080C9;
    background: #fff;
    color: #0080C9;
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease;
}
.story-stage-btn:hover { background: #E6F3FB; }
.story-stage-btn:active { transform: scale(0.97); }

.story-stage-btn-primary {
    background: #6BB04F;
    color: #fff;
    border-color: #6BB04F;
}
.story-stage-btn-primary:hover { background: #5a9c41; }

.story-stage-btn-stop {
    background: #E74C3C;
    color: #fff;
    border-color: #E74C3C;
}
.story-stage-btn-stop:hover { background: #c63d2f; }

/* Playback speed slider in the Player popup toolbar. Sits next to
   Replay/Stop, takes the same vertical space as the buttons so the
   toolbar row stays a single line on desktop, wraps cleanly on narrow
   viewports thanks to the toolbar's flex-wrap. */
.story-stage-speed {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 14px;
    border: 2px solid #0080C9;
    border-radius: 999px;
    background: #fff;
    color: #0080C9;
    font-weight: 600;
    font-size: 14px;
    user-select: none;
}
.story-stage-speed-label {
    line-height: 1;
}
.story-stage-speed-input {
    /* Compact slider — the toolbar is already crowded on small screens. */
    width: 120px;
    accent-color: #0080C9;
    cursor: pointer;
}
.story-stage-speed-value {
    min-width: 3ch;
    text-align: right;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.story-stage-scene {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: 60vh;
    border-radius: 14px;
    overflow: hidden;
    background: #cfe7f5;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08);
    touch-action: none;
    margin-inline: auto;
}

/* When max-height kicks in (short viewports), the aspect ratio is broken
   by the height clamp — preserve scene width manually so the stage stays
   inside the popup gutters. */
@media (max-aspect-ratio: 16/10) {
    .story-stage-scene {
        width: calc(60vh * 16 / 10);
        max-width: 100%;
    }
}

.story-stage-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.story-stage-character {
    position: absolute;
    width: 16%;
    aspect-ratio: 1 / 1;
    left: 50%;
    top: 70%;
    transform: translate(-50%, -50%);
    cursor: grab;
    transition: filter 0.1s ease;
    z-index: 2;
}
.story-stage-character.is-dragging { cursor: grabbing; filter: brightness(1.05); }
.story-stage-character.is-running  { cursor: default; }
/* Player popup: the character is read-only (no drag), so the grab
   cursor would be misleading. */
.story-stage-character-locked { cursor: default; }
.story-stage-character img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.25));
    /* Rotation is driven by JS: setFacing() snaps on open/reset,
       stepTurn() drives a per-frame tween. A CSS transition here
       would lag behind the tween and slow turns visibly. */
}

.story-stage-bubble {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, -8px);
    background: #fff;
    color: #222;
    border: 2px solid #0080C9;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    pointer-events: none;
}
.story-stage-bubble::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #0080C9;
}

.story-stage-hint {
    margin: 0;
    text-align: center;
    color: #555;
    font-size: 14px;
}
/* Collapse the hint paragraph when it has no text — the player popup
   uses an empty hint as a placeholder for flashHint, and an empty
   paragraph shouldn't add stray whitespace under the scene. */
.story-stage-hint:empty { display: none; }
.story-stage-hint.is-flash {
    color: #E74C3C;
    font-weight: 700;
    display: block;
}

/* -----------------------------------------------------------------
   Asset picker
   ----------------------------------------------------------------- */

.story-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 6px 2px 2px;
}

.story-picker-tile {
    appearance: none;
    border: 3px solid transparent;
    background: #f7f7f9;
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.story-picker-tile:hover {
    border-color: #0080C9;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}
.story-picker-tile:active { transform: scale(0.98); }
.story-picker-tile.is-selected {
    border-color: #6BB04F;
    background: #E8F5E0;
}
.story-picker-tile img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}
.story-picker-grid-background .story-picker-tile img {
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
}
.story-picker-tile-label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    pointer-events: none;
}
