/* ==================== APTITUDE TEST STYLES ==================== */

.aptitude-questionnaire,
.aptitude-test {
    position: fixed;
    inset: 0;
    width: 100vw;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a0a2e 50%, #0a0a0f 100%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    font-family: 'Cinzel', 'Noto Serif SC', serif;
    padding: max(20px, env(safe-area-inset-top))
        max(14px, env(safe-area-inset-right))
        max(20px, env(safe-area-inset-bottom))
        max(14px, env(safe-area-inset-left));
    box-sizing: border-box;
    transition: opacity 0.5s ease;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

.aptitude-questionnaire.hidden,
.aptitude-test.hidden {
    opacity: 0;
    pointer-events: none;
}

.aptitude-questionnaire.active,
.aptitude-test.active {
    opacity: 1;
    pointer-events: all;
}

/* Session feedback must remain legible over every stop of the dark backdrop. */
#aptitude-questionnaire-container #test-save-status {
    color: #efe7ff;
    font-size: 14px;
    line-height: 1.5;
}

/* Header del Test */
.test-header {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeInDown 0.8s ease;
}

.test-emblem {
    font-size: 80px;
    margin-bottom: 20px;
    animation: rotate 3s linear infinite;
}

.test-title {
    font-size: 32px;
    color: #FFD700;
    margin-bottom: 15px;
    -webkit-text-stroke: 0.85px rgba(10, 8, 6, 0.95);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.9);
}

.test-description {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Progress Container */
.test-progress-container {
    max-width: 800px;
    margin: 0 auto 40px;
    width: 100%;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
    color: rgba(248, 236, 211, 0.95);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.88);
}

.question-counter,
.block-indicator {
    font-weight: 600;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--codex-ember, #c9742f), #FFD700);
    border-radius: 4px;
    transition: width 0.4s ease;
    box-shadow: 0 0 10px rgba(var(--codex-ember-rgb, 201, 116, 47), 0.6);
}

/* Question Area */
.test-question-area {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 24px;
}

.block-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding: 20px;
    background: rgba(75, 0, 130, 0.3);
    border-radius: 10px;
    border: 2px solid rgba(var(--codex-ember-rgb, 201, 116, 47), 0.4);
}

.block-icon {
    font-size: 48px;
    animation: pulse 2s ease-in-out infinite;
}

.block-title {
    font-size: 24px;
    color: #b597ff;
    margin: 0;
    text-shadow: 0 0 12px rgba(var(--codex-ember-rgb, 201, 116, 47), 0.6), 0 1px 8px rgba(0, 0, 0, 0.8);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.block-description {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 30px;
    padding: 0 20px;
    font-style: italic;
}

/* Question Card */
.question-card {
    background: linear-gradient(135deg, rgba(30, 20, 50, 0.9), rgba(20, 10, 40, 0.9));
    border: 3px solid rgba(var(--codex-ember-rgb, 201, 116, 47), 0.5);
    border-radius: 15px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(var(--codex-ember-rgb, 201, 116, 47), 0.3);
    animation: fadeInUp 0.6s ease;
    margin-bottom: 14px;
}

.question-text {
    font-size: 20px;
    color: #fff;
    margin-bottom: 40px;
    line-height: 1.8;
    text-align: center;
    font-weight: 500;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Likert Scale */
.likert-scale {
    margin-top: 30px;
    margin-bottom: 30px;
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px;
    min-height: 34px;
    align-items: flex-end;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

.label-start {
    text-align: left;
}

.label-end {
    text-align: right;
}

.scale-options {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 10px;
}

.scale-option {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(var(--codex-ember-rgb, 201, 116, 47), 0.4);
    border-radius: 10px;
    padding: 20px 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scale-option:hover {
    background: rgba(var(--codex-ember-rgb, 201, 116, 47), 0.2);
    border-color: rgba(255, 215, 0, 0.6);
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(var(--codex-ember-rgb, 201, 116, 47), 0.4);
}

.scale-option.selected {
    background: linear-gradient(135deg, rgba(var(--codex-ember-rgb, 201, 116, 47), 0.6), rgba(75, 0, 130, 0.6));
    border-color: #FFD700;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
}

.option-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--codex-ember-rgb, 201, 116, 47), 0.3), transparent);
    border: 3px solid rgba(var(--codex-ember-rgb, 201, 116, 47), 0.6);
    transition: all 0.3s ease;
}

.scale-option:hover .option-circle {
    border-color: rgba(255, 215, 0, 0.8);
    background: radial-gradient(circle, rgba(255, 215, 0, 0.3), transparent);
    transform: scale(1.1);
}

.scale-option.selected .option-circle {
    background: radial-gradient(circle, #FFD700, rgba(255, 215, 0, 0.5));
    border-color: #FFD700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), inset 0 0 15px rgba(255, 215, 0, 0.5);
}

.scale-numbers {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    padding: 0 10px;
}

.scale-numbers span {
    flex: 1;
    text-align: center;
}

/* Navigation */
.test-navigation {
    max-width: 800px;
    margin: 14px auto 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    position: static;
    inset: auto;
    transform: none;
    z-index: 5;
    background: linear-gradient(180deg, rgba(10, 10, 15, 0), rgba(10, 10, 15, 0.52));
    border-radius: 10px;
    padding: 12px 12px;
    flex-shrink: 0;
}

.nav-info {
    flex: 1 1 240px;
    text-align: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    white-space: normal;
    min-width: 180px;
}

.answered-count {
    font-weight: 600;
    color: #9370db;
}

/* Buttons */
.aptitude-questionnaire .btn-primary,
.aptitude-questionnaire .btn-secondary,
.aptitude-test .btn-primary,
.aptitude-test .btn-secondary {
    padding: 15px 35px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Cinzel', serif;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.25;
    max-width: 100%;
    min-width: 150px;
    max-width: 100%;
}

@media (max-width: 1100px) {
    .test-navigation {
        gap: 12px;
        align-items: stretch;
    }

    .test-navigation .btn-secondary,
    .test-navigation .btn-primary {
        flex: 1 1 220px;
    }

    .test-navigation .nav-info {
        order: 3;
        flex: 1 1 100%;
    }
}

.aptitude-questionnaire .btn-primary,
.aptitude-test .btn-primary {
    background: linear-gradient(135deg, var(--codex-ember, #c9742f), var(--codex-ember-plate, #d98a3f));
    color: white;
    box-shadow: 0 4px 15px rgba(var(--codex-ember-rgb, 201, 116, 47), 0.4);
}

.aptitude-questionnaire .btn-primary:hover:not(:disabled),
.aptitude-test .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(var(--codex-ember-rgb, 201, 116, 47), 0.6);
}

.aptitude-questionnaire .btn-primary:active:not(:disabled),
.aptitude-test .btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.aptitude-questionnaire .btn-secondary,
.aptitude-test .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(var(--codex-ember-rgb, 201, 116, 47), 0.4);
}

.aptitude-questionnaire .btn-secondary:hover:not(:disabled),
.aptitude-test .btn-secondary:hover:not(:disabled) {
    background: rgba(var(--codex-ember-rgb, 201, 116, 47), 0.2);
    border-color: rgba(var(--codex-ember-rgb, 201, 116, 47), 0.6);
    transform: translateY(-2px);
}

.aptitude-questionnaire .btn-primary:disabled,
.aptitude-questionnaire .btn-secondary:disabled,
.aptitude-test .btn-primary:disabled,
.aptitude-test .btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (min-width: 769px) {
    .aptitude-questionnaire,
    .aptitude-test {
        align-items: center;
        justify-content: flex-start;
    }

    .test-header {
        margin-bottom: 10px;
        width: min(900px, 100%);
    }

    .test-emblem {
        font-size: 48px;
        margin-bottom: 8px;
    }

    .test-title {
        font-size: clamp(24px, 2.6vw, 34px);
        margin-bottom: 8px;
    }

    .test-description {
        font-size: 15px;
        line-height: 1.5;
    }

    .test-progress-container {
        margin: 0 auto 12px;
        max-width: 900px;
    }

    .test-question-area {
        max-width: 900px;
        gap: 8px;
        width: 100%;
    }

    .block-header {
        padding: 12px 16px;
        margin-bottom: 4px;
    }

    .block-icon {
        font-size: 40px;
    }

    .block-title {
        font-size: clamp(18px, 2vw, 22px);
        line-height: 1.2;
    }

    .block-description {
        margin-bottom: 6px;
        padding: 0 4px;
        font-size: 13px;
        line-height: 1.35;
    }

    .question-card {
        padding: 18px 22px 16px;
        margin-bottom: 10px;
    }

    .question-text {
        font-size: clamp(20px, 2.2vw, 26px);
        line-height: 1.34;
        margin-bottom: 16px;
    }

    .likert-scale {
        margin-top: 8px;
        margin-bottom: 12px;
    }

    .scale-labels {
        margin-bottom: 8px;
        min-height: 24px;
        font-size: 14px;
    }

    .scale-options {
        gap: 10px;
        margin-bottom: 8px;
    }

    .scale-option {
        padding: 14px 8px;
    }

    .option-circle {
        width: 34px;
        height: 34px;
    }

    .test-navigation {
        max-width: 900px;
        margin: 8px auto 0;
        padding: 0;
        gap: 12px;
        display: grid;
        grid-template-columns: minmax(150px, 210px) 1fr minmax(150px, 210px);
        align-items: center;
        background: transparent;
        position: static !important;
        inset: auto !important;
        transform: none !important;
        width: 100%;
    }

    .nav-info {
        min-width: 0;
        font-size: 15px;
    }

    .test-navigation .btn-primary,
    .test-navigation .btn-secondary {
        min-width: 0;
        width: 100%;
        padding: 11px 18px;
        font-size: 15px;
    }
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .aptitude-questionnaire,
    .aptitude-test {
        padding: 12px 10px calc(12px + env(safe-area-inset-bottom));
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
        touch-action: pan-y;
    }

    .test-header {
        margin-bottom: 6px;
    }

    .test-progress-container {
        margin: 0 auto 6px;
    }

    .test-title {
        font-size: 18px;
        line-height: 1.2;
        margin-bottom: 6px;
        /* A este tamaño el contorno oscuro borraba los trazos finos de Cinzel. */
        -webkit-text-stroke: 0;
    }

    .test-description {
        display: none;
    }

    .test-emblem {
        font-size: 34px;
        margin-bottom: 4px;
    }

    .question-card {
        padding: 12px 12px 10px;
        margin-bottom: 0;
    }

    .test-question-area {
        overflow: hidden;
        padding-bottom: 0;
        gap: 8px;
    }

    .question-text {
        font-size: 16px;
        line-height: 1.45;
        margin-bottom: 10px;
        color: rgba(255, 255, 255, 0.96);
        text-shadow: 0 1px 8px rgba(0, 0, 0, 0.82);
    }

    .block-title {
        font-size: 18px;
        line-height: 1.25;
    }

    .block-icon {
        font-size: 28px;
    }

    .block-description {
        display: none;
    }

    .scale-options {
        gap: 5px;
    }

    .scale-option {
        padding: 7px 3px;
        border-radius: 8px;
    }

    .option-circle {
        width: 17px;
        height: 17px;
        border-width: 2px;
    }

    .scale-labels {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        margin-bottom: 8px;
        font-size: 12px;
        line-height: 1.2;
        color: rgba(248, 236, 211, 0.96);
        font-weight: 500;
    }

    .label-start {
        justify-self: start;
        text-align: left;
    }

    .label-end {
        justify-self: end;
        text-align: right;
    }

    .scale-numbers {
        font-size: 12px;
        margin-top: 6px;
        color: rgba(248, 236, 211, 0.96);
        padding: 0 2px;
    }

    .test-navigation {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "info info"
            "prev next";
        gap: 8px;
        margin-top: 6px;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        background: linear-gradient(180deg, rgba(10, 10, 15, 0.16), rgba(10, 10, 15, 0.74));
    }

    #aptitude-questionnaire-container .test-navigation .btn-primary,
    #aptitude-questionnaire-container .test-navigation .btn-secondary {
        flex: 0 0 auto !important;
        align-self: stretch;
    }

    .aptitude-questionnaire .btn-primary,
    .aptitude-questionnaire .btn-secondary,
    .aptitude-test .btn-primary,
    .aptitude-test .btn-secondary {
        width: 100%;
        min-width: 0;
        flex: 0 0 auto !important;
        min-height: 38px;
        max-height: 40px;
        padding: 6px 10px;
        font-size: 13px;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-info {
        grid-area: info;
        white-space: normal;
        min-width: 0;
        font-size: 11px;
        line-height: 1.2;
        margin-bottom: 0;
    }

    #btn-prev {
        grid-area: prev;
    }

    #btn-next {
        grid-area: next;
    }
}

@media (max-width: 480px) {
    .aptitude-questionnaire,
    .aptitude-test {
        padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
    }

    .test-emblem {
        display: none;
    }

    .test-title {
        font-size: 15px;
        line-height: 1.2;
        margin-bottom: 4px;
    }

    .progress-info {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .block-header {
        padding: 10px;
        gap: 8px;
        margin-bottom: 8px;
    }

    .question-card {
        padding: 10px 10px 8px;
    }

    .block-title {
        font-size: 16px;
    }

    .question-text {
        font-size: 14px;
        margin-bottom: 10px;
        line-height: 1.34;
    }

    .scale-labels {
        font-size: 11px;
        gap: 4px;
        margin-bottom: 6px;
    }

    .scale-option {
        padding: 6px 2px;
    }

    .option-circle {
        width: 16px;
        height: 16px;
        border-width: 2px;
    }

    .scale-numbers {
        font-size: 11px;
    }

    .aptitude-questionnaire .btn-primary,
    .aptitude-questionnaire .btn-secondary,
    .aptitude-test .btn-primary,
    .aptitude-test .btn-secondary {
        min-height: 34px;
        max-height: 36px;
        padding: 6px 8px;
        font-size: 12px;
    }

    .test-navigation {
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        gap: 6px;
    }
}

@media (max-width: 360px) {
    .question-card {
        padding: 12px 8px;
    }

    .question-text {
        font-size: 13px;
    }

    .scale-options {
        gap: 4px;
    }

    .scale-option {
        padding: 5px 2px;
    }

    .option-circle {
        width: 14px;
        height: 14px;
    }

    .aptitude-questionnaire .btn-primary,
    .aptitude-questionnaire .btn-secondary,
    .aptitude-test .btn-primary,
    .aptitude-test .btn-secondary {
        min-height: 32px;
        max-height: 34px;
        font-size: 11px;
    }
}

/* ==================== LIQUID GLASS / AERO UPGRADE ==================== */
@media (prefers-reduced-motion: no-preference) {
    .aptitude-questionnaire::before,
    .aptitude-test::before {
        content: "";
        position: fixed;
        inset: -20%;
        z-index: -1;
        pointer-events: none;
        background:
            radial-gradient(38vw 38vw at 12% 18%, rgba(var(--codex-ember-rgb, 201, 116, 47), 0.28), transparent 60%),
            radial-gradient(32vw 32vw at 88% 14%, rgba(255, 215, 0, 0.10), transparent 62%),
            radial-gradient(45vw 45vw at 50% 100%, rgba(75, 0, 130, 0.35), transparent 65%);
        filter: blur(40px) saturate(140%);
        animation: aptitudeAuroraDrift 26s ease-in-out infinite alternate;
    }
}

@keyframes aptitudeAuroraDrift {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(2%, -3%, 0) scale(1.08); }
}

.block-header,
.question-card,
.test-navigation {
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.question-card {
    position: relative;
    background: linear-gradient(135deg, rgba(40, 26, 66, 0.55), rgba(18, 10, 36, 0.55));
    border: 1px solid rgba(183, 148, 244, 0.35);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(138, 43, 226, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
    overflow: hidden;
    transform-style: preserve-3d;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    will-change: transform;
}

.question-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.12) 48%, transparent 62%);
    background-size: 220% 220%;
    background-position: 120% 0;
    pointer-events: none;
    transition: background-position 1.1s ease;
}

.question-card:hover::before {
    background-position: -20% 0;
}

.scale-option {
    backdrop-filter: blur(6px) saturate(130%);
    -webkit-backdrop-filter: blur(6px) saturate(130%);
}

.block-header {
    background: linear-gradient(135deg, rgba(75, 0, 130, 0.32), rgba(30, 12, 55, 0.32));
    border: 1px solid rgba(var(--codex-ember-rgb, 201, 116, 47), 0.32);
}


/* Configured onboarding introduction belongs to its pinned flow session. */
.aptitude-questionnaire [data-onboarding-flow-copy="step-questionnaire"] {
    flex-shrink: 0;
    width: 100%;
    max-width: 800px;
    text-align: center;
    color: #f1e7ff;
    margin: 0 auto 20px;
}
.aptitude-questionnaire [data-onboarding-flow-copy="step-questionnaire"] h2 {
    font-family: 'Cinzel', serif;
    font-size: clamp(18px, 4.5vw, 24px);
    line-height: 1.4;
    overflow-wrap: anywhere;
    margin: 0 0 12px;
}
.aptitude-questionnaire [data-onboarding-flow-copy="step-questionnaire"] p {
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0;
}
