/*
 * Coding Ireland proprietary interactive activity
 * Copyright (c) 2017-2026 Coding Ireland. All rights reserved.
 *
 * Part of the Coding Ireland online learning platform. Licensed for use only
 * as delivered on the platform. Copying, redistributing, or adapting this
 * file, in whole or in part, for use in any other product or service is not
 * permitted. Ref: CI-mfl-cognate-hunter
 */
/**
 * Cognate Hunter Activity Styles
 * Multi-language word connection game with SVG line drawing
 */

/* ===== 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.5rem 2rem;
    background: var(--bg-section);
    border-radius: var(--radius-large);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.start-icon {
    font-size: 3rem;
    color: var(--primary-purple);
    margin-bottom: 0.75rem;
}

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

.start-text {
    font-family: 'Nunito', sans-serif;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.start-text small {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-muted);
}

.start-btn {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
}

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

/* ===== Game Area ===== */
.game-area {
    position: relative;
    min-height: 55vh;
    background: linear-gradient(135deg, var(--bg-section) 0%, #f8f9fa 100%);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-soft);
    margin-top: 1rem;
    overflow: hidden;
}

/* ===== SVG Connection Overlay ===== */
.connection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.connection-line {
    stroke: url(#successGradient);
    stroke-width: 3;
    stroke-linecap: round;
    opacity: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.connection-group.animate-in .connection-line {
    opacity: 1;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 0.6s ease-out forwards;
}

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

.connection-center {
    fill: var(--correct-green);
    opacity: 0;
    transform-origin: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.connection-group.animate-in .connection-center {
    animation: popIn 0.3s ease-out 0.4s forwards;
}

@keyframes popIn {
    0% { opacity: 0; r: 0; }
    70% { r: 10; }
    100% { opacity: 1; r: 8; }
}

/* ===== Word Cloud Container ===== */
.word-cloud {
    position: relative;
    width: 100%;
    min-height: 55vh;
    padding: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    gap: 1rem;
}

/* ===== Word Items ===== */
.word-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border: 3px solid #e0e0e0;
    border-radius: var(--radius-medium);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    user-select: none;
}

.word-item:hover:not(.matched):not(.wrong) {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: var(--primary-blue);
    z-index: 20;
}

.word-item:active:not(.matched) {
    transform: translateY(-1px) scale(1.01);
}

.word-item.selected {
    background: linear-gradient(145deg, var(--primary-blue) 0%, var(--primary-purple) 100%);
    color: white;
    border-color: var(--primary-purple);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 0 0 4px rgba(155, 126, 189, 0.3), 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 25;
}

.word-item.matched {
    background: linear-gradient(145deg, var(--correct-green) 0%, #6BC5C5 100%);
    color: white;
    border-color: var(--correct-green);
    cursor: pointer;
    opacity: 0.9;
    transform: scale(0.95);
}

.word-item.matched:hover {
    transform: scale(0.97);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    opacity: 1;
}

.word-item.matched::after {
    content: '\f02d'; /* book icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--warning-yellow);
    color: #2d3436;
    font-size: 0.65rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.word-item.matched:hover::after {
    opacity: 1;
}

.word-item.wrong {
    background: linear-gradient(145deg, var(--incorrect-red) 0%, #e74c3c 100%);
    color: white;
    border-color: var(--incorrect-red);
    animation: shake 0.5s ease-out;
}

.word-item.hint-highlight {
    animation: hintPulse 0.8s ease-in-out 3;
    z-index: 30;
}

@keyframes hintPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(253, 203, 110, 0.8);
        border-color: var(--warning-yellow);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(253, 203, 110, 0);
        border-color: var(--warning-yellow);
    }
}

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

/* ===== Word Content ===== */
.word-flag {
    width: 24px;
    height: auto;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.word-text {
    font-family: 'Baloo 2', cursive;
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
}

.word-item.selected .word-text,
.word-item.matched .word-text,
.word-item.wrong .word-text {
    color: white;
}

.word-audio-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    color: inherit;
}

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

.word-item:not(.selected):not(.matched):not(.wrong) .word-audio-btn {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-muted);
}

.word-item:not(.selected):not(.matched):not(.wrong) .word-audio-btn:hover {
    background: rgba(0, 0, 0, 0.12);
    color: var(--primary-blue);
}

/* ===== Selection Indicator ===== */
.selection-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(145deg, #ffffff 0%, var(--bg-section) 100%);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-soft);
    margin-top: 1rem;
    flex-wrap: wrap;
    min-height: 54px;
}

.selection-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.selected-words {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
    min-height: 28px;
    align-items: center;
}

.no-selection {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
}

.selected-word-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    background: linear-gradient(145deg, var(--primary-blue) 0%, var(--primary-purple) 100%);
    color: white;
    border-radius: var(--radius-round);
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    animation: badgePop 0.3s ease-out;
}

.selected-word-badge .badge-flag {
    width: 18px;
    height: auto;
    border-radius: 2px;
}

@keyframes badgePop {
    0% { transform: scale(0.8); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.selection-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ===== Etymology Panel ===== */
.etymology-panel {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(145deg, #2d3436 0%, #636e72 100%);
    color: white;
    border-radius: var(--radius-large);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    z-index: 100;
    max-width: 90%;
    width: max-content;
    max-width: 500px;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

.etymology-panel.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.etymology-content {
    flex: 1;
}

.etymology-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.etymology-title {
    font-family: 'Baloo 2', cursive;
    font-size: 1.3rem;
    margin: 0;
    color: var(--warning-yellow);
}

.etymology-origin {
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-style: italic;
    margin: 0 0 0.35rem 0;
    opacity: 0.9;
    color: #a8dadc;
}

.etymology-description {
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.5;
}

.etymology-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.etymology-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

/* ===== Language Flags in Header ===== */
.language-flags {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.language-flags img {
    width: 26px;
    height: auto;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* ===== Mobile Hint ===== */
.mobile-hint {
    padding: 0.5rem;
}

.swipe-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== Completion Stats ===== */
.completion-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-family: 'Baloo 2', cursive;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-purple);
    display: block;
}

.stat-label {
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Responsive Styles ===== */

/* Large screens */
@media (min-width: 1200px) {
    .word-cloud {
        min-height: 60vh;
        padding: 2rem;
        gap: 1.25rem;
    }

    .word-item {
        padding: 0.7rem 1.25rem;
    }

    .word-text {
        font-size: 1.2rem;
    }
}

/* Tablet */
@media (max-width: 992px) {
    .game-area {
        min-height: 50vh;
    }

    .word-cloud {
        min-height: 50vh;
        padding: 1rem;
        gap: 0.75rem;
    }

    .word-item {
        padding: 0.5rem 0.9rem;
    }

    .word-text {
        font-size: 1rem;
    }

    .btn-text {
        display: none;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .game-area {
        min-height: 45vh;
        margin-top: 0.5rem;
    }

    .word-cloud {
        min-height: 45vh;
        padding: 0.75rem;
        gap: 0.6rem;
    }

    .word-item {
        padding: 0.45rem 0.75rem;
    }

    .word-text {
        font-size: 0.95rem;
    }

    .word-flag {
        width: 20px;
    }

    .word-audio-btn {
        width: 22px;
        height: 22px;
        font-size: 0.75rem;
    }

    .etymology-panel {
        bottom: 1rem;
        left: 0.5rem;
        right: 0.5rem;
        transform: translateX(0) translateY(120%);
        width: auto;
        max-width: none;
        flex-direction: column;
        padding: 1rem;
    }

    .etymology-panel.visible {
        transform: translateX(0) translateY(0);
    }

    .etymology-close {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }

    .selection-indicator {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: var(--radius-large) var(--radius-large) 0 0;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        z-index: 50;
        padding: 0.75rem 1rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        background: white;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }

    .game-area {
        margin-bottom: 70px;
    }

    .completion-stats {
        gap: 1.5rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* Very small phones */
@media (max-width: 400px) {
    .word-cloud {
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .word-item {
        padding: 0.4rem 0.65rem;
    }

    .word-text {
        font-size: 0.9rem;
    }

    .word-flag {
        width: 18px;
    }

    .selected-word-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
}

/* ===== Fullscreen Mode ===== */
:fullscreen .activity-container,
:-webkit-full-screen .activity-container,
:-moz-full-screen .activity-container {
    padding: 1.5rem;
}

:fullscreen .game-area,
:-webkit-full-screen .game-area,
:-moz-full-screen .game-area {
    min-height: 70vh;
}

:fullscreen .word-cloud,
:-webkit-full-screen .word-cloud,
:-moz-full-screen .word-cloud {
    min-height: 70vh;
}

/* ===== Accessibility ===== */
.word-item:focus-visible {
    outline: 3px solid var(--primary-purple);
    outline-offset: 3px;
}

.btn-control:focus-visible,
.btn-primary-activity:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .word-item,
    .connection-line,
    .connection-center,
    .etymology-panel,
    .selected-word-badge {
        transition: none;
        animation: none;
    }

    .connection-group.animate-in .connection-line {
        opacity: 1;
        stroke-dasharray: none;
        stroke-dashoffset: 0;
    }

    .connection-group.animate-in .connection-center {
        opacity: 1;
    }

    .etymology-panel.visible {
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Print Styles ===== */
@media print {
    .activity-header,
    .selection-indicator,
    .etymology-panel,
    .start-overlay,
    .mobile-hint {
        display: none !important;
    }

    .game-area {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
