/**
 * BOLANDILA Interactive Game Template
 * Components CSS
 *
 * Role of this file:
 * - Styles reusable UI components
 * - Text boxes, buttons, modals, banners
 * - Items, carousel, drag/drop, quiz, reward overlay
 * - Level 6 scale markers
 */

/*
|--------------------------------------------------------------------------
| Text boxes
|--------------------------------------------------------------------------
*/

.text-box {
    width: 100%;
    max-height: var(--text-box-max-height);
    overflow-y: auto;
    overflow-x: hidden;

    padding: var(--text-box-padding);

    background: var(--text-box-background);
    border: var(--text-box-border);
    border-radius: var(--text-box-border-radius);

    backdrop-filter: var(--text-box-backdrop-filter);
    -webkit-backdrop-filter: var(--text-box-backdrop-filter);

    box-shadow: var(--text-box-shadow);

    color: var(--color-text);
    text-align: center;

    overscroll-behavior: contain;
}

    .screen[data-screen-id="level_3_carousel"] .carousel-description .text-box {
        max-height: 25vh;
    }

.text-box.is-compact {
    padding: 14px 15px;
}

.text-box.is-large {
    max-height: 48vh;
}

.text-box h2,
.text-box h3 {
    margin: 0 0 0.55em;
    color: var(--color-gold-light);
    line-height: 1.1;
}

.text-box ul,
.text-box ol {
    margin: 0.75em 0 0.75em 1.2em;
    text-align: left;
}

.text-box li {
    margin-bottom: 0.4em;
}

/*
|--------------------------------------------------------------------------
| Buttons
|--------------------------------------------------------------------------
*/

.game-button {
    position: relative;

    min-height: var(--button-min-height);
    padding: var(--button-padding);

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: var(--button-border-radius);

    font-size: var(--game-button-font-size);
    font-weight: 700;
    line-height: 1.1;
    text-align: center;

    transition:
        transform 180ms ease,
        filter 180ms ease,
        box-shadow 180ms ease,
        opacity 180ms ease;

    will-change: transform;
}

.game-button.is-primary {
    color: var(--button-primary-color);
    background: var(--button-primary-background);
    border: var(--button-primary-border);
    box-shadow: var(--button-primary-shadow);
}

.game-button.is-outline {
    color: var(--button-outline-color);
    background: var(--button-outline-background);
    border: var(--button-outline-border);
    box-shadow: var(--button-outline-shadow);
}

.game-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.07);
}

.game-button:active {
    transform: translateY(1px) scale(0.99);
}

.game-button:disabled,
.game-button.is-disabled {
    opacity: 0.48;
    cursor: not-allowed;
    pointer-events: none;
}

.game-button.is-small {
    min-height: 38px;
    padding: 9px 16px;
    font-size: 15px;
}

.game-button.is-full {
    width: 100%;
}

/*
|--------------------------------------------------------------------------
| Modals
|--------------------------------------------------------------------------
*/

.modal-backdrop {
    position: absolute;
    inset: 0;
    z-index: 1;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background: var(--modal-overlay-background);
}

.modal-box {
    position: relative;
    z-index: 2;

    width: var(--modal-width);
    max-height: var(--modal-max-height);
    overflow-y: auto;
    overflow-x: hidden;

    padding: var(--modal-padding);

    background: var(--modal-background);
    border: var(--modal-border);
    border-radius: var(--modal-border-radius);

    backdrop-filter: var(--modal-backdrop-filter);
    -webkit-backdrop-filter: var(--modal-backdrop-filter);

    box-shadow: var(--modal-shadow);

    color: var(--color-text);
    text-align: center;

    overscroll-behavior: contain;
}

.modal-title {
    margin: 0 0 12px;

    color: var(--color-gold-light);
    font-size: clamp(24px, 5.2vw, 34px);
    font-weight: 700;
    line-height: 1.08;

    text-shadow: var(--title-text-shadow);
}

.modal-body {
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: var(--button-gap);
}

.modal-box.is-danger {
    border-color: rgba(255, 82, 82, 0.86);
    box-shadow:
        var(--modal-shadow),
        0 0 34px rgba(255, 82, 82, 0.16);
}

.modal-box.is-success {
    border-color: rgba(255, 226, 122, 0.90);
}

/*
|--------------------------------------------------------------------------
| Banners
|--------------------------------------------------------------------------
*/

.banner-box {
    position: absolute;

    padding: var(--banner-padding);

    background: var(--banner-background);
    border: var(--banner-border);
    border-radius: var(--banner-border-radius);

    backdrop-filter: var(--banner-backdrop-filter);
    -webkit-backdrop-filter: var(--banner-backdrop-filter);

    box-shadow: var(--banner-shadow);

    color: var(--banner-color);
    line-height: var(--game-line-height);

    overflow: auto;
    overscroll-behavior: contain;
}

.banner-box h3 {
    margin: 0 0 0.45em;
    color: var(--color-gold-light);
    font-size: 1.12em;
    line-height: 1.1;
}

.banner-close {
    position: absolute;
    top: 7px;
    right: 7px;

    width: 28px;
    height: 28px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 999px;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid rgba(246, 200, 76, 0.60);

    color: var(--color-gold-light);
    font-size: 18px;
    line-height: 1;

    transition:
        transform 160ms ease,
        filter 160ms ease;
}

.banner-close:hover {
    transform: scale(1.04);
    filter: brightness(1.08);
}

.banner-box.has-close {
    padding-right: 42px;
}

/*
|--------------------------------------------------------------------------
| Item buttons / selectable images
|--------------------------------------------------------------------------
*/

.items-row,
.items-grid,
.carousel-stage,
.drag-drop-stage,
.quiz-answers {
    position: relative;
    width: 100%;
}

.items-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2.5%;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: center;
    justify-items: center;
}

.game-item {
    position: relative;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 18px;

    transition: var(--item-transition);
    cursor: pointer;
    will-change: transform, filter;
}

.game-item img {
    width: 100%;
    height: auto;
    object-fit: contain;
    pointer-events: none;

    filter:
        drop-shadow(0 10px 18px rgba(0, 0, 0, 0.38))
        drop-shadow(0 0 12px rgba(246, 200, 76, 0.08));
}

.game-item:hover {
    transform: translateY(-2px) scale(1.015);
    filter: brightness(1.06);
}

.game-item:active {
    transform: translateY(1px) scale(0.985);
}

.game-item.is-selected {
    filter: brightness(1.55)
        drop-shadow(0px 0px 10px rgba(246, 200, 76, 1));
}

.game-item.is-correct,
.game-item.has-success-glow,
.has-success-glow {
    filter:
        brightness(1.52)
        drop-shadow(0px 0px 30px rgba(999, 999, 999, 0.98));
}

.game-item.is-disabled {
    opacity: 0.48;
    pointer-events: none;
}

/*
|--------------------------------------------------------------------------
| Level 2 drones
|--------------------------------------------------------------------------
*/

.level-2-drones {
    position: absolute;
    top: 38%;
    left: 6%;
    right: 6%;
    width: auto;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3%;
}

.level-2-drones .game-item {
    width: 30%;
    max-width: 160px;
}

/*
|--------------------------------------------------------------------------
| Carousel
|--------------------------------------------------------------------------
*/

.carousel-stage {
    position: absolute;
    top: 24%;
    left: 7%;
    width: 86%;

    display: flex;
    flex-direction: column;
    align-items: center;
}

.carousel-visual {
    position: relative;

    width: 76%;
    max-width: 330px;
    aspect-ratio: 1 / 1;

    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-slot {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;
    object-fit: contain;

    opacity: 0.92;
    pointer-events: none;
}

.carousel-item {
    position: relative;
    z-index: 2;

    width: 64%;
    max-width: 220px;

    transition:
        opacity 220ms ease,
        transform 220ms ease,
        filter 220ms ease;
}

.carousel-item img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.carousel-controls {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    z-index: 3;

    display: flex;
    justify-content: space-between;

    transform: translateY(-50%);
    pointer-events: none;
}

.carousel-arrow {
    width: 42px;
    height: 42px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 999px;

    background: rgba(5, 5, 8, 0.60);
    border: 1px solid rgba(246, 200, 76, 0.72);
    color: var(--color-gold-light);

    font-size: 30px;
    line-height: 1;

    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.38);

    pointer-events: auto;

    transition:
        transform 160ms ease,
        filter 160ms ease;
}

.carousel-arrow:hover {
    transform: scale(1.04);
    filter: brightness(1.1);
}

.carousel-description {
    margin-top: 12px;
    width: 100%;
}

.carousel-actions {
    margin-top: 12px;
    width: 100%;
}

/*
|--------------------------------------------------------------------------
| Drag and drop
|--------------------------------------------------------------------------
*/

.drag-drop-stage {
    position: absolute;
    top: 31%;
    left: 6%;
    width: 88%;

    display: flex;
    flex-direction: column;
    gap: 22px;
}

.draggable-items,
.drop-slots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3%;
}

.draggable-item,
.drop-slot {
    position: relative;

    width: 29%;
    aspect-ratio: 1 / 1;

    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.draggable-item {
    cursor: grab;
    touch-action: none;
}

.draggable-item:active {
    cursor: grabbing;
}

.draggable-item img,
.drop-slot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.drop-slot {
    border-radius: 18px;
    overflow: visible;
    flex: 0 0 auto;
}

/*
 * The slot background and the placed item must not participate in flex layout.
 * Otherwise, when an item is dropped into a slot, the slot can visually shift
 * and the placed item can appear behind the slot image.
 */
.drop-slot .slot-bg {
    position: absolute;
    inset: 0;
    z-index: 1;

    width: 100%;
    height: 100%;
    object-fit: contain;

    pointer-events: none;
}

.drop-slot .placed-item {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;

    width: 74%;
    height: 74%;
    object-fit: contain;

    transform: translate(-50%, -50%);
    pointer-events: none;

    filter:
        drop-shadow(0 8px 16px rgba(0, 0, 0, 0.42))
        drop-shadow(0 0 18px rgba(246, 200, 76, 0.18));
}

.drop-slot.is-active {
    filter: drop-shadow(0 0 18px rgba(246, 200, 76, 0.44));
}

.drop-slot.is-filled .slot-bg {
    opacity: 0.48;
}

.drag-clone {
    position: absolute;
    z-index: 100;

    width: 26%;
    pointer-events: none;

    transform: translate(-50%, -50%);
    filter:
        drop-shadow(0 12px 22px rgba(0, 0, 0, 0.45))
        drop-shadow(0 0 22px rgba(246, 200, 76, 0.42));
}

/*
|--------------------------------------------------------------------------
| Quiz
|--------------------------------------------------------------------------
*/

.quiz-box {
    width: 100%;
}

.quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 10px;

    margin-top: 14px;
}

.quiz-answer {
    width: 100%;
    min-height: 44px;

    padding: 11px 14px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 16px;

    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(246, 200, 76, 0.62);

    color: var(--color-text);
    text-align: center;
    line-height: 1.2;

    box-shadow: inset 0 0 18px rgba(246, 200, 76, 0.06);

    transition:
        transform 160ms ease,
        filter 160ms ease,
        border-color 160ms ease,
        background-color 160ms ease;
}

.quiz-answer:hover {
    transform: translateY(-1px);
    filter: brightness(1.07);
    border-color: rgba(246, 200, 76, 0.88);
}

.quiz-answer:active {
    transform: translateY(1px) scale(0.99);
}

.quiz-answer.is-selected {
    background: rgba(246, 200, 76, 0.16);
    border-color: rgba(246, 200, 76, 0.95);
}

/*
|--------------------------------------------------------------------------
| Reward overlay
|--------------------------------------------------------------------------
*/

.reward-stage {
    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;
}

.reward-image {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    object-fit: cover;

    filter:
        drop-shadow(0 0 28px rgba(246, 200, 76, 0.36))
        drop-shadow(0 0 58px rgba(246, 200, 76, 0.16));
}

.reward-button-wrap {
    position: absolute;
    left: 7%;
    bottom: 7%;
    width: 86%;
    z-index: 3;
}

/*
|--------------------------------------------------------------------------
| Level 6 balance scales
|--------------------------------------------------------------------------
*/

.balance-stage {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;
}

.scale-track {
    position: absolute;

    height: 5%;

    background: transparent;
    touch-action: none;
}

.scale-marker {
    position: absolute;
    top: 50%;
    left: 0;

    width: var(--scale-marker-width);
    height: var(--scale-marker-height);

    transform: translate(-50%, -50%);

    background: var(--scale-marker-background);
    border: var(--scale-marker-border);
    border-radius: var(--scale-marker-border-radius);
    box-shadow: var(--scale-marker-shadow);

    cursor: grab;
    touch-action: none;

    transition: var(--scale-marker-transition);
}

.scale-marker::after {
    content: "";

    position: absolute;
    left: 50%;
    bottom: -9px;

    width: 0;
    height: 0;

    transform: translateX(-50%);

    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 10px solid var(--color-gold);
    filter: drop-shadow(0 0 8px rgba(246, 200, 76, 0.74));
}

.scale-marker:active {
    cursor: grabbing;
    filter: brightness(1.1);
}

.scale-marker.is-on-target {
    filter:
        brightness(1.12)
        drop-shadow(0 0 18px rgba(246, 200, 76, 0.85));
}

/*
|--------------------------------------------------------------------------
| Debugger
|--------------------------------------------------------------------------
*/

.debugger-panel {
    background: rgba(0, 0, 0, 0.78);
    border: 1px solid rgba(246, 200, 76, 0.65);
    border-radius: 14px;

    color: var(--color-text);

    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.35;

    padding: 12px;

    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.58);
}

.debugger-panel pre {
    white-space: pre-wrap;
    word-break: break-word;
}

.debugger-toggle {
    width: 100%;

    margin-bottom: 8px;
    padding: 7px 9px;

    border-radius: 10px;

    background: rgba(5, 5, 8, 0.82);
    border: 1px solid rgba(246, 200, 76, 0.54);

    color: var(--color-gold-light);
    text-align: center;
}

.debugger-panel.is-collapsed {
    max-height: none;
    overflow: hidden;
}

.debugger-panel.is-collapsed .debugger-body {
    display: none;
}

/*
|--------------------------------------------------------------------------
| Interaction placeholder
|--------------------------------------------------------------------------
*/

.interaction-placeholder {
    width: 100%;
    min-height: 1px;
}

.interaction-placeholder-full {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.interaction-placeholder-multi {
    position: absolute;
    top: 30%;
    left: 8%;
    width: 84%;
}

/*
|--------------------------------------------------------------------------
| Debugger extra controls
|--------------------------------------------------------------------------
*/

.debugger-section {
    display: flex;
    flex-direction: column;
    gap: 8px;

    margin-top: 10px;
    padding-top: 10px;

    border-top: 1px solid rgba(246, 200, 76, 0.22);
}

.debugger-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.debugger-select {
    width: 100%;
    min-height: 34px;

    padding: 7px 9px;

    border-radius: 10px;
    border: 1px solid rgba(246, 200, 76, 0.54);

    background: rgba(0, 0, 0, 0.72);
    color: var(--color-text);

    font-family: inherit;
    font-size: 12px;
}
/*
|--------------------------------------------------------------------------
| Hard hide debugger outside debug rendering
|--------------------------------------------------------------------------
*/

.debugger-panel[hidden],
.debugger-panel.is-force-hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/*
|--------------------------------------------------------------------------
| Persistent scroll indicators for text-heavy boxes
|--------------------------------------------------------------------------
|
| Native mobile scrollbars are often hidden until the user starts scrolling.
| These wrapper-based indicators make long text boxes visibly scrollable:
| - persistent custom rail/thumb on the right;
| - bottom fade and animated down cue while more content remains below.
|
*/

.scroll-hint-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
}

.scroll-hint-wrap > .text-box,
.scroll-hint-wrap > .modal-box {
    width: 100%;
}

.scroll-hint-wrap.is-modal-scroll-hint {
    width: var(--modal-width);
    max-width: calc(100vw - 40px);
}

.scroll-hint-wrap.is-modal-scroll-hint > .modal-box {
    width: 100%;
}

.scroll-hint-rail,
.scroll-hint-fade,
.scroll-hint-cue {
    pointer-events: none;
    opacity: 0;
    transition: opacity 180ms ease;
}

.scroll-hint-rail {
    position: absolute;
    top: 14px;
    right: 8px;
    bottom: 38px;
    z-index: 12;

    width: 5px;
    min-height: 34px;

    border-radius: 999px;
    background: rgba(255, 255, 255, 0.13);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 0 12px rgba(246, 200, 76, 0.14);
}

.scroll-hint-thumb {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;

    min-height: 24px;

    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 224, 128, 0.98), rgba(246, 200, 76, 0.76));
    box-shadow: 0 0 10px rgba(246, 200, 76, 0.5);
    transform: translateY(0);
    transition: height 120ms ease, transform 80ms linear;
}

.scroll-hint-fade {
    position: absolute;
    left: 2px;
    right: 2px;
    bottom: -1px;
    z-index: 10;

    height: 46px;

    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 18px;
    background: linear-gradient(0deg, rgba(5, 5, 8, 0.92) 0%, rgba(5, 5, 8, 0.58) 45%, rgba(5, 5, 8, 0) 100%);
}

.scroll-hint-cue {
    position: absolute;
    left: 50%;
    bottom: 12px;
    z-index: 13;

    width: 22px;
    height: 22px;

    transform: translateX(-50%);
    border-radius: 999px;
    background: rgba(246, 200, 76, 0.14);
    box-shadow: 0 0 14px rgba(246, 200, 76, 0.22);
}

.scroll-hint-cue::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 6px;

    width: 8px;
    height: 8px;

    border-right: 2px solid rgba(255, 232, 166, 0.98);
    border-bottom: 2px solid rgba(255, 232, 166, 0.98);
    transform: rotate(45deg);
    animation: scrollHintCuePulse 950ms ease-in-out infinite;
}

.scroll-hint-wrap.is-scrollable .scroll-hint-rail {
    opacity: 1;
}

.scroll-hint-wrap.has-more .scroll-hint-fade,
.scroll-hint-wrap.has-more .scroll-hint-cue {
    opacity: 1;
}

.scroll-hint-wrap.is-not-scrollable .scroll-hint-rail,
.scroll-hint-wrap.is-not-scrollable .scroll-hint-fade,
.scroll-hint-wrap.is-not-scrollable .scroll-hint-cue,
.scroll-hint-wrap.is-at-end .scroll-hint-fade,
.scroll-hint-wrap.is-at-end .scroll-hint-cue {
    opacity: 0;
}

@keyframes scrollHintCuePulse {
    0%, 100% {
        transform: translateY(-2px) rotate(45deg);
        opacity: 0.65;
    }

    50% {
        transform: translateY(3px) rotate(45deg);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .scroll-hint-cue::before {
        animation: none;
    }
}

/*
|--------------------------------------------------------------------------
| Hide native scrollbar where custom scroll hints are active
|--------------------------------------------------------------------------
|
| Mobile browsers often hide/show native scrollbars inconsistently. The game
| uses its own persistent scroll rail/thumb for .text-box and .modal-box, so
| the browser scrollbar is hidden while native touch scrolling remains active.
|
*/

.text-box,
.modal-box {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.text-box::-webkit-scrollbar,
.modal-box::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none;
}
