/* ===== VARIABLES CSS (CHARTE) ===== */
:root {
    --color-bg: #F5F6F4;
    --color-text: #2E2E2E;
    --color-accent: #5C7A8A;
    --color-positive: #8FAF9F;
    --color-alert: #E6C79C;
    --color-btn-yes: #8FAF9F;
    --color-btn-no: #E0E0E0;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 16px;
    --spacing: 16px;

    /* Responsive typography - Mobile first */
    --font-size-h1: 48px;
    --font-size-h2: 40px;
    --font-size-p: 32px;
    --font-size-briefing: 40px;
    --font-size-stimulus: 180px;
    --font-size-button: 36px;
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    touch-action: manipulation;
}

/* ===== LAYOUT ===== */
.screen {
    display: none;
    flex-direction: column;
    min-height: 100dvh;
    max-height: 100dvh;
    padding: var(--spacing);
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.screen.active {
    display: flex;
    opacity: 1;
}

.screen-header {
    flex-shrink: 0;
    text-align: center;
    padding: 0 0 var(--spacing) 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen-header .btn-icon {
    position: absolute;
    left: 0;
    display: inline-block;
    margin-bottom: 0;
    border: none;
    outline: none;
    box-shadow: none;
    background: transparent;
    color: var(--color-accent);
}

.screen-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: calc(var(--spacing) * 0.5);
    padding-top: 0;
}

.screen-footer {
    flex-shrink: 0;
    padding: var(--spacing) 0 0 0;
}

/* ===== TYPOGRAPHIE ===== */
h1 {
    font-size: var(--font-size-h1);
    font-weight: 600;
    color: var(--color-accent);
    margin-bottom: calc(var(--spacing) / 2);
}

h2 {
    font-size: var(--font-size-h2);
    font-weight: 600;
    margin-bottom: var(--spacing);
}

h3 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: var(--spacing);
}

p {
    font-size: var(--font-size-p);
    line-height: 1.6;
}

/* ===== RÈGLE ===== */
.rule-card {
    background: white;
    padding: var(--spacing);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
    max-width: 100%;
    width: 100%;
}

.rule-card h2 {
    font-size: var(--font-size-h2);
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.4;
}

.rule-banner {
    background: white;
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
    font-size: 32px;
    font-weight: 600;
    color: var(--color-text);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* ===== STIMULUS ===== */
.stimulus-container {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 0;
    margin: 0;
}

.stimulus {
    font-size: var(--font-size-stimulus);
    font-weight: 600;
    text-align: center;
    transition: opacity 0.2s ease;
}

.stimulus.shape {
    width: 150px;
    height: 150px;
    border-radius: 50%;
}

.stimulus.shape.square {
    border-radius: 8px;
}

.stimulus.shape.triangle {
    width: 0;
    height: 0;
    border-left: 75px solid transparent;
    border-right: 75px solid transparent;
    border-bottom: 130px solid currentColor;
    font-size: 0;
}

/* ===== BOUTONS ===== */
.btn {
    min-height: 80px;
    padding: 20px 24px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-family);
    font-size: var(--font-size-button);
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

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

.btn-primary {
    background: var(--color-accent);
    color: white;
    box-shadow: 0 4px 12px rgba(92, 122, 138, 0.3);
}

.btn-yes {
    background: var(--color-btn-yes);
    color: var(--color-text);
    flex: 1;
    min-width: 0;
}

.btn-no {
    background: var(--color-btn-no);
    color: var(--color-text);
    border: 2px solid #ccc;
    flex: 1;
    min-width: 0;
}

.response-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    justify-content: center;
}

.btn-icon {
    min-height: 80px;
    width: 80px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: var(--color-accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-size: 40px;
}

.btn-secondary {
    background: white;
    color: var(--color-accent);
    border: 2px solid var(--color-accent);
}

/* ===== RÉSUMÉ ===== */
.summary-grid {
    display: grid;
    gap: var(--spacing);
    width: 100%;
    max-width: 100%;
}

.metric-card {
    background: white;
    padding: var(--spacing);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.metric-label {
    font-size: 26px;
    color: #666;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 48px;
    font-weight: 600;
    color: var(--color-accent);
}

.metric-description {
    font-size: 26px;
    color: #888;
    margin-top: 12px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing);
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* ===== FEEDBACK ===== */
.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: calc(var(--spacing) * 2);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    font-size: 20px;
    font-weight: 500;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.feedback.show {
    opacity: 1;
}

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

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

.mb-1 {
    margin-bottom: var(--spacing);
}

.mb-2 {
    margin-bottom: calc(var(--spacing) * 2);
}

/* Conteneur briefing */
.briefing-container {
    max-width: 100%;
    margin: 0 auto;
    text-align: left;
}

/* Texte briefing */
.briefing-text {
    font-size: var(--font-size-briefing);
    line-height: 1.6;
    color: #555;
    margin-bottom: 12px;
}

/* Texte note */
.note-text {
    font-size: 32px;
    color: #888;
    margin-top: 12px;
}

/* Conteneur settings/help/stats */
.content-container {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
}

/* Légende stats */
.stats-legend {
    background: white;
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 26px;
}

/* Conteneur des boutons en ligne */
.buttons-row {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* Bouton principal dans buttons-row */
.btn-ready-main {
    width: 100%;
}

/* Bouton settings inline dans buttons-row */
.btn-settings-inline {
    position: static !important;
    width: 100%;
    min-height: 80px;
    font-size: 48px;
}

/* ===== RESPONSIVE ===== */
/* Mobile petit (480px et plus) */
@media (min-width: 480px) {
    :root {
        --font-size-h1: 52px;
        --font-size-h2: 44px;
        --font-size-briefing: 44px;
        --font-size-stimulus: 200px;
        --font-size-button: 38px;
    }

    .stimulus-container {
        height: 280px;
    }

    .stimulus.shape {
        width: 160px;
        height: 160px;
    }

    .stimulus.shape.triangle {
        border-left: 80px solid transparent;
        border-right: 80px solid transparent;
        border-bottom: 140px solid currentColor;
    }

    .rule-card {
        padding: calc(var(--spacing) * 1.5);
    }

    .metric-card {
        padding: calc(var(--spacing) * 1.5);
    }

    .briefing-container {
        max-width: 480px;
    }

    .note-text {
        font-size: 36px;
        margin-top: 16px;
    }

    .briefing-text {
        margin-bottom: 20px;
    }

    .stats-legend {
        padding: 16px;
        gap: 20px;
        font-size: 28px;
    }

    .buttons-row {
        flex-direction: row;
        max-width: 480px;
    }

    .screen-body {
        gap: calc(var(--spacing) * 1.5);
    }

    .btn-ready-main {
        flex: 1;
    }

    .btn-settings-inline {
        width: 80px;
        min-height: 80px;
    }
}

/* Tablette (768px et plus) */
@media (min-width: 768px) {
    :root {
        --font-size-h1: 56px;
        --font-size-h2: 48px;
        --font-size-briefing: 48px;
        --font-size-stimulus: 220px;
        --font-size-button: 40px;
    }

    .screen {
        padding: calc(var(--spacing) * 2);
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 600px;
    }

    .stimulus-container {
        height: 400px;
        max-width: 400px;
    }

    .stimulus.shape {
        width: 180px;
        height: 180px;
    }

    .stimulus.shape.triangle {
        border-left: 90px solid transparent;
        border-right: 90px solid transparent;
        border-bottom: 156px solid currentColor;
    }

    .response-buttons {
        max-width: 600px;
        gap: var(--spacing);
    }

    .action-buttons {
        max-width: 400px;
    }

    .rule-card {
        padding: calc(var(--spacing) * 2);
        max-width: 500px;
    }

    .rule-banner {
        padding: var(--spacing);
        font-size: 36px;
    }

    .metric-value {
        font-size: 52px;
    }

    .metric-label,
    .metric-description {
        font-size: 28px;
    }

    .btn {
        min-height: 90px;
        padding: var(--spacing) calc(var(--spacing) * 2);
    }

    .btn-icon {
        min-height: 90px;
        width: 90px;
    }

    .content-container {
        max-width: 600px;
    }

    .stats-legend {
        gap: 32px;
        font-size: 32px;
    }

    .buttons-row {
        max-width: 500px;
    }

    .btn-settings-inline {
        width: 90px;
        min-height: 90px;
    }

    .screen-body {
        gap: calc(var(--spacing) * 2);
        justify-content: center;
    }

    .screen-header {
        padding: var(--spacing) 0;
    }

    .screen-footer {
        padding: var(--spacing) 0;
    }
}

/* Desktop (1024px et plus) */
@media (min-width: 1024px) {
    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 800px;
    }

    .content-container {
        max-width: 800px;
    }
}

/* ===== DEBUG MODE ===== */
.debug-info {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px;
    font-size: 12px;
    font-family: monospace;
    display: none;
}

body.debug-mode .debug-info {
    display: block;
}

/* ===== STATISTIQUES ===== */
.stat-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.stat-bar-fill {
    height: 100%;
    background: var(--color-accent);
    transition: width 0.5s ease;
    border-radius: 4px;
}

.stat-bar-avg {
    position: absolute;
    top: 0;
    height: 100%;
    width: 2px;
    background: #ff6b6b;
    z-index: 2;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--color-accent);
    cursor: pointer;
    border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--color-accent);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}
