:root {
    --bg-color: #f4f6f8;
    --text-color: #1a1a1a;
    --primary-color: #0056b3;
    --accent-color: #ffb703;
    --button-bg: #ffffff;
    --button-border: #cccccc;
    --highlight-color: rgba(255, 183, 3, 0.7);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    text-align: center;
    padding: 1rem;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h1 {
    margin: 0;
    font-size: 2rem;
}

p#artwork-artist {
    margin: 0.5rem 0 0;
    font-size: 1.2rem;
    color: #555;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}


#visual-area {
    flex: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

#image-container {
    position: relative;
    display: inline-block; /* S'adapte exactement à la taille de l'image */
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#artwork-image {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 75vh;
}

#highlight-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    transition: all 0.3s ease;
}

.highlight-circle {
    position: absolute;
    border: 6px solid var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--accent-color);
    transform: translate(-50%, -50%);
    animation: pulse 1.5s infinite alternate;
}

@keyframes pulse {
    from { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    to { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
}

#description-container {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    width: 100%;
    text-align: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#interaction-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#sequence-container {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

#sequence-question {
    text-align: center;
    font-size: 1.8rem;
    margin-top: 0;
    color: var(--primary-color);
}

#icons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    width: 100%;
    margin-top: 1rem;
}

.icon-button {
    background-color: var(--button-bg);
    border: 4px solid var(--button-border);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    transition: transform 0.1s, border-color 0.2s, background-color 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.icon-button:hover, .icon-button:focus {
    border-color: var(--primary-color);
    transform: scale(1.05);
    outline: none;
}

.icon-button:active {
    transform: scale(0.95);
}

.icon-button.active {
    border-color: var(--accent-color);
    background-color: #fff9e6;
    transform: scale(1.05);
}

.arasaac-icon {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

.icon-label {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text-color);
}

#controls-container {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.nav-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 1rem 2rem;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: background-color 0.2s, transform 0.1s;
}

.nav-button:hover {
    background-color: #004494;
    transform: scale(1.05);
}

.nav-button:active {
    transform: scale(0.95);
}

/* Styles pour le SVG (Option 2) */
#highlight-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.highlight-path {
    fill: rgba(255, 183, 3, 0.2); /* Remplissage léger */
    stroke: var(--accent-color);
    stroke-width: 0.8; /* En pourcentage du viewBox 100x100 */
    stroke-linecap: round;
    stroke-linejoin: round;
    animation: svgPulse 1.5s infinite alternate;
}

@keyframes svgPulse {
    from { opacity: 0.6; stroke-width: 0.5; }
    to { opacity: 1; stroke-width: 1.2; box-shadow: 0 0 10px var(--accent-color); }
}

/* --- BOUTONS VOCAUX --- */
.speak-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    margin-left: 10px;
    vertical-align: middle;
    transition: transform 0.2s;
    opacity: 0.8;
}
.speak-btn:hover {
    transform: scale(1.2);
    opacity: 1;
}

.question-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* --- CONFETTIS GAMIFICATION --- */
.confetti {
    position: fixed;
    top: -10px;
    width: 12px;
    height: 24px;
    z-index: 9999;
    animation: fall linear forwards;
    border-radius: 2px;
}

@keyframes fall {
    0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}


/* Gear icon — accès discret à l'espace enseignant (questions.html) */
.teacher-gear {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.15);
    color: rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    font-size: 18px;
    text-decoration: none;
    z-index: 9999;
    transition: transform 0.25s ease, background 0.2s, color 0.2s;
    user-select: none;
}
.teacher-gear:hover {
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    transform: rotate(60deg);
}


/* Replay-sound button on icon buttons */
.icon-button { position: relative; }
.sound-replay-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 255, 255, 0.85);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s;
}
.sound-replay-btn:hover { transform: scale(1.1); }


/* ────────── Mobile / vertical adaptive layout ──────────
   Goal: everything fits in one viewport, no scrolling on phone.
   - Header gets compact (title + artist on one line, smaller font).
   - Image takes the largest share of vertical space.
   - Question + icons compress to fit; icons get smaller but stay tappable.
   - Description shrinks to a small text area; can scroll inside if long.
   - Next button floats at the bottom-right so it doesn't steal layout space.
*/
@media (max-width: 768px) {
    html, body { height: 100vh; overflow: hidden; }
    body { display: flex; flex-direction: column; }

    header {
        padding: 0.35rem 0.7rem;
        flex: 0 0 auto;
        text-align: left;
    }
    header h1 { font-size: 0.95rem; display: inline; vertical-align: middle; }
    header p#artwork-artist {
        display: inline; font-size: 0.72rem; color: #666;
        margin: 0 0 0 0.5em; vertical-align: middle;
    }

    main {
        flex: 1; min-height: 0;
        padding: 0.4rem; gap: 0.4rem;
        display: flex; flex-direction: column;
        overflow: hidden;
    }

    #visual-area { flex: 1 1 55%; min-height: 0; gap: 0.3rem; }
    #image-container { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
    #artwork-image { max-height: 100%; max-width: 100%; height: auto; width: auto; object-fit: contain; }
    #description-container {
        flex: 0 0 auto;
        padding: 0.4rem 0.6rem;
        font-size: 0.78rem;
        max-height: 3.5em;
        overflow-y: auto;
        line-height: 1.25;
    }

    #interaction-area { flex: 1 1 45%; min-height: 0; gap: 0.4rem; }
    #sequence-container {
        padding: 0.5rem 0.7rem 0.4rem;
        flex: 1 1 auto; min-height: 0;
        overflow: hidden;
        gap: 0.3rem;
    }
    #sequence-question {
        font-size: 0.92rem;
        margin: 0 0 0.2rem;
        line-height: 1.2;
    }
    .question-header { gap: 5px; }
    .speak-btn { font-size: 1.1rem; margin-left: 4px; }

    #icons-grid {
        grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
        gap: 0.4rem;
        margin-top: 0.2rem;
        max-width: 100%;
    }
    .icon-button {
        padding: 0.35rem;
        gap: 0.2rem;
        border-width: 2px;
        border-radius: 9px;
    }
    .arasaac-icon { width: 44px; height: 44px; }
    .icon-label { font-size: 0.7rem; line-height: 1.05; text-align: center; }

    .sound-replay-btn {
        top: 2px; right: 2px;
        width: 20px; height: 20px;
        font-size: 10px;
    }

    /* Next button floats at the bottom-right so it doesn't steal layout space */
    #controls-container {
        position: fixed;
        bottom: 10px;
        right: 10px;
        margin: 0;
        z-index: 100;
    }
    .nav-button {
        padding: 0.5rem 0.95rem;
        font-size: 0.88rem;
        border-radius: 22px;
        box-shadow: 0 4px 14px rgba(0, 86, 179, 0.45);
    }
}

/* Mobile landscape — side-by-side: image left, question+icons right.
   Description is hidden (saves vertical space; description was already in artwork header). */
@media (max-width: 1000px) and (orientation: landscape) and (max-height: 540px) {
    header { padding: 0.3rem 0.7rem; }
    header h1 { font-size: 0.95rem; }
    header p#artwork-artist { font-size: 0.75rem; }

    main {
        flex-direction: row;
        gap: 0.6rem;
        padding: 0.4rem;
    }
    #visual-area { flex: 1.3 1 0; gap: 0.3rem; }
    #description-container { display: none; }
    #interaction-area { flex: 1 1 0; }
    #sequence-question { font-size: 0.85rem; }
    #icons-grid {
        grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
        gap: 0.35rem;
    }
    .arasaac-icon { width: 40px; height: 40px; }
    .icon-label { font-size: 0.66rem; }
    .nav-button { padding: 0.4rem 0.8rem; font-size: 0.82rem; }
}
