:root {
    --primary-color: #0d47a1; /* Deep ocean blue */
    --secondary-color: #00bcd4; /* Cyan / water */
    --accent-color: #ffca28; /* Golden yellow for buttons / fish */
    --text-color: #ffffff;
    --font-ar: 'Cairo', sans-serif;
    --border-radius: 20px;
}

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

html {
    overflow-x: hidden;
}

body {
    font-family: var(--font-ar);
    color: var(--text-color);
    overflow-x: hidden;
    min-height: 100vh;
}

/* OCEAN BACKGROUND & ANIMATIONS */
.ocean-background {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(180deg, #0288d1 0%, #01579b 100%);
    z-index: -1;
    overflow: hidden;
}

.bubbles {
    position: absolute;
    width: 100%;
    height: 100%;
}

.bubble {
    position: absolute;
    bottom: -50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    animation: rise infinite ease-in;
}

@keyframes rise {
    0% { transform: translateY(0) scale(1); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(-100vh) scale(1.5); opacity: 0; }
}

.seaweeds {
    position: absolute;
    bottom: -20px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 8rem;
    opacity: 0.5;
    pointer-events: none;
}
.seaweed {
    transform-origin: bottom;
    animation: sway 4s infinite ease-in-out alternate;
}
.seaweed-right {
    animation-delay: 1s;
    transform: scaleX(-1);
}

@keyframes sway {
    0% { transform: rotate(-5deg); }
    100% { transform: rotate(5deg); }
}

/* GLASSMORPHISM PANELS */
.glass-panel {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* TYPOGRAPHY */
h1, h2, h3, h4 {
    margin-bottom: 1rem;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.section-title {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--accent-color);
}

.hidden {
    display: none !important;
}

/* BUTTONS */
.btn {
    display: inline-block;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: var(--font-ar);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.btn-primary {
    background-color: #25D366; /* WhatsApp green */
    color: white;
}

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

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

/* LANDING PAGE */
.landing-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.hero-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 3rem;
    margin-bottom: 4rem;
}

.hero-content {
    flex: 1;
    min-width: 300px;
}

.main-title {
    font-size: 4.5rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.8rem;
    font-weight: 700;
    color: #e0f7fa;
    margin-bottom: 1.5rem;
}

.description {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #e1f5fe;
    margin-bottom: 2rem;
}

.hero-visual {
    flex: 1;
    min-width: 300px;
    text-align: center;
}

.cover-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
    transform: rotate(-3deg);
    transition: transform 0.4s;
    border: 5px solid rgba(255,255,255,0.2);
}
.cover-image:hover {
    transform: rotate(0deg) scale(1.03);
}

.cta-group {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

/* BENEFITS & DOWNLOADS GRID */
.benefits-section, .downloads-section {
    margin-bottom: 4rem;
}

.benefits-grid, .downloads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.benefit-card, .download-item {
    text-align: center;
    transition: transform 0.3s;
}
.benefit-card:hover, .download-item:hover {
    transform: translateY(-10px);
    background: rgba(255, 255, 255, 0.25);
}

.benefit-card .icon, .download-item .icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}

.benefit-card p, .download-item p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #e1f5fe;
}

/* ACTION SECTION */
.action-section {
    text-align: center;
    margin-bottom: 4rem;
}

.code-access-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
}

.input-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.input-group input {
    flex: 1;
    padding: 15px;
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    border-radius: 12px;
    font-size: 1.2rem;
    font-family: var(--font-ar);
    outline: none;
    transition: border-color 0.3s;
}
.input-group input::placeholder {
    color: rgba(255,255,255,0.6);
}
.input-group input:focus {
    border-color: var(--accent-color);
}

.error-message {
    color: #ff5252;
    margin-top: 1rem;
    font-weight: bold;
    background: rgba(255,0,0,0.1);
    padding: 10px;
    border-radius: 8px;
}

/* APPLICATION CONTAINER */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.app-header {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.app-title {
    margin: 0;
    font-size: 2rem;
    color: var(--accent-color);
}

.app-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-ar);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-control:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.btn-control:active {
    transform: translateY(-1px);
}

#btn-games {
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
}

#btn-downloads {
    background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
}

#btn-download-full-book {
    background: linear-gradient(135deg, #f12711 0%, #f5af19 100%);
}


/* MAP VIEW */
.map-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
    background: rgba(255,255,255,0.1);
    padding: 3rem;
    border-radius: var(--border-radius);
    backdrop-filter: blur(10px);
}

.day-bubble {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    transition: transform 0.3s, background 0.3s;
    border: 4px solid var(--accent-color);
}

.day-bubble.locked {
    background: rgba(207, 216, 220, 0.8);
    color: #78909c;
    border-color: #90a4ae;
    cursor: not-allowed;
    box-shadow: none;
}

.day-bubble:not(.locked):hover {
    transform: scale(1.15) translateY(-5px);
    background: var(--accent-color);
    color: var(--primary-color);
    border-color: white;
}

/* READER & ACTIVITIES */
.reader-view, .activity-view {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.6rem;
    line-height: 1.9;
}

.text-content {
    margin-bottom: 2rem;
}

/* Tooltip (Vocabulaire) — version responsive */
.vocab {
    color: var(--accent-color);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-thickness: 3px;
    cursor: pointer;
    font-weight: bold;
}

/* Tooltip flottant géré par JS */
#vocab-tooltip {
    position: fixed;
    background-color: var(--primary-color);
    color: white;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-family: var(--font-ar);
    max-width: min(280px, 85vw);
    white-space: normal;
    text-align: center;
    line-height: 1.5;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    border: 2px solid var(--accent-color);
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
#vocab-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.quiz-option {
    display: block;
    width: 100%;
    padding: 18px;
    margin-bottom: 15px;
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-ar);
    color: white;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 15px;
    background: rgba(0,0,0,0.2);
    cursor: pointer;
    text-align: right;
    transition: all 0.2s;
}

.quiz-option:hover {
    background: rgba(255,255,255,0.2);
    border-color: white;
}

.quiz-option.correct {
    background-color: #4caf50;
    border-color: #81c784;
}

.quiz-option.wrong {
    background-color: #f44336;
    border-color: #e57373;
}

.success-message {
    text-align: center;
    margin-top: 2rem;
    background: rgba(76, 175, 80, 0.2);
    border: 2px solid #4caf50;
    padding: 2rem;
    border-radius: 15px;
    color: white;
    font-size: 1.8rem;
    font-weight: bold;
}

.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    border-top: 2px solid rgba(255,255,255,0.2);
    padding-top: 2rem;
}

/* GAMES VIEW */
.games-view {
    max-width: 900px;
    margin: 0 auto;
}

/* =========================================
   DIPLOME ET PROJET
========================================= */
.diploma-view, .project-view {
    padding: 20px;
}

@media print {
    body * {
        visibility: hidden;
    }
    #project-view, #project-view * {
        visibility: visible;
    }
    #project-view {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        background: white;
    }
    .btn, .nav-buttons, #project-title, p {
        display: none !important;
    }
    #stickers-img {
        width: 100%;
        max-height: 100vh;
        object-fit: contain;
    }
    
    /* Impression de l'éditeur d'histoire */
    #story-creator-view {
        visibility: visible !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: transparent;
        padding: 0;
    }
    #story-creator-view .no-print, .editor-layout > div:first-child {
        display: none !important;
    }
    #book-container {
        display: block !important;
        background: transparent !important;
        padding: 0 !important;
    }
    .story-page {
        page-break-before: always; /* Force nouvelle page */
        box-shadow: none !important;
        border: none !important;
        background: white !important;
    }
    .story-page:first-child {
        page-break-before: avoid;
    }
}

/* =========================================
   STORY CREATOR (EDITEUR)
========================================= */
.story-page {
    width: 210mm;
    height: 297mm;
    background: white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    border-radius: 5px;
    flex-shrink: 0;
    padding: 20mm;
    font-family: 'Cairo', sans-serif;
    font-size: 24px;
    line-height: 1.6;
    color: #37474f;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

/* =========================================
   RESPONSIVE MOBILE
========================================= */
@media (max-width: 768px) {

    /* Prevent any horizontal overflow */
    body, .app-container, .landing-container {
        overflow-x: hidden;
    }

    .landing-container, .app-container {
        padding: 1rem;
    }

    /* Hero section stacks vertically */
    .hero-section {
        flex-direction: column;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }
    .hero-content, .hero-visual {
        min-width: unset;
        width: 100%;
    }
    .main-title {
        font-size: 2.8rem;
    }
    .tagline {
        font-size: 1.3rem;
    }
    .description {
        font-size: 1rem;
    }

    /* CTA buttons stack */
    .cta-group {
        flex-direction: column;
        gap: 0.8rem;
    }
    .cta-group .btn {
        width: 100%;
        text-align: center;
    }

    /* App header: smaller and wraps */
    .app-header {
        flex-direction: column;
        gap: 0.8rem;
        padding: 0.8rem 1rem;
    }
    .app-title {
        font-size: 1.4rem;
        text-align: center;
    }
    .app-controls {
        justify-content: center;
        gap: 8px;
    }
    .btn-control {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    /* Map view: smaller bubbles */
    .map-view {
        padding: 1.5rem;
        gap: 1rem;
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }
    .day-bubble {
        width: 70px;
        height: 70px;
        font-size: 1.5rem;
    }

    /* Reader & activity: smaller font */
    .reader-view, .activity-view {
        font-size: 1.2rem;
        line-height: 1.7;
    }
    .quiz-option {
        font-size: 1.1rem;
        padding: 12px;
    }

    /* Story pages: scale down to fit mobile screen */
    .story-page {
        width: 100%;
        height: auto;
        min-height: 80vw;
        padding: 5vw;
        font-size: 16px;
    }

    /* Vocab tooltip: avoid going off screen */
    .vocab::after {
        white-space: normal;
        width: 200px;
        left: 0;
        transform: none;
    }

    /* Buttons: full width on mobile for easier tapping */
    .nav-buttons {
        flex-direction: column;
        gap: 0.8rem;
    }
    .nav-buttons .btn {
        width: 100%;
        text-align: center;
    }

    /* Input group stacks on mobile */
    .input-group {
        flex-direction: column;
    }
    .input-group .btn {
        width: 100%;
    }

    /* Games view */
    .games-view {
        padding: 0;
    }

    /* Success/final action buttons */
    .final-action-buttons {
        flex-direction: column !important;
        gap: 12px !important;
    }
    .final-action-buttons .btn {
        width: 100% !important;
        font-size: 1rem !important;
    }
}

.story-page[contenteditable]:empty:before,
.editable-page[contenteditable]:empty:before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
    cursor: text;
}

.story-page img.inserted-sticker {
    cursor: pointer;
    border: 2px solid transparent;
    transition: border 0.2s;
    vertical-align: middle;
    margin: 5px;
    display: inline-block;
}

.story-page img.inserted-sticker.selected {
    border: 3px dashed #ffca28;
}
