/* ==========================================================================
   Cometa Diário — Footer
   ========================================================================== */

.cd-footer {
    margin-top: auto;
    background: var(--color-primary-dark);
    color: rgba(255, 255, 255, 0.82);
    font-family: var(--font-body);
    border-top: 3px solid var(--color-accent);
}

[data-theme="dark"] .cd-footer {
    background: #0a0d12;
    border-top-color: var(--color-primary);
}

/* --- Logo centralizada --- */
.cd-footer__logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    padding: clamp(2.5rem, 6vw, 4rem) clamp(1rem, 4vw, 2rem);
    text-align: center;
}

.cd-footer__logo-link {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 480px;
    margin-inline: auto;
    line-height: 0;
    text-decoration: none;
}

.cd-footer__logo {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: clamp(80px, 12vw, 120px);
    margin-inline: auto;
    object-fit: contain;
}

.cd-footer__logo--light {
    filter: brightness(0) invert(1);
    opacity: 0.96;
}

.cd-footer__logo--dark {
    display: none;
}

[data-theme="dark"] .cd-footer__logo--light {
    display: none;
}

[data-theme="dark"] .cd-footer__logo--dark {
    display: block;
    filter: none;
    opacity: 1;
}

.cd-footer__site-name {
    display: block;
    font-family: var(--font-heading);
    font-size: clamp(2rem, 8vw, 3rem);
    font-weight: 700;
    color: #fff;
    text-align: center;
    line-height: 1.15;
}

/* --- Barra inferior --- */
.cd-footer__bar {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.18);
    padding-block: 1rem;
}

.cd-footer__bar-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}

.cd-footer__copy {
    margin: 0;
    flex: 1 1 12rem;
    min-width: 0;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.45;
}

.cd-footer__credit {
    margin: 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    flex-shrink: 0;
}

.cd-footer__firmis {
    color: rgba(255, 255, 255, 0.88);
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition);
}

.cd-footer__firmis:hover {
    color: var(--color-accent);
    text-decoration: none;
}

/* --- Botão flutuante: voltar ao topo --- */
.cd-back-top {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right, 0px));
    bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
    z-index: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(var(--color-primary-rgb, 14, 57, 92), 0.2);
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--color-primary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.92);
    transition:
        opacity 0.25s ease,
        visibility 0.25s ease,
        transform 0.25s ease,
        background var(--transition),
        color var(--transition),
        box-shadow var(--transition);
}

.cd-back-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.cd-back-top:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

.cd-back-top:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
}

.cd-back-top__icon {
    transform: rotate(-90deg);
}

.cd-back-top .cd-icon {
    width: 20px;
    height: 20px;
}

[data-theme="dark"] .cd-back-top {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-accent);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .cd-back-top:hover {
    background: var(--color-primary);
    color: #fff;
}

@media (prefers-reduced-motion: reduce) {
    .cd-back-top {
        transition: opacity 0.15s ease, visibility 0.15s ease;
    }

    .cd-back-top.is-visible {
        transform: none;
    }
}

/* --- Mobile --- */
@media (max-width: 768px) {
    .cd-footer__logo-wrap {
        padding: 2rem 1.25rem 1.25rem;
    }

    .cd-footer__logo-link {
        max-width: none;
    }

    .cd-footer__logo {
        max-width: min(320px, 90vw);
        max-height: 88px;
        min-height: 56px;
    }

    .cd-footer__site-name {
        font-size: clamp(1.75rem, 9vw, 2.5rem);
    }

    .cd-footer__bar {
        padding: 0.875rem 0;
    }

    .cd-footer__bar-inner {
        flex-direction: column;
        align-items: center;
        gap: 0.875rem;
        text-align: center;
    }

    .cd-footer__copy {
        flex: none;
        width: 100%;
        text-align: center;
        font-size: 0.75rem;
        line-height: 1.5;
    }

    .cd-footer__credit {
        text-align: center;
        width: 100%;
    }

    .cd-back-top {
        width: 40px;
        height: 40px;
        right: max(0.875rem, env(safe-area-inset-right, 0px));
        bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    }

    .cd-back-top .cd-icon {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 400px) {
    .cd-footer__logo {
        max-width: 94vw;
        max-height: 76px;
    }
}
