/* style.css */

/* Basic body styling */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #2c3e50; /* Dark blue background */
    color: #ecf0f1; /* Light gray text */
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* Ensure it takes full viewport height */
    padding: 20px;
    box-sizing: border-box; /* Include padding in element's total width and height */
}
/* --- BATTLE ZONE STYLES --- */

#battle-zone {
    height: 120px; /* Increased height slightly for better visual */
    background-color: #2c3e50;
    border: 2px solid #a2d2ff;
    border-radius: 8px;
    margin-bottom: 15px;
    position: relative; 
    overflow: hidden; 
    display: block; 

    background-image: url('media/battlefield_nature.png'); 
    background-size: cover; 
    background-position: center bottom;
    background-repeat: no-repeat;
}


#middle-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    border-left: 3px dashed #a2d2ff; /* Dotted line style */
    transform: translateX(-1.5px); /* Center the line exactly */
}
/* This creates the movable, full-size grayscale layer */'
#battle-zone.theme-cleansed {
    background-image: url('battle-background-cleansed.png');
    background-size: cover; /* Ensures the image covers the entire zone */
    background-position: center bottom; /* Adjusts image to show ground at bottom */
    background-repeat: no-repeat;
}
/* Styles for the movable pollution overlay (the B&W effect) */
#battle-zone #battle-polluted-overlay {
    position: absolute;
    top: 0;
    
    /* --- NEW FIX: Anchor to the right and set initial width to 50% --- */
    left: auto; /* Ensure it's not anchored to the left */
    right: 0; /* Anchor the element to the right edge */
    width: 50%; /* It initially covers the right half of the battle-zone */

    height: 100%;
    
    /* This filter applies B&W to everything *behind* it */
    backdrop-filter: grayscale(100%);
    
    /* We don't need a static translate anymore */
    transform: none; 
    
    background-color: rgba(0, 0, 0, 0.2); /* Slight dark tint for "polluted" look */
    z-index: 5; /* Above background image, below characters */
    
    /* The transition is still needed for the win animation */
    transition: width 0.5s ease-out; 
}




#player-character, #enemy-character {
    width: 90px;  /* --- ADJUST SIZE --- */
    height: 90px; /* --- ADJUST SIZE --- */
    position: absolute; 
    
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
	/* Ensure the transition property is present for the JavaScript to control */
    transition: left 0.2s ease-out, right 0.0s ease-out, transform 0.0s ease-in-out, opacity 0.3s ease;
}

#player-character {
    background-image: url('media/player.png'); 
    left: 15%; 
}

#enemy-character {
    background-image: url('media/enemy.png'); 
    right: 15%; 
}
/* --- END BATTLE ZONE STYLES --- */

/* Projectile Styles */
.projectile {
    position: absolute;
    top: 35px; /* Adjust vertical position */
    opacity: 0; /* Hidden by default */
    
    /* NEW TEXT STYLES */
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 0.5em;
    font-weight: bold;
    white-space: nowrap; /* Keep answer on one line */
    border: 2px solid;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

#player-projectile {
    /* Player's projectile (Correct Answer) */
    background-color: #e0f7fa; /* Light cyan */
    color: #00796b; /* Dark green/cyan text */
    border-color: #26a69a;
  
}

#enemy-projectile {
    /* Enemy's projectile (Wrong Answer) */
    background-color: #ffebee; /* Light red */
    color: #c62828; /* Dark red text */
    border-color: #e57373;
   
}
/* Class applied by JS on win */
#player-character.conquering {
    animation: conquer-walk 0.5s linear forwards; /* 0.5s matches CLEANSING_ANIMATION_DURATION */
    z-index: 15; /* Ensure the player walks *over* the receding pollution overlay */
}

/* Animation classes to be added by JS */
.shoot-right {
    animation: shoot-right 0.3s ease-in forwards;
}
.shoot-left {
    animation: shoot-left 0.3s ease-in forwards;
}
/* --- KEYFRAME ANIMATIONS --- */

@keyframes shoot-right {
    from {
        opacity: 1;
        /* 'left' property will be set by JS */
    }
    to {
        opacity: 1;
        left: calc(85% - 80px); 
    }
}

@keyframes shoot-left {
    from {
        opacity: 1;
        /* 'right' property will be set by JS */
    }
    to {
        opacity: 1;
        right: calc(85% - 80px);
    }
}
/* Animation for the player to walk across the battle zone */
@keyframes conquer-walk {
    0% {
        left: 15%; /* Starting position */
    }
    100% {
        left: calc(85% - 90px); /* Ending position: Near the right edge. (85% is where the enemy starts, subtract character width of 90px) */
    }
}
/* --- PLAY AGAIN STYLES --- */

.hidden {
    display: none;
}

/* Main game container styling */
#game-container {
    background-color: #34495e; /* Slightly lighter dark blue */
    padding: 20px auto;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 600px; /* Limit width for better readability */
	min-height: 500px; /* Adjust as needed, but let content dictate height */
    width: 100%;
}

/* Player Stats Styling */
#player-stats {
    margin-bottom: 20px;
    font-size: 1.2em;
    color: #a2d2ff;
    border-bottom: 1px solid #3498db;
    padding-bottom: 10px;
}
#score-display {
    font-weight: bold;
    color: #2ecc71; /* Green for score */
}
#health-display {
    font-weight: bold;
    color: #e74c3c; /* Red for health */
}

/* Question text styling */
#question-text {
    font-size: 1.4em; /* Base size */
    margin-bottom: 10px;
    color: #a2d2ff; /* Lighter blue for question */
    min-height: 40px; /* Give it some space even when loading */
    line-height: 1.5; /* Adjust line height for fractions */
	word-break: break-word; /
}

/* Options container layout */
#options-container {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two columns */
    gap: 15px; /* Space between buttons */
    margin-bottom: 25px;
}


/* Option button styling */
.option-button {
    background-color: #3498db; /* Bright blue */
    color: white;
    border: none;
    padding: 10px 15px; /* Further adjust padding for fractions */
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    /* Ensure fractions inside buttons align */
    display: inline-flex; /* Use flex */
    align-items: center; /* Vertically center content */
    justify-content: center; /* Horizontally center content */
    min-height: 50px; /* Adjust min height if needed */
    line-height: 1; /* Reset line height for button itself */
    text-align: center; /* Ensure text alignment is center */
    vertical-align: middle; /* Try aligning the flex container */
}
.option-button sup {
    position: relative; /* Allow positioning relative to normal flow */
    top: -0.4em;       /* Adjust this value to visually raise the exponent */
    font-size: 0.75em; /* Keep exponent size smaller */
    line-height: 0;    /* Prevent sup from affecting button line height */
    vertical-align: baseline; /* Reset vertical-align, rely on 'top' */
    margin-left: 0.1em; /* Optional: slight space before exponent */
}
/* ... (Rest of button styles: hover, active, disabled) ... */
.option-button:hover:not(:disabled) { background-color: #2980b9; transform: translateY(-2px); }
.option-button:active:not(:disabled) { transform: translateY(0); }
.option-button:disabled { cursor: not-allowed; opacity: 0.6; }


/* ... (Rest of styles: feedback, next button, correct/incorrect) ... */
#feedback-message { font-size: 1.1em; margin-top: 15px; min-height: 30px; font-weight: bold; }
.option-button.correct { background-color: #27ae60; box-shadow: 0 0 15px rgba(39, 174, 96, 0.8); }
.option-button.incorrect { background-color: #c0392b; box-shadow: 0 0 15px rgba(192, 57, 43, 0.8); }


/* --- FRACTION STYLES --- */
.fraction {
    display: inline-flex; /* Changed to inline-flex */
    flex-direction: column;
    justify-content: center;
    vertical-align: middle; /* Important for alignment with other text */
    margin: 0 0.2em;
    line-height: 1; /* Keep fraction lines tight */
    text-align: center; /* Center numerator/denominator */
}

.numerator,
.denominator {
    display: block;
    text-align: center;
    padding: 0 0.3em;
    line-height: 1.1; /* Slightly increase line-height for readability */
}

.denominator {
    border-top: 1.5px solid currentColor;
    margin-top: 0.1em;
    padding-top: 0.1em;
}
/* --- Adjust Superscript Position in Denominator --- */
.denominator sup {
    position: relative; /* Allow positioning */
    top: 0.1em;       /* Move the exponent DOWN (adjust value as needed) */
    /* You can keep other sup styles or inherit them */
    font-size: 0.75em;
    line-height: 0;
    vertical-align: baseline;
    margin-left: 0.1em;
}

/* Adjust font size inside fractions */
.fraction .numerator,
.fraction .denominator {
    font-size: 0.9em; /* Keep slightly smaller */
}

/* Ensure superscript aligns well within fraction context */
.fraction sup {
    font-size: 0.75em; /* Keep superscript size relative */
    vertical-align: super;
    line-height: 0; /* Prevent sup from affecting line height */
}
/* General superscript styling */
sup {
    font-size: 0.75em;
    line-height: 0;
    position: relative; // Maybe add this globally too?
    top: -0.4em;        // Maybe add this globally too?
    vertical-align: baseline;
}
/* --- LEVEL SELECTOR STYLES --- */

#level-selector-container {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap; /* Allows it to stack on small screens */
    padding-bottom: 15px;
    border-bottom: 1px solid #3498db;
}

#level-selector-container label {
    font-size: 1.1em;
    color: #a2d2ff;
}

#level-select {
    background-color: #2c3e50; /* Dark background */
    color: white;
    border: 1px solid #3498db; /* Blue border */
    border-radius: 5px;
    padding: 5px;
    font-size: 1em;
}

/* --- LEVEL LIST MODAL STYLES --- */

/* Style for the "View Levels" button */
#show-levels-btn {
    background-color: #2c3e50; /* Dark background */
    color: #a2d2ff;
    border: 1px solid #a2d2ff; /* Light blue border */
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease;
}

#show-levels-btn:hover {
    background-color: #34495e;
    color: white;
}

/* The Modal (background overlay) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 10; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.6); /* Black w/ opacity */
}

/* Modal Content Box */
.modal-content {
    background-color: #34495e; /* Same as game container */
    margin: 10% auto; /* 10% from the top and centered */
    padding: 20px 30px;
    border: 1px solid #3498db;
    border-radius: 10px;
    width: 80%;
    max-width: 600px; /* Max width */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* The Close Button (X) */
.modal-close-btn {
    color: #a2d2ff;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.modal-close-btn:hover,
.modal-close-btn:focus {
    color: #ecf0f1;
    text-decoration: none;
    cursor: pointer;
}

#level-list-content {
    max-height: 400px; /* Make the list scrollable */
    overflow-y: auto;
    padding-right: 15px; /* Space for scrollbar */
    margin-top: 15px;
}

#level-list-content p {
    margin: 10px 0;
    font-size: 1.1em;
    padding-bottom: 5px;
    border-bottom: 1px solid #2c3e50;
}

#level-list-content strong {
    color: #a2d2ff; /* Light blue for level number */
    display: inline-block;
    width: 80px; /* Align skills */
}
/* --- MEDIA QUERIES FOR RESPONSIVENESS --- */

@media (max-width: 600px) {
    /* Make container padding slightly smaller on phones */
    #game-container {
        padding: 20px 15px;
    }

    /* Reduce question font size */
    #question-text {
        font-size: 1.5em; /* Smaller font for small screens */
        line-height: 1.4; /* Adjust line height */
    }

    /* * This is the main fix:
     * Stack option buttons vertically on small screens
     */
    #options-container {
        grid-template-columns: 1fr; /* One column, full width */
        gap: 12px; /* Slightly smaller gap */
    }

    /* Adjust button font size for better fit */
    .option-button {
        font-size: 1.0em; /* Slightly smaller font */
        padding: 12px 10px; /* Adjust padding */
    }

    /* Adjust level selector for better stacking */
    #level-selector-container {
        gap: 8px;
    }

    #level-selector-container label {
        font-size: 1.0em;
    }

    /* Make modal take up more of the screen */
    .modal-content {
        width: 90%;
        margin: 15% auto;
        padding: 20px 20px;
    }
}
/* --- NEW MAP STYLES --- */
#map-container {
    width: 100%;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #3498db;
    text-align: center;
}

#map-label {
    font-size: 1.1em;
    color: #a2d2ff;
    margin-bottom: 10px;
    font-weight: bold;
}

/* The "window" for our map */
#map-viewport {
    position: relative; /* This is crucial for absolute positioning children */
    width: 100%;
    height: 100px; /* Slightly taller to better fit the static map-tile */
    background-color: #2c3e50;
    border-radius: 8px;
    overflow: hidden; /* Hides parts off-screen */

    /* The static, full-color background map */
    background-image: url('media/map-tile.png');
    background-repeat: repeat; /* Repeat to fill the viewport */
    background-size: auto 100%; /* Maintain aspect ratio, fill height */
    background-position: left center; /* Start from left */
}

/* The player's icon on the map - now it moves! */
#map-player-marker {
    position: absolute;
    top: 50%; /* Vertically center */
    transform: translateY(-50%); /* Adjust for exact centering */
    
    /* ---Default start position, will be updated by JS --- */
    left: 30px; /* Start at the far left */

    width: 40px;
    height: 40px;
    background-image: url('media/player.png'); /* Your owl! */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    
    z-index: 10; /* Make sure it's above the overlay */
    transition: left 0.5s ease-out; /* Smooth movement for the owl */
}

/* This is the magic overlay for the B&W effect */
#map-bw-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    
    /* --- NEW: The B&W overlay starts fully covering, then its left edge moves right --- */
    left: 0; 
    width: 100%; /* Initially, the entire map is B&W */
    
    /* This turns everything behind it to grayscale */
    backdrop-filter: grayscale(100%);
    
    z-index: 5; /* Below the player marker */
    transition: transform 0.5s ease-out; /* Smooth movement for the overlay */
}
/* --- MAP MODAL STYLES --- */

/* We reuse the .modal style you already have */
#map-modal {
    display: none; /* Hidden by default */
    z-index: 20; /* Make sure it's on top */
}

/* Make the map container fill the modal width */
#map-modal #map-container {
    width: 100%;
    margin-bottom: 20px;
    padding-bottom: 0;
    border-bottom: none; 
}

/* Style for the new "Start Battle" button */
#start-battle-btn {
    background-color: #2ecc71; /* Green */
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-top: 10px;
    width: 100%;
}

#start-battle-btn:hover {
    background-color: #27ae60;
}