/* ==========================================================================
   css/cartas.css
   Tela "Minhas Cartas"
   ========================================================================== */

/* ============================================================
   TELA
   ============================================================ */

.tela-cartas {
    min-height: 100dvh;

    background-image: url('../assets/fundos/fundo-cartas.png');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;

    display: flex;
    flex-direction: column;
    align-items: center;

    padding-bottom: 32px;

    overflow-x: hidden;
}

/* ============================================================
   BANNER
   ============================================================ */

.cartas-banner-img {
    width: 100%;
    max-width: 520px;
    height: auto;
    display: block;
    flex-shrink: 0;
}

/* ============================================================
   SUBTÍTULO E CONTADOR
   ============================================================ */

.cartas-subtitulo {
    margin: 8px 0 2px;
    padding: 0 16px;

    font-size: 0.88rem;
    font-weight: 700;
    color: rgba(255, 249, 220, 0.88);
    text-align: center;
    text-shadow: 0 1px 4px rgba(30, 18, 6, 0.5);
}

.cartas-contador {
    margin: 0 0 10px;
    padding: 5px 16px 6px;

    font-size: 0.82rem;
    font-weight: 900;
    color: #fff8df;
    text-align: center;

    background: rgba(20, 12, 4, 0.28);
    border-radius: 999px;

    text-shadow: 0 1px 4px rgba(30, 18, 6, 0.5);
}

/* ============================================================
   GRADE DE CARTAS
   ============================================================ */

.cartas-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 0 0 4px;
    width: min(92vw, 430px);
}

@media (min-width: 600px) {
    .cartas-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: min(92vw, 600px);
        gap: 12px;
    }

    .cartas-banner-img {
        max-width: 640px;
    }
}

@media (min-width: 960px) {
    .cartas-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        width: min(92vw, 900px);
        gap: 16px;
    }

    .cartas-banner-img {
        max-width: 900px;
    }
}

/* ============================================================
   ITEM DE CARTA
   ============================================================ */

.carta-item {
    position: relative;
    display: block;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.carta-item--desbloqueada {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.carta-item--desbloqueada:hover,
.carta-item--desbloqueada:focus-visible {
    transform: scale(1.05) translateY(-3px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
    outline: none;
}

.carta-item--desbloqueada:active {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.carta-item--bloqueada {
    cursor: default;
}

.carta-item--bloqueada:focus-visible {
    outline: 3px solid rgba(106, 183, 255, 0.7);
    outline-offset: 2px;
}

.carta-thumb {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
}

.carta-item--bloqueada .carta-thumb {
    opacity: 0.32;
    filter: grayscale(80%) brightness(0.78);
}

/* ============================================================
   OVERLAY DE BLOQUEIO
   ============================================================ */

.carta-bloqueio-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.carta-bloqueio-img {
    width: 44%;
    max-width: 68px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

/* ============================================================
   FEEDBACK INLINE
   ============================================================ */

.carta-feedback {
    min-height: 1.4em;
    margin: 6px 0 0;
    padding: 4px 18px;
    text-align: center;
    font-size: 0.84rem;
    font-weight: 600;
    color: transparent;
    border-radius: 999px;
    transition: color 0.2s, background 0.2s;
}

.carta-feedback--ativo {
    color: rgba(255, 255, 255, 0.92);
    background: rgba(0, 0, 0, 0.3);
}

/* ============================================================
   BOTÃO VOLTAR
   — visual herdado de .btn-secundario (componentes.css)
   — esta regra controla apenas o espaçamento
   ============================================================ */

.cartas-btn-voltar {
    margin: 6px 0 0;
}

/* ============================================================
   ACESSIBILIDADE — elemento visualmente oculto mas lido por
   leitores de tela (usado em aria-labelledby e para TTS)
   ============================================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   MODAL DA CARTA — foco na imagem
   ============================================================ */

#mc-overlay-carta .rp-card {
    position: relative;

    width: min(94vw, 380px);
    max-width: min(94vw, 380px);

    padding: 0;
    overflow: hidden;
    overflow-y: auto;

    background-color: #fdf4e3;
    background-image: url('../assets/fundos/fundo-popup.png');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;

    border: 2px solid rgba(245, 166, 35, 0.95);
    border-radius: 20px;
}

/* Botão ✕ posicionado no canto superior direito */
.rp-carta-fechar {
    position: absolute;
    top: 8px;
    right: 10px;
    z-index: 2;

    width: 44px;
    height: 44px;

    border: none;
    border-radius: 50%;

    background: rgba(255, 249, 237, 0.9);
    color: #6b4a1e;

    font-size: 1.1rem;
    font-weight: 900;
    line-height: 1;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.rp-carta-fechar:hover {
    background: rgba(232, 204, 138, 0.55);
}

.rp-carta-fechar:focus-visible {
    outline: 3px solid #6ab7ff;
    outline-offset: 2px;
}

/* Banner no topo do card */
.rp-carta-banner {
    width: 100%;
    height: auto;
    display: block;
    max-height: 64px;
    object-fit: contain;
}

/* Container central do modal */
.rp-carta-conteudo {
    padding: 10px 16px 18px;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Imagem da carta — protagonista visual */
.rp-carta-imagem {
    width: 100%;
    max-width: 300px;
    max-height: 56dvh;

    display: block;
    margin: 0 auto;

    object-fit: contain;
    border-radius: 10px;
}

/* Ações: áudio + fechar */
.rp-carta-acoes {
    width: 100%;
    display: flex;
    gap: 8px;
}

.rp-carta-acoes .btn-audio {
    flex: 1;
}

.rp-carta-acoes .btn-secundario {
    flex: 1;
}

/* Landscape: modal mais compacto */
@media (orientation: landscape) and (max-height: 560px) {
    #mc-overlay-carta .rp-card {
        width: min(94vw, 360px);
        max-width: min(94vw, 360px);
        max-height: calc(100dvh - 20px);
        overflow-y: auto;
    }

    .rp-carta-banner {
        max-height: 44px;
    }

    .rp-carta-imagem {
        max-height: 44dvh;
        max-width: 220px;
    }

    .rp-carta-conteudo {
        padding: 8px 12px 14px;
        gap: 8px;
    }
}
