/**
 * Universal Placement Engine — Styles
 *
 * Mobile-first, embeds cleanly into any WordPress theme.
 * Uses scoped class names (upe-*) to avoid conflicts.
 */

/* ══════════════════════════════════════════════
   Reset & Container
   ══════════════════════════════════════════════ */

.upe-engine {
    --upe-primary:    #D92B2B;
    --upe-primary-dk: #A81E1E;
    --upe-success:    #27AE60;
    --upe-danger:     #D92B2B;
    --upe-warning:    #E67E22;
    --upe-bg:         #1E1E1E;
    --upe-bg-alt:     #2a2a2a;
    --upe-bg-hover:   #333333;
    --upe-border:     rgba(255,255,255,0.08);
    --upe-text:       #ffffff;
    --upe-text-muted: rgba(255,255,255,0.52);
    --upe-text-light: rgba(255,255,255,0.28);
    --upe-radius:     12px;
    --upe-radius-sm:  8px;
    --upe-shadow:     0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --upe-shadow-lg:  0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.06);
    --upe-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--upe-text);
    line-height: 1.6;
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 16px;
    box-sizing: border-box;
}

/* ══════════════════════════════════════════════
   Astra Theme Override — Nuclear Reset
   Forces all text inside the engine to be visible
   regardless of theme button/element styling.
   ══════════════════════════════════════════════ */

#upe-engine button,
#upe-engine button span,
#upe-engine .upe-option,
#upe-engine .upe-option__text,
#upe-engine .upe-option__key,
#upe-engine .upe-chip,
#upe-engine .upe-btn,
#upe-engine input,
#upe-engine label,
#upe-engine div,
#upe-engine span,
#upe-engine p,
#upe-engine h2,
#upe-engine h3 {
    color: #ffffff !important;
}

#upe-engine .upe-btn--primary,
#upe-engine .upe-btn--record {
    color: #ffffff !important;
}

#upe-engine .upe-card__subtitle,
#upe-engine .upe-question__context,
#upe-engine .upe-text-muted,
#upe-engine .upe-progress__ability,
#upe-engine .upe-purchase-card__desc {
    color: var(--upe-text-muted) !important;
}

#upe-engine .upe-feedback--correct {
    color: var(--upe-success) !important;
}

#upe-engine .upe-feedback--incorrect {
    color: var(--upe-danger) !important;
}

.upe-engine *, .upe-engine *::before, .upe-engine *::after {
    box-sizing: border-box;
}

/* ══════════════════════════════════════════════
   Cards
   ══════════════════════════════════════════════ */

.upe-card {
    background: var(--upe-bg);
    border: 1px solid var(--upe-border);
    border-radius: var(--upe-radius);
    box-shadow: var(--upe-shadow);
    overflow: hidden;
    animation: upe-fadeUp 400ms ease-out;
}

.upe-card--centered {
    text-align: center;
    padding: 48px 24px;
}

.upe-card__header {
    padding: 28px 24px 0;
}

.upe-card__title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--upe-text);
    letter-spacing: -0.02em;
}

.upe-card__subtitle {
    font-size: 15px;
    color: var(--upe-text-muted);
    margin: 0;
    line-height: 1.5;
}

.upe-card__body {
    padding: 20px 24px 28px;
}

/* ══════════════════════════════════════════════
   Forms & Inputs
   ══════════════════════════════════════════════ */

.upe-form-group {
    margin-bottom: 16px;
}

.upe-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 6px; 
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.upe-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 1.5px solid var(--upe-border);
    border-radius: var(--upe-radius-sm);
    background: #ffffff;
    color: #000000;
    transition: border-color var(--upe-transition), box-shadow var(--upe-transition);
    outline: none;
}

.upe-input:focus {
    border-color: var(--upe-primary);
    box-shadow: 0 0 0 3px rgba(207, 46, 46, 0.12);
}

.upe-inline-input {
    display: inline-block;
    width: 120px;
    padding: 4px 8px;
    font-size: inherit;
    font-family: inherit;
    border: none;
    border-bottom: 2px solid var(--upe-primary);
    background: transparent;
    color: var(--upe-primary);
    outline: none;
    text-align: center;
    transition: border-color var(--upe-transition);
}

.upe-inline-input:focus {
    border-bottom-color: var(--upe-primary-dk);
}

/* ══════════════════════════════════════════════
   Buttons
   ══════════════════════════════════════════════ */

.upe-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--upe-radius-sm);
    cursor: pointer;
    transition: all var(--upe-transition);
    width: 100%;
    text-align: center;
}

.upe-btn--primary {
    background: var(--upe-primary);
    color: #fff;
}

.upe-btn--primary:hover {
    background: var(--upe-primary-dk);
    transform: translateY(-1px);
    box-shadow: var(--upe-shadow);
}

.upe-btn--primary:disabled {
    background: var(--upe-text-light);
    cursor: not-allowed;
    transform: none;
}

.upe-btn--secondary {
    background: var(--upe-bg-alt);
    color: var(--upe-text);
    border: 1.5px solid var(--upe-border);
}

.upe-btn--secondary:hover {
    background: var(--upe-bg-hover);
}

.upe-btn--ghost {
    background: transparent;
    color: var(--upe-text-muted);
    padding: 10px 20px;
    font-size: 14px;
}

.upe-btn--ghost:hover {
    color: var(--upe-text);
    background: var(--upe-bg-alt);
}

.upe-btn--sm {
    padding: 10px 20px;
    font-size: 14px;
    width: auto;
    margin-top: 16px;
}

.upe-btn--record {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--upe-danger);
    color: #fff;
    font-size: 24px;
    padding: 0;
    flex-direction: column;
    gap: 2px;
}

.upe-btn--record .upe-btn__label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.upe-btn--recording {
    animation: upe-pulse 1.5s ease-in-out infinite;
}

/* ══════════════════════════════════════════════
   Progress Bar
   ══════════════════════════════════════════════ */

.upe-progress {
    margin-bottom: 20px;
}

.upe-progress__bar {
    height: 6px;
    background: var(--upe-bg-alt);
    border-radius: 3px;
    overflow: hidden;
}

.upe-progress__fill {
    height: 100%;
    background: var(--upe-primary);
    border-radius: 3px;
    width: 0%;
    transition: width 600ms ease-out;
}

.upe-progress__meta {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 13px;
}

.upe-progress__ability {
    color: var(--upe-text-muted);
    font-weight: 500;
}

.upe-progress__level {
    color: var(--upe-primary);
    font-weight: 700;
    font-size: 14px;
}

/* ══════════════════════════════════════════════
   Strikes (3-fail indicator)
   ══════════════════════════════════════════════ */

.upe-strikes {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.upe-strike {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--upe-border);
    transition: all var(--upe-transition);
}

.upe-strike--active {
    background: var(--upe-danger);
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.3);
}

/* ══════════════════════════════════════════════
   Question Types
   ══════════════════════════════════════════════ */

.upe-question__prompt {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
    color: #000000;
}

.upe-question__context {
    font-size: 15px;
    color: var(--upe-text-muted);
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--upe-bg-alt);
    border-radius: var(--upe-radius-sm);
    border-left: 3px solid var(--upe-primary);
    line-height: 1.5;
}

.upe-question__skill {
    display: inline-block;
    margin-top: 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--upe-text-light);
    padding: 4px 10px;
    background: var(--upe-bg-alt);
    border-radius: 4px;
}

/* Options (MC, T/F) */
.upe-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.upe-options--binary {
    flex-direction: row;
    gap: 12px;
}

.upe-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #2a2a2a !important;
    border: 1.5px solid rgba(255,255,255,0.12);
    border-radius: var(--upe-radius-sm);
    cursor: pointer;
    transition: all var(--upe-transition);
    text-align: left;
    font-size: 15px;
    width: 100%;
    color: #ffffff !important;
}

.upe-option * {
    color: #000000 !important;
}

.upe-option:hover {
    border-color: var(--upe-primary);
    background: #f5f5f5;
}

.upe-option--selected {
    border-color: var(--upe-primary);
    background: #f0f0f0;
    box-shadow: 0 0 0 2px rgba(207, 46, 46, 0.15);
}

.upe-option--binary {
    flex: 1;
    justify-content: center;
    font-weight: 600;
    padding: 16px;
}

.upe-option__key {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--upe-bg-alt);
    font-size: 13px;
    font-weight: 700;
    color: #666666;
    flex-shrink: 0;
}

.upe-option--selected .upe-option__key {
    background: var(--upe-primary);
    color: #fff;
}

.upe-option__text {
    flex: 1;
    color: #000000 !important;
}

/* ══════════════════════════════════════════════
   Reorder (word chips)
   ══════════════════════════════════════════════ */

.upe-reorder {
    margin-top: 16px;
}

.upe-reorder__result {
    min-height: 52px;
    padding: 12px;
    background: var(--upe-bg-alt);
    border: 2px dashed var(--upe-border);
    border-radius: var(--upe-radius-sm);
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.upe-reorder__placeholder {
    color: var(--upe-text-light);
    font-size: 14px;
}

.upe-reorder__pool {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.upe-chip {
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 20px;
    border: 1.5px solid var(--upe-border);
    background: var(--upe-bg);
    cursor: pointer;
    transition: all var(--upe-transition);
    color: #000000;
}

.upe-chip:hover {
    border-color: var(--upe-primary);
    background: rgba(207, 46, 46, 0.04);
}

.upe-chip--used {
    opacity: 0.4;
    transform: scale(0.95);
}

.upe-chip--placed {
    background: var(--upe-primary);
    color: #fff;
    border-color: var(--upe-primary);
}

/* ══════════════════════════════════════════════
   Matching
   ══════════════════════════════════════════════ */

.upe-matching {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.upe-match-item {
    padding: 12px 14px;
    font-size: 14px;
    border: 1.5px solid var(--upe-border);
    border-radius: var(--upe-radius-sm);
    background: var(--upe-bg);
    cursor: pointer;
    transition: all var(--upe-transition);
    text-align: left;
    color: #000000;
}

.upe-match-item:hover {
    border-color: var(--upe-primary);
}

.upe-match-item--active {
    border-color: var(--upe-primary);
    background: rgba(207, 46, 46, 0.08);
    box-shadow: 0 0 0 2px rgba(207, 46, 46, 0.15);
}

.upe-match-item--matched {
    opacity: 0.5;
    pointer-events: none;
    border-color: var(--upe-success);
}

/* ══════════════════════════════════════════════
   Passage (Reading)
   ══════════════════════════════════════════════ */

.upe-passage {
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--upe-bg-alt);
    border-radius: var(--upe-radius-sm);
    border: 1px solid var(--upe-border);
    max-height: 220px;
    overflow-y: auto;
}

.upe-passage__text {
    font-size: 15px;
    line-height: 1.7;
    color: #000000;
}

/* ══════════════════════════════════════════════
   Audio Player (Listening)
   ══════════════════════════════════════════════ */

.upe-audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--upe-bg-alt);
    border-radius: var(--upe-radius-sm);
}

.upe-audio-player__hint {
    font-size: 13px;
    color: var(--upe-text-muted);
}

/* ══════════════════════════════════════════════
   Voice Recorder (Tier 2)
   ══════════════════════════════════════════════ */

.upe-recorder {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
    gap: 16px;
}

.upe-recorder__controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.upe-recorder__timer {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--upe-text-muted);
    min-width: 48px;
}

.upe-recorder__visualizer {
    width: 100%;
    height: 48px;
    background: var(--upe-bg-alt);
    border-radius: var(--upe-radius-sm);
}

/* ══════════════════════════════════════════════
   Feedback
   ══════════════════════════════════════════════ */

.upe-feedback {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--upe-radius-sm);
    margin-top: 16px;
    font-size: 15px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(8px);
    transition: all 300ms ease-out;
}

.upe-feedback--visible {
    opacity: 1;
    transform: translateY(0);
}

.upe-feedback--correct {
    background: rgba(5, 150, 105, 0.1);
    color: var(--upe-success);
    border: 1px solid rgba(5, 150, 105, 0.2);
}

.upe-feedback--incorrect {
    background: rgba(220, 38, 38, 0.08);
    color: var(--upe-danger);
    border: 1px solid rgba(220, 38, 38, 0.15);
}

.upe-feedback__icon {
    font-size: 20px;
    font-weight: 700;
}

/* ══════════════════════════════════════════════
   Ceiling & Upsell
   ══════════════════════════════════════════════ */

.upe-ceiling-badge,
.upe-result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--upe-primary);
    color: #fff;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.upe-ceiling-skills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.upe-skill-tag {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
}

.upe-skill-tag--fail {
    background: rgba(220, 38, 38, 0.08);
    color: var(--upe-danger);
    border: 1px solid rgba(220, 38, 38, 0.15);
}

.upe-upsell {
    padding-top: 20px;
    border-top: 1px solid var(--upe-border);
}

.upe-upsell h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 8px;
}

.upe-upsell p {
    font-size: 14px;
    color: var(--upe-text-muted);
    margin: 0 0 16px;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════
   Results & Purchase
   ══════════════════════════════════════════════ */

.upe-skills-breakdown {
    margin-bottom: 24px;
}

.upe-skill-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.upe-skill-row__label {
    width: 90px;
    font-size: 13px;
    font-weight: 600;
    color: var(--upe-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.upe-skill-row__bar {
    flex: 1;
    height: 8px;
    background: var(--upe-bg-alt);
    border-radius: 4px;
    overflow: hidden;
}

.upe-skill-row__fill {
    height: 100%;
    background: var(--upe-primary);
    border-radius: 4px;
    transition: width 800ms ease-out;
}

.upe-skill-row__pct {
    width: 36px;
    text-align: right;
    font-size: 14px;
    font-weight: 700;
    color: #000000;
}

.upe-purchase-options h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 16px;
}

.upe-purchase-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.upe-purchase-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 12px;
    border: 1.5px solid var(--upe-border);
    border-radius: var(--upe-radius-sm);
    text-decoration: none;
    color: #000000;
    transition: all var(--upe-transition);
    text-align: center;
}

.upe-purchase-card:hover {
    border-color: var(--upe-primary);
    transform: translateY(-2px);
    box-shadow: var(--upe-shadow);
}

.upe-purchase-card--highlight {
    border-color: var(--upe-primary);
    background: rgba(207, 46, 46, 0.04);
}

.upe-purchase-card__label {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #000000;
}

.upe-purchase-card__desc {
    font-size: 12px;
    color: var(--upe-text-muted);
}

/* ══════════════════════════════════════════════
   Spinner
   ══════════════════════════════════════════════ */

.upe-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--upe-border);
    border-top-color: var(--upe-primary);
    border-radius: 50%;
    animation: upe-spin 800ms linear infinite;
    margin: 0 auto 20px;
}

/* ══════════════════════════════════════════════
   Loading
   ══════════════════════════════════════════════ */

.upe-loading {
    text-align: center;
    padding: 24px;
    color: var(--upe-text-muted);
    font-size: 14px;
}

.upe-error {
    text-align: center;
    padding: 24px;
    color: var(--upe-danger);
    font-size: 14px;
}

/* ══════════════════════════════════════════════
   Animations
   ══════════════════════════════════════════════ */

@keyframes upe-fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes upe-spin {
    to { transform: rotate(360deg); }
}

@keyframes upe-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50%      { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
}

.upe-shake {
    animation: upe-shake 400ms ease-out;
}

@keyframes upe-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-8px); }
    50%      { transform: translateX(8px); }
    75%      { transform: translateX(-4px); }
}

/* ══════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════ */

@media (max-width: 480px) {
    .upe-engine {
        padding: 12px 12px;
    }

    .upe-card__header {
        padding: 20px 16px 0;
    }

    .upe-card__body {
        padding: 16px 16px 20px;
    }

    .upe-purchase-grid {
        grid-template-columns: 1fr;
    }

    .upe-matching {
        grid-template-columns: 1fr;
    }
}
/* ══════════════════════════════════════════════
   CRITICAL FIX - Override Theme CSS
   Must be at bottom to ensure highest priority
   ══════════════════════════════════════════════ */

.upe-engine .upe-option,
.upe-engine .upe-option *,
.upe-engine .upe-option .upe-option__text,
.upe-engine button.upe-option,
.upe-engine button.upe-option span,
.upe-engine .upe-options .upe-option,
.upe-engine .upe-options .upe-option * {
    color: #ffffff !important;
    background-color: #2a2a2a !important;
}

.upe-engine .upe-option:hover,
.upe-engine .upe-option:hover * {
    color: #ffffff !important;
    background-color: #333333 !important;
    border-color: var(--upe-primary) !important;
}

.upe-engine .upe-option--selected,
.upe-engine .upe-option--selected * {
    color: #ffffff !important;
    background-color: #3a1a1a !important;
}


/* ══════════════════════════════════════════════
   Fullscreen Mode
   ══════════════════════════════════════════════ */

.upe-fullscreen-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.97);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: upe-fadeIn 300ms ease-out;
}

.upe-fullscreen-overlay .upe-engine {
    max-width: 640px;
    width: 640px;
    margin: 0 auto;
    padding: 20px;
}

.upe-fullscreen-overlay .upe-promo-form {
    width: 640px;
    height: 90vh;
    overflow-y: auto;
    position: relative;
    margin: 0 auto;
}

.upe-fullscreen-close {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 99999;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--upe-transition);
}

.upe-fullscreen-close:hover {
    background: rgba(255,255,255,0.2);
}

body.upe-locked {
    overflow: hidden;
}

@keyframes upe-fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ══════════════════════════════════════════════
   Payment screen — uniform black buttons, red hover
   ══════════════════════════════════════════════ */
.upe-engine .upe-screen--payment .upe-btn {
    background: #2a2a2a !important;
    color: #ffffff !important;
    border: 1.5px solid rgba(255,255,255,0.12) !important;
}
.upe-engine .upe-screen--payment .upe-btn:hover {
    background: #2a2a2a !important;
    border-color: var(--upe-primary) !important;
    color: #ffffff !important;
}
/* Landing — Certify button: red stroke on hover */
.upe-engine #upe-landing-certify {
    border: 1.5px solid var(--upe-border) !important;
}
.upe-engine #upe-landing-certify:hover {
    background: transparent !important;
    border-color: var(--upe-primary) !important;
    color: #ffffff !important;
}
