/* static/css/interactive_practice.css - MathoPrint Interactive Practice Arena */

.ip-overlay {
    position: fixed;
    inset: 0;
    z-index: 1085;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    animation: ipFadeIn 0.2s ease-out;
}

.ip-overlay.d-none {
    display: none !important;
}

@keyframes ipFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ipPopIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ipShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.ip-shell {
    width: 100%;
    max-width: 820px;
    max-height: 94vh;
    background: #F8FAFC;
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.32);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ipPopIn 0.24s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.ip-shell[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

.ip-shell[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

/* Header Bar */
.ip-header {
    background: linear-gradient(135deg, #1E3A5F 0%, #243B64 55%, #2D5CA8 100%);
    color: #ffffff;
    padding: 16px 22px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ip-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ip-badge-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ip-topic-title {
    font-weight: 800;
    font-size: 1.05rem;
    margin: 0;
    line-height: 1.25;
}

.ip-topic-sub {
    font-size: 0.78rem;
    opacity: 0.85;
}

.ip-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ip-stat-pill {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.84rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ip-stat-pill.streak-hot {
    background: linear-gradient(135deg, #F59E0B, #EA580C);
    border-color: rgba(255, 255, 255, 0.35);
}

.ip-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.ip-icon-btn:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: scale(1.05);
}

/* Progress Bar */
.ip-progress-track {
    height: 7px;
    width: 100%;
    background: #E2E8F0;
    overflow: hidden;
}

.ip-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3978D5, #42B883);
    transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Body */
.ip-body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1;
}

/* Hub / 28-Topic Picker */
.ip-hub-controls {
    background: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
}

.ip-hub-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.ip-hub-label {
    font-size: 0.82rem;
    font-weight: 800;
    color: #475569;
    margin-inline-end: 4px;
}

.ip-hub-pill {
    border: 1.5px solid #CBD5E1;
    background: #F8FAFC;
    color: #1E3A5F;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ip-hub-pill:hover {
    border-color: #3978D5;
    background: #EFF6FF;
}

.ip-hub-pill.active {
    background: #3978D5;
    border-color: #3978D5;
    color: #ffffff;
}

.ip-topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 10px;
}

.ip-topic-tile {
    background: #ffffff;
    border: 2px solid #E2E8F0;
    border-radius: 14px;
    padding: 11px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-align: start;
    transition: all 0.16s ease;
}

.ip-topic-tile:hover {
    border-color: #93C5FD;
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
}

.ip-topic-tile.selected {
    border-color: #3978D5;
    background: #EFF6FF;
    box-shadow: 0 0 0 3px rgba(57, 120, 213, 0.16);
}

.ip-tile-symbol {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: #ffffff;
    font-weight: 800;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ip-tile-name {
    font-size: 0.84rem;
    font-weight: 800;
    color: #1E3A5F;
    line-height: 1.25;
}

/* Question Meta & Stage */
.ip-question-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 10px;
}

.ip-q-counter {
    font-size: 0.86rem;
    font-weight: 800;
    color: #3978D5;
    background: #EBF3FF;
    padding: 5px 13px;
    border-radius: 999px;
}

.ip-attempts-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #64748B;
    font-weight: 600;
}

.ip-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #42B883;
    transition: background 0.2s ease;
}

.ip-dot.used {
    background: #CBD5E1;
}

.ip-stage-card {
    background: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 18px;
    padding: 24px 20px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
    text-align: center;
    margin-bottom: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ip-stage-card.state-correct {
    border-color: #22C55E;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

.ip-stage-card.state-wrong {
    border-color: #EF4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
    animation: ipShake 0.36s ease;
}

.ip-question-prompt {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 14px;
}

.ip-big-equation {
    font-size: clamp(1.55rem, 3.6vw, 2.25rem);
    font-weight: 800;
    color: #1E3A5F;
    letter-spacing: 0.5px;
    margin: 8px 0 12px;
}

.ip-vertical-calc {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 2rem;
    font-weight: 800;
    color: #1E3A5F;
    min-width: 120px;
    margin: 4px auto 12px;
    direction: ltr;
}

.ip-vertical-calc .ip-v-line {
    border-bottom: 3px solid #1E3A5F;
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 4px;
}

/* Interactive Answer Inputs */
.ip-input-area {
    max-width: 440px;
    margin: 14px auto 0;
}

.ip-answer-input {
    width: 100%;
    font-size: 1.45rem;
    font-weight: 800;
    text-align: center;
    padding: 12px 16px;
    border: 2px solid #CBD5E1;
    border-radius: 14px;
    color: #0F172A;
    background: #F8FAFC;
    transition: all 0.18s ease;
    outline: none;
}

.ip-answer-input:focus {
    border-color: #3978D5;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(57, 120, 213, 0.15);
}

.ip-answer-input.is-valid {
    border-color: #22C55E;
    background: #F0FDF4;
    color: #15803D;
}

.ip-answer-input.is-invalid {
    border-color: #EF4444;
    background: #FEF2F2;
    color: #B91C1C;
}

/* Choice Buttons */
.ip-choice-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 14px;
}

.ip-choice-btn {
    min-width: 96px;
    padding: 12px 20px;
    font-size: 1.15rem;
    font-weight: 800;
    border-radius: 14px;
    border: 2px solid #CBD5E1;
    background: #ffffff;
    color: #1E3A5F;
    cursor: pointer;
    transition: all 0.16s ease;
}

.ip-choice-btn:hover:not(:disabled) {
    border-color: #3978D5;
    background: #EFF6FF;
    transform: translateY(-2px);
}

.ip-choice-btn.selected {
    border-color: #3978D5;
    background: #3978D5;
    color: #ffffff;
}

.ip-choice-btn.correct {
    border-color: #22C55E;
    background: #22C55E;
    color: #ffffff;
}

.ip-choice-btn.wrong {
    border-color: #EF4444;
    background: #EF4444;
    color: #ffffff;
}

/* Interactive Pyramid & Prop Table Inputs */
.ip-pyramid-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 10px auto;
    direction: ltr;
}

.ip-pyr-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.ip-pyr-cell {
    width: 68px;
    height: 44px;
    border-radius: 8px;
    border: 2px solid #243B64;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
}

.ip-pyr-cell.given {
    background: #EFF6FF;
    color: #1E3A5F;
}

.ip-pyr-input {
    width: 68px;
    height: 44px;
    border-radius: 8px;
    border: 2px solid #3978D5;
    text-align: center;
    font-weight: 800;
    font-size: 1.05rem;
    color: #0F172A;
    background: #ffffff;
    outline: none;
}

.ip-pyr-input:focus {
    box-shadow: 0 0 0 3px rgba(57, 120, 213, 0.22);
}

.ip-pyr-input.is-valid,
.ip-table-input.is-valid {
    border-color: #22C55E;
    background: #F0FDF4;
    color: #15803D;
}

.ip-pyr-input.is-invalid,
.ip-table-input.is-invalid {
    border-color: #EF4444;
    background: #FEF2F2;
    color: #B91C1C;
}

.ip-table-input {
    width: 72px;
    padding: 5px 6px;
    text-align: center;
    font-weight: 800;
    border: 2px solid #3978D5;
    border-radius: 8px;
    outline: none;
}

/* Interactive Clickable SVG Shapes */
.ip-svg-interactive rect[data-cell],
.ip-svg-interactive path[data-slice],
.ip-svg-interactive rect[data-slice] {
    cursor: pointer;
    transition: opacity 0.14s ease, fill 0.14s ease;
}

.ip-svg-interactive rect[data-cell]:hover,
.ip-svg-interactive path[data-slice]:hover,
.ip-svg-interactive rect[data-slice]:hover {
    opacity: 0.82;
}

/* Quick Mobile Keypad (6x3 = 18 keys including < > = -) */
.ip-keypad {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    max-width: 440px;
    margin: 12px auto 0;
    direction: ltr;
}

.ip-key {
    padding: 9px 4px;
    border-radius: 10px;
    border: 1px solid #CBD5E1;
    background: #F8FAFC;
    color: #1E293B;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.ip-key:hover {
    background: #E2E8F0;
    border-color: #94A3B8;
}

.ip-key.ip-key-sym {
    background: #EFF6FF;
    border-color: #BFDBFE;
    color: #1D4ED8;
}

.ip-key.ip-key-sym:hover {
    background: #DBEAFE;
}

/* Feedback & Hint Banner */
.ip-feedback {
    border-radius: 14px;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ip-feedback.fb-success {
    background: #DCFCE7;
    color: #166534;
    border: 1px solid #86EFAC;
}

.ip-feedback.fb-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

.ip-feedback.fb-hint {
    background: #FEF9C3;
    color: #854D0E;
    border: 1px solid #FDE047;
}

/* Footer Controls */
.ip-footer {
    background: #ffffff;
    border-top: 1px solid #E2E8F0;
    padding: 14px 22px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

/* Summary Screen */
.ip-summary-hero {
    text-align: center;
    padding: 10px 0 18px;
}

.ip-score-ring {
    width: 124px;
    height: 124px;
    border-radius: 50%;
    margin: 0 auto 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #EFF6FF, #ECFDF5);
    border: 6px solid #42B883;
    box-shadow: 0 10px 25px rgba(66, 184, 131, 0.22);
}

.ip-score-pct {
    font-size: 2rem;
    font-weight: 900;
    color: #1E3A5F;
    line-height: 1;
}

.ip-score-frac {
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
    margin-top: 4px;
}

.ip-stars {
    font-size: 1.85rem;
    color: #F59E0B;
    letter-spacing: 4px;
    margin-bottom: 6px;
}

.ip-summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 16px 0 20px;
}

.ip-summary-box {
    background: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 14px;
    padding: 12px 10px;
    text-align: center;
}

.ip-summary-box .val {
    font-size: 1.2rem;
    font-weight: 800;
    color: #1E3A5F;
}

.ip-summary-box .lbl {
    font-size: 0.76rem;
    color: #64748B;
    font-weight: 600;
}

.ip-mistake-item {
    background: #ffffff;
    border: 1px solid #FECACA;
    border-radius: 12px;
    padding: 11px 14px;
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

/* Launch Button */
.btn-mlp-interactive {
    background: linear-gradient(135deg, #6366F1 0%, #3978D5 100%);
    color: #ffffff !important;
    border: none;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-mlp-interactive:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.38);
    color: #ffffff !important;
}

@media (max-width: 576px) {
    .ip-shell {
        max-height: 96vh;
        border-radius: 16px;
    }
    .ip-body {
        padding: 14px 12px;
    }
    .ip-topic-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .ip-summary-stats {
        grid-template-columns: 1fr;
    }
}

@media print {
    #interactivePracticeModal {
        display: none !important;
    }
}