/* ==========================================================================
   TRIGO CIRCLE GAME STYLES
   Développé pour StimuludoGameEngine.
   ========================================================================== */

/* --- 1. Score Box Réglée (Pipeline Règle 3.1) --- */
.score-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    padding: 0;
    box-sizing: border-box;
}

.score-box #current-score {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
}

@media (max-width: 600px) {
    .score-box #current-score {
        font-size: 0.95rem;
    }
}

/* --- 2. Workspace & Arène (Pipeline Règle 5.1 : Centrage Vertical Parfait) --- */
.workspace-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 0.25rem 0.5rem;
    box-sizing: border-box;
}

.trigo-arena {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: 100%;
    position: relative;
    gap: 0.4rem;
    user-select: none;
    -webkit-user-select: none;
}

/* --- 3. Consigne Textuelle Épurée (Pipeline Règle 3.2 : Style .time-instruction) --- */
.trigo-instruction {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-primary, #fafafa);
    text-align: center;
    min-height: 48px;
    margin: 0;
    padding: 0;
}

.trigo-instruction .prompt-label {
    opacity: 0.85;
}

.trigo-instruction .prompt-angle-math {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none !important;
    color: var(--text-primary, #ffffff);
}

/* Fraction Mathématique */
.math-fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    line-height: 1;
    margin: 0 0.15rem;
    font-size: 0.95em;
    text-transform: none !important;
}

.math-fraction .math-num {
    padding-bottom: 2px;
    border-bottom: 2.5px solid currentColor;
    text-align: center;
    text-transform: none !important;
}

.math-fraction .math-denom {
    padding-top: 2px;
    text-align: center;
    text-transform: none !important;
}

.math-whole {
    font-size: 1.2em;
    font-weight: 700;
    text-transform: none !important;
}

.math-pi {
    text-transform: none !important;
    font-family: inherit;
    font-weight: 700;
    font-size: 1.05em;
    padding: 0 1px;
}

/* --- 4. Conteneur SVG & Proportions (Pipeline Règle 5.2 : Aucune Déformation) --- */
.trigo-svg-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    aspect-ratio: 1 / 1;
    max-height: calc(100% - 54px);
    max-width: min(82vh, 580px);
}

.trigo-svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
    overflow: visible;
    touch-action: manipulation;
}

/* Agrandissement en plein écran (Fullscreen) */
:fullscreen .trigo-svg-container,
:-webkit-full-screen .trigo-svg-container,
.is-fullscreen .trigo-svg-container {
    max-width: min(86vh, 86vw);
    max-height: calc(100% - 65px);
}

/* --- 5. Éléments Graphiques SVG --- */
.trigo-circle-bg {
    fill: var(--card-bg, #27272a);
    stroke: var(--border-color, #3f3f46);
    stroke-width: 1.5;
    opacity: 0.45;
}

.trigo-circle-main {
    fill: none;
    stroke: var(--text-primary, #fafafa);
    stroke-width: 2.2px;
    opacity: 0.9;
}

.trigo-axis {
    stroke: var(--text-secondary, #d4d4d8);
    stroke-width: 1.4px;
    opacity: 0.55;
}

.trigo-axis-arrow {
    fill: var(--text-secondary, #d4d4d8);
    opacity: 0.75;
}

.trigo-axis-label {
    fill: var(--text-primary, #fafafa);
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-anchor: middle;
    dominant-baseline: central;
    opacity: 0.85;
}

.trigo-guide-line {
    stroke: var(--text-secondary, #d4d4d8);
    stroke-width: 1.1px;
    stroke-dasharray: 4 4;
    opacity: 0.35;
    transition: opacity 0.25s ease, stroke 0.25s ease;
}

.trigo-guide-line.enhanced {
    opacity: 0.7;
    stroke-width: 1.3px;
    stroke: var(--text-primary, #fafafa);
}

.trigo-ray-line {
    stroke: var(--text-secondary, #d4d4d8);
    stroke-width: 1.2px;
    stroke-dasharray: 4 4;
    opacity: 0.45;
    transition: opacity 0.2s ease, stroke 0.2s ease;
}

.trigo-ray-line.visible {
    opacity: 0.75;
    stroke: var(--text-primary, #fafafa);
}

/* Graduations / Encoches sur le cercle marquant chaque arrêt d'angle */
.trigo-tick-line {
    stroke: var(--text-primary, #fafafa);
    stroke-width: 2.2px;
    stroke-linecap: round;
    opacity: 0.8;
    pointer-events: none;
    transition: stroke 0.15s ease, opacity 0.15s ease, stroke-width 0.15s ease;
}

.trigo-tick-line.axis-tick {
    stroke-width: 2.8px;
    opacity: 0.95;
}

.trigo-tick-line.active {
    stroke: var(--accent-color, #72DE5F);
    stroke-width: 3.2px;
    opacity: 1;
    filter: drop-shadow(0 0 5px var(--accent-color, #72DE5F));
}

.trigo-tick-line.success {
    stroke: var(--accent-color, #72DE5F) !important;
    stroke-width: 3.2px !important;
    opacity: 1 !important;
    filter: drop-shadow(0 0 6px var(--accent-color, #72DE5F)) !important;
}

.trigo-tick-line.error {
    stroke: var(--accent-color-secondary, #ef4444) !important;
    stroke-width: 3.2px !important;
    opacity: 1 !important;
    filter: drop-shadow(0 0 6px var(--accent-color-secondary, #ef4444)) !important;
}

.trigo-tick-line.reveal {
    stroke: var(--accent-color, #72DE5F) !important;
    stroke-width: 3.5px !important;
    opacity: 1 !important;
    filter: drop-shadow(0 0 8px var(--accent-color, #72DE5F)) !important;
}

/* --- 6. Secteur Angulaire Interactif Épuré (depuis l'angle 0 jusqu'au rayon) --- */
.trigo-angle-sector {
    fill: var(--accent-color, #72DE5F);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.trigo-angle-sector.visible {
    opacity: 0.3;
}

.trigo-angle-sector.sector-success {
    fill: var(--accent-color, #72DE5F) !important;
    opacity: 0.45 !important;
}

.trigo-angle-sector.sector-error {
    fill: var(--accent-color-secondary, #ef4444) !important;
    opacity: 0.45 !important;
}

.trigo-angle-sector.sector-reveal {
    fill: var(--accent-color, #72DE5F) !important;
    opacity: 0.5 !important;
}

/* Rayon de base (angle 0, segment x=0 à x=1) */
.trigo-baseline-ray {
    stroke: var(--accent-color, #72DE5F);
    stroke-width: 2.2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease, stroke 0.15s ease;
}

.trigo-baseline-ray.visible {
    opacity: 0.85;
}

.trigo-baseline-ray.success {
    stroke: var(--accent-color, #72DE5F) !important;
    opacity: 1 !important;
}

.trigo-baseline-ray.error {
    stroke: var(--accent-color-secondary, #ef4444) !important;
    opacity: 1 !important;
}

.trigo-baseline-ray.reveal {
    stroke: var(--accent-color, #72DE5F) !important;
    opacity: 1 !important;
}

/* Rayon terminal de l'angle survolé */
.trigo-hover-ray {
    stroke: var(--accent-color, #72DE5F);
    stroke-width: 2.2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease, stroke 0.15s ease;
}

.trigo-hover-ray.visible {
    opacity: 0.85;
}

.trigo-hover-ray.success {
    stroke: var(--accent-color, #72DE5F) !important;
    stroke-width: 3px !important;
    opacity: 1 !important;
    filter: drop-shadow(0 0 8px var(--accent-color, #72DE5F)) !important;
}

.trigo-hover-ray.error {
    stroke: var(--accent-color-secondary, #ef4444) !important;
    stroke-width: 3px !important;
    opacity: 1 !important;
    filter: drop-shadow(0 0 8px var(--accent-color-secondary, #ef4444)) !important;
}

.trigo-hover-ray.reveal {
    stroke: var(--accent-color, #72DE5F) !important;
    stroke-width: 3.5px !important;
    opacity: 1 !important;
    filter: drop-shadow(0 0 12px var(--accent-color, #72DE5F)) !important;
}

/* Libellés d'angle */
.trigo-sector-label {
    fill: var(--text-secondary, #d4d4d8);
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: central;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, fill 0.15s ease;
}

.trigo-sector-label.active {
    opacity: 1;
    fill: var(--text-primary, #fafafa);
    font-weight: 700;
}

.trigo-sector-label.success {
    opacity: 1 !important;
    fill: var(--accent-color, #72DE5F) !important;
    font-weight: 800 !important;
}

.trigo-sector-label.error {
    opacity: 1 !important;
    fill: var(--accent-color-secondary, #ef4444) !important;
    font-weight: 800 !important;
}

.trigo-sector-label.reveal {
    opacity: 1 !important;
    fill: var(--accent-color, #72DE5F) !important;
    font-weight: 800 !important;
    font-size: 14px !important;
}

.trigo-labels-group.show-all .trigo-sector-label {
    opacity: 0.75;
}

/* Rayon Actif / Réussite */
.trigo-active-radius {
    stroke: var(--accent-color, #72DE5F);
    stroke-width: 3;
    stroke-linecap: round;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.trigo-active-radius.visible {
    opacity: 0.9;
}

.trigo-active-radius.success {
    stroke: var(--accent-color, #72DE5F) !important;
    opacity: 1;
}

.trigo-active-radius.reveal {
    stroke: var(--accent-color, #72DE5F) !important;
    stroke-width: 3.5;
    opacity: 1;
}

.trigo-active-radius.error {
    stroke: var(--accent-color-secondary, #ef4444) !important;
    opacity: 1;
}

/* Flash de validation sur l'arène */
.trigo-arena.flash-success {
    animation: trigoFlashSuccess 0.5s ease-out;
}
.trigo-arena.flash-failure {
    animation: trigoFlashFailure 0.5s ease-out;
}

@keyframes trigoFlashSuccess {
    0% {
        box-shadow: inset 0 0 0 3px var(--accent-color, #72DE5F), 0 0 25px var(--accent-glow, rgba(114, 222, 95, 0.4));
    }
    100% {
        box-shadow: inset 0 0 0 0 transparent, 0 0 0 transparent;
    }
}

@keyframes trigoFlashFailure {
    0% {
        box-shadow: inset 0 0 0 3px var(--accent-color-secondary, #ef4444), 0 0 25px color-mix(in srgb, var(--accent-color-secondary, #ef4444) 45%, transparent);
    }
    100% {
        box-shadow: inset 0 0 0 0 transparent, 0 0 0 transparent;
    }
}

/* --- 7. Sandbox Stats & Historique (Pipeline Règle 8.2) --- */
#history-chart .history-bar-wrapper.has-error .history-bar {
    background-color: var(--accent-color-secondary, #ef4444) !important;
    box-shadow: 0 0 10px color-mix(in srgb, var(--accent-color-secondary, #ef4444) 45%, transparent) !important;
}

/* Responsive Micro-Ajustements */
@media (max-width: 480px) {
    .trigo-instruction {
        font-size: 1.05rem;
        letter-spacing: 1.5px;
    }
    .trigo-instruction .prompt-angle-math {
        font-size: 1.45rem;
    }
    .trigo-svg-container {
        max-width: min(78vh, 96vw);
    }
}
