/* ===== VARIABLES & RESET ===== */
:root {
    --primary: #4361ee;
    --primary-light: #4895ef;
    --secondary: #3a0ca3;
    --accent: #f72585;
    --success: #4cc9f0;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    --border-radius: 12px;
    --shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 12px 30px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */
.app-header {
    background: linear-gradient(to right, var(--secondary), var(--primary));
    color: white;
    padding: 0.8rem 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header-container {
    display: flex;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    gap: 1.5rem;
}

.logo {
    height: 50px;
    width: auto;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.header-text h1 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    line-height: 1.3;
}

.header-text h2 {
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.95;
    line-height: 1.3;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 2rem;
    width: 100%;
}

.page {
    display: none;
    animation: fadeIn 0.5s ease;
}

.page.active {
    display: block;
}

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

/* ===== LANDING PAGE ===== */
.landing-container {
    text-align: center;
}

/* SIMPLIFIED INSTRUCTION - Increased font size, left-aligned */
.instruction-simple {
    font-size: 1.2rem; /* Increased from 1.1rem */
    color: var(--gray);
    margin-bottom: 2.5rem;
    font-weight: 300;
    line-height: 1.6;
    max-width: 800px;
    margin-left: 0; /* Changed from auto */
    margin-right: 0; /* Changed from auto */
    text-align: left; /* Left-aligned */
    padding: 0 1rem; /* Added padding for better readability */
}

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 1rem;
}

.video-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    text-align: left;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.video-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
}

.video-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-bottom: 4px solid var(--primary-light);
}

.video-card-content {
    padding: 1.2rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.video-card h3 {
    font-family: 'Poppins', sans-serif;
    color: var(--secondary);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    line-height: 1.4;
}

.practice-button {
    background: linear-gradient(to right, var(--primary), var(--primary-light));
    color: white;
    border: none;
    padding: 0.7rem 1.2rem;
    border-radius: 50px;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
    align-self: flex-start;
}

.practice-button:hover {
    background: linear-gradient(to right, var(--secondary), var(--primary));
    transform: scale(1.05);
}

/* ===== VIDEO PAGE ===== */
.back-button {
    background: var(--gray-light);
    color: var(--dark);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.back-button:hover {
    background: var(--gray);
    color: white;
}

.video-instruction {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--success);
}

.video-instruction i {
    color: var(--success);
    font-size: 1.2rem;
    margin-right: 0.6rem;
}

.video-instruction h3 {
    display: inline;
    font-family: 'Poppins', sans-serif;
    color: var(--secondary);
    font-size: 1.1rem;
}

.video-instruction p {
    margin-top: 0.4rem;
    color: var(--gray);
    font-size: 0.95rem;
}

/* Video Player - Simplified */
.video-wrapper {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

/* Video title moved ABOVE video */
.video-title-container {
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--gray-light);
}

.video-title-container i {
    color: var(--accent);
    font-size: 1.2rem;
    margin-right: 0.8rem;
}

#video-title {
    font-family: 'Poppins', sans-serif;
    color: var(--secondary);
    font-size: 1.2rem;
    display: inline;
    font-weight: 600;
}

.video-player-container {
    position: relative;
}

.video-player {
    width: 100%;
    border-radius: 8px;
    display: block;
    background: #000;
    max-height: 70vh; /* Prevent covering text on mobile */
}

/* Mobile-specific video handling to prevent fullscreen on transcript click */
@media (max-width: 768px) {
    .transcript-segment {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    
    .video-player:fullscreen {
        max-height: 100vh !important;
    }
    
    /* Prevent video from interfering with transcript clicks */
    .video-player {
        pointer-events: auto;
    }
}

/* ===== TRANSCRIPT ===== */
.transcript-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.transcript-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.transcript-header h3 {
    font-family: 'Poppins', sans-serif;
    color: var(--secondary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.1rem;
}

.transcript-header i {
    color: var(--primary);
    font-size: 1.1rem;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background: #ccc;
    border-radius: 34px;
    transition: var(--transition);
}

.toggle-slider:before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--success);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-label {
    font-weight: 500;
    color: var(--dark);
    font-size: 0.9rem;
}

/* Transcript Content */
.transcript-content {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 1rem;
}

.transcript-segment {
    padding: 0.9rem 1rem;
    margin-bottom: 0.6rem;
    border-radius: 8px;
    background: #f8f9fa;
    border-left: 4px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.transcript-segment:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.transcript-segment.active {
    background: linear-gradient(to right, #e3f2fd, #bbdefb);
    border-left-color: var(--primary);
    box-shadow: 0 4px 8px rgba(67, 97, 238, 0.15);
}

.english-text {
    font-size: 1rem;
    color: var(--dark);
    margin-bottom: 0.4rem;
    font-weight: 500;
    line-height: 1.4;
}

.chinese-text {
    font-size: 0.95rem;
    color: var(--gray);
    padding-left: 0.5rem;
    border-left: 2px solid var(--success);
    transition: var(--transition);
    line-height: 1.4;
}

.chinese-text.hidden {
    display: none;
}

/* ===== FOOTER ===== */
.app-footer {
    background: var(--dark);
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    font-size: 0.9rem;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .app-header {
        padding: 0.6rem 1rem;
    }
    
    .header-container {
        flex-direction: row;
        text-align: left;
        gap: 1rem;
        align-items: center;
    }
    
    .logo {
        height: 40px;
        flex-shrink: 0;
    }
    
    .header-text h1 {
        font-size: 1rem;
        line-height: 1.2;
    }
    
    .header-text h2 {
        font-size: 0.85rem;
        line-height: 1.2;
    }
    
    .main-content {
        padding: 0 1rem;
        margin: 1rem auto;
    }
    
    .instruction-simple {
        font-size: 1.1rem; /* Slightly smaller on mobile but still larger than before */
        margin-bottom: 2rem;
        text-align: left; /* Keep left-aligned on mobile */
        padding: 0 0.5rem;
    }
    
    .video-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .video-thumbnail {
        height: 160px;
    }
    
    .video-card h3 {
        font-size: 0.95rem;
    }
    
    .practice-button {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .video-instruction {
        padding: 0.8rem 1rem;
        margin-bottom: 1.2rem;
    }
    
    .video-instruction h3 {
        display: block;
        margin-bottom: 0.4rem;
        font-size: 1rem;
    }
    
    .video-wrapper {
        padding: 0.8rem;
        margin-bottom: 1.2rem;
    }
    
    #video-title {
        font-size: 1rem;
    }
    
    .video-player {
        max-height: 50vh; /* Prevent covering transcript */
    }
    
    .transcript-container {
        padding: 1rem;
    }
    
    .transcript-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .transcript-header h3 {
        font-size: 1rem;
    }
    
    .transcript-segment {
        padding: 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    .english-text {
        font-size: 0.95rem;
    }
    
    .chinese-text {
        font-size: 0.9rem;
    }
    
    .toggle-label {
        font-size: 0.85rem;
    }
    
    .back-button {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .header-container {
        gap: 0.8rem;
    }
    
    .logo {
        height: 35px;
    }
    
    .header-text h1 {
        font-size: 0.9rem;
    }
    
    .header-text h2 {
        font-size: 0.8rem;
    }
    
    .instruction-simple {
        font-size: 1rem; /* Adjusted for very small screens */
    }
    
    .video-thumbnail {
        height: 140px;
    }
    
    .video-card-content {
        padding: 1rem;
    }
    
    .video-player {
        max-height: 40vh;
    }
}