/* map-game.css - Interactive map skills game styles */

.map-game-wrapper {
    background: #f3f4f6;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 2rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.map-game-layout {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

@media (min-width: 900px) {
    .map-game-layout {
        flex-direction: row;
        align-items: stretch;
    }
}

/* Map Grid Constraints */
.map-grid-container {
    flex: 1;
    position: relative;
    background: #e5e7eb; /* Light gray */
    border-radius: 12px;
    padding: 3rem 2rem 4rem 5.5rem; /* Room for axes (top right bottom left) */
    min-height: 450px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.map-grid {
    position: relative;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1;
    background: #fdfbf7; /* Topographic cream */
    border: 3px solid #334155;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    container-type: inline-size;
}

/* Internal grid lines - Blue lines typical of Eastings/Northings */
.map-grid-cell {
    border-right: 2px solid #60a5fa;
    border-top: 2px solid #60a5fa;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}
.map-grid-cell:nth-child(4n) { border-right: none; }
.map-grid-cell:nth-child(-n+4) { border-top: none; }

.map-grid-cell:hover {
    background: rgba(139, 92, 246, 0.15);
}

.map-grid-cell.highlight {
    background: rgba(139, 92, 246, 0.3);
    border: 3px solid #7c3aed;
    z-index: 2;
}

.map-grid-cell.correct {
    background: rgba(34, 197, 94, 0.4) !important;
    border: 4px solid #16a34a !important;
}
.map-grid-cell.wrong {
    background: rgba(239, 68, 68, 0.4) !important;
    animation: shake 0.4s;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

/* Axis Labels */
.axis-label {
    position: absolute;
    font-size: clamp(0.75rem, 4cqi, 1.1rem);
    font-weight: 800;
    color: #000000; /* pure black */
    background: rgba(255,255,255,0.7);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

/* Eastings (Bottom) */
.easting {
    bottom: -2.3rem;
    transform: translateX(-50%);
}
/* Northings (Left) */
.northing {
    left: -2.8rem;
    transform: translateY(50%);
}

/* Axis Titles */
.axis-title {
    position: absolute;
    font-size: clamp(0.6rem, 3.5cqi, 0.9rem);
    font-weight: 900;
    color: #000000;
    letter-spacing: 2px;
    white-space: nowrap;
}
.easting-title {
    bottom: -4rem;
    left: 50%;
    transform: translateX(-50%);
}
.northing-title {
    left: -4.5rem;
    top: 50%;
    transform: translate(-50%, -50%) rotate(-90deg);
}

/* Items on Map */
.map-item {
    position: absolute;
    font-size: clamp(1rem, 7cqi, 1.4rem);
    transform: translate(-50%, 50%);
    z-index: 10;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Explicit red center-point so students know exactly where the coordinate is */
.map-item::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: #ef4444; /* bright red */
    border: 1px solid white;
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
}

/* Tenths Sub-grid (for 6-figure) */
.sub-grid {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    background-size: 10% 10%;
    background-image: 
        linear-gradient(to right, rgba(139, 92, 246, 0.35) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(139, 92, 246, 0.35) 1px, transparent 1px);
    pointer-events: none;
}
.sub-grid.active {
    display: block;
}

/* Coordinates overlay */
.coord-tooltip {
    position: absolute;
    background: #0f172a;
    color: #f8fafc;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    transform: translate(-50%, -150%);
    z-index: 20;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
}

/* Panel Styles */
.map-game-panel {
    flex: 1;
    background: #f1f5f9; /* changed from white to light gray-blue */
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.game-header {
    background: #e2e8f0;
    padding: 1.25rem 1.75rem;
    border-bottom: 2px solid #cbd5e1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: #000000;
    font-weight: 800;
}

.game-score {
    background: #8b5cf6;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 700;
}

.game-body {
    padding: 1.75rem;
    flex: 1;
    font-size: 1.15rem; /* Larger text for readability */
    color: #000000; /* Pure black */
    line-height: 1.7;
}

/* Force global <p> tags inside game to be black */
.game-body p {
    color: #000000 !important;
}

.game-body-title {
    color: #000000;
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
    font-weight: 800;
}

.rule-box {
    background: #e2e8f0;
    border-left: 6px solid #f59e0b;
    padding: 1.25rem;
    margin: 1.25rem 0;
    border-radius: 0 8px 8px 0;
    color: #000000;
    font-weight: 500;
}

/* Options for Multiple Choice */
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.75rem;
}

.quiz-option {
    background: #f8fafc;
    border: 2px solid #94a3b8;
    padding: 1rem 1.25rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    font-size: 1.1rem;
    text-align: left;
    color: #000000;
}

.quiz-option:hover {
    background: #f1f5f9;
    border-color: #64748b;
}

.quiz-option.active-select {
    background: rgba(139, 92, 246, 0.15);
    border-color: #8b5cf6;
    color: #6d28d9;
}

.quiz-option.correct {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #14532d;
}

.quiz-option.wrong {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #7f1d1d;
}

.game-actions {
    padding: 1.5rem 1.75rem;
    border-top: 2px solid #cbd5e1;
    display: flex;
    justify-content: space-between;
    background: #f1f5f9;
    gap: 1rem;
}

.game-actions button {
    white-space: nowrap;
    flex: 1; /* allow buttons to grow and fit equally */
    text-align: center;
    max-width: fit-content;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .map-grid-container {
        padding: 2.5rem 1.5rem 1.5rem 2.5rem;
        min-height: 300px;
    }
    .axis-label {
        font-size: 0.9rem;
    }
    .map-item {
        font-size: 1.2rem;
    }
}
@media (max-width: 480px) {
    .map-grid-container {
        padding: 2.5rem 1.5rem 3.5rem 4rem;
    }
    .axis-title {
        font-size: 0.85rem;
    }
    .easting-title {
        bottom: -3.5rem;
    }
    .northing-title {
        left: -3rem;
    }
    .easting {
        bottom: -1.6rem;
    }
    .northing {
        left: -1.8rem;
    }
    .game-actions {
        padding: 1rem 1rem;
        gap: 0.5rem;
    }
    .game-actions button {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    .quiz-option {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }
}
