/* ============================================
   GRADE 1 MATH ADVENTURE - RESPONSIVE STYLES
   Modern, kid-friendly, fully responsive
   ============================================ */

/* Font loaded via HTML link for better performance */

/* CSS Variables for consistent theming */
:root {
    --primary-blue: #3498db;
    --primary-green: #2ecc71;
    --primary-orange: #e67e22;
    --primary-purple: #9b59b6;
    --primary-gold: #f1c40f;
    --primary-pink: #ec4899;
    --primary-teal: #14b8a6;
    --primary-indigo: #6366f1;
    --primary-rose: #f43f5e;
    --primary-cyan: #06b6d4;
    --primary-lime: #84cc16;
    --primary-gray: #6b7280;
    --text-dark: #333;
    --text-light: #666;
    --bg-light: #f0f8ff;
    --bg-white: #ffffff;
    --shadow: 0 4px 15px rgba(0,0,0,0.1);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.15);
    --radius: 16px;
    --radius-small: 10px;
}

/* Base styles */
* {
    box-sizing: border-box;
}

html {
    /* Improve text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Nunito', 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    text-align: center;
    padding: 20px;
    margin: 0;
    color: var(--text-dark);
    line-height: 1.6;
    /* Better font rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main container - now transparent on homepage, white on quiz/history */
.container {
    max-width: 900px;
    margin: 0 auto;
    background: transparent;
    padding: 20px;
}

/* Container with card background (for quiz, history, review pages) */
.container-card {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-white);
    padding: 25px 20px;
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

@media (min-width: 480px) {
    .container {
        padding: 30px;
    }
    .container-card {
        padding: 30px;
    }
}

@media (min-width: 768px) {
    .container {
        padding: 40px;
    }
    .container-card {
        padding: 40px;
    }
}

/* Typography */
h1 {
    color: var(--text-dark);
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 10px;
}

@media (min-width: 480px) {
    h1 {
        font-size: 2rem;
    }
}

h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

p {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* ============================================
   MENU GRID - Responsive card layout
   ============================================ */
.menu-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 25px 0;
}

@media (min-width: 400px) {
    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 700px) {
    .menu-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

/* Menu cards */
.card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 15px;
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: var(--radius);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 70px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.card:hover::before {
    left: 100%;
}

@media (min-width: 480px) {
    .card {
        font-size: 1.25rem;
        padding: 25px 20px;
        min-height: 90px;
    }
}

.card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
}

.card:focus {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

.card:active {
    transform: translateY(-2px) scale(1.01);
}

/* Card color classes - More vibrant gradients */
.purple { background: linear-gradient(135deg, #a855f7, #7c3aed); box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3); }
.blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3); }
.orange { background: linear-gradient(135deg, #f97316, #ea580c); box-shadow: 0 4px 15px rgba(249, 115, 22, 0.3); }
.green { background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3); }
.gold { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: var(--text-dark); text-shadow: none; box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3); }
.indigo { background: linear-gradient(135deg, #818cf8, #6366f1); box-shadow: 0 4px 15px rgba(129, 140, 248, 0.3); }
.teal { background: linear-gradient(135deg, #2dd4bf, #14b8a6); box-shadow: 0 4px 15px rgba(45, 212, 191, 0.3); }
.pink { background: linear-gradient(135deg, #f472b6, #ec4899); box-shadow: 0 4px 15px rgba(244, 114, 182, 0.3); }
.rose { background: linear-gradient(135deg, #fb7185, #f43f5e); box-shadow: 0 4px 15px rgba(251, 113, 133, 0.3); }
.cyan { background: linear-gradient(135deg, #22d3ee, #06b6d4); box-shadow: 0 4px 15px rgba(34, 211, 238, 0.3); }
.lime { background: linear-gradient(135deg, #a3e635, #84cc16); box-shadow: 0 4px 15px rgba(163, 230, 53, 0.3); }
.gray { background: linear-gradient(135deg, #9ca3af, #6b7280); box-shadow: 0 4px 15px rgba(156, 163, 175, 0.3); }

/* ============================================
   QUIZ BUTTONS - Large touch targets
   ============================================ */
.option-btn {
    display: block;
    width: 100%;
    margin: 10px 0;
    padding: 18px 15px;
    font-size: 1.2rem;
    font-weight: 600;
    font-family: inherit;
    border: 3px solid #e0e0e0;
    border-radius: var(--radius);
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 60px;
    touch-action: manipulation;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

@media (min-width: 480px) {
    .option-btn {
        font-size: 1.35rem;
        padding: 20px;
    }
}

.option-btn:hover:not([disabled]) {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-color: var(--primary-blue);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.15);
}

.option-btn:focus:not([disabled]) {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

.option-btn:active:not([disabled]) {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.1);
}

.option-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-container {
    margin: 15px 0 25px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue), var(--primary-green));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 5px;
}

.progress-text {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

/* ============================================
   HEADER (Quiz page)
   ============================================ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

#strand-badge {
    background: var(--primary-purple);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.95rem;
}

#score-board {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-gold);
}

/* ============================================
   HISTORY LIST - Mobile-friendly cards
   ============================================ */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-card {
    background: var(--bg-white);
    border: 2px solid #f0f0f0;
    border-radius: var(--radius-small);
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: box-shadow 0.2s ease;
}

.history-card:hover {
    box-shadow: var(--shadow);
}

.history-info {
    flex: 1;
    min-width: 150px;
    text-align: left;
}

.history-date {
    display: block;
    font-size: 0.85rem;
    color: var(--text-light);
}

.history-strand {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-dark);
    text-transform: capitalize;
}

.history-mood {
    display: block;
    font-size: 0.9rem;
    margin-top: 4px;
}

.history-score {
    font-size: 1.4rem;
    font-weight: 800;
    min-width: 60px;
    text-align: center;
}

.score-good {
    color: var(--primary-green);
}

.score-needs-work {
    color: var(--primary-orange);
}

.empty-state {
    padding: 40px 20px;
    color: var(--text-light);
    font-size: 1.1rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-small {
    display: inline-block;
    background: var(--primary-blue);
    color: white;
    padding: 10px 18px;
    border-radius: var(--radius-small);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
    min-height: 44px;
    line-height: 1.5;
}

.btn-small:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-small:focus {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

.btn-secondary {
    display: inline-block;
    margin-top: 20px;
    text-decoration: none;
    color: var(--text-light);
    font-size: 1rem;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: var(--radius-small);
    transition: all 0.2s ease;
    min-height: 44px;
}

.btn-secondary:hover {
    background: #f0f0f0;
    color: var(--text-dark);
}

/* Next/Finish buttons in quiz */
#next-btn, #finish-btn {
    display: inline-block;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-small);
    cursor: pointer;
    margin: 10px 5px;
    transition: all 0.2s ease;
    min-height: 50px;
}

#next-btn {
    background: var(--primary-blue);
    color: white;
}

#next-btn:hover {
    background: #2980b9;
}

#finish-btn {
    background: var(--primary-green);
    color: white;
}

#finish-btn:hover {
    background: #27ae60;
}

/* ============================================
   CODING MAZE GRID
   ============================================ */
.maze-grid {
    margin: 20px auto;
    border-collapse: collapse;
    background: #333;
    border-radius: var(--radius-small);
    overflow: hidden;
}

.maze-grid td {
    width: 50px;
    height: 50px;
    font-size: 1.8rem;
    border: 2px solid #555;
    background: #fff;
    text-align: center;
    vertical-align: middle;
}

@media (min-width: 480px) {
    .maze-grid td {
        width: 60px;
        height: 60px;
        font-size: 2.2rem;
    }
}

/* ============================================
   CANADIAN COINS - Responsive
   ============================================ */
.coin-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.coin {
    border-radius: 50%;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.nickel {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #e0e0e0, #bdbdbd);
    border: 2px solid #9e9e9e;
    font-size: 0.85rem;
    color: #757575;
}
.nickel::after { content: "5¢"; }

.dime {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #e0e0e0, #bdbdbd);
    border: 2px solid #9e9e9e;
    font-size: 0.75rem;
    color: #757575;
}
.dime::after { content: "10¢"; }

.quarter {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #e0e0e0, #bdbdbd);
    border: 2px solid #9e9e9e;
    font-size: 0.9rem;
    color: #757575;
}
.quarter::after { content: "25¢"; }

.loonie {
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, #ffd700, #f1c40f);
    border: 3px solid #d4ac0d;
    font-size: 1rem;
    color: #9a7d0a;
}
.loonie::after { content: "$1"; }

.toonie {
    width: 65px;
    height: 65px;
    background: radial-gradient(circle, #ffd700 45%, #bdbdbd 46%);
    border: 2px solid #9e9e9e;
    font-size: 1.1rem;
    color: #9a7d0a;
}
.toonie::after { content: "$2"; }

@media (min-width: 480px) {
    .nickel { width: 60px; height: 60px; font-size: 0.95rem; }
    .dime { width: 45px; height: 45px; font-size: 0.8rem; }
    .quarter { width: 75px; height: 75px; font-size: 1rem; }
    .loonie { width: 70px; height: 70px; font-size: 1.1rem; }
    .toonie { width: 80px; height: 80px; font-size: 1.2rem; }
}

/* ============================================
   REVIEW CARDS (in review.html)
   ============================================ */
.review-card {
    border: 2px solid #ddd;
    border-radius: var(--radius-small);
    padding: 15px;
    margin-bottom: 15px;
    text-align: left;
    background: var(--bg-white);
}

.correct {
    border-left: 8px solid var(--primary-green);
}

.wrong {
    border-left: 8px solid #e74c3c;
    background: #fff5f5;
}

.ans-tag {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    color: white;
    margin: 5px 5px 5px 0;
    font-size: 0.9rem;
}

.bg-green { background: var(--primary-green); }
.bg-red { background: #e74c3c; }
.bg-blue { background: var(--primary-blue); }

/* ============================================
   STREAK & ACHIEVEMENT BADGES
   ============================================ */
.streak-counter {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #ff9500, #ff5e3a);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.95rem;
    animation: pulse 1s ease-in-out infinite;
}

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

.achievement-badge {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f1c40f, #e67e22);
    color: white;
    padding: 20px 35px;
    border-radius: 20px;
    text-align: center;
    animation: badgePop 0.5s ease-out forwards;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.achievement-badge h3 {
    margin: 0 0 5px;
    font-size: 1.4rem;
}

.achievement-badge p {
    margin: 0;
    font-size: 1rem;
    color: white;
    opacity: 0.9;
}

@keyframes badgePop {
    0% { transform: translateX(-50%) scale(0); opacity: 0; }
    60% { transform: translateX(-50%) scale(1.1); }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ============================================
   MASCOT
   ============================================ */
.mascot {
    position: fixed;
    bottom: 15px;
    right: 15px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    z-index: 50;
}

.mascot-emoji {
    font-size: 2.5rem;
    animation: bounce 2s infinite ease-in-out;
}

@media (min-width: 480px) {
    .mascot-emoji {
        font-size: 3rem;
    }
}

.mascot-bubble {
    background: white;
    padding: 10px 14px;
    border-radius: 15px 15px 0 15px;
    box-shadow: var(--shadow);
    max-width: 140px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
    display: none !important;
}

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

/* Focus visible for accessibility */
:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ============================================
   USER HEADER STYLES
   ============================================ */
.user-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 5px 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* ============================================
   CLOCK SVG STYLES
   ============================================ */
.clock {
    display: block;
    margin: 15px auto;
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   ONBOARDING OVERLAY
   ============================================ */
.onboarding {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    text-align: center;
}

.onboarding-content {
    background: white;
    padding: 40px 30px;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 100%;
}

.onboarding-emoji {
    font-size: 4rem;
    margin-bottom: 10px;
}

.onboarding h1 {
    font-size: 1.8rem;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.onboarding p {
    color: var(--text-light);
    margin-bottom: 25px;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    background: white;
    border: 2px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-dark);
}

.btn-google:hover {
    background: #f8f8f8;
    border-color: #bbb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-google img {
    width: 20px;
    height: 20px;
}

.btn-divider {
    margin: 15px 0 !important;
    color: #aaa !important;
    font-size: 0.9rem !important;
}

.btn-guest {
    display: block;
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: 2px solid var(--primary-purple);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--primary-purple);
}

.btn-guest:hover {
    background: var(--primary-purple);
    color: white;
}

.guest-note {
    font-size: 0.8rem !important;
    color: #aaa !important;
    margin-top: 15px !important;
    margin-bottom: 0 !important;
}

/* Local badge for guest history */
.local-badge {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

/* ============================================
   HOMEPAGE SPECIFIC STYLES
   Cards directly on gradient, no white container
   ============================================ */
.home-container {
    background: transparent;
}

.home-title {
    color: white;
    font-size: 2rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    margin-bottom: 5px;
}

@media (min-width: 480px) {
    .home-title {
        font-size: 2.5rem;
    }
}

@media (min-width: 768px) {
    .home-title {
        font-size: 3rem;
    }
}

.home-subtitle {
    color: rgba(255,255,255,0.9);
    font-size: 1.2rem;
    margin-bottom: 25px;
}

.home-header .user-info {
    color: rgba(255,255,255,0.9);
}

.home-header .user-avatar {
    border: 2px solid rgba(255,255,255,0.5);
}

/* Light button variant for use on dark/gradient backgrounds */
.btn-light {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
    backdrop-filter: blur(10px);
}

.btn-light:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

/* Secondary button light variant */
a.btn-secondary.btn-light {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-small);
}

a.btn-secondary.btn-light:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* ============================================
   LANGUAGE SWITCHER
   ============================================ */
.lang-switcher {
    display: flex;
    gap: 2px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 2px;
    margin-right: auto;
}

.lang-switcher a {
    display: block;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    color: rgba(255,255,255,0.8);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.lang-switcher a:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

.lang-switcher a.active {
    background: rgba(255,255,255,0.25);
    color: white;
}
