/* Sentence Scramble styles */

/* Definition modal styles */
.definition-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.definition-modal .modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
}

.definition-modal .close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
}

@keyframes background-flash {

    0%,
    100% {
        background: linear-gradient(45deg, #2c3e50, #000000);
        box-shadow: none;
    }

    50% {
        background: #00d9ff;
        box-shadow: 0 0 20px #00d9ff;
    }
}


/* Sentence Scramble game background (use scramble illustration as background) */
.sentence-scramble-game .game-area {
    background-image: url('../assets/images/sentence-scramble/sentence-scramble-bg.png');
}

/* Layout for new game-area sub-containers */
.game-area {
    display: flex;
    flex-direction: column;
}

.progress-bar-container {
    height: 50px;
}

/* spacing-div removed for sentence-scramble; kept in vowel-teams.css where needed */

.game-elements-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Bring containers above game-area background and add border */
.progress-bar-container,
.game-elements-container,
.sentence-scramble-game .progress-bar-container {
    position: relative;
    z-index: 10;
}

/* Ensure all game-area descendants are above background */
.game-area * {
    position: relative;
    z-index: 10;
}

/* Layout inside game-elements-container: two stacked panels */
.game-elements-container {
    display: flex;
    flex-direction: column;
    /* removed gap between child panels */
    height: 100%;
}

/* Layout for Sentence Scramble three-zone vertical layout */
.sentence-scramble-game .game-elements-container {
    display: flex;
    flex-direction: column;
    height: 95%;
}

/* Ensure progress bar has minimum height */
.sentence-scramble-game .progress-bar-container {
    /* fixed height for progress bar */
    height: 30px;
    min-height: 30px;
    position: relative;
    overflow: visible;
    /* allow rabbit/turtle to show off-screen */
}

/* Place the main game elements above other background layers but below UI chrome */
.sentence-scramble-game .game-elements-container {
    z-index: 5;
    position: relative;
}

.sentence-scramble-game .game-elements-container .image-display {
    /* Make image display vertically flexible */
    flex: 1 1 auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(145deg, #00000063, #00000063);
}

/* Make drop zone height fit content, not fixed percentage */
.sentence-scramble-game .game-elements-container .sentence-drop-zone {
    flex: 0 0 auto;
    height: fit-content;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.sentence-scramble-game .game-elements-container .scramble-sentence {
    flex: 0 0 20%;
    height: 20%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.sentence-scramble-game .image-display img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sentence-scramble-game .image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    padding: 12px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

/* Drop zone and scramble tile styling for Sentence Scramble */
.sentence-scramble-game .sentence-drop-zone {
    border: 2px dashed rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.6);
    padding: 4px;
    box-sizing: border-box;
    min-height: 60px;
}

.sentence-scramble-game .sentence-drop-zone .drop-placeholder {
    color: rgba(0, 0, 0, 0.5);
    font-style: italic;
}

/* Ensure these styles apply even if .sentence-scramble-game wrapper is missing */
.game-elements-container .sentence-drop-zone .drop-placeholder,
.sentence-drop-zone .drop-placeholder {
    color: rgba(0, 0, 0, 0.6);
    font-style: italic;
}

.sentence-scramble-game .scrambled-text {
    width: 100%;
    padding: 6px 8px;
    color: #333;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.8);
    text-align: left;
    margin-bottom: 8px;
    border-radius: 4px;
}

.game-elements-container .scrambled-text,
.scrambled-text {
    width: 100%;
    padding: 6px 8px;
    color: #222;
    font-weight: 700;
    background: transparent;
    text-align: left;
    margin-bottom: 8px;
}

.sentence-scramble-game .scrambled-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
    justify-content: center;
}

.game-elements-container .scrambled-tiles,
.scrambled-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
    justify-content: center;
}

.sentence-scramble-game .scramble-sentence {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    align-items: center;
    justify-content: flex-start;
}

.sentence-scramble-game .scramble-word {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: linear-gradient(145deg, #ffffff, #f1f1f1);
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    cursor: grab;
    user-select: none;
    font-weight: 600;
    text-transform: none;
}

.game-elements-container .scramble-word,
.scramble-word {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: linear-gradient(145deg, #ffffff, #f1f1f1);
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    cursor: grab;
    user-select: none;
    font-weight: 600;
    color: #000;
}

.sentence-scramble-game .scramble-word:active {
    cursor: grabbing;
}

/* Keyboard focus for scramble words */
.sentence-scramble-game .scramble-word:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
}

.sentence-scramble-game .sentence-drop-zone .scramble-word {
    background: linear-gradient(145deg, #90d5ff, #d1ecff);
}


.game-elements-container .element-container {
    box-sizing: border-box;
    /* allow inner content to scroll if needed */
    overflow: auto;
}

.game-area {
    /* Generic game area style if needed, specific background handled above */
    position: relative;
    flex-grow: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}



/* Responsive grid for vowel teams selection */

.ss-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(80px, auto);
    gap: 10px;
    width: 100%;
    /* following style is to keep selection item scrollable and prevent their container from pushing inline ads down when opening the page */
    height: 35vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
}

/* Mobile override: smaller row height for selection grid */
@media (max-width: 600px) {


    .ss-grid {
        grid-auto-rows: 60px;
    }
}


@media (max-width: 600px) {

    .sentence-scramble-game .scramble-word,
    .scramble-word {
        padding: 4px 6px;
    }

    /* Increase word tile font size from 0.9rem to 1rem on mobile */
    .sentence-scramble-game .scramble-word {
        font-size: 1rem;
    }

    /* Increase drop placeholder font size */
    .sentence-scramble-game .sentence-drop-zone .drop-placeholder {
        font-size: 1rem;
    }
}


/* Cute colorful street style for progress bar */
.progress-bar-container {
    background: #333;
    /* darker asphalt street */
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.progress-bar-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(to right,
            #fff,
            #fff 20px,
            rgba(255, 255, 255, 0) 20px,
            rgba(255, 255, 255, 0) 40px);
    transform: translateY(-50%);
}

/* Progress bar vehicle and finish line styling */
.progress-bar-container .progress-car,
.progress-bar-container .progress-finish {
    width: auto;
}

/* Specific heights for car and finish line */
.progress-bar-container .progress-car {
    height: 40px;
    /* start further off-screen */
    transform: translateX(-60%);
}

.progress-bar-container .progress-finish {
    height: 60px;
}

/* Alias the same progress bar visuals for Sentence Scramble (ss-) so the
   game area shows the original road/car/finishline look without modifying
   the vowel-teams rules. This keeps visual parity while using ss- IDs. */
.sentence-scramble-game .progress-bar-container,
.sentence-scramble-game #ss-progressBarContainer {
    background: #333;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sentence-scramble-game .progress-bar-container::before,
.sentence-scramble-game #ss-progressBarContainer::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(to right,
            #fff,
            #fff 20px,
            rgba(255, 255, 255, 0) 20px,
            rgba(255, 255, 255, 0) 40px);
    transform: translateY(-50%);
}

.sentence-scramble-game .progress-bar-container .progress-car,
.sentence-scramble-game #ss-progressBarContainer .progress-car,
.sentence-scramble-game .progress-bar-container .progress-finish,
.sentence-scramble-game #ss-progressBarContainer .progress-finish {
    width: auto;
}

/* Legacy progress-car rules removed */

.sentence-scramble-game .progress-bar-container .progress-finish,
.sentence-scramble-game #ss-progressBarContainer .progress-finish {
    /* finish line at right edge */
    position: absolute;
    top: 0;
    right: 0;
    height: 30px;
    width: auto;
    z-index: 5;
}

/* Position and size rabbit and turtle at start of progress bar */
/* Position and size turtle at start of progress bar */
.sentence-scramble-game .progress-bar-container .progress-turtle {
    position: absolute;
    top: 0;
    left: 0;
    height: 30px;
    width: auto;
    z-index: 3;
    filter: drop-shadow(5px 5px 5px #222);
    /* Smooth slide when turtle position changes */
    transition: transform 900ms linear;
    will-change: transform;
}

/* Position rabbit above turtle */
.sentence-scramble-game .progress-bar-container .progress-rabbit {
    position: absolute;
    top: 0;
    left: 0;
    height: 30px;
    width: auto;
    z-index: 4;
    filter: drop-shadow(5px 5px 5px #222);
    /* Smooth slide when rabbit position changes */
    transition: transform 420ms cubic-bezier(.2, .8, .2, 1);
    will-change: transform;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Alias styles for Sentence Scramble tiles: keep visual parity with .vowel-team-box */
.topics-tenses-box {
    background-color: #ccc;
    color: #555;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    cursor: pointer;
    font-size: clamp(1em, 3vw, 1.8em);
    font-weight: 600;
    font-family: 'CustomMain', Arial, sans-serif;
    text-transform: uppercase;
    transition: background-color 0.2s ease, transform 0.1s ease;
    user-select: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* Info button styling to mirror parts-of-speech selection */
.topics-tenses-box .info-button {
    position: absolute;
    top: -8px;
    right: -8px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
}

.ss-selection-screen {
    /* inherit the same layout/spacing as the original vowel-selection-screen */
    --ss-alias-placeholder: 1;
}

.ss-selection-screen,
.ss-selection-screen * {
    /* No-op aliasing: keep existing rules that target .vowel-selection-screen by not changing specificity.
       If later we need to override, we can add explicit rules here. */
    --ss-alias-placeholder: 1;
}

.topics-tenses-box.selected {
    background: linear-gradient(90deg, #3498db, #2980b9);
    color: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.topics-tenses-box:hover:not(.selected) {
    background-color: #bbb;
    transform: scale(1.03);
}

/* Ensure grid cells size similarly to the original vowel-team-box behavior */
.topics-tenses-box,
.ss-grid .topics-tenses-box {
    width: 100%;
    height: 100%;
    white-space: normal;
    padding: clamp(5px, 1vw, 10px);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-size: clamp(0.8rem, 2vw, 1.1rem);
    line-height: 1.2;
    word-break: break-word;
    hyphens: auto;
    font-family: Arial, sans-serif;
    aspect-ratio: auto !important;
}

/* Ensure sentence-scramble grid tiles use capitalization regardless of global rules */
.ss-grid .topics-tenses-box {
    text-transform: capitalize !important;
}

@media (min-width: 601px) {
    .topics-tenses-box {
        width: 95%;
        margin: 0 auto;
    }
}
