/* ============================================
   Kids Learning Platform — Main Stylesheet
   Design guidelines from Section 7 of the plan
   ============================================ */

/* === Disable zoom on touch devices (kids tapping) === */
* {
    -ms-touch-action: manipulation;
    touch-action: manipulation;
}

/* === CSS Custom Properties (Design Tokens) === */
:root {
    /* Colors */
    --color-primary: #4A90D9;
    --color-primary-dark: #3A7BC8;
    --color-primary-light: #6BA5E3;
    --color-secondary: #FF8C42;
    --color-secondary-dark: #E87A30;
    --color-secondary-light: #FFA666;
    --color-success: #4CAF50;
    --color-success-light: #66BB6A;
    --color-error: #E57373;
    --color-error-dark: #D32F2F;
    --color-warning: #FFD700;
    --color-bg: #FFF8F0;
    --color-card: #FFFFFF;
    --color-text: #333333;
    --color-text-light: #666666;
    --color-text-muted: #999999;
    --color-border: #E8E0D8;

    /* Typography */
    --font-family: 'Nunito', 'Segoe UI', sans-serif;
    --font-size-body: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-h1: 32px;
    --font-size-h2: 24px;
    --font-size-h3: 20px;
    --font-size-small: 14px;
    --font-weight-normal: 400;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-extrabold: 800;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Borders & Shadows */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.10);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.06);

    /* Layout */
    --container-max: 1200px;
    --header-height: 70px;
}

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

html {
    font-size: var(--font-size-body);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--color-primary-dark);
}

/* === Container === */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-bold);
    line-height: 1.3;
    color: var(--color-text);
}

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }

p {
    margin-bottom: var(--space-md);
    color: var(--color-text-light);
}

/* === Header === */
.site-header {
    background: var(--color-card);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--color-text);
    font-weight: var(--font-weight-extrabold);
    font-size: var(--font-size-lg);
}

.logo:hover {
    color: var(--color-primary);
}

.logo-mascot {
    width: 42px;
    height: 42px;
}

.logo-img {
    height: 36px;
    width: auto;
}

.logo-text {
    white-space: nowrap;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nav-link {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-light);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--color-primary);
    background: rgba(74, 144, 217, 0.08);
}

/* === Locale Switcher === */
.locale-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: var(--space-sm);
    background: var(--color-bg);
    border-radius: var(--radius-full);
    padding: 2px;
}

.locale-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 32px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: var(--font-weight-bold);
    color: var(--color-text-muted);
    transition: all 0.2s;
    text-decoration: none;
}

.locale-flag:hover {
    color: var(--color-primary);
    background: white;
}

.locale-flag.active {
    background: white;
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

/* === Main Content === */
.site-main {
    flex: 1;
}

/* === Footer === */
.site-footer {
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    padding: var(--space-lg) 0;
    margin-top: var(--space-3xl);
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--font-size-small);
    color: var(--color-text-muted);
}

.footer-link {
    color: var(--color-text-muted);
    font-weight: var(--font-weight-semibold);
}

.footer-link:hover {
    color: var(--color-primary);
}

.footer-links {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    font-family: var(--font-family);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    min-width: 48px;
    text-align: center;
    line-height: 1.2;
    user-select: none;
}

.btn:focus-visible {
    outline: 3px solid var(--color-primary-light);
    outline-offset: 2px;
}

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

.btn-primary:hover {
    background: var(--color-primary-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: var(--color-secondary-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:hover {
    background: var(--color-success-light);
    color: white;
}

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

.btn-outline:hover {
    background: var(--color-primary);
    color: white;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 8px 16px;
    font-size: var(--font-size-body);
    min-height: 40px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: var(--font-size-xl);
    min-height: 56px;
    border-radius: var(--radius-lg);
}

.btn-icon {
    padding: 12px;
    border-radius: var(--radius-full);
}

/* === Cards === */
.card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: var(--space-lg);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.card-title {
    font-size: var(--font-size-h3);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-sm);
}

/* === Feature Cards (Home page) === */
.feature-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: var(--space-xl);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-md);
}

.feature-icon img {
    width: 100%;
    height: 100%;
}

.feature-card h3 {
    font-size: var(--font-size-h3);
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

.feature-card p {
    color: var(--color-text-light);
    font-size: var(--font-size-body);
    margin-bottom: 0;
}

/* === Hero Section === */
.hero {
    padding: var(--space-3xl) 0;
    background:
        url('/assets/img/backgrounds/dashboard-bg.svg') no-repeat center bottom / contain;
    min-height: 60vh;
    display: flex;
    align-items: center;
}

.hero-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2xl);
}

.hero-text {
    flex: 1;
    max-width: 560px;
}

.hero-title {
    font-size: clamp(28px, 5vw, 44px);
    font-weight: var(--font-weight-extrabold);
    color: var(--color-text);
    margin-bottom: var(--space-md);
    line-height: 1.2;
}

.hero-subtitle {
    font-size: var(--font-size-xl);
    color: var(--color-text-light);
    margin-bottom: var(--space-xl);
}

.hero-actions {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.hero-mascot {
    flex-shrink: 0;
}

.hero-mascot img {
    width: 260px;
    height: 260px;
}

/* === Features Grid === */
.features {
    padding: var(--space-3xl) 0;
}

.section-title {
    text-align: center;
    font-size: var(--font-size-h1);
    margin-bottom: var(--space-2xl);
    color: var(--color-text);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-lg);
}

/* === Forms === */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-family);
    font-size: var(--font-size-body);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-card);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 48px;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

.form-error {
    color: var(--color-error-dark);
    font-size: var(--font-size-small);
    margin-top: var(--space-xs);
}

.form-card {
    max-width: 460px;
    margin: var(--space-2xl) auto;
    background: var(--color-card);
    padding: var(--space-2xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

/* === Alert / Flash Messages === */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    font-weight: var(--font-weight-semibold);
}

.alert-success {
    background: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #A5D6A7;
}

.alert-error {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #EF9A9A;
}

.alert-warning {
    background: #FFF8E1;
    color: #F57F17;
    border: 1px solid #FFE082;
}

.alert-info {
    background: #E3F2FD;
    color: #1565C0;
    border: 1px solid #90CAF9;
}

/* === Error Pages === */
.error-page {
    min-height: calc(100vh - var(--header-height) - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl) 0;
}

.error-content {
    text-align: center;
    max-width: 500px;
}

.error-mascot {
    margin-bottom: var(--space-lg);
}

.error-mascot img {
    width: 180px;
    height: 180px;
    margin: 0 auto;
}

.error-code {
    font-size: 80px;
    font-weight: var(--font-weight-extrabold);
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: var(--space-sm);
}

.error-message {
    font-size: var(--font-size-h2);
    margin-bottom: var(--space-sm);
}

.error-submessage {
    font-size: var(--font-size-lg);
    color: var(--color-text-light);
    margin-bottom: var(--space-xl);
}

.error-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* === Subject Navigation Cards === */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
}

.subject-card {
    background: var(--color-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    padding: var(--space-xl);
    text-align: center;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 3px solid transparent;
}

.subject-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.subject-card--math { border-color: #4A90D9; }
.subject-card--english { border-color: #FF8C42; }
.subject-card--romanian { border-color: #4CAF50; }
.subject-card--science { border-color: #AB47BC; }

.subject-card img {
    width: 64px;
    height: 64px;
}

.subject-card h3 {
    font-size: var(--font-size-h3);
}

/* === Game Answer Buttons === */
.answer-btn {
    width: 100%;
    padding: 16px 24px;
    font-family: var(--font-family);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    background: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 64px;
    text-align: left;
}

.answer-btn:hover {
    border-color: var(--color-primary);
    background: rgba(74, 144, 217, 0.05);
    transform: scale(1.02);
}

.answer-btn.correct {
    background: #E8F5E9;
    border-color: var(--color-success);
    color: #2E7D32;
}

.answer-btn.wrong {
    background: #FFEBEE;
    border-color: var(--color-error);
    color: #C62828;
}

.answer-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* === Progress Bar === */
.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    transition: width 0.5s ease;
}

/* === XP & Streak displays === */
.xp-display {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-secondary);
}

.streak-display {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-weight: var(--font-weight-bold);
    color: var(--color-secondary);
}

.streak-display img {
    width: 24px;
    height: 24px;
}

/* === Utility === */
.text-center { text-align: center; }
.text-muted  { color: var(--color-text-muted); }
.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mt-xl  { margin-top: var(--space-xl); }
.mb-sm  { margin-bottom: var(--space-sm); }
.mb-md  { margin-bottom: var(--space-md); }
.mb-lg  { margin-bottom: var(--space-lg); }
.mb-xl  { margin-bottom: var(--space-xl); }
.gap-md { gap: var(--space-md); }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === Responsive === */
@media (max-width: 768px) {
    :root {
        --font-size-h1: 26px;
        --font-size-h2: 22px;
        --header-height: 60px;
    }

    .hero-content {
        flex-direction: column-reverse;
        text-align: center;
    }

    .hero-actions {
        justify-content: center;
    }

    .hero-mascot img {
        width: 180px;
        height: 180px;
    }

    .logo-text {
        font-size: var(--font-size-body);
    }

    .features-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    .footer-inner {
        flex-direction: column;
        gap: var(--space-sm);
        text-align: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--space-md);
    }

    .hero-mascot img {
        width: 140px;
        height: 140px;
    }

    .main-nav {
        gap: var(--space-sm);
    }

    .btn-lg {
        padding: 14px 24px;
        font-size: var(--font-size-lg);
    }
}
