/* --- SWIPE ANIMATIONS --- */
@keyframes slideOutLeft { 0% { transform: translateX(0); opacity: 1; } 100% { transform: translateX(-60px); opacity: 0; } }
@keyframes slideInRight { 0% { transform: translateX(60px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { 0% { transform: translateX(0); opacity: 1; } 100% { transform: translateX(60px); opacity: 0; } }
@keyframes slideInLeft { 0% { transform: translateX(-60px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }

.tab-content { display: none; width: 100%; }
.tab-content.active { display: block; opacity: 1; transform: translateX(0); }
.tab-content.slide-out-left { display: block; animation: slideOutLeft var(--swipe-speed) ease-in forwards; }
.tab-content.slide-in-right { display: block; animation: slideInRight var(--swipe-speed) ease-out forwards; }
.tab-content.slide-out-right { display: block; animation: slideOutRight var(--swipe-speed) ease-in forwards; }
.tab-content.slide-in-left { display: block; animation: slideInLeft var(--swipe-speed) ease-out forwards; }

.tab-image-container {
    position: relative;
    width: 100%;
    height: 250px;
    background-size: cover;
    background-position: center;
    border-radius: 10px;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.tab-image-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0);
    border-radius: 10px;
}

.tab-image-container h2 {
    position: relative;
    z-index: 1;
    color: var(--primary-color);
    margin: 0;
    padding: 0;
    border-bottom: none !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    text-align: center;
}


body.light-mode .tab-image-container h2 {
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* --- TYPOGRAPHY & LISTS --- */
h2 {
    color: var(--primary-color);
    margin-top: 0;
    border-bottom: 2px solid #333;
    padding-bottom: 15px;
    margin-bottom: 25px;
    font-size: 1.8em;
}
body.light-mode h2 { border-bottom-color: #eee; }

ul { list-style-type: none; padding: 0; }
li { margin-bottom: 15px; line-height: 1.6; font-size: 1.1em; }
p { line-height: 1.8; font-size: 1.1em; margin-bottom: 20px; }
.reading-content .title-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.reading-content h2 {
    margin-bottom: 0;
    width: 100%;
}

.reading-content h3 { color: var(--primary-color); margin-top: 30px; }
body.light-mode .reading-content h3 { color: #333; }

.article-part {
    position: relative;
    padding: 10px;
    border-radius: 8px;
    transition: background-color 0.3s;
}

.article-part:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.article-part.editing {
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.2);
}

/* --- WARMUP & DISCUSSION HOVER EFFECTS --- */
#warmup li, #discussion li {
    padding: 15px 20px;
    border-left: 4px solid transparent;
    border-radius: 8px;
    transition: all 0.3s var(--smooth);
    cursor: default;
    position: relative;
}

#warmup li:hover, #discussion li:hover {
    background-color: rgba(229, 9, 20, 0.15); /* Light red tint */
    border-left-color: var(--primary-color); /* Red accent line */
    padding-left: 25px; /* Slide text */
    transform: scale(1.02); /* Lift */
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

body.light-mode #warmup li:hover, body.light-mode #discussion li:hover {
    background-color: rgba(229, 9, 20, 0.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

/* --- INTERACTIVE QUESTIONS --- */
.question { margin-bottom: 30px; padding: 20px; padding-bottom: 40px; border-radius: 10px; transition: background-color 0.3s; position: relative; }
.question:hover { background-color: rgba(255,255,255,0.03); }
body.light-mode .question:hover { background-color: rgba(0,0,0,0.03); }
.question p { font-weight: 700; margin-bottom: 15px; }

.options li {
    padding: 15px 20px; border: 2px solid #444; border-radius: 8px; cursor: pointer;
    transition: all 0.3s var(--smooth); position: relative; background: transparent;
}
body.light-mode .options li { border-color: #ddd; }
.options li:hover { border-color: #888; transform: translateX(10px); background-color: rgba(255,255,255,0.05); }
body.light-mode .options li:hover { background-color: rgba(0,0,0,0.05); }
.options li.selected { border-color: var(--primary-color); background-color: rgba(229, 9, 20, 0.1); transform: scale(1.02); font-weight: bold; }

.tf-question {
    padding: 20px; border: 2px solid #444; border-radius: 10px;
    display: flex; justify-content: space-between; align-items: center; gap: 20px;
    transition: all 0.3s var(--smooth); margin-bottom: 15px;
    position: relative;
    padding-bottom: 50px;
}

body:not(.edit-mode-enabled) .tf-question {
    padding-bottom: 20px;
}
body.light-mode .tf-question { border-color: #ddd; }
.tf-question:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.tf-options { display: flex; gap: 10px; }

.tf-btn {
    padding: 10px 25px; border: 2px solid transparent; background-color: #333; color: #fff;
    cursor: pointer; border-radius: 50px; font-weight: bold; transition: all 0.3s var(--bounce);
}
body.light-mode .tf-btn { background-color: #eee; color: #333; }
.tf-btn:hover { transform: scale(1.1); }
.tf-btn.selected { background-color: var(--primary-color); box-shadow: 0 0 15px var(--primary-color); color: white; }

/* Feedback Animations */
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pulseGreen { 0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); transform: scale(1); } 50% { transform: scale(1.05); } 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); transform: scale(1); } }

.correct { background-color: var(--correct-color-dark) !important; border-color: #2f9246 !important; animation: pulseGreen 0.6s; }
.incorrect { background-color: var(--incorrect-color-dark) !important; border-color: #cf3c4f !important; animation: shake 0.4s; }
body.light-mode .correct { background-color: var(--correct-color-light) !important; border-color: #2f9246 !important; }
body.light-mode .incorrect { background-color: var(--incorrect-color-light) !important; border-color: #cf3c4f !important; }
.show-correct { border-color: #2f9246 !important; box-shadow: 0 0 15px #2f9246; transform: scale(1.02); }

.answers-checked .options li,
.answers-checked .tf-btn {
    pointer-events: none;
}

/* --- BUTTONS --- */
.answers-actions { text-align: center; margin-top: 40px; }
.action-btn {
    background-color: var(--primary-color); color: #fff; border: none; padding: 14px 35px;
    font-size: 1.2em; font-weight: bold; border-radius: 50px; cursor: pointer;
    transition: all 0.3s var(--bounce); box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-transform: uppercase; letter-spacing: 1px; position: relative; overflow: hidden;
}
.action-btn:hover { background-color: var(--primary-hover); transform: translateY(-3px) scale(1.05); box-shadow: 0 10px 20px rgba(229, 9, 20, 0.4); }
.action-btn:active { transform: translateY(1px) scale(0.98); }
.reset-btn { background-color: #555; display: none; }
.reset-btn:hover { background-color: #666; box-shadow: 0 10px 20px rgba(0,0,0,0.3); }

.score-display {
    text-align: center;
    margin-top: 20px;
    font-size: 1.2em;
    font-weight: bold;
    color: var(--text-color-dark);
    padding: 10px;
    border-radius: 5px;
    background-color: rgba(0,0,0,0.2);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out;
}

body.light-mode .score-display {
    color: var(--text-color-light);
    background-color: rgba(255,255,255,0.5);
}

/* --- FLASHCARDS & MATCHING GAME --- */
.flashcard-instructions { text-align: center; margin: -10px 0 30px 0; color: #aaa; font-style: italic; }

.flashcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 30px; padding: 10px; }
.flashcard { background-color: transparent; height: 220px; perspective: 1000px; cursor: pointer; position: relative; display: flex; flex-direction: column; }
.flashcard:hover .flashcard-inner { transform: translateY(-10px) rotateX(5deg); box-shadow: 0 15px 35px rgba(0,0,0,0.4); }

.flashcard-inner {
    position: relative; width: 100%; height: 100%;
    transition: transform 0.6s var(--bounce), box-shadow 0.3s;
    transform-style: preserve-3d; box-shadow: var(--shadow-dark); border-radius: 15px;
}
body.light-mode .flashcard-inner { box-shadow: var(--shadow-light); }
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-front, .flashcard-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden; display: flex;
    align-items: center; justify-content: center;
    padding: 30px; box-sizing: border-box;
    border-radius: 15px; color: #fff;
    text-align: center; flex-direction: column;
    transform-style: preserve-3d;
}

.flashcard-front p {
    margin-bottom: 20px;
}

.audio-button-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    backface-visibility: hidden;
}

.audio-button {
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
    position: relative;
}

.audio-button::after {
    content: '';
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    border-radius: 50%;
    z-index: 1;
}

.audio-button:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.audio-button img {
    width: 24px;
    height: 24px;
    filter: invert(1);
}

.audio-button.loading img {
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}
.flashcard-front { background: linear-gradient(135deg, var(--primary-color), #b2070f); font-weight: 800; font-size: 1.8em; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.flashcard-back { background: linear-gradient(135deg, var(--light-red-color), #d32f2f); transform: rotateY(180deg); font-size: 1.1em; line-height: 1.5; font-weight: 500; box-shadow: inset 0 0 20px rgba(0,0,0,0.1); }

/* MATCHING GAME STYLES */
.matching-wrapper { display: none; width: 100%; }
.matching-grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.match-item {
    background-color: #2a2a2a; border: 2px solid #444; border-radius: 8px;
    padding: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    text-align: center; font-weight: 500; transition: transform 0.4s var(--smooth), background-color 0.3s; min-height: 60px;
    position: relative; z-index: 1;
}

.defs-col .match-item {
    font-size: 0.9em;
}
body.light-mode .match-item { background-color: #fff; border-color: #ddd; }
.match-item:hover { transform: scale(1.02); border-color: #888; z-index: 2; }

.match-item.selected { border-color: var(--primary-color); background-color: rgba(229, 9, 20, 0.1); transform: scale(1.05); box-shadow: 0 5px 15px rgba(229,9,20,0.2); z-index: 3; }
.match-item.matched { 
    background-color: rgba(46, 204, 113, 0.2) !important; 
    border-color: #2f9246 !important; 
    opacity: 0.8; pointer-events: none; 
    z-index: 1;
}
.match-item.match-error { animation: shake 0.4s; background-color: rgba(229, 9, 20, 0.2); border-color: var(--primary-color); }

.match-group {
    display: grid;
    gap: 15px;
}

.group-separator {
    grid-column: 1 / -1;
    border: none;
    height: 2px;
    background-color: var(--primary-color);
    margin: 20px 0;
}

/* --- PARTICLES --- */
.particle { position: absolute; width: 8px; height: 8px; border-radius: 50%; pointer-events: none; animation: particle-burst 1s ease-out forwards; }
@keyframes particle-burst { 0% { transform: translate(0, 0) scale(1); opacity: 1; } 100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; } }

/* --- MEDIA QUERIES --- */
@media (max-width: 1100px) {
    .main-wrapper { max-width: 100%; }
    .header, .tabs-container, .content-container { padding-left: 20px; padding-right: 20px; margin-left: 0; margin-right: 0; }
    .logo { font-size: 2em; }
    .tabs-container { overflow-x: auto; -ms-overflow-style: none; scrollbar-width: none; padding-bottom: 5px; scroll-behavior: smooth; }
    .tabs-container::-webkit-scrollbar { display: none; }
    .tabs { justify-content: flex-start; min-width: max-content; }
}

@media (max-width: 700px) {
    .matching-grid-layout { grid-template-columns: 1fr 1fr; gap: 10px; }
    .match-item { font-size: 0.9em; padding: 10px; min-height: 100px; }
    .tf-question { flex-direction: column; align-items: stretch; text-align: center; }
    .tf-options { justify-content: center; margin-top: 10px; }
}

/* --- AI DEFINITION TOOLTIP --- */
.clickable-word {
    cursor: pointer;
    transition: background-color 0.3s;
}

.user-clicked-highlight {
    background-color: rgba(229, 9, 20, 0.5); /* Darker red highlight */
    color: #ffffff !important;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    border-radius: 3px;
    padding: 0 2px;
}

.esl-ai-tooltip {
    position: absolute;
    background-color: #1c1c1c;
    color: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 10001;
    max-width: 350px;
    font-size: 1em;
    line-height: 1.6;
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.esl-ai-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.esl-ai-tooltip strong {
    color: var(--primary-color);
}

.esl-ai-tooltip em {
    font-style: italic;
    color: #aaa;
}

.esl-audio-button {
    background: none;
    border: none;
    cursor: pointer;
    width: 24px;
    height: 24px;
    padding: 0;
    margin-right: 10px;
    vertical-align: middle;
}

.esl-audio-button svg {
    fill: var(--primary-color);
    transition: transform 0.2s;
}

.esl-audio-button:hover svg {
    transform: scale(1.1);
}

body.light-mode .user-clicked-highlight {
    background-color: rgba(229, 9, 20, 0.2);
    color: #000000 !important;
}

body.light-mode .esl-ai-tooltip {
    background-color: #ffffff;
    color: #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

body.light-mode .esl-ai-tooltip em {
    color: #777;
}
