/**
 * Activity Common Styles
 * Shared styles for all learning activities
 * Based on MFL lesson playful, colorful design
 */

/* ===== Design System Variables ===== */
:root {
    /* Primary Colors - Soft, child-friendly palette */
    --primary-blue: #5B9BD5;
    --primary-purple: #9B7EBD;
    --primary-green: #7CB97C;
    --primary-orange: #F5A962;
    --primary-red: #E87B73;
    --primary-pink: #E9A0C3;
    --primary-yellow: #F9D56E;
    --primary-teal: #6BC5C5;

    /* Neutral Colors */
    --bg-cream: #FAFBFC;
    --bg-section: #FFFFFF;
    --text-dark: #3D4852;
    --text-muted: #8A9BA8;

    /* Shadows - Softer shadows */
    --shadow-soft: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-button: 0 4px 0 rgba(0,0,0,0.1);
    --shadow-button-hover: 0 6px 0 rgba(0,0,0,0.1);
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.08);

    /* Border Radius */
    --radius-large: 20px;
    --radius-medium: 14px;
    --radius-small: 10px;
    --radius-round: 50px;

    /* Feedback Colors - Softer feedback colors */
    --correct-green: #7CB97C;
    --correct-bg: #E8F5E9;
    --incorrect-red: #E87B73;
    --incorrect-bg: #FFEBEE;
    --warning-yellow: #F9D56E;
}

/* ===== Base Typography ===== */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Nunito:wght@400;600;700&display=swap');

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg-cream);
    background-image: linear-gradient(135deg, #f5f7fa 0%, #f8f9fb 100%);
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text-dark);
}

/* ===== Activity Container ===== */
.activity-container {
    min-height: 100vh;
    padding: 1rem;
    padding-bottom: 2rem;
}

/* ===== Header Styles ===== */
.activity-header {
    background: var(--bg-section);
    border-radius: var(--radius-large) !important;
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border: none !important;
}

.activity-instructions {
    font-family: 'Baloo 2', cursive;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-purple);
    flex: 1;
    min-width: 200px;
}

.controls-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

/* ===== Button Styles ===== */
.btn-activity {
    background: var(--bg-cream);
    border: 3px solid transparent;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-round);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-dark);
}

.btn-activity:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-activity.active,
.btn-activity:focus {
    background: var(--primary-blue);
    color: white;
}

/* Primary action buttons */
.btn-primary-activity {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-teal) 100%);
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: var(--radius-round);
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: var(--shadow-button), 0 4px 12px rgba(91, 155, 213, 0.25);
}

.btn-primary-activity:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-button-hover), 0 6px 16px rgba(91, 155, 213, 0.3);
}

.btn-primary-activity:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

/* Success button */
.btn-success-activity {
    background: linear-gradient(135deg, var(--primary-green) 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.75rem;
    border-radius: var(--radius-round);
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}

.btn-success-activity:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 0 rgba(0,0,0,0.2);
}

/* Control buttons (smaller, for header) */
.btn-control {
    background: linear-gradient(180deg, #f5f5f5 0%, #e0e0e0 100%);
    border: 2px solid #ddd;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-round);
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-dark);
    box-shadow: 0 3px 0 rgba(0,0,0,0.1);
}

.btn-control:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 rgba(0,0,0,0.1);
    background: linear-gradient(180deg, #fff 0%, #f0f0f0 100%);
}

.btn-control:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.btn-control i {
    margin-right: 0.35rem;
}

/* Button group styling */
.btn-group-activity {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===== Feedback States ===== */
.correct {
    border-color: var(--correct-green) !important;
    background-color: var(--correct-bg) !important;
}

.incorrect {
    border-color: var(--incorrect-red) !important;
    background-color: var(--incorrect-bg) !important;
}

.correct-border {
    border: 4px solid var(--correct-green) !important;
}

.incorrect-border {
    border: 4px solid var(--incorrect-red) !important;
}

/* ===== Progress Indicator ===== */
.progress-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 1rem;
    flex-wrap: wrap;
}

.progress-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #e0e0e0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.1);
}

.progress-dot.active {
    transform: scale(1.3);
    box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--primary-blue);
}

.progress-dot.viewed {
    background: linear-gradient(135deg, var(--warning-yellow) 0%, var(--primary-orange) 100%);
}

.progress-dot.mastered,
.progress-dot.completed {
    background: linear-gradient(135deg, var(--correct-green) 0%, #20c997 100%);
}

/* ===== Activity Card Base ===== */
.activity-card {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-purple) 100%);
    color: #fff;
    border: 4px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-medium);
    touch-action: none;
    user-select: none;
    box-shadow: var(--shadow-card);
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
}

.activity-card:hover,
.activity-card:focus {
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
    transform: translateY(-4px);
}

.activity-card:active {
    transform: translateY(-2px);
}

/* ===== Timer Styles ===== */
.timer-container {
    text-align: center;
    margin-bottom: 1rem;
}

.timer-badge {
    display: inline-block;
    background: var(--bg-section);
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-round);
    font-family: 'Baloo 2', cursive;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-blue);
    box-shadow: var(--shadow-soft);
}

.timer-container.warning .timer-badge {
    background: var(--warning-yellow);
    color: var(--text-dark);
}

.timer-container.danger .timer-badge {
    background: var(--incorrect-red);
    color: white;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.05); }
}

/* ===== Score Display ===== */
.score-container {
    text-align: center;
    margin-bottom: 1rem;
}

.score-badge {
    display: inline-block;
    background: var(--bg-section);
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-round);
    font-family: 'Baloo 2', cursive;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-green);
    box-shadow: var(--shadow-soft);
}

/* ===== Audio Button ===== */
.audio-btn {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-small);
    cursor: pointer;
    transition: all 0.2s;
}

.audio-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.audio-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.audio-btn.playing {
    animation: audioPlaying 0.5s ease-in-out infinite;
}

@keyframes audioPlaying {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ===== Drag-Drop Zones ===== */
.takezone,
.dropzone-area {
    background: var(--bg-section);
    border: dashed 4px var(--primary-blue);
    border-radius: var(--radius-large);
    padding: 1.25rem;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: all 0.3s;
    box-shadow: var(--shadow-soft);
}

.takezone {
    background: linear-gradient(180deg, #e3f2fd 0%, #fff 100%);
}

.dropzone-area {
    background: linear-gradient(180deg, #f3e5f5 0%, #fff 100%);
    border-color: var(--primary-purple);
}

/* ===== Draggable Items ===== */
.drag-item {
    width: 100%;
    max-width: 300px;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-purple) 100%);
    color: #fff;
    border: 3px solid rgba(255,255,255,0.4);
    border-radius: var(--radius-medium);
    touch-action: none;
    user-select: none;
    box-shadow: 0 4px 0 rgba(0,0,0,0.15), var(--shadow-card);
    text-align: center;
    font-family: 'Nunito', sans-serif;
    font-size: 1.15em;
    font-weight: 600;
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.drag-item:hover {
    box-shadow: 0 6px 0 rgba(0,0,0,0.15), 0 10px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(-3px);
}

.drag-item.dragging {
    opacity: 0.95;
    cursor: grabbing;
    z-index: 1000;
    transform: scale(1.05);
    box-shadow: 0 12px 35px rgba(0,0,0,0.3);
}

.drag-item.matched {
    background: linear-gradient(135deg, var(--correct-green) 0%, #20c997 100%);
    cursor: default;
    pointer-events: none;
}

.drag-item img {
    max-width: 60px;
    max-height: 60px;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ===== Drop Targets ===== */
.drop-target {
    width: 100%;
    max-width: 300px;
    padding: 1rem 1.25rem;
    min-height: 75px;
    background: var(--bg-section);
    border: dashed 3px #bbb;
    border-radius: var(--radius-medium);
    text-align: center;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
}

.drop-target img {
    max-width: 80px;
    max-height: 80px;
    border-radius: 8px;
    object-fit: contain;
}

.drop-target.drop-active {
    background-color: var(--correct-bg);
    border-color: var(--correct-green);
    border-style: solid;
    transform: scale(1.02);
}

.drop-target.matched {
    background-color: var(--correct-bg);
    border: solid 3px var(--correct-green);
}

.drop-target.incorrect {
    background-color: var(--incorrect-bg);
    border: solid 3px var(--incorrect-red);
    animation: shake 0.5s ease;
}

/* ===== Shake Animation ===== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-8px) rotate(-1deg); }
    30% { transform: translateX(8px) rotate(1deg); }
    45% { transform: translateX(-6px); }
    60% { transform: translateX(6px); }
    75% { transform: translateX(-3px); }
    90% { transform: translateX(3px); }
}

/* ===== Bounce Animation ===== */
@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ===== Modal Enhancements ===== */
.modal-content {
    border-radius: var(--radius-large);
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-body {
    padding: 2rem;
}

.completion-icon {
    font-size: 5rem;
    margin-bottom: 1.5rem;
}

.completion-icon.success {
    color: var(--warning-yellow);
    animation: starBounce 0.7s ease-out;
}

.completion-icon.timeout {
    color: var(--text-muted);
}

@keyframes starBounce {
    0% { transform: scale(0) rotate(-20deg); }
    50% { transform: scale(1.2) rotate(10deg); }
    70% { transform: scale(0.9) rotate(-5deg); }
    100% { transform: scale(1) rotate(0); }
}

.completion-message {
    font-family: 'Baloo 2', cursive;
    font-size: 1.5rem;
    color: var(--text-dark);
}

/* ===== Section Cards ===== */
.section-card {
    background: var(--bg-section);
    border-radius: var(--radius-large);
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: 1.5rem;
}

.section-title {
    font-family: 'Baloo 2', cursive;
    font-size: 1.75rem;
    color: var(--primary-purple);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Zone Labels ===== */
.zone-label {
    font-family: 'Baloo 2', cursive;
    font-size: 1rem;
    color: var(--primary-purple);
    margin-bottom: 0.5rem;
}

.zone-label .badge {
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-pink) 100%);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-round);
    font-weight: 600;
    font-size: 0.85rem;
}

/* ===== Mobile Warning ===== */
.mobile-hint {
    background: linear-gradient(135deg, var(--warning-yellow) 0%, var(--primary-orange) 100%);
    color: var(--text-dark);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-small);
    font-size: 0.9rem;
    font-weight: 600;
}

/* ===== Responsive Styles ===== */
@media (max-width: 768px) {
    .activity-header {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }

    .activity-instructions {
        text-align: center;
        font-size: 1.15rem;
    }

    .controls-container {
        align-items: center;
        width: 100%;
    }

    .btn-group-activity {
        justify-content: center;
        width: 100%;
    }

    .drag-item,
    .drop-target {
        font-size: 1em;
        padding: 0.875rem 1rem;
    }

    .progress-dot {
        width: 12px;
        height: 12px;
    }

    .takezone,
    .dropzone-area {
        min-height: 220px;
        padding: 1rem;
    }
}

@media (min-width: 992px) {
    .drag-item,
    .drop-target {
        font-size: 1.25em;
    }

    .activity-instructions {
        font-size: 1.4rem;
    }
}

/* ===== Fullscreen Mode Adjustments ===== */
:fullscreen .activity-container {
    background: var(--bg-cream);
    background-image: linear-gradient(135deg, #f5f7fa 0%, #f8f9fb 100%);
}

:fullscreen .activity-header {
    position: sticky;
    top: 0;
    z-index: 100;
}

/* ===== Accessibility ===== */
.activity-card:focus-visible,
.drag-item:focus-visible,
.drop-target:focus-visible,
.btn-activity:focus-visible,
.btn-control:focus-visible {
    outline: 3px solid var(--primary-purple);
    outline-offset: 3px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .activity-card,
    .drag-item,
    .drop-target,
    .progress-dot,
    .btn-activity,
    .btn-control {
        transition: none;
    }

    @keyframes shake {
        0%, 100% { transform: none; }
    }

    @keyframes pulse {
        0%, 100% { opacity: 1; }
    }

    @keyframes bounce {
        0%, 100% { transform: none; }
    }

    @keyframes starBounce {
        0%, 100% { transform: none; }
    }
}

/* ===== Print Styles ===== */
@media print {
    .activity-header,
    .controls-container,
    .btn-activity,
    .btn-control {
        display: none !important;
    }

    body {
        background: white !important;
    }
}

/* ===== Points Toast ===== */
.points-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.points-toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--primary-green) 0%, #20c997 100%);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-round);
    font-family: 'Baloo 2', cursive;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 4px 20px rgba(124, 185, 124, 0.4);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.points-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.points-toast.hide {
    opacity: 0;
    transform: translateX(100%);
}

.points-toast-icon {
    font-size: 1.3rem;
    animation: starPop 0.4s ease-out;
}

.points-toast-text {
    font-weight: 800;
}

.points-toast-total {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
}

@keyframes starPop {
    0% { transform: scale(0) rotate(-45deg); }
    60% { transform: scale(1.3) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

/* Mobile adjustments for toast */
@media (max-width: 768px) {
    .points-toast-container {
        top: auto;
        bottom: 1rem;
        right: 50%;
        transform: translateX(50%);
    }

    .points-toast {
        font-size: 1rem;
        padding: 0.6rem 1rem;
        transform: translateY(100%);
    }

    .points-toast.show {
        transform: translateY(0);
    }

    .points-toast.hide {
        transform: translateY(100%);
    }
}
