/**
 * Estanar Mini Assessments — quiz + email-gate styles.
 *
 * Dark Estanar/CIP-brand background with SOLID-white question cards on top —
 * maximum readability for long questionnaires while keeping the branded
 * dark-purple atmosphere.
 *
 * SCOPING (spec §7.8): every rule that touches the shared design-system
 * classes (.estanar-question-card, .estanar-likert-scale,
 * .estanar-likert-scale__option) is scoped under `.estanar-ma-page
 * .estanar-ma-quiz` so the sibling estanar-cip-assessment plugin's UI is
 * never affected.
 */

/* ===========================================================================
 * QUIZ STAGE (Stage 2)
 * ========================================================================= */

.estanar-ma-page .estanar-ma-quiz {
    background-color: var(--ma-clr-dark);
    color: var(--ma-clr-white);
    padding-bottom: clamp(2rem, 5vw, 4rem);
}

/* Sticky scale-anchor reference bar. */
.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__scale-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(16, 0, 71, 0.92);
    backdrop-filter: blur(10px);
    border-block-end: 1px solid var(--ma-clr-card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem clamp(1rem, 4vw, 2rem);
    font-size: 0.9rem;
    color: var(--ma-clr-white-muted);
    font-weight: 500;
}

/* The high-end anchor (right in LTR) gets the gold treatment. */
.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__scale-bar .estanar-ma-quiz__scale-end:last-child {
    color: var(--ma-clr-gold);
    font-weight: 600;
}

[dir="rtl"] .estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__scale-bar {
    flex-direction: row-reverse;
}

/* In RTL, the high-end label still ends up as the last visual child after the
 * row-reverse flip — but we also colour the first-child gold to be safe. */
[dir="rtl"] .estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__scale-bar .estanar-ma-quiz__scale-end:first-child {
    color: var(--ma-clr-gold);
    font-weight: 600;
}

[dir="rtl"] .estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__scale-bar .estanar-ma-quiz__scale-end:last-child {
    color: var(--ma-clr-white-muted);
    font-weight: 500;
}

/* Progress bar — gradient cyan → gold to visualise progression. */
.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__progress {
    max-width: 1000px;
    margin: 1.5rem auto 1rem;
    padding: 0 clamp(1rem, 4vw, 2rem);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__progress-bar {
    flex: 1;
    height: 10px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: var(--ma-radius-pill);
    overflow: hidden;
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__progress-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--ma-clr-cyan), var(--ma-clr-gold));
    border-radius: var(--ma-radius-pill);
    transition: width 0.3s ease;
}

[dir="rtl"] .estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__progress-bar {
    transform: scaleX(-1);
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__progress-counter {
    font-size: 0.95rem;
    color: var(--ma-clr-white);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Question cards — SOLID white panels on the dark backdrop. */
.estanar-ma-page .estanar-ma-quiz .estanar-question-card,
.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__question {
    background: var(--ma-clr-card-bg-solid);
    color: var(--ma-clr-dark);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--ma-radius-md);
    padding: clamp(1.25rem, 3vw, 1.75rem);
    margin-bottom: 1.25rem;
    box-shadow: var(--ma-shadow-card);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.estanar-ma-page .estanar-ma-quiz .estanar-question-card[data-answered="true"] {
    border-color: var(--ma-clr-gold);
    box-shadow: 0 0 0 2px var(--ma-clr-gold), var(--ma-shadow-card);
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__question-number {
    display: inline-block;
    background: var(--ma-clr-cta-main);
    color: var(--ma-clr-white);
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: var(--ma-radius-pill);
    min-width: 36px;
    height: 36px;
    line-height: 36px;
    padding: 0 0.6rem;
    text-align: center;
    margin: 0 0 1rem;
}

.estanar-ma-page.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__question-text {
    font-size: clamp(1rem, 2vw, 1.15rem);
    color: var(--ma-clr-dark);
    line-height: 1.6;
    margin: 0 0 1.25rem;
    font-weight: 600;
}

.estanar-ma-page.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__question-number {
    color: var(--ma-clr-white);
}

/* Likert grid — 5 columns desktop, 3 tablet, 2 mobile. */
.estanar-ma-page .estanar-ma-quiz .estanar-likert-scale,
.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__likert {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.6rem;
}

@media (max-width: 768px) {
    .estanar-ma-page .estanar-ma-quiz .estanar-likert-scale,
    .estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__likert {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .estanar-ma-page .estanar-ma-quiz .estanar-likert-scale,
    .estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__likert {
        grid-template-columns: repeat(2, 1fr);
    }
}

[dir="rtl"] .estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__likert {
    direction: rtl;
}

/* Likert option buttons. */
.estanar-ma-page .estanar-ma-quiz .estanar-likert-scale__option,
.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__option {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.85rem 0.5rem;
    background: #F4F5FB;
    border: 2px solid rgba(16, 0, 71, 0.12);
    border-radius: var(--ma-radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
    text-align: center;
    min-height: 84px;
    color: var(--ma-clr-dark);
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__option:hover {
    transform: translateY(-3px);
    border-color: var(--ma-clr-cyan);
    background: rgba(145, 205, 239, 0.18);
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__option:has(input:checked) {
    background: var(--ma-clr-cta-main);
    border-color: var(--ma-clr-cta-main);
    color: var(--ma-clr-white);
    box-shadow: 0 6px 16px rgba(34, 70, 255, 0.35);
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__option:has(input:focus-visible) {
    outline: 2px solid var(--ma-clr-gold);
    outline-offset: 2px;
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__option-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: inherit;
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__option-label {
    font-size: 0.75rem;
    color: inherit;
    opacity: 0.85;
    line-height: 1.3;
}

/* Submit CTA at end of the question list. */
.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__submit {
    display: block;
    margin: 2.5rem auto 0;
    background: var(--ma-clr-cta-main);
    color: var(--ma-clr-white);
    border: 2px solid var(--ma-clr-cta-main);
    padding: 1.1rem 2.5rem;
    font-size: clamp(1rem, 2vw, 1.15rem);
    font-weight: 600;
    border-radius: var(--ma-radius-pill);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__submit:not(:disabled):hover,
.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__submit:not(:disabled):focus-visible {
    background: var(--ma-clr-cta-main-hover);
    border-color: var(--ma-clr-cta-main-hover);
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(34, 70, 255, 0.45);
}

.estanar-ma-page .estanar-ma-quiz .estanar-ma-quiz__submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--ma-clr-white-muted);
    box-shadow: none;
}

/* Screen-reader-only helper for the question legend. */
.estanar-ma-page .estanar-ma-quiz .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===========================================================================
 * EMAIL GATE MODAL (Stage 3)
 * ========================================================================= */

.estanar-ma-page .estanar-ma-email-gate {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.estanar-ma-page .estanar-ma-email-gate[hidden] {
    display: none;
}

.estanar-ma-page .estanar-ma-email-gate__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 0, 71, 0.78);
    backdrop-filter: blur(6px);
    z-index: 0;
}

.estanar-ma-page .estanar-ma-email-gate__modal {
    position: relative;
    z-index: 1;
    background: var(--ma-clr-card-bg-solid);
    border-radius: var(--ma-radius-lg);
    padding: clamp(1.5rem, 4vw, 2.25rem);
    max-width: 480px;
    width: 100%;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    color: var(--ma-clr-dark);
}

.estanar-ma-page .estanar-ma-email-gate__title {
    font-family: 'Cairo', sans-serif;
    font-size: clamp(1.3rem, 3vw, 1.6rem);
    font-weight: 700;
    color: var(--ma-clr-dark);
    margin: 0 0 0.5rem;
}

.estanar-ma-page .estanar-ma-email-gate__sub {
    font-size: 0.97rem;
    color: rgba(16, 0, 71, 0.75);
    margin: 0 0 1.5rem;
    line-height: 1.65;
}

.estanar-ma-page .estanar-ma-email-gate__form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.estanar-ma-page .estanar-ma-email-gate__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.estanar-ma-page .estanar-ma-email-gate__label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ma-clr-dark);
}

.estanar-ma-page .estanar-ma-email-gate__field input[type="email"],
.estanar-ma-page .estanar-ma-email-gate__field input[type="text"] {
    padding: 0.85rem 1rem;
    border: 2px solid rgba(16, 0, 71, 0.15);
    border-radius: var(--ma-radius-sm);
    font-size: 1rem;
    font-family: inherit;
    color: var(--ma-clr-dark);
    background: var(--ma-clr-white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.estanar-ma-page .estanar-ma-email-gate__field input[type="email"]:focus,
.estanar-ma-page .estanar-ma-email-gate__field input[type="text"]:focus {
    border-color: var(--ma-clr-cta-main);
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 70, 255, 0.18);
}

.estanar-ma-page .estanar-ma-email-gate__consent {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: rgba(16, 0, 71, 0.8);
    line-height: 1.55;
}

.estanar-ma-page .estanar-ma-email-gate__consent input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--ma-clr-cta-main);
}

.estanar-ma-page .estanar-ma-email-gate__error {
    font-size: 0.88rem;
    color: #d63030;
    min-height: 1.2em;
    margin: 0;
}

.estanar-ma-page .estanar-ma-email-gate__cta {
    background: var(--ma-clr-cta-main);
    color: var(--ma-clr-white);
    border: 2px solid var(--ma-clr-cta-main);
    padding: 1rem 1.5rem;
    border-radius: var(--ma-radius-pill);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.estanar-ma-page .estanar-ma-email-gate__cta:not(:disabled):hover,
.estanar-ma-page .estanar-ma-email-gate__cta:not(:disabled):focus-visible {
    background: var(--ma-clr-cta-main-hover);
    border-color: var(--ma-clr-cta-main-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(34, 70, 255, 0.4);
}

.estanar-ma-page .estanar-ma-email-gate__cta:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
