/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #fafafa;
}

/* Top Controls Bar */
.top-controls {
    background: white;
    border-bottom: 1px solid #e5e5e5;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.controls-wrapper {
    max-width: 740px;
    margin: 0 auto;
    padding: 12px 20px;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: flex-end;
}

.controls label {
    font-weight: 500;
    font-size: 14px;
    color: #666;
}

.controls select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

/* Container - Medium style */
.container {
    margin: 0 auto;
    padding: 0;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 60px 40px 50px 40px;
}

.hero-section h1 {
    font-size: 48px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 20px;
    font-family: Georgia, 'Times New Roman', serif;
    letter-spacing: -0.02em;
}

.hero-section .subtitle {
    font-size: 20px;
    color: #666;
    line-height: 1.5;
    font-weight: 300;
    max-width: 600px;
    margin: 0 auto;
}

/* Two Column Layout */
.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 100px;
    align-items: start;
    padding: 0 120px 80px 120px;
}

.input-column {
    text-align: center;
}

.examples-column {
    text-align: left;
}

#english-input {
    width: 100%;
    min-height: 600px;
    padding: 40px 48px;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    font-size: 21px;
    line-height: 1.8;
    resize: vertical;
    font-family: Georgia, 'Times New Roman', serif;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

#english-input:empty:not(:focus)::before {
    content: '✨ Paste your article here';
    color: #999;
    font-style: italic;
}

#english-input:focus {
    outline: none;
    border-color: #1a8917;
    box-shadow: 0 4px 16px rgba(26, 137, 23, 0.1);
    transform: translateY(-2px);
}

#english-input:hover:not(:focus) {
    border-color: #ccc;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
}

.input-container {
    position: relative;
    margin-bottom: 32px;
    width: 100%;
}

.char-counter {
    position: absolute;
    bottom: 12px;
    right: 16px;
    font-size: 12px;
    color: #999;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#start-reading-btn {
    padding: 20px 64px;
    background: #1a8917;
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-size: 19px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(26, 137, 23, 0.2);
}

#start-reading-btn:hover {
    background: #156d13;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 137, 23, 0.35);
}

/* Tooltips */
.has-tooltip {
    position: relative;
    cursor: help;
}

.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.has-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(0px);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

.has-tooltip:hover::after,
.has-tooltip:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

.has-tooltip:hover::before {
    transform: translateX(-50%) translateY(4px);
}

/* Tooltips that grow downward */
.tooltip-down::after {
    bottom: auto;
    top: 100%;
    transform: translateX(-50%) translateY(8px);
}

.tooltip-down::before {
    bottom: auto;
    top: 100%;
    transform: translateX(-50%) translateY(0px);
    border-top-color: transparent;
    border-bottom-color: rgba(0, 0, 0, 0.9);
}

.tooltip-down:hover::after {
    transform: translateX(-50%) translateY(4px);
}

.tooltip-down:hover::before {
    transform: translateX(-50%) translateY(-4px);
}


/* Reading instructions badges */
.reading-instructions {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

/* Enhanced Difficulty Legend */
.difficulty-legend-enhanced {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 2px solid #e5e5e5;
}

.legend-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.gradient-bar-enhanced {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gradient-fill {
    width: 120px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, 
        #d4a017 0%,
        #e67e22 33%,
        #c0392b 66%,
        #922b21 100%
    );
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.difficulty-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.difficulty-label.easy {
    color: #d4a017;
}

.difficulty-label.hard {
    color: #922b21;
}

/* Hint Text - Non-button style */
.hint-text {
    font-size: 13px;
    color: #7f8c8d;
    font-style: normal;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.hint-text em {
    font-style: italic;
    color: #95a5a6;
}

/* Examples Section */
.examples-section {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 48px;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.examples-section h3 {
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 32px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.example-text-original {
    background: white;
    padding: 24px 32px;
    border-radius: 8px;
    margin-bottom: 32px;
    border-left: 4px solid #1a8917;
    font-size: 16px;
    line-height: 1.7;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.example-text-original strong {
    color: #1a8917;
    display: block;
    margin-bottom: 14px;
}

.example-translation {
    background: white;
    padding: 24px 32px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.example-level {
    font-size: 13px;
    font-weight: 600;
    color: #1a8917;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.example-content {
    font-size: 17px;
    line-height: 1.9;
    color: #1a1a1a;
    font-family: Georgia, 'Times New Roman', serif;
}

/* Article Reading Area */
article {
    background: white;
    padding: 60px 120px;
    border-radius: 4px;
    max-width: 1400px;
    margin: 60px auto;
}

.secondary-btn {
    padding: 8px 16px;
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

.primary-btn {
    padding: 10px 24px;
    background: #1a8917;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    position: relative;
}

.primary-btn:not(.hidden) {
    animation: subtlePulse 2s ease-in-out infinite;
}

.primary-btn:hover {
    background: #156d13;
    animation: none;
}

@keyframes subtlePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(26, 137, 23, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(26, 137, 23, 0);
    }
}

/* Reward Button - Colorful and Simple */
.reward-btn {
    padding: 12px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.reward-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* Legacy Compact Difficulty Legend (deprecated) */
.difficulty-legend-compact {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gradient-bar-compact {
    width: 80px;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, 
        #d4a017 0%,
        #e67e22 33%,
        #c0392b 66%,
        #922b21 100%
    );
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Article Content - Medium style typography */
.article-content {
    font-size: 21px;
    line-height: 2;
    color: #1a1a1a;
    font-family: Georgia, 'Times New Roman', serif;
    letter-spacing: -0.003em;
}

.article-content p {
    margin-bottom: 30px;
}

/* Chinese text with inline translations */
.chinese-word {
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.chinese-word:hover {
    color: #1a8917;
}

/* English translation (shown inline for difficult words) */
.inline-translation {
    color: #666;
    font-size: 0.75em;
    font-style: italic;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin-left: 4px;
    opacity: 0.8;
}

/* Loading indicator */
#loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 20px 40px;
    border-radius: 8px;
    font-size: 18px;
    z-index: 1500;
}

#loading.hidden {
    display: none;
}

/* Vocabulary link */
.vocab-link {
    color: #1a8917;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: 6px 12px;
    transition: color 0.2s;
}

.vocab-link:hover {
    color: #156d13;
}

/* Hidden elements */
.hidden {
    display: none;
}

/* Confetti Animation */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    z-index: 9999;
    animation: confettiFall linear forwards;
    pointer-events: none;
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Scored words (highlighted Chinese characters) */
.scored-word {
    transition: color 0.3s;
    cursor: text;
    font-weight: 500;
}

.scored-word:hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

/* Article header adjustments */
.article-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e5e5;
    flex-wrap: wrap;
    gap: 15px;
}

/* Responsive design */
@media (max-width: 1400px) {
    .two-column-layout {
        padding: 0 80px 80px 80px;
        gap: 60px;
    }
}

@media (max-width: 1024px) {
    .two-column-layout {
        padding: 0 40px 80px 40px;
        grid-template-columns: 1fr;
        gap: 40px;
    }
    
    article {
        padding: 60px 60px;
        margin: 60px 40px;
    }
}

@media (max-width: 768px) {
    article {
        padding: 40px 25px;
        margin: 40px 20px;
    }
    
    .hero-section {
        padding: 40px 20px 40px 20px;
    }
    
    .hero-section h1 {
        font-size: 36px;
    }
    
    .hero-section .subtitle {
        font-size: 18px;
    }
    
    .two-column-layout {
        padding: 0 20px 60px 20px;
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .article-content {
        font-size: 19px;
        line-height: 1.8;
    }
    
    .controls {
        flex-wrap: wrap;
    }
    
    .reading-instructions {
        flex-direction: column;
        width: 100%;
        gap: 12px;
    }
    
    .difficulty-legend-enhanced {
        width: 100%;
        justify-content: center;
    }
    
    .hint-text {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
    
    .has-tooltip::after {
        white-space: normal;
        max-width: 200px;
        text-align: center;
    }
    
    .gradient-bar-compact {
        width: 60px;
    }
}
