/* ===================================
   YC LEARNING HUB - RESPONSIVE STYLES
   Phase 2: Mobile-First Design
   =================================== */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px; /* Base for rem calculations */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    line-height: 1.6;
    color: #333;
    /* Prevent horizontal scroll on mobile */
    overflow-x: hidden;
}

/* ===================================
   CONTAINER - Fluid & Responsive
   =================================== */
.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* ===================================
   HEADER - Mobile First
   =================================== */
.header {
    text-align: center;
    margin-bottom: 32px;
    animation: fadeInDown 0.8s ease-out;
    position: relative;
}

.header h1 {
    font-size: clamp(1.75rem, 5vw, 3rem);
    color: #fff;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    letter-spacing: -0.5px;
    line-height: 1.2;
    padding: 0 8px;
}

.subtitle {
    font-size: clamp(1rem, 3vw, 1.25rem);
    color: rgba(255,255,255,0.9);
    margin-bottom: 24px;
    font-weight: 300;
    padding: 0 16px;
}

/* ===================================
   PROGRESS BAR - Touch Friendly
   =================================== */
.progress-container {
    background: rgba(255,255,255,0.2);
    border-radius: 50px;
    height: 14px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 12px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00d9ff, #00ff88);
    border-radius: 50px;
    transition: width 0.5s ease-out;
    box-shadow: 0 0 20px rgba(0,255,136,0.5);
}

.progress-text {
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
}

/* ===================================
   MODULES - Card Layout
   =================================== */
.module {
    background: #fff;
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

/* Staggered animation delays */
.module:nth-child(1) { animation-delay: 0.1s; }
.module:nth-child(2) { animation-delay: 0.15s; }
.module:nth-child(3) { animation-delay: 0.2s; }
.module:nth-child(4) { animation-delay: 0.25s; }
.module:nth-child(5) { animation-delay: 0.3s; }
.module:nth-child(6) { animation-delay: 0.35s; }
.module:nth-child(7) { animation-delay: 0.4s; }

/* ===================================
   MODULE HEADER - Touch Optimized
   =================================== */
.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    cursor: pointer;
    background: #fff;
    transition: background 0.3s ease;
    /* Minimum touch target height */
    min-height: 72px;
    /* Prevent text selection on tap */
    -webkit-user-select: none;
    user-select: none;
    /* Touch feedback */
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.1);
}

.module-header:hover {
    background: #f8f9ff;
}

/* Active state for touch devices */
.module-header:active {
    background: #f0f2ff;
}

.module-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0; /* Allows text truncation */
}

.module-number {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(102,126,234,0.4);
}

.module-title h2 {
    font-size: 1rem;
    color: #1a1a2e;
    font-weight: 600;
    line-height: 1.3;
    /* Text truncation for long titles */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ===================================
   MODULE STATUS - Touch Targets
   =================================== */
.module-status {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    padding-left: 8px;
}

/* Custom Checkbox - Large Touch Target */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    /* Invisible touch area around checkbox */
}

.completion-checkbox {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: #667eea;
    transition: transform 0.2s ease;
}

.completion-checkbox:hover {
    transform: scale(1.15);
}

.completion-checkbox:checked {
    animation: checkPop 0.3s ease;
}

/* Expand Icon */
.expand-icon {
    font-size: 0.85rem;
    color: #999;
    transition: transform 0.3s ease, color 0.3s ease;
    width: 24px;
    text-align: center;
}

.module.active .expand-icon {
    transform: rotate(180deg);
    color: #667eea;
}

/* ===================================
   MODULE CONTENT - Expandable
   =================================== */
.module-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    background: #fafbff;
}

.module.active .module-content {
    max-height: 5000px; /* Large enough for any content */
}

.content-inner {
    padding: 20px 32px 28px 36px;
}

/* ===================================
   CONTENT SECTIONS
   =================================== */
.content-section {
    margin-top: 24px;
}

.content-section:first-child {
    margin-top: 16px;
}

.content-section h3 {
    font-size: 1.05rem;
    color: #667eea;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    line-height: 1.4;
    padding-left: 4px;
}

.content-section ul,
.content-section ol {
    margin-left: 28px;
    color: #444;
}

.content-section li {
    margin-bottom: 10px;
    line-height: 1.7;
    font-size: 0.95rem;
}

.content-section p {
    color: #444;
    margin-bottom: 12px;
    line-height: 1.8;
    font-size: 0.95rem;
}

/* ===================================
   CONCEPT CARDS - Responsive
   =================================== */
.concept-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    transition: all 0.3s ease;
}

.concept-card h4 {
    color: #1a1a2e;
    font-size: 1rem;
    margin-bottom: 12px;
    font-weight: 600;
    line-height: 1.4;
}

.concept-card ul,
.concept-card ol {
    margin-left: 18px;
}

.concept-card li {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

/* ===================================
   RULE BOXES (Mom Test Module)
   =================================== */
.rule-box {
    background: linear-gradient(135deg, #f8f9ff, #fff);
    border-radius: 10px;
    padding: 16px;
    margin: 14px 0;
    border: 1px solid #e8e8ff;
}

.rule-box h5 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.bad-example {
    background: #fff0f0;
    color: #c0392b;
    padding: 10px 12px;
    border-radius: 8px;
    margin: 8px 0;
    font-size: 0.9rem;
    border-left: 3px solid #e74c3c;
    line-height: 1.5;
}

.good-example {
    background: #f0fff4;
    color: #27ae60;
    padding: 10px 12px;
    border-radius: 8px;
    margin: 8px 0;
    font-size: 0.9rem;
    border-left: 3px solid #2ecc71;
    line-height: 1.5;
}

/* ===================================
   TAKEAWAY BOX
   =================================== */
.takeaway-box {
    background: linear-gradient(135deg, #667eea15, #764ba215);
    border-radius: 10px;
    padding: 16px;
    border: 1px solid #667eea30;
}

.takeaway-box p {
    margin-bottom: 10px;
    font-weight: 500;
    color: #333;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.takeaway-box p:last-child {
    margin-bottom: 0;
}

/* ===================================
   COMPLETED MODULE STATE
   =================================== */
.module.completed {
    border-left: 4px solid #00d26a;
}

.module.completed .module-number {
    background: linear-gradient(135deg, #00d26a, #00b359);
    box-shadow: 0 4px 12px rgba(0,210,106,0.4);
}

/* ===================================
   ANIMATIONS
   =================================== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes checkPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ===================================
   SCROLLBAR - Custom
   =================================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

/* ===================================
   TABLET BREAKPOINT (768px+)
   =================================== */
@media (min-width: 768px) {
    .container {
        padding: 40px 24px;
    }
    
    .header {
        margin-bottom: 40px;
    }
    
    .module {
        border-radius: 16px;
        margin-bottom: 20px;
    }
    
    .module:hover {
        box-shadow: 0 8px 30px rgba(0,0,0,0.15);
        transform: translateY(-2px);
    }
    
    .module-header {
        padding: 20px 24px;
        min-height: 80px;
    }
    
    .module-title {
        gap: 16px;
    }
    
    .module-number {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        font-size: 1.1rem;
    }
    
    .module-title h2 {
        font-size: 1.15rem;
    }
    
    .module-status {
        gap: 16px;
    }
    
    .content-inner {
        padding: 24px 36px 32px 42px;
    }
    
    .content-section h3 {
        font-size: 1.15rem;
    }
    
    .content-section li,
    .content-section p {
        font-size: 1rem;
    }
    
    .concept-card {
        padding: 20px;
        border-radius: 12px;
    }
    
    .concept-card h4 {
        font-size: 1.1rem;
    }
    
    .concept-card li {
        font-size: 0.95rem;
    }
    
    .rule-box {
        padding: 18px;
    }
    
    .rule-box h5 {
        font-size: 1rem;
    }
    
    .bad-example,
    .good-example {
        font-size: 0.95rem;
    }
    
    .takeaway-box {
        padding: 20px;
        border-radius: 12px;
    }
    
    .takeaway-box p {
        font-size: 1rem;
    }
}

/* ===================================
   DESKTOP BREAKPOINT (1024px+)
   =================================== */
@media (min-width: 1024px) {
    .container {
        max-width: 900px;
        padding: 50px 32px;
    }

    .header h1 {
        font-size: 3rem;
    }

    .subtitle {
        font-size: 1.25rem;
    }

    .progress-container {
        height: 16px;
    }

    .module-header {
        padding: 24px 28px;
    }

    .module-title h2 {
        font-size: 1.25rem;
    }

    .content-inner {
        padding: 28px 40px 36px 48px;
    }

    .content-section {
        margin-top: 28px;
    }

    .concept-card {
        padding: 24px;
    }

    .takeaway-box {
        padding: 24px;
    }
}
/* ===================================
   PHASE 3: DARK MODE
   =================================== */

/* Theme Toggle Button */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50px;
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.toggle-icon {
    font-size: 1.2rem;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toggle-icon.moon {
    display: none;
}

/* Dark Mode Active State for Toggle */
[data-theme="dark"] .toggle-icon.sun {
    display: none;
}

[data-theme="dark"] .toggle-icon.moon {
    display: inline;
}

/* ===================================
   DARK MODE VARIABLES & STYLES
   =================================== */

/* Dark mode body */
[data-theme="dark"] body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* Dark mode header */
[data-theme="dark"] .header h1 {
    color: #f0f0f0;
}

[data-theme="dark"] .subtitle {
    color: rgba(255, 255, 255, 0.7);
}

/* Dark mode progress */
[data-theme="dark"] .progress-container {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .progress-text {
    color: rgba(255, 255, 255, 0.7);
}

/* Dark mode module cards */
[data-theme="dark"] .module {
    background: #1e2746;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .module:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .module-header {
    background: #1e2746;
}

[data-theme="dark"] .module-header:hover {
    background: #252f4a;
}

[data-theme="dark"] .module-header:active {
    background: #2a3550;
}

[data-theme="dark"] .module-title h2 {
    color: #e8e8e8;
}

[data-theme="dark"] .expand-icon {
    color: #888;
}

[data-theme="dark"] .module.active .expand-icon {
    color: #667eea;
}

/* Dark mode module content */
[data-theme="dark"] .module-content {
    background: #161d30;
}

[data-theme="dark"] .content-section h3 {
    color: #8b9dea;
}

[data-theme="dark"] .content-section ul,
[data-theme="dark"] .content-section ol,
[data-theme="dark"] .content-section p,
[data-theme="dark"] .content-section li {
    color: #c8c8c8;
}

/* Dark mode concept cards */
[data-theme="dark"] .concept-card {
    background: #232d48;
    border-left-color: #667eea;
}

[data-theme="dark"] .concept-card h4 {
    color: #e0e0e0;
}

[data-theme="dark"] .concept-card li,
[data-theme="dark"] .concept-card p {
    color: #b8b8b8;
}

/* Dark mode rule boxes */
[data-theme="dark"] .rule-box {
    background: #232d48;
    border-color: #3a4568;
}

[data-theme="dark"] .rule-box h5 {
    color: #e0e0e0;
}

[data-theme="dark"] .bad-example {
    background: rgba(255, 107, 107, 0.15);
    color: #ff8a8a;
}

[data-theme="dark"] .good-example {
    background: rgba(81, 207, 102, 0.15);
    color: #6de882;
}

/* Dark mode takeaway box */
[data-theme="dark"] .takeaway-box {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
    border-color: rgba(102, 126, 234, 0.4);
}

[data-theme="dark"] .takeaway-box p {
    color: #d0d0d0;
}

/* Dark mode footer */
[data-theme="dark"] .footer p {
    color: rgba(255, 255, 255, 0.5);
}

/* Dark mode scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Smooth transition for theme changes */
body,
.module,
.module-header,
.module-content,
.content-section,
.concept-card,
.rule-box,
.takeaway-box {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ===================================
   DARK MODE - RESPONSIVE ADJUSTMENTS
   =================================== */
@media (min-width: 768px) {
    .theme-toggle {
        top: 24px;
        right: 24px;
        padding: 10px 20px;
    }

    .toggle-icon {
        font-size: 1.3rem;
    }
}

@media (min-width: 1024px) {
    .theme-toggle {
        top: 32px;
        right: 32px;
        padding: 12px 24px;
    }

    .toggle-icon {
        font-size: 1.4rem;
    }
}

/* Mobile positioning fix */
@media (max-width: 480px) {
    .theme-toggle {
        top: 12px;
        right: 12px;
        padding: 6px 12px;
    }

    .toggle-icon {
        font-size: 1rem;
    }
}
/* ===================================
   PHASE 4: PROGRESS TRACKING
   =================================== */

/* Progress percentage display */
.progress-percentage {
    opacity: 0.8;
    font-size: 0.85em;
    margin-left: 4px;
}

/* Completed module styling */
.module.completed {
    border-left: 4px solid #00ff88;
}

.module.completed .module-number {
    background: linear-gradient(135deg, #00d9ff, #00ff88);
    box-shadow: 0 4px 12px rgba(0, 255, 136, 0.4);
}

.module.completed .module-title h2 {
    color: #2d8659;
}

/* Completion checkmark animation */
.module.completed .module-header::after {
    content: '✓';
    position: absolute;
    right: 70px;
    font-size: 1.2rem;
    color: #00d9a0;
    animation: checkAppear 0.4s ease-out;
}

.module-header {
    position: relative;
}

@keyframes checkAppear {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-45deg);
    }
    50% {
        transform: scale(1.3) rotate(10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* Progress bar glow when complete */
.progress-bar.complete {
    background: linear-gradient(90deg, #00ff88, #00d9ff, #00ff88);
    background-size: 200% 100%;
    animation: progressGlow 2s ease infinite;
}

@keyframes progressGlow {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Celebration effect when all complete */
.all-complete .header h1 {
    animation: celebrateTitle 0.6s ease;
}

@keyframes celebrateTitle {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.02);
    }
    50% {
        transform: scale(1.05);
    }
    75% {
        transform: scale(1.02);
    }
}

/* Celebration banner */
.celebration-banner {
    background: linear-gradient(135deg, #00d9ff, #00ff88);
    color: #1a1a2e;
    text-align: center;
    padding: 16px 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    font-weight: 600;
    font-size: 1.1rem;
    animation: bannerSlideIn 0.5s ease-out;
    box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
}

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

.celebration-banner .emoji {
    font-size: 1.3rem;
    margin: 0 8px;
}

/* Reset progress button */
.reset-progress-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-top: 12px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.reset-progress-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.reset-progress-btn:active {
    transform: scale(0.98);
}

/* Dark mode progress styles */
[data-theme="dark"] .module.completed {
    border-left-color: #00ff88;
}

[data-theme="dark"] .module.completed .module-title h2 {
    color: #6de882;
}

[data-theme="dark"] .module.completed .module-header::after {
    color: #00ff88;
}

[data-theme="dark"] .celebration-banner {
    background: linear-gradient(135deg, #00d9ff, #00ff88);
    color: #1a1a2e;
}

[data-theme="dark"] .reset-progress-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .reset-progress-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .celebration-banner {
        padding: 20px 32px;
        font-size: 1.2rem;
    }

    .module.completed .module-header::after {
        right: 80px;
        font-size: 1.3rem;
    }
}

@media (min-width: 1024px) {
    .celebration-banner {
        padding: 24px 40px;
        font-size: 1.3rem;
    }

    .module.completed .module-header::after {
        right: 90px;
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .module.completed .module-header::after {
        right: 60px;
        font-size: 1rem;
    }

    .celebration-banner {
        padding: 14px 20px;
        font-size: 1rem;
    }
}
