/**
 * Language Map Activity Styles
 * Interactive drag-and-drop map for matching flags/languages to countries
 */

/* ===== Activity Container Override ===== */
.activity-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Start Overlay ===== */
.start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(250, 251, 252, 0.98) 0%, rgba(245, 247, 250, 0.98) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    padding: 1rem;
}

.start-overlay.hidden {
    display: none;
}

.start-content {
    text-align: center;
    padding: 1.25rem 1.5rem;
    background: var(--bg-section);
    border-radius: var(--radius-large);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-width: 340px;
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.start-icon {
    font-size: 2.5rem;
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
}

.start-title {
    font-family: 'Baloo 2', cursive;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.start-text {
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.start-btn {
    margin-top: 0.25rem;
}

/* ===== Map Selector ===== */
.map-selector-container {
    margin: 1rem 0;
}

.map-selector-label {
    display: block;
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.map-selector {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-medium);
    border: 2px solid var(--border-color);
    background-color: white;
    color: var(--text-dark);
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.map-selector:hover {
    border-color: var(--primary-blue);
}

.map-selector:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.map-selector option {
    padding: 0.5rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== Layout ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    padding: 1rem;
    min-height: 0;
    overflow: visible;
}

.map-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    min-width: 0;
    z-index: 1;
}

.tray-section {
    width: 180px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    z-index: 2;
    overflow: visible;
}

/* ===== Map Container ===== */
.map-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-section);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-soft);
    padding: 1rem;
    overflow: hidden;
}

.map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 3rem;
    color: var(--text-muted);
    font-family: 'Nunito', sans-serif;
}

.map-loading.hidden {
    display: none;
}

.map-svg {
    width: 100%;
    height: auto;
    display: block;
    max-height: 50vh;
}

/* ===== Country Styling ===== */
.country {
    fill: #E8EDF2;
    stroke: #B8C4D0;
    stroke-width: 0.5;
    transition: fill 0.2s ease, stroke 0.2s ease, stroke-width 0.15s ease;
    cursor: pointer;
}

.country:hover {
    fill: #D0DCE8;
    stroke: var(--primary-blue);
    stroke-width: 1;
}

/* Valid drop target during drag */
.country.valid-drop {
    fill: #FFF3CD;
    stroke: #FFC107;
    stroke-width: 1.5;
    animation: pulseCountry 1s ease-in-out infinite;
}

@keyframes pulseCountry {
    0%, 100% { fill: #FFF3CD; }
    50% { fill: #FFE69C; }
}

/* Active drop hover */
.country.drop-active {
    fill: var(--correct-bg);
    stroke: var(--correct-green);
    stroke-width: 2;
}

/* Country has correct placement */
.country.has-placement {
    fill: #D4EDDA;
    stroke: #28A745;
    stroke-width: 1;
}

/* Incorrect placement flash */
.country.incorrect-flash {
    fill: var(--incorrect-bg);
    stroke: var(--incorrect-red);
    animation: countryShake 0.5s ease;
}

@keyframes countryShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* ===== Country Labels ===== */
.country-label {
    font-family: 'Nunito', sans-serif;
    font-size: 8px;
    font-weight: 600;
    fill: var(--text-muted);
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: middle;
}

/* ===== Targeting Dot ===== */
/* Small dot on dragged items showing exact drop point */
.targeting-dot {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-blue);
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.map-item.dragging .targeting-dot {
    opacity: 1;
}

/* Dot turns green when over a valid country */
.targeting-dot.over-valid {
    background: var(--correct-green);
}

/* ===== Success Message ===== */
.success-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(145deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-radius: var(--radius-round);
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    margin-top: 0.75rem;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
    animation: slideUp 0.3s ease-out;
}

.success-message.hidden {
    display: none;
}

.success-message i {
    font-size: 1.2rem;
    color: #28a745;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Items Tray ===== */
.items-tray {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    padding: 0.75rem;
    background: linear-gradient(180deg, #f8f9fa 0%, #fff 100%);
    border: dashed 3px var(--primary-blue);
    border-radius: var(--radius-large);
    flex: 1;
    overflow: visible;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.items-tray:empty::after {
    content: 'All done!';
    color: var(--correct-green);
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    text-align: center;
    padding: 1rem;
}

/* ===== Draggable Items ===== */
.map-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-round);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: grab;
    user-select: none;
    touch-action: none;
    box-shadow: var(--shadow-button);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
}

.map-item:hover:not(.dragging) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-button-hover);
}

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

.map-item.dragging {
    position: relative;
    cursor: grabbing;
    opacity: 0.95;
    z-index: 9999 !important;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
    transition: none; /* Disable transition during drag for smooth movement */
    /* Note: transform is set dynamically by interact.js during drag */
}

/* Flag items - purple/pink gradient */
.map-item.flag-item {
    background: linear-gradient(145deg, var(--primary-purple) 0%, var(--primary-pink) 100%);
    color: white;
}

.map-item.flag-item .flag-img {
    width: 24px;
    height: auto;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Language items - orange/yellow gradient */
.map-item.language-item {
    background: linear-gradient(145deg, var(--primary-orange) 0%, var(--primary-yellow) 100%);
    color: var(--text-dark);
}

.map-item .item-name {
    font-size: 0.9rem;
}

/* ===== Placed Pins on Map ===== */
.placed-pin {
    position: absolute;
    z-index: 10;
    pointer-events: none;
    animation: pinDrop 0.3s ease-out;
}

.placed-pin.flag-pin {
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.placed-pin.flag-pin .flag-img {
    width: 28px;
    height: auto;
    border-radius: 2px;
    display: block;
}

.placed-pin.language-pin {
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, var(--primary-orange), var(--primary-yellow));
    color: var(--text-dark);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-medium);
    font-family: 'Nunito', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

@keyframes pinDrop {
    0% {
        transform: translate(-50%, -150%) scale(1.3);
        opacity: 0;
    }
    60% {
        transform: translate(-50%, -40%) scale(0.95);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Multiple pins stacking */
.placed-pin[data-stack="1"] { transform: translate(-50%, -50%); }
.placed-pin[data-stack="2"] { transform: translate(-30%, -70%); }
.placed-pin[data-stack="3"] { transform: translate(-70%, -70%); }
.placed-pin[data-stack="4"] { transform: translate(-50%, -90%); }

/* ===== Score Badge Enhancement ===== */
.header-score {
    min-width: 70px;
    text-align: center;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .map-section {
        flex: none;
    }

    .tray-section {
        width: 100%;
        flex: none;
    }

    .items-tray {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.75rem;
        flex: none;
        min-height: 60px;
        overflow-y: visible;
    }

    .map-container {
        padding: 0.5rem;
        border-radius: var(--radius-medium);
    }

    .map-svg {
        max-height: 40vh;
    }

    .map-item {
        font-size: 0.85rem;
        padding: 0.4rem 0.75rem;
    }

    .map-item .flag-img {
        width: 20px;
    }

    .placed-pin.flag-pin .flag-img {
        width: 22px;
    }

    .placed-pin.language-pin {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
    }

    .country-label {
        font-size: 6px;
    }

    .success-message {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 480px) {
    .map-item {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }

    .map-item .item-name {
        font-size: 0.8rem;
    }
}

/* ===== Fullscreen Adjustments ===== */
:fullscreen .map-section,
:-webkit-full-screen .map-section {
    padding: 1.5rem;
}

:fullscreen .map-svg,
:-webkit-full-screen .map-svg {
    max-height: 60vh;
}

:fullscreen .map-container,
:-webkit-full-screen .map-container {
    max-width: 1100px;
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    .country.valid-drop {
        animation: none;
    }

    .placed-pin {
        animation: none;
    }

    .country.incorrect-flash {
        animation: none;
    }
}

/* Focus styles for keyboard navigation */
.map-item:focus {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

.country:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 1px;
}
