/* Persiana — galeria de imagens em expansão (persiana).
   Desktop: expande no hover. Mobile: toque abre (classe .wpe-aberta via JS).
   Valores dinâmicos por widget vêm de custom properties (--wpe-*). */

.wpe-wrap { width: 100%; }

/* Cabeçalho */
.wpe-cab { max-width: 720px; margin: 0 auto 28px; }
.wpe-titulo { margin: 0 0 8px; font-size: 30px; font-weight: 600; line-height: 1.2; }
.wpe-sub { margin: 0; font-size: 14px; line-height: 1.5; }

/* Grade da persiana */
.wpe-grid {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    gap: 8px;
    height: 400px;
}

.wpe-item {
    position: relative;
    display: block;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    cursor: pointer;
    background: #0f1720;
    border-radius: 8px;
    text-decoration: none;
    transition: flex var(--wpe-vel, 500ms) ease;
}

/* Abertura: desktop hover; mobile classe .wpe-aberta */
.wpe-grid:hover .wpe-item { flex: 1 1 0; }
.wpe-grid .wpe-item:hover { flex: var(--wpe-flex, 5) 1 0; }
.wpe-item.wpe-aberta { flex: var(--wpe-flex, 5) 1 0 !important; }

/* Imagem preenche o item inteiro (vence limites do tema) */
.wpe-item img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center;
    filter: var(--wpe-filtro, none);
    transition: filter var(--wpe-vel, 500ms) ease, transform var(--wpe-vel, 500ms) ease;
}
.wpe-item:hover img,
.wpe-item.wpe-aberta img { filter: grayscale(0); }

/* Overlay só quando há legenda */
.wpe-item.tem-cap::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(to top, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 60%);
}

/* Legenda */
.wpe-cap {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px;
    opacity: 0;
    transition: opacity var(--wpe-vel, 500ms) ease;
    pointer-events: none;
}
.wpe-item:hover .wpe-cap,
.wpe-item.wpe-aberta .wpe-cap { opacity: 1; }
.wpe-cap-txt {
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    line-height: 1.2;
    white-space: normal;
}
.wpe-cap-desc {
    display: block;
    margin-top: 6px;
    color: rgba(255,255,255,.85);
    font-size: 13px;
    line-height: 1.4;
    white-space: normal;
}

/* Ícone no topo da tira */
.wpe-icone-wrap {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 2;
    display: flex;
    padding: 14px;
    pointer-events: none;
}
.wpe-icone { display: inline-flex; line-height: 1; }
.wpe-icone svg { width: 32px; height: 32px; }

/* Título na tira FECHADA (só o título; some ao abrir) */
.wpe-fechado {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    pointer-events: none;
    transition: opacity var(--wpe-vel, 500ms) ease;
}
.wpe-fechado-txt {
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    text-align: center;
}
.wpe-label-vertical   .wpe-fechado-txt { writing-mode: vertical-rl; transform: rotate(180deg); }
.wpe-label-horizontal .wpe-fechado-txt { writing-mode: horizontal-tb; transform: none; }

/* Modo hifenizado (horizontal): quebra por sílaba pt-BR, sem hífen visível */
.wpe-label-hifen .wpe-fechado {
    padding: 6px; /* borda mínima */
}
.wpe-label-hifen .wpe-fechado-txt {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
    /* remove o traço visível da hifenização, mantendo a quebra na sílaba */
    -webkit-hyphenate-character: "";
    hyphenate-character: "";
    width: 100%;
    line-height: 1.15;
}

/* Ao abrir (hover/aberta), esconde o título fechado e mostra a legenda */
.wpe-item:hover .wpe-fechado,
.wpe-item.wpe-aberta .wpe-fechado { opacity: 0; }

.wpe-titulo, .wpe-sub, .wpe-cap-txt, .wpe-cap-desc, .wpe-fechado-txt { font-family: inherit; }
.wpe-item:focus-visible { outline: 2px solid #0066ff; outline-offset: -2px; }

/* ═══ MOBILE: vira grade de cards quadrados ═══ */
@media (max-width: 767px) {
    /* Grade */
    .wpe-grid {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: var(--wpe-mob-gap, 10px);
        height: auto !important;
    }
    .wpe-mob-col-2 .wpe-grid { grid-template-columns: 1fr 1fr; }

    /* Cada item vira um card fechado, sem expansão de persiana */
    .wpe-item {
        flex: none !important;
        width: auto !important;
        height: var(--wpe-mob-altura, 180px);
        border-radius: 12px;
        transition: none;
    }
    .wpe-mob-col-2 .wpe-item { height: calc(var(--wpe-mob-altura, 180px) * 0.9); }

    /* Imagem sempre colorida e preenchendo */
    .wpe-item img { filter: grayscale(0) !important; }

    /* Esconde o rótulo de "persiana fechada" no mobile (usamos a legenda) */
    .wpe-fechado { display: none !important; }

    /* Legenda sempre visível: título aparece; descrição escondida até tocar */
    .wpe-cap {
        opacity: 1 !important;
        position: absolute;
        inset: auto 0 0 0;
        z-index: 2;
        justify-content: flex-end;
        padding: 14px;
    }
    .wpe-cap-txt {
        font-size: 16px;
        line-height: 1.2;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    /* Descrição escondida por padrão no mobile */
    .wpe-cap-desc {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        margin-top: 0;
        transition: max-height var(--wpe-vel, 400ms) ease, opacity var(--wpe-vel, 400ms) ease, margin-top var(--wpe-vel, 400ms) ease;
    }
    /* Ao tocar (classe via JS): expande a descrição */
    .wpe-item.wpe-mob-aberto { height: auto; min-height: var(--wpe-mob-altura, 180px); }
    .wpe-item.wpe-mob-aberto .wpe-cap-desc {
        max-height: 320px;
        opacity: 1;
        margin-top: 6px;
    }
    .wpe-item.wpe-mob-aberto .wpe-cap-txt {
        -webkit-line-clamp: unset;
        overflow: visible;
    }

    /* Overlay mais forte no mobile para o texto ler bem */
    .wpe-item.tem-cap::after {
        background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.2) 70%, rgba(0,0,0,0) 100%);
    }

    /* Indicador de "toque para ver mais" (setinha) */
    .wpe-item.tem-cap .wpe-cap::after {
        content: "";
        position: absolute;
        top: 12px;
        right: 12px;
        width: 22px;
        height: 22px;
        border-radius: 999px;
        background: rgba(255,255,255,.25) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat center/14px;
        transition: transform var(--wpe-vel, 400ms) ease;
    }
    .wpe-item.wpe-mob-aberto.tem-cap .wpe-cap::after { transform: rotate(180deg); }

    /* Ícone do topo menor no mobile */
    .wpe-icone svg { width: 26px; height: 26px; }
    .wpe-icone-wrap { padding: 10px; }
}


/* ── Flag "Manter tamanho vertical" ──
   Ao abrir, a imagem aparece INTEIRA na proporção real (sem zoom/corte).
   A tira aberta ocupa só a largura da imagem; as outras preenchem o resto. */
.wpe-manter-vertical .wpe-item { background: #0b0f14; }

/* A imagem aberta define a largura (altura total, largura proporcional) */
.wpe-manter-vertical .wpe-grid:not(:hover) .wpe-item.wpe-ativa img,
.wpe-manter-vertical .wpe-item:hover img,
.wpe-manter-vertical .wpe-item.wpe-aberta img {
    position: relative !important;
    inset: auto !important;
    width: auto !important;
    height: 100% !important;
    max-width: none !important;
    object-fit: contain !important;
    object-position: center;
    margin: 0 auto;
}
/* A tira aberta encolhe à largura da imagem (não estica via flex) */
.wpe-manter-vertical .wpe-grid .wpe-item:hover,
.wpe-manter-vertical .wpe-grid:not(:hover) .wpe-item.wpe-ativa {
    flex: 0 1 auto !important;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* As demais tiras dividem o espaço restante igualmente */
.wpe-manter-vertical .wpe-grid:hover .wpe-item:not(:hover),
.wpe-manter-vertical .wpe-grid:not(:hover) .wpe-item:not(.wpe-ativa) {
    flex: 1 1 0 !important;
}

/* No mobile (card aberto por toque), mostra a imagem inteira */
@media (max-width: 767px) {
    .wpe-manter-vertical .wpe-item.wpe-mob-aberto img {
        object-fit: contain !important;
        object-position: center;
    }
}
