/* ============================================
   TAG PAGE — projeto especial, patrocínio e
   espaços comerciais próprios.
   Configuração: Tags → Editar tag.
   ============================================ */

.tag-archive {
    background: var(--tag-page-bg, var(--color-background));
    color: var(--tag-page-text, var(--color-text));
    min-height: 60vh;
}

/* ---------- Cabeçalho enxuto ---------- */

.tag-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: clamp(1.5rem, 4vw, 3rem) 0;
    background-color: var(--tag-hero-bg, var(--povo-black));
    background-image: radial-gradient(
        120% 160% at 50% 0%,
        rgba(var(--tag-accent-rgb, 0, 229, 255), 0.16) 0%,
        transparent 65%
    );
    color: #fff;
    isolation: isolate;
}

.tag-hero--compact { min-height: 180px; }
.tag-hero--medium  { min-height: 220px; }
.tag-hero--tall    { min-height: 380px; }

.tag-hero--project {
    border-bottom: 3px solid var(--tag-accent, var(--brand));
}

.tag-hero__media {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.tag-hero__media img,
.tag-hero__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.tag-hero__scrim {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, calc(var(--tag-hero-overlay, 0.55) * 0.35)) 0%,
        rgba(0, 0, 0, calc(var(--tag-hero-overlay, 0.55) * 0.7)) 55%,
        rgba(0, 0, 0, var(--tag-hero-overlay, 0.55)) 100%
    );
}

.tag-hero__content {
    position: relative;
    z-index: 2;
    width: 100%;
    container-type: inline-size;
    text-align: center;
}

/* Logo do projeto */
.tag-hero__logo {
    margin: 0 auto 14px;
}

.tag-hero__logo-img {
    display: block;
    width: auto;
    max-width: min(240px, 60vw);
    max-height: 54px;
    margin: 0 auto;
    object-fit: contain;
}

/* Traço de marca do projeto */
.tag-hero__accent {
    display: block;
    width: 48px;
    height: 4px;
    margin: 0 auto 14px;
    border-radius: 999px;
    background: var(--tag-accent, var(--brand));
}

/*
 * Título em uma única linha.
 * O PHP envia um divisor baseado na quantidade de caracteres da tag
 * (--tag-title-divisor); o tamanho usa a largura do container (cqw).
 * O main.js faz o ajuste fino após o carregamento das fontes e no resize.
 */
.tag-hero__title {
    --tag-title-divisor: 7.44;
    margin: 0 auto;
    max-width: 100%;
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: #fff !important;
    text-shadow: 0 2px 24px rgba(0, 0, 0, 0.65), 0 1px 3px rgba(0, 0, 0, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: normal;
    word-break: normal;

    font-size: clamp(1.5rem, 6vw, 3rem);
    font-size: min(3.25rem, calc(100cqw / var(--tag-title-divisor)));
}

@supports not (font-size: 1cqw) {
    .tag-hero__title {
        font-size: clamp(1.25rem, 7vw, 3rem);
    }
}

.tag-hero__tagline {
    max-width: 62ch;
    margin: 12px auto 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: var(--text-base);
    line-height: 1.5;
}

/* Selo de patrocínio */
.tag-sponsor {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 18px auto 0;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: #0A0A0A;
    font-size: 12px;
    line-height: 1.3;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}

.tag-sponsor__label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #52525B;
}

.tag-sponsor__brand {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #0A0A0A;
    text-decoration: none;
}

.tag-sponsor__brand:hover {
    color: #0A0A0A;
}

.tag-sponsor__logo {
    display: block;
    width: auto;
    max-height: 18px;
    max-width: 90px;
    object-fit: contain;
}

.tag-sponsor__name {
    font-weight: 700;
}

.tag-sponsor__until {
    color: #71717A;
    font-size: 11px;
}

/* ---------- Banner da seção ---------- */

.tag-banner-slot {
    padding: clamp(1rem, 2.5vw, 1.5rem) 0 0;
}

.tag-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    max-width: 970px;
    margin: 0 auto;
    text-align: center;
}

.tag-banner__link {
    display: block;
    max-width: 100%;
}

.tag-banner__img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 160px;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.tag-banner__html {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.tag-banner__html img,
.tag-banner__html iframe {
    max-width: 100%;
    height: auto;
}

/* ---------- Área de conteúdo ---------- */

.tag-posts {
    padding: clamp(1.75rem, 4vw, 3rem) 0 clamp(3rem, 6vw, 5rem);
}

/* ---------- Layout com barra lateral ---------- */

.tag-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(1.5rem, 3vw, 2.5rem);
}

@media (min-width: 1024px) {
    .tag-layout.has-sidebar {
        grid-template-columns: minmax(0, 1fr) 300px;
        align-items: start;
    }
}

.tag-main {
    min-width: 0;
}

.tag-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    min-width: 0;
}

.tag-sidebar .tag-ad-slot {
    max-width: 100%;
    margin: 0;
}

.tag-sidebar-widgets {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.tag-sidebar .widget {
    padding: var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-background);
}

.tag-sidebar .widget-title {
    margin: 0 0 var(--space-3);
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 700;
    line-height: 1.2;
}

.tag-sidebar-bottom.is-sticky {
    position: sticky;
    top: 84px;
}

@media (max-width: 992px) {
    .tag-sidebar-bottom.is-sticky {
        position: static;
    }
}

/* Anúncio institucional da sidebar */
.tag-sidebar-house {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 10px;
    min-height: 250px;
    padding: var(--space-6);
    border: 1px solid rgba(0, 229, 255, .35);
    border-radius: var(--radius-xl);
    background:
        radial-gradient(120% 100% at 50% 0%, rgba(0, 229, 255, .16), transparent 65%),
        var(--povo-black);
    color: #fff;
}

.tag-sidebar-house__label {
    color: var(--muted, #A1A1AA);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.tag-sidebar-house__kicker {
    color: var(--brand);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.tag-sidebar-house__title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -.02em;
    color: #fff;
}

.tag-sidebar-house__text {
    margin: 0;
    color: rgba(255, 255, 255, .72);
    font-size: var(--text-sm);
    line-height: 1.5;
}

.tag-sidebar-house__cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding: 11px 18px;
    border-radius: 999px;
    background: var(--brand);
    color: var(--ink);
    font-size: var(--text-sm);
    font-weight: 700;
    text-decoration: none;
}

.tag-sidebar-house__cta:hover {
    background: #fff;
    color: var(--ink);
}

/* ---------- Faixa fixa mobile ---------- */

.tag-sticky-mobile {
    display: none;
}

@media (max-width: 768px) {
    .tag-sticky-mobile {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 99990;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px 42px 8px 12px;
        background: var(--povo-black);
        border-top: 1px solid rgba(255, 255, 255, .14);
        box-shadow: 0 -8px 24px rgba(0, 0, 0, .28);
    }

    .tag-sticky-mobile__inner {
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .tag-sticky-mobile__inner img,
    .tag-sticky-mobile__img,
    .tag-sticky-mobile__html img {
        display: block;
        width: auto;
        max-width: 100%;
        max-height: 50px;
        height: auto;
    }

    .tag-sticky-mobile__html {
        width: 100%;
        text-align: center;
    }

    .tag-sticky-mobile__close {
        position: absolute;
        top: 50%;
        right: 8px;
        transform: translateY(-50%);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        padding: 0;
        border: 1px solid rgba(255, 255, 255, .2);
        border-radius: 50%;
        background: rgba(255, 255, 255, .08);
        color: #fff;
        font-size: 18px;
        line-height: 1;
        cursor: pointer;
    }

    body.has-tag-sticky-ad {
        padding-bottom: 74px;
    }
}

/* ---------- Espaços publicitários ---------- */

.tag-ad-slot {
    max-width: 970px;
    margin: clamp(1.5rem, 3vw, 2.5rem) auto;
    text-align: center;
}

.tag-ad-slot:first-child {
    margin-top: 0;
}

.tag-ad-slot__label {
    display: block;
    margin-bottom: 6px;
    color: var(--tag-page-muted, var(--color-text-muted));
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.tag-ad-slot__inner img {
    display: inline-block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
}

.tag-ad-slot__html {
    max-width: 100%;
    overflow: hidden;
}

.tag-ad-slot__html img,
.tag-ad-slot__html iframe {
    max-width: 100%;
    height: auto;
}

.tag-ad-slot--mid {
    grid-column: 1 / -1;
}

.tag-ad-slot--bottom {
    margin-top: clamp(2rem, 4vw, 3rem);
    margin-bottom: 0;
    padding-top: clamp(1.5rem, 3vw, 2rem);
    border-top: 1px solid var(--tag-page-border, var(--color-border));
}

/* ---------- Títulos de seção ---------- */

.tag-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin: clamp(2rem, 4vw, 3rem) 0 var(--space-5);
}

.tag-section-head--main {
    margin-top: clamp(1.5rem, 3vw, 2.5rem);
}

.tag-section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 2vw, 1.5rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--tag-page-text, var(--color-text));
}

.tag-section-title::before {
    content: "";
    flex: 0 0 auto;
    width: 6px;
    height: 1.1em;
    border-radius: 3px;
    background: var(--tag-accent, var(--brand));
}

.tag-section-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--tag-page-muted, var(--color-text-secondary));
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--transition-fast);
}

.tag-section-link:hover {
    color: var(--brand-ink);
}

/* ---------- Primeiro post em destaque ---------- */

.tag-featured-post {
    margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--povo-black);
}

.tag-featured-post__link {
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: clamp(320px, 40vw, 480px);
    padding: clamp(1.25rem, 4vw, 2.75rem);
    overflow: hidden;
    color: #fff;
    text-decoration: none;
    isolation: isolate;
}

.tag-featured-post--no-image .tag-featured-post__link {
    background: linear-gradient(135deg, var(--povo-black) 0%, #1a1a2e 100%);
}

.tag-featured-post__media {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.tag-featured-post__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform var(--transition-slow);
}

.tag-featured-post:hover .tag-featured-post__media img {
    transform: scale(1.03);
}

.tag-featured-post__scrim {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.05) 20%,
        rgba(0, 0, 0, 0.45) 62%,
        rgba(0, 0, 0, 0.82) 100%
    );
}

.tag-featured-post--no-image .tag-featured-post__scrim {
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.1) 0%,
        rgba(0, 0, 0, 0.55) 100%
    );
}

.tag-featured-post__content {
    position: relative;
    z-index: 2;
    width: 100%;
}

.tag-featured-post__content::before {
    content: "";
    display: block;
    width: 40px;
    height: 3px;
    margin-bottom: 14px;
    border-radius: 3px;
    background: var(--tag-accent, var(--brand));
}

.tag-featured-post__title {
    max-width: 24ch;
    margin: 0;
    color: #fff !important;
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3.4vw, 2.6rem);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.4);
}

@media (max-width: 640px) {
    .tag-featured-post__link {
        min-height: 260px;
        padding: var(--space-5);
    }

    .tag-featured-post__title {
        max-width: none;
        font-size: clamp(1.35rem, 6vw, 1.9rem);
    }
}

/* ---------- Grade de posts ---------- */

.tag-posts__grid {
    display: grid;
    gap: var(--space-6);
    align-items: stretch;
}

.tag-posts__grid--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tag-posts__grid--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tag-posts__grid--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 992px) {
    .tag-posts__grid--cols-3,
    .tag-posts__grid--cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .tag-posts__grid--cols-2,
    .tag-posts__grid--cols-3,
    .tag-posts__grid--cols-4 {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-4);
    }
}

/* ---------- Card ---------- */

.tag-card {
    height: 100%;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

.tag-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
    border-color: var(--brand-ink);
}

.tag-card__link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.tag-card__media {
    position: relative;
    flex: 0 0 auto;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--color-background-alt);
}

.tag-card__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.tag-card:hover .tag-card__media img {
    transform: scale(1.04);
}

.tag-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 2rem;
    color: var(--brand-ink);
    background: linear-gradient(135deg, var(--povo-lime-light) 0%, var(--color-background-alt) 100%);
}

.tag-card__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: var(--space-5);
}

.tag-card__date {
    display: block;
    margin-bottom: var(--space-2);
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--brand-ink);
}

.tag-card__title {
    margin: 0 0 var(--space-2);
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text);
}

.tag-card__excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0 0 var(--space-4);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    color: var(--color-text-secondary);
}

.tag-card__author {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: auto;
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border-light);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.tag-card__author img {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
}

/* ---------- Layout: lista horizontal ---------- */

.tag-posts__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.tag-posts__list .tag-card__link {
    flex-direction: row;
    align-items: stretch;
}

.tag-posts__list .tag-card__media {
    flex: 0 0 340px;
    width: 340px;
    aspect-ratio: 16 / 10;
}

.tag-posts__list .tag-card__body {
    justify-content: center;
}

.tag-posts__list .tag-card__title {
    font-size: var(--text-2xl);
}

@media (max-width: 720px) {
    .tag-posts__list .tag-card__link {
        flex-direction: column;
    }

    .tag-posts__list .tag-card__media {
        flex-basis: auto;
        width: 100%;
    }
}

/* ---------- Seções curadas do projeto ---------- */

.tag-project-sections {
    display: flex;
    flex-direction: column;
}

.tag-project-section + .tag-project-section {
    margin-top: clamp(1rem, 2vw, 1.5rem);
}

@media (max-width: 640px) {
    .tag-project-section .tag-posts__grid {
        display: flex;
        gap: var(--space-4);
        overflow-x: auto;
        padding-bottom: var(--space-2);
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }

    .tag-project-section .tag-posts__grid::-webkit-scrollbar {
        display: none;
    }

    .tag-project-section .tag-card {
        flex: 0 0 82%;
        scroll-snap-align: start;
    }
}

/* ---------- Nuvem de tags ---------- */

.tag-cloud-section {
    margin-top: clamp(2.5rem, 5vw, 4rem);
    padding-top: clamp(1.5rem, 3vw, 2rem);
    border-top: 1px solid var(--tag-page-border, var(--color-border));
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
}

.tag-cloud .tag {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-background);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.tag-cloud .tag:hover {
    background: var(--tag-accent, var(--brand));
    border-color: var(--tag-accent, var(--brand));
    color: var(--tag-on-accent, #0A0A0A);
}

/* ---------- Paginação ---------- */

.tag-posts .pagination {
    margin-top: var(--space-12);
}

.tag-posts .pagination-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.tag-posts .pagination-list a,
.tag-posts .pagination-list span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-md);
    background: var(--color-background-alt);
    color: var(--color-text);
    font-size: var(--text-sm);
    text-decoration: none;
}

.tag-posts .pagination-list a:hover,
.tag-posts .pagination-list .current {
    background: var(--povo-lime);
    color: var(--povo-black);
}

/* ---------- Sem posts ---------- */

.tag-posts .no-posts {
    padding: var(--space-16) var(--space-4);
    text-align: center;
}

.tag-posts .no-posts-icon {
    display: block;
    margin-bottom: var(--space-4);
    font-size: 4rem;
    color: var(--brand-ink);
}

/* ---------- Responsivo ---------- */

@media (max-width: 768px) {
    .tag-hero--compact { min-height: 150px; }
    .tag-hero--medium  { min-height: 180px; }
    .tag-hero--tall    { min-height: 290px; }

    .tag-hero__title {
        font-size: min(2.1rem, calc(100cqw / var(--tag-title-divisor)));
    }

    .tag-hero__logo-img {
        max-height: 42px;
    }

    .tag-sponsor {
        margin-top: 14px;
    }
}

@media (max-width: 480px) {
    .tag-hero {
        padding: var(--space-6) 0;
    }

    .tag-hero--compact { min-height: 135px; }
    .tag-hero--medium  { min-height: 165px; }
    .tag-hero--tall    { min-height: 250px; }

    .tag-hero__tagline {
        font-size: var(--text-sm);
    }

    .tag-banner__img {
        max-height: 130px;
    }

    .tag-section-head {
        align-items: flex-start;
    }

    .tag-section-title {
        font-size: 1.1rem;
    }

    .tag-cloud .tag {
        padding: 7px 12px;
    }
}

/* ---------- Preferência por menos movimento ---------- */

@media (prefers-reduced-motion: reduce) {
    .tag-card,
    .tag-card__media img,
    .tag-featured-post__media img {
        transition: none;
    }

    .tag-card:hover {
        transform: none;
    }

    .tag-card:hover .tag-card__media img,
    .tag-featured-post:hover .tag-featured-post__media img {
        transform: none;
    }
}
