/*
============================================================================
PROJECTE: Motor Educatiu Step Quiz (Vanilla JS)
FITXER: css/estadistica-inversa.css
ROL: Estils específics de l'exercici invers d'estadística.
DEPENDÈNCIES: S'ha de carregar DESPRÉS de shared.css.
============================================================================
*/
:root {
    --bg-color:      #fef7ff;
    --primary:       #9333ea;
    --primary-light: #f3e8ff;
    --primary-dark:  #6b21a8;
    --primary-hover: #7e22ce;
    --text-main:     #1e293b;
    --text-muted:    #64748b;
    --border-light:  #e2e8f0;
    --border-heavy:  #cbd5e1;
    --success:       #10b981;
    --danger:        #ef4444;
    --danger-light:  #fee2e2;
}

h1 { color: var(--primary-dark); }
.header-info { background-color: #faf5ff; }
.level-text  { color: var(--primary-dark); }
.score-text  { color: var(--primary); }

/* ── PROMPT ── */
.prompt-box {
    padding: 20px 24px 10px;
    max-width: 700px;
    margin: 0 auto;
    font-size: 1.08em;
    line-height: 1.65;
    color: var(--text-main);
}

/* ── BADGES DE CONDICIONS ── */
.cond-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 24px 10px;
    max-width: 700px;
    margin: 0 auto;
}
.cond-badge {
    display: inline-block;
    padding: 6px 16px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1.5px solid #d8b4fe;
    border-radius: 99px;
    font-size: 0.95em;
    font-weight: 700;
    font-family: monospace;
    letter-spacing: 0.3px;
}

/* ── PROGRÉS (solucions trobades) ── */
.progress-info {
    text-align: center;
    padding: 0 24px 8px;
    max-width: 700px;
    margin: 0 auto;
}
.progress-badge {
    display: inline-block;
    padding: 6px 16px;
    background: #eff6ff;
    color: #1e40af;
    border: 1.5px solid #93c5fd;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
}
.progress-partial {
    background: #f0fdf4;
    color: #065f46;
    border-color: #86efac;
}

/* ── INPUT GRID ── */
.input-grid {
    padding: 8px 24px 12px;
    max-width: 700px;
    margin: 0 auto;
}
.input-cells {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}
.num-input {
    width: 56px;
    height: 56px;
    text-align: center;
    font-family: monospace;
    font-size: 1.6em;
    font-weight: 700;
    border: 2.5px solid var(--border-heavy);
    border-radius: 12px;
    outline: none;
    color: var(--text-main);
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.num-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(147,51,234,0.15);
}
.num-input.num-correct {
    border-color: var(--success) !important;
    background: #f0fdf4 !important;
    color: #047857 !important;
}
.num-input.num-wrong {
    border-color: var(--danger) !important;
    background: var(--danger-light) !important;
    animation: shake 0.3s;
}

/* ── CHECK BAR ── */
.check-bar {
    padding: 8px 24px;
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}
#btn-check {
    min-width: 180px;
    touch-action: manipulation;
}

/* ── DIAGNOSTIC PAS A PAS ── */
.diagnostic-box {
    display: none;
    max-width: 660px;
    margin: 8px auto;
    padding: 14px 18px;
    background: #f8fafc;
    border: 1.5px solid var(--border-light);
    border-radius: 10px;
    animation: fadeSlide 0.3s ease;
}
.diag-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-wrap: wrap;
}
.diag-row:last-child { border-bottom: none; }
.diag-label {
    font-weight: 700;
    font-size: 0.95em;
    color: var(--text-main);
    min-width: 140px;
}
.diag-value {
    font-family: monospace;
    font-weight: 600;
    font-size: 1em;
    color: var(--primary-dark);
}
.diag-target {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-left: auto;
}
.diag-ok .diag-value { color: #047857; }
.diag-err .diag-value { color: #b91c1c; }
.diag-err { background: #fef2f2; border-radius: 6px; padding: 6px 8px; margin: 2px -8px; }

/* ── FEEDBACK ── */
.feedback-wrap {
    padding: 6px 24px;
    max-width: 700px;
    margin: 0 auto;
}
.feedback-bar {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.98em;
    font-weight: 500;
    line-height: 1.55;
    transition: opacity 0.3s;
    text-align: center;
}
.fb-ok   { color: #047857; background: #d1fae5; }
.fb-err  { color: #991b1b; background: #fee2e2; }
.fb-warn { color: #92400e; background: #fef3c7; }

/* ── AJUDA ── */
.help-bar {
    padding: 6px 24px;
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}
.btn-help {
    display: inline-block;
    padding: 8px 20px;
    font-size: 0.9em;
    font-weight: 700;
    color: #92400e;
    background: #fef3c7;
    border: 1.5px solid #f59e0b;
    border-radius: 99px;
    cursor: pointer;
    touch-action: manipulation;
}
.btn-help:hover { background: #fde68a; }

.help-panel {
    display: none;
    max-width: 660px;
    margin: 8px auto 16px;
    padding: 14px 20px;
    background: #fffbeb;
    border: 1.5px solid #fde68a;
    border-radius: 10px;
    text-align: left;
    animation: fadeSlide 0.3s ease;
}
.help-line {
    font-size: 0.95em;
    color: #78350f;
    line-height: 1.7;
}

/* ── BOTÓ SEGÜENT (apareix quan la resposta és correcta) ── */
#btn-check.btn-next-shake {
    background-color: #059669;
    animation: nextShake 1.5s ease-in-out;
}
@keyframes nextShake {
    0%   { transform: scale(1);    box-shadow: none; }
    10%  { transform: translateX(-6px) scale(1.04); }
    20%  { transform: translateX( 6px) scale(1.04); }
    30%  { transform: translateX(-4px) scale(1.06); box-shadow: 0 0 18px rgba(5,150,105,0.7); }
    40%  { transform: translateX( 4px) scale(1.06); box-shadow: 0 0 18px rgba(5,150,105,0.7); }
    50%  { transform: translateX(0)    scale(1.08); box-shadow: 0 0 24px rgba(5,150,105,0.9); }
    70%  { transform: scale(1.05); box-shadow: 0 0 16px rgba(5,150,105,0.6); }
    100% { transform: scale(1);    box-shadow: 0 0 8px  rgba(5,150,105,0.3); }
}

/* ── ANIMACIONS ── */
@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-5px); }
    75%      { transform: translateX(5px); }
}

/* ── RESPONSIU ── */
@media (max-width: 480px) {
    .prompt-box, .cond-badges, .input-grid, .check-bar, .feedback-wrap, .help-bar, .progress-info { padding-left: 12px; padding-right: 12px; }
    .num-input { width: 48px; height: 48px; font-size: 1.4em; }
    .diag-label { min-width: 100px; font-size: 0.88em; }
    .diagnostic-box { padding: 10px 12px; }
}
