/* ==========================================================================
   SINGLE / READER — Layout de leitura do post
   Base: Figma 277:1392 (articleReader). Reusa tokens de typography.css/main.css.
   ========================================================================== */

.reader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

/* coluna do artigo */
.reader__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 64px;
    width: min(800px, 100%);
    padding: 120px 32px 0;
    margin: 0 auto;
    /* frame de leitura opaco: textura de pontos nunca sob texto corrido (Figma) */
    background-color: var(--color-bg);
}

/* header: título + meta */
.reader__header {
    display: flex;
    flex-direction: column;
    gap: 36px;
    width: 100%;
    padding-bottom: 56px;
    border-bottom: 1.5px solid var(--color-on-primary-30);
}

.reader__title {
    margin: 0;
    max-width: 100%;
    /* escala com a fonte (+Aa), mas com teto por viewport p/ não estourar a largura */
    font-size: min(var(--font-size-display), 12vw);
    text-align: center;
    overflow-wrap: break-word;
    color: var(--color-text);
}

.reader__meta {
    display: flex;
    justify-content: center;
    gap: 18px;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: var(--font-size-button);
}

.reader__author { color: var(--color-text); }
.reader__date   { color: var(--color-on-primary-60); }

/* corpo */
.reader__body {
    width: 100%;
    overflow-wrap: break-word;
    color: var(--color-text);
}

.reader__body > * + * { margin-top: 64px; }
.reader__body p:empty { display: none; }
.reader__body a       { color: var(--color-accent); }
.reader__body img     { max-width: 100%; height: auto; }

.reader__body hr {
    width: 100%;
    max-width: 100%;
    height: 0;
    border: 0;
    border-top: 1.5px solid var(--color-on-primary-30);
    margin: 64px 0;
}

/* reader-default — capa opcional */
.reader__cover {
    width: 100%;
    margin: 0;
}
.reader__cover img {
    display: block;
    width: 100%;
    height: auto;
}

/* ==========================================================================
   IMAGENS NO CORPO (blocos do editor) — usadas pelo reader imageStack
   ========================================================================== */

.reader__body figure.wp-block-image a {
    display: block;
}

.reader__body figure.wp-block-image img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-inline: auto; /* centra imagens menores que a coluna */
}

/* legenda "Image description" */
.reader__body figure.wp-block-image figcaption {
    margin-top: 16px;
    font-family: var(--font-primary);
    font-size: var(--font-size-excerpt);
    line-height: var(--line-height-excerpt);
    text-align: left;
    color: var(--color-text);
}

/* galeria: fileira de imagens com alturas uniformes (Figma 655:2055) */
.reader__body .wp-block-gallery.has-nested-images {
    display: flex;
    flex-wrap: wrap;
    gap: 64px;
    justify-content: center;
    align-items: flex-start;
}

.reader__body .wp-block-gallery.has-nested-images figure.wp-block-image {
    width: auto;
    margin: 0;
}

.reader__body .wp-block-gallery.has-nested-images figure.wp-block-image img {
    height: 360px;
    width: auto;
    max-width: none;
    object-fit: cover;
}

/* ==========================================================================
   READER imageStack — coluna mais larga; texto/imagens normais a 800,
   destaque (wide) e galeria estouram para 1000
   ========================================================================== */

.reader--imagestack .reader__content {
    width: min(1000px, 100%);
}

.reader--imagestack .reader__header {
    width: min(800px, 100%);
}

.reader--imagestack .reader__body > * {
    width: min(800px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.reader--imagestack .reader__body > .alignwide,
.reader--imagestack .reader__body > .wp-block-gallery {
    width: min(1000px, 100%);
}

/* ==========================================================================
   READER BOTTOM — "You reached the bottom" + Next Post
   ========================================================================== */

.reader-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 56px 32px;
}

.reader-bottom__end {
    display: flex;
    align-items: center;
    gap: 16px;
}

.reader-bottom__icon {
    width: 52px;
    height: auto;
    flex-shrink: 0;
    opacity: 0.3; /* igual ao Figma (vetor é sólido #383838) */
}

.reader-bottom__label {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: var(--font-size-button);
    color: var(--color-on-primary-50);
}

.reader-bottom__next {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 8px 24px;
    border-radius: 48px;
    background: var(--color-on-primary-10);
    color: var(--color-on-primary-70);
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: var(--font-size-button);
    text-decoration: none;
    transition: background 0.2s ease;
}

.reader-bottom__next:hover { background: var(--color-on-primary-20); }

/* ==========================================================================
   RESPONSIVIDADE
   ========================================================================== */

@media (max-width: 600px) {
    .reader__content { padding-top: 64px; gap: 40px; }
    .reader__title   { font-size: 3rem; }
    .reader-bottom   { flex-direction: column; gap: 16px; }

    /* galeria empilha; imagens ocupam a largura toda */
    .reader__body .wp-block-gallery.has-nested-images { gap: 32px; }
    .reader__body .wp-block-gallery.has-nested-images figure.wp-block-image img {
        height: auto;
        width: 100%;
    }
}

/* ==========================================================================
   TIRA DE GALERIA no rodapé do post (auto do conteúdo) — Figma 655:1852 / Frame 143
   Mesma altura, largura natural (aspect preservado), em fileira; abre o viewer.
   ========================================================================== */

.reader__gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    align-items: center;
    width: min(1000px, 100%);
    margin: 0 auto;
    padding: 24px 32px 0;
    box-sizing: border-box;
}

.reader__gallery-item {
    display: block;
    height: 220px;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    overflow: hidden;
    line-height: 0;
}

.reader__gallery-item img {
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s ease;
}

.reader__gallery-item:hover img { opacity: 0.85; }

@media (max-width: 600px) {
    .reader__gallery { gap: 12px; padding: 16px 16px 0; }
    .reader__gallery-item { height: 140px; }
}

/* ==========================================================================
   GALLERY VIEW — lightbox das imagens do post (Figma 658:2166)
   ========================================================================== */

.reader__body img { cursor: zoom-in; }

.gallery-view {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-bg);
    /* textura de pontos "BG texture" do Figma — var compartilhada (main.css) */
    background-image: var(--bg-dots);
    background-size: var(--bg-dots-size);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.gallery-view.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0s;
}

.gallery-view__stage {
    display: flex;
    max-width: 90vw;
    max-height: 85vh;
}

.gallery-view__image {
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

/* Back + Navigator — mesmo dark do menu flutuante */
.gallery-view__back,
.gallery-view__nav {
    position: fixed;
    bottom: 32px;
    z-index: 201;
    display: flex;
    align-items: center;
    height: 64px;
    background-color: rgba(25, 25, 22, 0.9);
    border: none;
    border-radius: 100px;
}

.gallery-view__back {
    left: 32px;
    width: 64px;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.gallery-view__nav {
    right: 32px;
    gap: 4px;
    padding: 8px;
}

.gallery-view__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: none;
    background: none;
    border-radius: 48px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.gallery-view__btn:hover { background-color: rgba(255, 255, 255, 0.1); }

.gallery-view__back svg,
.gallery-view__btn svg { width: 22px; height: 22px; display: block; }

.gallery-view__back svg path,
.gallery-view__btn svg path { stroke: rgba(255, 255, 255, 0.9); }

.gallery-view__counter {
    min-width: 44px;
    text-align: center;
    font-family: var(--font-primary);
    font-size: 20px;
    font-weight: 400;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
    .gallery-view__back { left: 16px; bottom: 16px; }
    .gallery-view__nav  { right: 16px; bottom: 16px; }
    .gallery-view__stage,
    .gallery-view__image { max-width: 92vw; max-height: 78vh; }
}
