/* Exercise system styles - includes drag-drop functionality */

.exercise-header {
    background-color: var(--card);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(0,0,0,0.06);
}

html[data-theme="dark"] .exercise-header {
    border-color: rgba(255,255,255,0.04);
}

.level-section {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0;
    padding: 0;
}

.level-section:last-child {
    margin-bottom: 0;
}

.level-section .subtitle {
    color: var(--main);
    font-weight: 600;
    text-transform: capitalize;
    margin-bottom: 0;
    text-align: right;
    padding-right: 0.5rem;
}

.exercise-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.exercise-selector {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50% !important;
    background-color: var(--bg);
    border: 2px solid var(--main);
    color: var(--main);
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-right: 0 !important;
    margin-bottom: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.exercise-selector:hover {
    background-color: var(--main);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(78, 143, 94, 0.3);
}

.exercise-selector:active {
    transform: translateY(0);
}

/* Button pop-in animation */
@keyframes buttonPopIn {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    70% {
        opacity: 1;
        transform: scale(1.15);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.exercise-selector.animate-pop {
    animation: buttonPopIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.exercise-selector.pre-animation {
    opacity: 0;
    transform: scale(0);
}

/* Celebration message */
.celebration-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid var(--main);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    z-index: 1001;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: celebration-bounce 0.6s ease-out;
}

html[data-theme="dark"] .celebration-message {
    background: rgba(21, 32, 39, 0.95);
    color: var(--text);
}

.celebration-message .emoticon {
    font-size: 6rem;
    margin-bottom: 1rem;
    display: block;
    animation: emoticon-pulse 1.5s ease-in-out infinite;
}

.celebration-message .phrase {
    font-size: 3rem;
    font-weight: 600;
    color: var(--main);
    margin: 0;
}

/* Responsive celebration message */
@media (max-width: 768px) {
    .celebration-message {
        padding: 1.5rem;
        border-radius: 15px;
        max-width: 90%;
        margin: 0 5%;
    }

    .celebration-message .emoticon {
        font-size: 4rem;
        margin-bottom: 0.75rem;
    }

    .celebration-message .phrase {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .celebration-message {
        padding: 1rem;
        border-radius: 12px;
    }

    .celebration-message .emoticon {
        font-size: 3rem;
        margin-bottom: 0.5rem;
    }

    .celebration-message .phrase {
        font-size: 1.5rem;
    }
}

@keyframes celebration-bounce {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

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

@keyframes selected-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(78, 143, 94, 0.4);
        border-color: var(--main);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 16px rgba(78, 143, 94, 0.6);
        border-color: var(--accent);
    }
}

.exercise-selector.is-active {
    background-color: var(--main);
    color: black;
    font-weight: 900;
    box-shadow: 0 2px 8px rgba(78, 143, 94, 0.4);
    animation: selected-pulse 2s ease-in-out infinite;
}

.exercise-selector.is-completed {
    background-color: var(--main);
    color: white;
    border-color: var(--main);
    position: relative;
}

.exercise-selector.is-completed.is-active {
    color: black;
    font-weight: 900;
}

.exercise-selector.is-completed::after {
    content: "✓";
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #4CAF50;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.exercise-info {
    text-align: center;
    padding: 1rem;
    background-color: rgba(78, 143, 94, 0.05);
    border-radius: 8px;
    border-left: 4px solid var(--main);
}

.exercise-info .subtitle {
    color: var(--main);
    margin-bottom: 0.5rem;
}

.questions-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.question-box {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    gap: 0.5rem;
}

.question-box.correct {
    background-color: rgba(76, 175, 80, 0.1);
    border-left-color: #4CAF50;
}

.question-box.incorrect {
    background-color: rgba(244, 67, 54, 0.1);
    border-left-color: #F44336;
}

.blank-input {
    display: inline-block;
    min-width: 4ch;
    width: 80px;
    padding: 0.25rem 0.5rem;
    margin: 0 4px;
    vertical-align: baseline;
}

.info-button {
    border-radius: 12px;
    border: 2px dashed var(--muted);
    font-weight: 600;
    font-family: monospace;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    background: none;
    transition: transform 0.12s ease;
}

.info-button:hover {
    transform: scale(1.1);
    border-color: var(--main);
}

.word-definition {
    border-bottom: 2px dashed var(--muted);
    cursor: pointer;
    transition: border-color 0.12s ease;
    position: relative;
}

.word-definition:hover {
    border-bottom-color: var(--main);
}

html[data-theme="dark"] .info-button {
    color: var(--text);
}

.has-tooltip-bottom[data-tooltip-multiline] {
    max-width: 180px;
    white-space: pre-line;
}

.has-tooltip-bottom::after,
.has-tooltip-bottom::before {
    z-index: 9999 !important;
}

.has-tooltip-bottom::after {
    position: fixed !important;
}

.info-button {
    position: relative;
    z-index: 10;
}

.info-button.is-tooltip-active::after,
.info-button.is-tooltip-active::before {
    z-index: 9999 !important;
}

.check-answers-button {
    background-color: var(--main) !important;
}

/* Drag-drop exercise styles (formerly wordorderexercise.css) */
.sentences-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.sentence-content {
    display: block;
    margin-bottom: 1rem;
}

.sentence-content-container {
    display: block;
    flex: 1;
}

.check-icon {
    display: inline;
    vertical-align: middle;
}

.sentence-words-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem;
    background-color: rgba(0,0,0,0.02);
    border-radius: 6px;
    border: 1px dashed var(--muted);
    min-height: 40px;
    align-items: flex-start;
    align-content: flex-start;
    clear: both;
    width: 100%;
}

html[data-theme="dark"] .sentence-words-tray {
    background-color: rgba(255,255,255,0.02);
    border-color: rgba(255,255,255,0.1);
}

.sentence-word {
    margin: 0;
    padding: 2px;
    display: inline-block;
    font-weight: 500;
}

.dropzone {
    display: inline-block;
    min-width: 60px;
    min-height: 24px;
    margin: 0;
    padding: 2px;
    border: 1px solid transparent;
    background-color: transparent;
    transition: all 0.2s ease;
    vertical-align: middle;
    font-size: 0.9rem;
    text-align: center;
    border-radius: 4px;
}

.dropzone > * {
    margin-right: 4px;
}

.dropzone > *:last-child {
    margin-right: 0;
}

/* Drag and drop visual feedback */
.dropzone.drag-highlight {
    border: 2px dashed #666;
    background-color: transparent;
}

.dropzone.correct {
    background-color: rgba(76, 175, 80, 0.2);
    border-color: #4CAF50;
}

.dropzone.incorrect {
    background-color: rgba(244, 67, 54, 0.2);
    border-color: #F44336;
}

.word {
    cursor: grab;
    user-select: none;
    transition: transform 0.1s ease;
}

.word:hover {
    transform: scale(1.1);
}

.word:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.sortable-ghost {
    opacity: 0.4;
}

.sortable-chosen {
    transform: scale(1.05);
}

.sortable-drag {
    transform: rotate(5deg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.field .checkbox {
    color: var(--text);
    font-weight: 500;
}

.field .checkbox input[type="checkbox"] {
    margin-right: 0.5rem;
}

@media (max-width: 768px) {
    /* Prevent horizontal overflow on mobile */
    body {
        overflow-x: hidden;
    }

    .container, .section, .box, .question-box {
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Allow main content sections to scroll naturally */
    .main-content-section {
        overflow: visible !important;
    }

    /* Fix hero banner overflow on narrow viewports */
    .hero, .hero-body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .exercise-header {
        padding: 0.75rem;
    }

    .level-section {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        text-align: center;
    }

    .level-section .subtitle {
        text-align: center;
        padding-right: 0;
        margin-bottom: 0.5rem;
    }

    .exercise-buttons {
        justify-content: center;
    }

    .exercise-selector {
        min-width: 2rem;
        height: 1.875rem;
        font-size: 0.8rem;
    }

    .question-box {
        flex-wrap: wrap;
    }

    .blank-input {
        max-width: 120px !important;
        min-width: 80px !important;
    }

    .sentence-words-tray {
        padding: 0.75rem;
        min-height: 50px;
    }

    .word {
        font-size: 0.9rem;
    }

    .share-exercise-button {
        margin-left: 0 !important;
        margin-top: 0.5rem;
    }

    /* Fix tooltips on mobile to prevent off-screen display */
    .has-tooltip-bottom::after {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        max-width: 90vw !important;
        white-space: normal !important;
        word-wrap: break-word !important;
    }

    .has-tooltip-bottom::before {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }

    .has-tooltip-bottom[data-tooltip-multiline] {
        max-width: none !important;
    }
}