/**
 * Spelling Mastery Module - Comprehensive Styling
 * Pattern-based spelling from phonics to etymology
 */

/* ========================================
   Color Palette & Variables
   ======================================== */
:root {
    --spelling-primary: #d946ef;
    --spelling-secondary: #a855f7;
    --spelling-accent: #c026d3;
    --spelling-light: #f5d0fe;
    --spelling-dark: #701a75;
    --spelling-success: #10b981;
    --spelling-warning: #f59e0b;
    --spelling-error: #ef4444;
    --spelling-info: #3b82f6;
    
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --card-shadow-hover: 0 10px 15px rgba(0, 0, 0, 0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Module Container
   ======================================== */
.spelling-module {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.spelling-header {
    text-align: center;
    margin-bottom: 3rem;
}

.spelling-title {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--spelling-primary), var(--spelling-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.spelling-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* ========================================
   Activity Cards
   ======================================== */
.activity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.activity-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    transition: var(--transition-smooth);
    border: 2px solid transparent;
    cursor: pointer;
}

.activity-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
    border-color: var(--spelling-primary);
}

.activity-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.activity-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--spelling-dark);
    margin-bottom: 0.5rem;
}

.activity-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.activity-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.activity-stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ========================================
   Word Cards
   ======================================== */
.word-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.word-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--spelling-primary), var(--spelling-secondary));
}

.word-card:hover {
    transform: scale(1.02);
    box-shadow: var(--card-shadow-hover);
}

.word-main {
    font-size: 2rem;
    font-weight: 700;
    color: var(--spelling-dark);
    margin-bottom: 0.5rem;
}

.word-pronunciation {
    font-size: 1rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 0.5rem;
}

.word-definition {
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.word-example {
    font-style: italic;
    color: var(--text-secondary);
    padding: 0.75rem;
    background: var(--spelling-light);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.word-pattern-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--spelling-primary);
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   Word Building Tool (Drag & Drop)
   ======================================== */
.word-builder {
    padding: 2rem;
    background: linear-gradient(135deg, var(--spelling-light), white);
    border-radius: 16px;
    margin: 2rem 0;
}

.morpheme-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    border: 2px dashed var(--spelling-primary);
}

.morpheme-tile {
    padding: 0.75rem 1.5rem;
    background: var(--spelling-primary);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    cursor: grab;
    transition: var(--transition-smooth);
    user-select: none;
}

.morpheme-tile:hover {
    transform: scale(1.05);
    background: var(--spelling-accent);
}

.morpheme-tile:active {
    cursor: grabbing;
}

.morpheme-tile.dragging {
    opacity: 0.5;
}

.word-construction-zone {
    min-height: 100px;
    padding: 2rem;
    background: white;
    border: 3px dashed var(--spelling-secondary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
}

.word-construction-zone.drag-over {
    background: var(--spelling-light);
    border-color: var(--spelling-primary);
    border-style: solid;
}

.word-construction-zone.correct {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--spelling-success);
    animation: pulse-success 0.5s ease;
}

.word-construction-zone.incorrect {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--spelling-error);
    animation: shake 0.5s ease;
}

/* ========================================
   Pattern Sorting Game
   ======================================== */
.pattern-sorting {
    padding: 2rem;
}

.pattern-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.pattern-category {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    border: 2px solid var(--border);
    transition: var(--transition-smooth);
    min-height: 200px;
}

.pattern-category.drag-over {
    border-color: var(--spelling-primary);
    background: var(--spelling-light);
}

.category-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--spelling-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--spelling-primary);
}

.word-tiles-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.word-tile {
    padding: 0.5rem 1rem;
    background: white;
    border: 2px solid var(--spelling-primary);
    border-radius: 8px;
    color: var(--spelling-dark);
    font-weight: 600;
    cursor: grab;
    transition: var(--transition-smooth);
}

.word-tile:hover {
    background: var(--spelling-light);
    transform: scale(1.05);
}

.word-tile:active {
    cursor: grabbing;
}

/* ========================================
   Spelling Bee Challenge
   ======================================== */
.spelling-bee {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
}

.bee-word-display {
    text-align: center;
    margin-bottom: 2rem;
}

.bee-pronunciation-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: var(--spelling-primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.bee-pronunciation-btn:hover {
    background: var(--spelling-accent);
    transform: scale(1.05);
}

.bee-pronunciation-btn:active {
    transform: scale(0.95);
}

.bee-input-area {
    margin-bottom: 2rem;
}

.bee-input {
    width: 100%;
    padding: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
    border: 3px solid var(--spelling-primary);
    border-radius: 12px;
    outline: none;
    transition: var(--transition-smooth);
    font-weight: 600;
    letter-spacing: 2px;
}

.bee-input:focus {
    border-color: var(--spelling-accent);
    box-shadow: 0 0 0 3px rgba(217, 70, 239, 0.1);
}

.bee-hint {
    text-align: center;
    font-style: italic;
    color: var(--text-secondary);
    margin-top: 1rem;
}

.bee-feedback {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-weight: 600;
    animation: slideIn 0.3s ease;
}

.bee-feedback.correct {
    background: rgba(16, 185, 129, 0.1);
    color: var(--spelling-success);
}

.bee-feedback.incorrect {
    background: rgba(239, 68, 68, 0.1);
    color: var(--spelling-error);
}

/* ========================================
   Etymology Explorer
   ======================================== */
.etymology-explorer {
    padding: 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
}

.etymology-word-header {
    text-align: center;
    margin-bottom: 2rem;
}

.etymology-word {
    font-size: 3rem;
    font-weight: 800;
    color: var(--spelling-dark);
    margin-bottom: 0.5rem;
}

.etymology-origin {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-style: italic;
}

.etymology-roots {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.root-part {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--spelling-primary), var(--spelling-secondary));
    color: white;
    border-radius: 8px;
    font-weight: 600;
}

.root-meaning {
    display: block;
    font-size: 0.875rem;
    opacity: 0.9;
}

.etymology-story {
    background: var(--spelling-light);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    line-height: 1.8;
}

.etymology-related {
    margin-top: 2rem;
}

.related-words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.related-word-card {
    padding: 1rem;
    background: white;
    border: 2px solid var(--spelling-primary);
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.related-word-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow);
}

/* ========================================
   Homophone Detective
   ======================================== */
.homophone-detective {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
}

.homophone-challenge-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
}

.homophone-words {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.homophone-word {
    padding: 1rem 2rem;
    background: var(--spelling-light);
    color: var(--spelling-dark);
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: 700;
}

.homophone-definitions {
    background: rgba(168, 85, 247, 0.05);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.definition-item {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    position: relative;
}

.definition-item::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--spelling-primary);
    font-size: 1.5rem;
}

.homophone-sentence {
    font-size: 1.25rem;
    text-align: center;
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--spelling-light);
    border-radius: 12px;
    font-weight: 500;
}

.homophone-blank {
    display: inline-block;
    min-width: 100px;
    padding: 0.25rem 1rem;
    background: white;
    border-bottom: 3px solid var(--spelling-primary);
    margin: 0 0.5rem;
}

.homophone-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.homophone-option {
    padding: 0.75rem 1.5rem;
    background: white;
    border: 2px solid var(--spelling-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-weight: 600;
}

.homophone-option:hover {
    background: var(--spelling-light);
    transform: scale(1.05);
}

.homophone-option.selected {
    background: var(--spelling-primary);
    color: white;
}

.homophone-option.correct {
    background: var(--spelling-success);
    color: white;
    border-color: var(--spelling-success);
}

.homophone-option.incorrect {
    background: var(--spelling-error);
    color: white;
    border-color: var(--spelling-error);
}

/* ========================================
   Spelling Journal
   ======================================== */
.spelling-journal {
    padding: 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
}

.journal-entry {
    padding: 1.5rem;
    background: rgba(245, 208, 254, 0.2);
    border-left: 4px solid var(--spelling-primary);
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.journal-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.journal-word {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--spelling-dark);
    margin-bottom: 0.5rem;
}

.journal-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.journal-status.mastered {
    background: rgba(16, 185, 129, 0.2);
    color: var(--spelling-success);
}

.journal-status.practicing {
    background: rgba(245, 158, 11, 0.2);
    color: var(--spelling-warning);
}

.journal-status.tricky {
    background: rgba(239, 68, 68, 0.2);
    color: var(--spelling-error);
}

.journal-notes {
    margin-top: 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* ========================================
   Progress Dashboard
   ======================================== */
.progress-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.progress-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    text-align: center;
}

.progress-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.progress-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--spelling-primary);
    margin-bottom: 0.5rem;
}

.progress-label {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--spelling-primary), var(--spelling-secondary));
    border-radius: 6px;
    transition: width 0.5s ease;
}

/* ========================================
   Achievement Badges
   ======================================== */
.achievements-section {
    padding: 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    margin: 2rem 0;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem;
}

.achievement-badge {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--spelling-light), white);
    border-radius: 12px;
    border: 2px solid transparent;
    transition: var(--transition-smooth);
}

.achievement-badge.earned {
    border-color: var(--spelling-primary);
    animation: pop 0.5s ease;
}

.achievement-badge.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.badge-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    display: block;
}

.badge-name {
    font-weight: 700;
    color: var(--spelling-dark);
    margin-bottom: 0.25rem;
    font-size: 0.9375rem;
}

.badge-requirement {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ========================================
   Streak Tracker
   ======================================== */
.streak-tracker {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--spelling-primary), var(--spelling-secondary));
    color: white;
    border-radius: 16px;
    margin: 2rem 0;
}

.streak-flame {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: flicker 2s ease-in-out infinite;
}

.streak-count {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.streak-label {
    font-size: 1.125rem;
    opacity: 0.9;
}

/* ========================================
   Buttons & Controls
   ======================================== */
.btn-spelling {
    padding: 0.75rem 2rem;
    background: var(--spelling-primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 1rem;
}

.btn-spelling:hover {
    background: var(--spelling-accent);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow);
}

.btn-spelling:active {
    transform: translateY(0);
}

.btn-spelling.secondary {
    background: var(--spelling-secondary);
}

.btn-spelling.outline {
    background: transparent;
    border: 2px solid var(--spelling-primary);
    color: var(--spelling-primary);
}

.btn-spelling.outline:hover {
    background: var(--spelling-primary);
    color: white;
}

.btn-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
}

/* ========================================
   Voice Recognition Indicator
   ======================================== */
.voice-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid var(--spelling-info);
    border-radius: 20px;
    color: var(--spelling-info);
    font-weight: 600;
    font-size: 0.875rem;
}

.voice-indicator.listening {
    animation: pulse-listening 1.5s ease-in-out infinite;
}

.voice-wave {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.voice-bar {
    width: 3px;
    height: 12px;
    background: var(--spelling-info);
    border-radius: 2px;
    animation: wave 0.8s ease-in-out infinite;
}

.voice-bar:nth-child(2) {
    animation-delay: 0.1s;
}

.voice-bar:nth-child(3) {
    animation-delay: 0.2s;
}

/* ========================================
   Animations
   ======================================== */
@keyframes pulse-success {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

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

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

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

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

@keyframes wave {
    0%, 100% { height: 12px; }
    50% { height: 20px; }
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .spelling-module {
        padding: 1rem;
    }
    
    .spelling-title {
        font-size: 2rem;
    }
    
    .activity-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .progress-dashboard {
        grid-template-columns: 1fr;
    }
    
    .word-main {
        font-size: 1.5rem;
    }
    
    .bee-input {
        font-size: 1.125rem;
        padding: 1rem;
    }
    
    .etymology-word {
        font-size: 2rem;
    }
    
    .morpheme-bank {
        justify-content: center;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-spelling {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .spelling-title {
        font-size: 1.5rem;
    }
    
    .activity-card {
        padding: 1.5rem;
    }
    
    .homophone-words {
        flex-direction: column;
    }
    
    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .btn-spelling,
    .voice-indicator,
    .streak-tracker {
        display: none;
    }
    
    .spelling-module {
        max-width: 100%;
    }
    
    .activity-card,
    .word-card,
    .progress-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ========================================
   Dark Mode Support
   ======================================== */
@media (prefers-color-scheme: dark) {
    .activity-card,
    .word-card,
    .spelling-bee,
    .etymology-explorer,
    .homophone-challenge-card,
    .spelling-journal,
    .progress-card,
    .achievements-section {
        background: #1f2937;
        color: #f3f4f6;
    }
    
    .activity-title,
    .word-main,
    .etymology-word {
        color: #f9fafb;
    }
    
    .word-construction-zone,
    .pattern-category {
        background: #374151;
    }
    
    .bee-input {
        background: #374151;
        color: #f3f4f6;
    }
}

