/*
|--------------------------------------------------------------------------
| 4education - Enigma de Imagem V24.2
|--------------------------------------------------------------------------
|
| Objetivo:
| - manter 2 x 2;
| - preservar proporção das imagens;
| - evitar imagens achatadas;
| - continuar cabendo bem no desktop;
| - manter componentes compartilhados intactos.
|
*/

:root {
    --enigma-primary: #c125fa;
    --enigma-primary-dark: #9e18d1;
    --enigma-primary-soft: #fbf4fe;
    --enigma-page: #f5f6f8;
    --enigma-surface: #ffffff;
    --enigma-text: #332c36;
    --enigma-muted: #766b79;
    --enigma-border: #e5dce8;
    --enigma-success: #3fa75a;
    --enigma-danger: #dc535e;

    /*
     * Largura única do conteúdo do Enigma.
     * Pergunta, jogo, feedback e ações usam a mesma medida.
     */
    --enigma-content-width: 820px;
}

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

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--enigma-page);
    color: var(--enigma-text);
    font-family: Arial, Helvetica, sans-serif;
}

button {
    font: inherit;
}

[hidden] {
    display: none !important;
}

/* =========================================================
   ESTRUTURA
   ========================================================= */

.enigma-image-layout {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.enigma-image-header {
    flex: 0 0 auto;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 11px 18px;
    background: var(--enigma-primary);
    box-shadow: 0 2px 8px rgba(42, 28, 47, .10);
}

.enigma-image-logo {
    display: block;
    width: auto;
    max-width: 210px;
    height: 46px;
    object-fit: contain;
}

.enigma-image-page {
    flex: 1 1 auto;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 12px 16px 14px;
}

.enigma-image-shell {
    width: min(920px, 100%);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

/* =========================================================
   PERGUNTA PADRÃO
   ========================================================= */

.enigma-image-question {
    width: min(var(--enigma-content-width), 100%) !important;
    max-width: var(--enigma-content-width) !important;
    margin: 0 auto !important;
    align-self: center !important;
}

.enigma-image-question #question-container {
    width: 100% !important;
    margin: 0 !important;
}

.enigma-image-question .question-text {
    display: -webkit-box !important;
    max-height: calc(1.5em * 3) !important;
    overflow: hidden !important;
    overflow-wrap: anywhere !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 3 !important;
    line-clamp: 3 !important;
}

/* =========================================================
   ÁREA DO JOGO
   ========================================================= */

.enigma-image-game {
    width: min(var(--enigma-content-width), 100%);
    max-width: var(--enigma-content-width);
    margin: 8px auto 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

/* =========================================================
   ALTERNATIVAS 2 X 2
   ========================================================= */

.enigma-image-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 10px;
}

.enigma-image-option {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 2px solid var(--enigma-border);
    border-radius: 13px;
    background: #ffffff;
    cursor: pointer;
    outline: 0;
    box-shadow: 0 3px 10px rgba(46, 34, 50, .045);
    transition:
        transform .16s ease,
        border-color .16s ease,
        box-shadow .16s ease,
        background-color .16s ease,
        opacity .16s ease;
}

.enigma-image-option:hover:not(.is-locked),
.enigma-image-option:focus-visible:not(.is-locked) {
    transform: translateY(-1px);
    border-color: var(--enigma-primary);
    box-shadow: 0 6px 14px rgba(193, 37, 250, .10);
}

.enigma-image-option:focus-visible {
    outline: 3px solid rgba(193, 37, 250, .18);
    outline-offset: 2px;
}

/*
|--------------------------------------------------------------------------
| Imagem
|--------------------------------------------------------------------------
|
| Não usamos "cover". Assim a imagem não é cortada e não parece achatada.
| A área mantém uma altura confortável para 2 linhas de cards.
|
*/

.enigma-image-option-media {
    position: relative;
    width: 100%;
    height: clamp(124px, 17vh, 148px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 7px;
    background:
        linear-gradient(
            145deg,
            #fbf8fc,
            #f3edf6
        );
}

.enigma-image-option-media > img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center;
    border-radius: 8px;
    transition: transform .22s ease;
}

.enigma-image-option:hover
.enigma-image-option-media > img {
    transform: scale(1.018);
}

.enigma-image-expand {
    position: absolute;
    right: 8px;
    bottom: 8px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, .88);
    border-radius: 8px;
    background: rgba(29, 22, 32, .74);
    color: #ffffff;
    font-size: 8px;
    font-weight: 800;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition:
        background-color .15s ease,
        transform .15s ease;
}

.enigma-image-expand:hover {
    background: var(--enigma-primary-dark);
    transform: translateY(-1px);
}

.enigma-image-expand svg {
    width: 11px;
    height: 11px;
    stroke-width: 2;
}

.enigma-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #a99bad;
}

.enigma-image-placeholder svg {
    width: 30px;
    height: 30px;
    stroke-width: 1.5;
}

.enigma-image-placeholder span {
    font-size: 9px;
    font-weight: 700;
}

/* =========================================================
   FAIXA DE TEXTO DA ALTERNATIVA
   ========================================================= */

.enigma-image-option-content {
    min-height: 43px;
    display: grid;
    grid-template-columns:
        28px
        minmax(0, 1fr)
        20px;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
}

.enigma-image-option-letter {
    width: 27px;
    height: 27px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--enigma-primary);
    color: #ffffff;
    font-size: 10px;
    font-weight: 850;
    line-height: 1;
}

.enigma-image-option-text {
    min-width: 0;
    display: -webkit-box;
    overflow: hidden;
    overflow-wrap: anywhere;
    color: var(--enigma-text);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.enigma-image-option-check {
    width: 19px;
    height: 19px;
    display: grid;
    place-items: center;
    border: 2px solid #ddd2e0;
    border-radius: 50%;
    color: transparent;
    font-size: 10px;
    font-weight: 900;
}

/* =========================================================
   ESTADOS
   ========================================================= */

.enigma-image-option.is-locked {
    cursor: default;
}

.enigma-image-option.is-muted {
    opacity: .48;
}

.enigma-image-option.is-correct {
    border-color: var(--enigma-success);
    background: #f2fbf4;
    opacity: 1;
}

.enigma-image-option.is-correct
.enigma-image-option-letter {
    background: var(--enigma-success);
}

.enigma-image-option.is-correct
.enigma-image-option-check {
    border-color: var(--enigma-success);
    background: var(--enigma-success);
    color: #ffffff;
}

.enigma-image-option.is-correct
.enigma-image-option-check::before {
    content: "✓";
}

.enigma-image-option.is-incorrect {
    border-color: var(--enigma-danger);
    background: #fff2f3;
    opacity: 1;
}

.enigma-image-option.is-incorrect
.enigma-image-option-letter {
    background: var(--enigma-danger);
}

.enigma-image-option.is-incorrect
.enigma-image-option-check {
    border-color: var(--enigma-danger);
    background: var(--enigma-danger);
    color: #ffffff;
}

.enigma-image-option.is-incorrect
.enigma-image-option-check::before {
    content: "×";
}

/* =========================================================
   RESULTADO / AÇÕES
   ========================================================= */

.enigma-image-result {
    width: min(var(--enigma-content-width), 100%);
    max-width: var(--enigma-content-width);
    margin: 0 auto;
}

.enigma-image-result.visible {
    display: block !important;
}

.enigma-image-error,
.enigma-image-empty {
    width: min(var(--enigma-content-width), 100%);
    max-width: var(--enigma-content-width);
    margin: 0 auto;
    padding: 12px 14px;
    border: 1px solid var(--enigma-border);
    border-radius: 11px;
    background: #ffffff;
}

.enigma-image-error {
    color: #9b3636;
    border-color: #efc1c1;
    background: #fff1f1;
}

.enigma-image-empty strong {
    display: block;
    margin-bottom: 4px;
}

.enigma-image-empty p {
    margin: 0;
    color: var(--enigma-muted);
}

/* =========================================================
   RODAPÉ
   ========================================================= */

.enigma-image-footer,
footer.enigma-image-footer,
.platform-footer.enigma-image-footer {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-height: 52px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: auto 0 0 !important;
    padding: 14px 18px !important;
    border: 0 !important;
    background: var(--enigma-primary-dark) !important;
    color: #ffffff !important;
    text-align: center !important;
}

.enigma-image-footer p,
footer.enigma-image-footer p,
.platform-footer.enigma-image-footer p {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    color: #ffffff !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    text-align: center !important;
}

/* =========================================================
   GALERIA
   ========================================================= */

.enigma-gallery {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(17, 13, 18, .78);
    backdrop-filter: blur(5px);
}

.enigma-gallery[hidden] {
    display: none !important;
}

.enigma-gallery-card {
    width: min(860px, 100%);
    max-height: calc(100dvh - 36px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 17px;
    background: #ffffff;
    box-shadow: 0 28px 80px rgba(0, 0, 0, .30);
}

.enigma-gallery-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 15px 17px;
    border-bottom: 1px solid var(--enigma-border);
}

.enigma-gallery-header span {
    display: block;
    margin-bottom: 3px;
    color: var(--enigma-primary-dark);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.enigma-gallery-header h2 {
    margin: 0;
    font-size: 17px;
}

.enigma-gallery-close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--enigma-border);
    border-radius: 9px;
    background: var(--enigma-page);
    color: var(--enigma-text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.enigma-gallery-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 360px;
    display: grid;
    grid-template-columns:
        54px
        minmax(0, 1fr)
        54px;
    align-items: center;
    gap: 10px;
    padding: 16px;
    overflow: hidden;
    background: #1d181f;
}

.enigma-gallery-image-wrap {
    min-width: 0;
    min-height: 0;
    height: min(62vh, 590px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.enigma-gallery-image-wrap img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 9px;
}

.enigma-gallery-arrow {
    width: 44px;
    height: 58px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .20);
    border-radius: 11px;
    background: rgba(255, 255, 255, .10);
    color: #ffffff;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
}

.enigma-gallery-arrow:hover:not(:disabled) {
    background: var(--enigma-primary);
}

.enigma-gallery-arrow:disabled {
    opacity: .24;
    cursor: default;
}

.enigma-gallery-footer {
    flex: 0 0 auto;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 17px;
    border-top: 1px solid var(--enigma-border);
}

#enigmaGalleryCounter {
    color: var(--enigma-primary-dark);
    font-size: 11px;
    font-weight: 850;
}

#enigmaGalleryCaption {
    min-width: 0;
    overflow: hidden;
    color: var(--enigma-muted);
    font-size: 11px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================================================
   DESKTOP BAIXO
   ========================================================= */

@media (min-width: 721px) and (max-height: 760px) {
    .enigma-image-header {
        min-height: 66px;
        padding-top: 9px;
        padding-bottom: 9px;
    }

    .enigma-image-logo {
        height: 42px;
    }

    .enigma-image-page {
        padding-top: 7px;
        padding-bottom: 7px;
    }

    .enigma-image-shell {
        gap: 7px;
    }

    /*
     * Mesmo em tela baixa, não reduz abaixo de 110px.
     * Assim a imagem não vira uma faixa achatada.
     */
    .enigma-image-option-media {
        height: 110px;
    }

    .enigma-image-option-content {
        min-height: 40px;
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .enigma-image-footer,
    footer.enigma-image-footer,
    .platform-footer.enigma-image-footer {
        min-height: 46px !important;
        padding-top: 11px !important;
        padding-bottom: 11px !important;
    }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 720px) {
    :root {
        --enigma-content-width: 100%;
    }

    .enigma-image-page {
        padding: 16px 10px 20px;
    }

    .enigma-image-shell {
        width: min(520px, 100%);
        gap: 12px;
    }

    /*
     * Mantém 2 x 2 também no mobile largo.
     * Em telas muito estreitas os cards ficam menores,
     * mas não viram uma coluna.
     */
    .enigma-image-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .enigma-image-option-media {
        height: clamp(105px, 26vw, 138px);
        padding: 5px;
    }

    .enigma-image-option-content {
        min-height: 45px;
        grid-template-columns:
            25px
            minmax(0, 1fr)
            18px;
        gap: 6px;
        padding: 6px 7px;
    }

    .enigma-image-option-letter {
        width: 24px;
        height: 24px;
        font-size: 9px;
    }

    .enigma-image-option-text {
        font-size: 10px;
    }

    .enigma-image-option-check {
        width: 17px;
        height: 17px;
    }

    .enigma-image-expand span {
        display: none;
    }

    .enigma-image-expand {
        min-width: 27px;
        padding-left: 6px;
        padding-right: 6px;
    }

    .enigma-gallery {
        padding: 10px;
    }

    .enigma-gallery-card {
        max-height: calc(100dvh - 20px);
    }

    .enigma-gallery-stage {
        min-height: 300px;
        grid-template-columns:
            42px
            minmax(0, 1fr)
            42px;
        gap: 5px;
        padding: 10px;
    }

    .enigma-gallery-image-wrap {
        height: min(58vh, 500px);
    }

    .enigma-gallery-arrow {
        width: 38px;
        height: 52px;
        font-size: 29px;
    }
}
