/* ═══════════════════════════════════════════════
   Exercicios Interativos — Player CSS
   v2: Enhanced design, animations, mobile-first
   ═══════════════════════════════════════════════ */

:root {
    --bg: #0f172a;
    --bg-gradient: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    --surface: #1e293b;
    --surface-elevated: #253247;
    --surface2: #334155;
    --border: #475569;
    --border-light: #374151;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-bg: rgba(99,102,241,.1);
    --green: #22c55e;
    --green-bg: rgba(34,197,94,.12);
    --green-border: rgba(34,197,94,.25);
    --red: #ef4444;
    --red-bg: rgba(239,68,68,.12);
    --red-border: rgba(239,68,68,.25);
    --yellow: #f59e0b;
    --yellow-bg: rgba(245,158,11,.1);
    --yellow-border: rgba(245,158,11,.25);
    --cyan: #22d3ee;
    --radius: 16px;
    --radius-lg: 20px;
    --radius-pill: 999px;
    --shadow: 0 4px 16px rgba(0,0,0,.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.4);
    --transition: .2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.player-body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-gradient);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

/* ── Progress bar ── */
.p-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--surface2);
    z-index: 100;
}
.p-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--cyan));
    transition: width .4s cubic-bezier(.4,0,.2,1);
    border-radius: 0 2px 2px 0;
    will-change: width;
}

/* ── Header ── */
.p-header {
    position: fixed;
    top: 4px;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(15,23,42,.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(71,85,105,.3);
    z-index: 99;
}
.p-header-left { display: flex; align-items: center; gap: 12px; }
.p-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
}
.p-back:hover { background: var(--surface2); color: var(--text); transform: scale(1.05); }
.p-counter {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: .03em;
}
.p-timer {
    font-size: 14px;
    font-weight: 800;
    color: var(--cyan);
    font-variant-numeric: tabular-nums;
    letter-spacing: .04em;
    background: rgba(34,211,238,.1);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(34,211,238,.2);
}

/* ── Body ── */
.p-body {
    padding: 76px 16px 40px;
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ── Question card ── */
.p-q-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    margin-bottom: 20px;
    animation: slideUp .35s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow);
}
.p-q-number {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--primary-light);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.p-q-number::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.p-q-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.6;
}

/* ── Alternatives ── */
.p-alts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: slideUp .4s cubic-bezier(.4,0,.2,1);
}
.p-alt {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    width: 100%;
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    position: relative;
    overflow: hidden;
}
.p-alt::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99,102,241,.05), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}
.p-alt:hover:not(.disabled) {
    border-color: var(--primary);
    background: rgba(99,102,241,.06);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(99,102,241,.15);
}
.p-alt:hover:not(.disabled)::before { opacity: 1; }
.p-alt:active:not(.disabled) { transform: scale(.98); }
.p-alt.disabled { cursor: default; pointer-events: none; }
.p-alt.correct {
    border-color: var(--green);
    background: var(--green-bg);
    animation: correctPulse .5s ease;
}
.p-alt.wrong {
    border-color: var(--red);
    background: var(--red-bg);
    animation: wrongShake .4s ease;
}
.p-alt-letra {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all var(--transition);
}
.p-alt.correct .p-alt-letra { background: var(--green); color: #fff; }
.p-alt.wrong .p-alt-letra { background: var(--red); color: #fff; }
.p-alt-text { flex: 1; font-weight: 500; line-height: 1.45; }

/* ── Hint button ── */
.p-hint-btn {
    transition: all var(--transition);
}
.p-hint-btn:hover {
    background: var(--yellow-bg) !important;
    border-color: var(--yellow-border) !important;
    transform: translateY(-1px);
}

/* ── Feedback ── */
.p-feedback {
    margin-top: 16px;
    padding: 20px;
    border-radius: var(--radius);
    display: flex;
    gap: 16px;
    align-items: flex-start;
    animation: slideUp .3s ease;
}
.p-feedback.correct { background: var(--green-bg); border: 1px solid var(--green-border); }
.p-feedback.wrong { background: var(--red-bg); border: 1px solid var(--red-border); }
.p-fb-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 900;
    flex-shrink: 0;
}
.p-feedback.correct .p-fb-icon { background: var(--green); color: #fff; }
.p-feedback.wrong .p-fb-icon { background: var(--red); color: #fff; }
.p-fb-title { font-size: 15px; font-weight: 800; margin-bottom: 6px; }
.p-feedback.correct .p-fb-title { color: var(--green); }
.p-feedback.wrong .p-fb-title { color: var(--red); }
.p-fb-text { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* ── Next button ── */
.p-actions {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    animation: slideUp .3s ease;
}
.p-btn-next {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 16px 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
    box-shadow: 0 8px 24px rgba(99,102,241,.35);
}
.p-btn-next:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(99,102,241,.45); }
.p-btn-next:active { transform: scale(.97); }

/* ── Results ── */
.p-results {
    padding: 36px 16px 56px;
    max-width: 640px;
    margin: 0 auto;
    animation: slideUp .5s cubic-bezier(.4,0,.2,1);
}
.p-r-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px 28px;
    text-align: center;
    margin-bottom: 28px;
    box-shadow: var(--shadow-lg);
}
.p-r-emoji { font-size: 60px; margin-bottom: 16px; }
.p-r-title { font-size: 28px; font-weight: 900; margin-bottom: 6px; }
.p-r-sub { font-size: 14px; color: var(--text-secondary); margin-bottom: 28px; }
.p-r-stats { display: flex; justify-content: center; gap: 32px; margin-bottom: 24px; }
.p-r-stat-val { font-size: 32px; font-weight: 900; }
.p-r-stat-val.correct-color { color: var(--green); }
.p-r-stat-val.wrong-color { color: var(--red); }
.p-r-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.p-r-bar-wrap {
    height: 8px;
    background: var(--surface2);
    border-radius: var(--radius-pill);
    margin-bottom: 20px;
    overflow: hidden;
}
.p-r-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--cyan));
    border-radius: var(--radius-pill);
    transition: width 1s cubic-bezier(.4,0,.2,1);
}
.p-r-details {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 28px;
}
.p-r-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.p-r-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: all var(--transition);
}
.p-r-btn.primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(99,102,241,.3);
}
.p-r-btn.primary:hover { background: var(--primary-light); transform: translateY(-2px); }
.p-r-btn.secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
}
.p-r-btn.secondary:hover { background: var(--border); }
.p-r-btn.ghost { color: var(--text-secondary); }
.p-r-btn.ghost:hover { color: var(--text); }

/* ── Review items ── */
.p-r-review { display: flex; flex-direction: column; gap: 10px; }
.p-r-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    border-left: 4px solid transparent;
    transition: all var(--transition);
}
.p-r-item:hover { background: var(--surface-elevated); }
.p-r-item.ok { border-left-color: var(--green); }
.p-r-item.err { border-left-color: var(--red); }
.p-r-item.disc { border-left-color: var(--primary-light); }
.p-r-item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.p-r-item-num {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.p-r-item-icon { font-size: 15px; font-weight: 900; flex-shrink: 0; }
.p-r-item.ok .p-r-item-icon { color: var(--green); }
.p-r-item.err .p-r-item-icon { color: var(--red); }
.p-r-item-text { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.p-r-item-answer { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.p-r-item-correct { font-size: 12px; color: var(--green); font-weight: 600; margin-bottom: 4px; }
.p-r-item-exp {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 10px;
}

/* ═══════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════ */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes correctPulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.02); }
    60% { transform: scale(.99); }
    100% { transform: scale(1); }
}
@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-8px); }
    30% { transform: translateX(8px); }
    45% { transform: translateX(-6px); }
    60% { transform: translateX(6px); }
    75% { transform: translateX(-3px); }
    90% { transform: translateX(3px); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Screen reader only ── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ═══════════════════════════════════════════════
   FOCUS & ACCESSIBILITY
   ═══════════════════════════════════════════════ */
:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}
.p-alt:focus-visible {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99,102,241,.3);
}
.p-btn-next:focus-visible {
    box-shadow: 0 0 0 3px rgba(99,102,241,.4);
}

/* ═══════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
    .p-body { padding: 72px 12px 32px; }
    .p-q-card { padding: 24px 18px; }
    .p-q-text { font-size: 16px; }
    .p-alt { padding: 16px 14px; font-size: 14px; gap: 12px; }
    .p-alt-letra { width: 34px; height: 34px; font-size: 13px; }
    .p-feedback { padding: 16px; gap: 12px; }
    .p-btn-next { padding: 14px 28px; font-size: 15px; }
    .p-results { padding: 28px 12px 48px; }
    .p-r-card { padding: 32px 20px; }
    .p-r-title { font-size: 24px; }
    .p-r-stats { gap: 20px; }
    .p-r-stat-val { font-size: 26px; }
    .p-r-btn { padding: 12px 20px; font-size: 13px; }
    .p-timer { font-size: 12px; padding: 4px 10px; }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    .p-body { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
    .p-results { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
