/*
============================================================================
PROJECTE: Motor Educatiu Step Quiz (Vanilla JS)
FITXER: css/mitjana.css
ROL: Estils específics del joc de mitjana aritmètica i ponderada.
DEPENDÈNCIES: S'ha de carregar DESPRÉS de shared.css.
============================================================================
*/
:root {
    --bg-color:      #eff6ff;
    --primary:       #2563eb;
    --primary-light: #dbeafe;
    --primary-dark:  #1e40af;
    --primary-hover: #1d4ed8;
    --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: #eff6ff; }
.level-text  { color: var(--primary-dark); }
.score-text  { color: var(--primary); }

/* ── ENUNCIAT ── */
.enunciat-wrap {
    padding: 20px 24px 8px;
    max-width: 700px;
    margin: 0 auto;
}

.problem-context {
    font-size: 1.05em;
    line-height: 1.6;
    color: var(--text-main);
    margin-bottom: 14px;
}

/* ── TAULA DE NOTES ── */
.notes-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 1em;
}
.notes-table th {
    background: var(--primary-dark);
    color: white;
    padding: 10px 14px;
    text-align: left;
    font-size: 0.88em;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.notes-table th:nth-child(2),
.notes-table th:nth-child(3) { text-align: center; }
.notes-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
}
.notes-table tbody tr:nth-child(even) { background: #f8fafc; }
.td-label {
    font-weight: 600;
    color: var(--text-main);
}
.td-value {
    text-align: center;
    font-family: monospace;
    font-size: 1.15em;
    font-weight: 700;
    color: var(--primary-dark);
}
.td-weight {
    text-align: center;
    font-family: monospace;
    font-size: 1em;
    font-weight: 600;
    color: var(--text-muted);
    background: #fef3c7;
}

/* ── PREGUNTA ── */
.problem-ask {
    font-size: 1.1em;
    color: var(--text-main);
    padding: 10px 16px;
    background: #f8fafc;
    border-left: 4px solid var(--primary);
    border-radius: 0 8px 8px 0;
    margin-bottom: 4px;
}

/* ── ZONA INPUT ── */
.input-wrap {
    padding: 10px 24px 6px;
    max-width: 700px;
    margin: 0 auto;
}
.answer-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}
.answer-label {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.95em;
}
.answer-input {
    width: 140px;
    height: 48px;
    text-align: center;
    font-family: monospace;
    font-size: 1.4em;
    font-weight: 700;
    border: 2px solid var(--border-heavy);
    border-radius: 10px;
    outline: none;
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.answer-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.answer-input.input-correct {
    border-color: var(--success) !important;
    background: #f0fdf4 !important;
    color: #047857 !important;
}
.answer-input.input-wrong {
    border-color: var(--danger) !important;
    background: var(--danger-light) !important;
    animation: shake 0.3s;
}
.btn-ok {
    background: var(--primary) !important;
    min-width: 120px;
}
.btn-ok:hover { background: var(--primary-hover) !important; }

/* ── FEEDBACK ── */
.feedback-wrap {
    padding: 6px 24px;
    max-width: 700px;
    margin: 0 auto;
}
.feedback-bar {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 500;
    line-height: 1.5;
    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 DESPLEGABLE ── */
.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;
    transition: background 0.15s;
    touch-action: manipulation;
}
.btn-help:hover { background: #fde68a; }

.help-panel {
    display: none;
    max-width: 700px;
    margin: 8px auto 16px;
    padding: 16px 22px;
    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;
    padding: 4px 0;
    border-bottom: 1px solid rgba(245,158,11,0.15);
}
.help-line:last-child {
    border-bottom: none;
    font-weight: 700;
    color: #92400e;
    padding-top: 8px;
}

@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) {
    .enunciat-wrap, .input-wrap, .feedback-wrap, .help-bar { padding-left: 12px; padding-right: 12px; }
    .notes-table th, .notes-table td { padding: 8px 8px; font-size: 0.9em; }
    .answer-input { width: 110px; height: 42px; font-size: 1.2em; }
    .answer-row { gap: 8px; }
    .help-panel { padding: 12px 14px; }
}
