/**
 * Cookie Consent — CortePlaca.pt
 * Reescrito em 2026-08-18 (Fase 1 do sistema de gestão de cookies).
 *
 * A versão anterior deste ficheiro nunca chegou a ser usada por nenhuma view.
 *
 * DECISÕES QUE SÃO LEGAIS, NÃO ESTÉTICAS — não "arrumar" sem ler:
 *   · `.cc-btn--accept` e `.cc-btn--reject` partilham TODA a aparência.
 *     Dar mais destaque ao "Aceitar" é um dark pattern e invalida o consentimento
 *     (EDPB Cookie Banner Task Force, Jan 2023). Se um dia levarem cores diferentes,
 *     têm de manter o mesmo peso visual, tamanho e contraste.
 *   · O banner NÃO tem overlay que bloqueie a página — um cookie wall condiciona o
 *     acesso ao consentimento, o que o torna não-livre (Art. 4(11) RGPD).
 *   · Os toggles das categorias opcionais nascem desligados (ver .cc-switch).
 */

/* ============================================================================
   TOKENS LOCAIS
   ============================================================================ */

.cc-root {
    --cc-ink: var(--ink, #193532);
    --cc-surface: #fff;
    --cc-line: rgba(25, 53, 50, 0.14);
    --cc-muted: #5b6b69;
    --cc-accent: var(--ink, #193532);
    --cc-radius: 14px;
    --cc-shadow: 0 -6px 28px rgba(16, 33, 31, 0.16);
    --cc-z-banner: 30050;
    --cc-z-modal: 30060;

    font-family: var(--cnvs-body-font, 'tenon', system-ui, sans-serif);
    color: var(--cc-ink);
}

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

.cc-banner {
    position: fixed;
    inset: auto 0 0 0;
    z-index: var(--cc-z-banner);
    background: var(--cc-surface);
    border-top: 1px solid var(--cc-line);
    box-shadow: var(--cc-shadow);
    padding: clamp(16px, 2.4vw, 22px) clamp(14px, 3vw, 28px);
    animation: cc-rise 0.28s ease-out;
}

.cc-banner[hidden] {
    display: none;
}

@keyframes cc-rise {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .cc-banner { animation: none; }
}

.cc-banner__inner {
    max-width: 1180px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: clamp(14px, 2.4vw, 32px);
    align-items: center;
}

.cc-banner__title {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.cc-banner__text {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--cc-muted);
    max-width: 74ch;
}

.cc-banner__text a {
    color: var(--cc-ink);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ============================================================================
   BOTÕES

   `.cc-actions` usa grid com colunas iguais: nenhum botão pode ficar maior que
   outro por acidente de conteúdo.
   ============================================================================ */

.cc-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 10px;
    align-items: stretch;
}

.cc-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 150px;
    min-height: 46px;
    padding: 12px 20px;
    border-radius: 10px;
    border: 1.5px solid var(--cc-accent);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}

.cc-btn:active {
    transform: translateY(1px);
}

.cc-btn:focus-visible {
    outline: 3px solid var(--red-coral, #FF6B6B);
    outline-offset: 2px;
}

/* Aceitar e Rejeitar são deliberadamente IDÊNTICOS. Ver cabeçalho do ficheiro. */
.cc-btn--accept,
.cc-btn--reject {
    background: var(--cc-accent);
    color: #fff;
}

.cc-btn--accept:hover,
.cc-btn--reject:hover {
    background: #0f2320;
    border-color: #0f2320;
}

.cc-btn--settings {
    background: transparent;
    color: var(--cc-ink);
}

.cc-btn--settings:hover {
    background: rgba(25, 53, 50, 0.06);
}

@media (max-width: 860px) {
    .cc-banner__inner {
        grid-template-columns: minmax(0, 1fr);
    }

    .cc-actions {
        grid-auto-flow: row;
    }

    .cc-btn {
        width: 100%;
    }
}

/* ============================================================================
   MODAL DE PREFERÊNCIAS
   ============================================================================ */

.cc-modal {
    position: fixed;
    inset: 0;
    z-index: var(--cc-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 3vw, 32px);
    background: rgba(16, 33, 31, 0.55);
}

.cc-modal[hidden] {
    display: none;
}

.cc-modal__panel {
    background: var(--cc-surface);
    border-radius: var(--cc-radius);
    width: min(680px, 100%);
    max-height: min(86vh, 780px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(16, 33, 31, 0.32);
}

.cc-modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px clamp(18px, 3vw, 26px) 14px;
    border-bottom: 1px solid var(--cc-line);
}

.cc-modal__title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.cc-modal__close {
    appearance: none;
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: 1.6rem;
    line-height: 1;
    padding: 4px 10px;
    cursor: pointer;
    color: var(--cc-muted);
}

.cc-modal__close:hover {
    background: rgba(25, 53, 50, 0.07);
    color: var(--cc-ink);
}

.cc-modal__close:focus-visible {
    outline: 3px solid var(--red-coral, #FF6B6B);
    outline-offset: 2px;
}

.cc-modal__body {
    padding: 6px clamp(18px, 3vw, 26px) 18px;
    overflow-y: auto;
    flex: 1;
}

.cc-modal__foot {
    padding: 16px clamp(18px, 3vw, 26px) 20px;
    border-top: 1px solid var(--cc-line);
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 10px;
}

@media (max-width: 620px) {
    .cc-modal__foot {
        grid-auto-flow: row;
    }
}

/* ============================================================================
   CATEGORIAS
   ============================================================================ */

.cc-category {
    border: 1px solid var(--cc-line);
    border-radius: 12px;
    padding: 16px 18px;
    margin-top: 14px;
}

.cc-category__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.cc-category__name {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.cc-category__desc {
    margin: 8px 0 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--cc-muted);
}

.cc-category__notice {
    margin: 10px 0 0;
    padding: 9px 12px;
    border-radius: 8px;
    background: rgba(214, 69, 69, 0.08);
    border: 1px solid rgba(214, 69, 69, 0.22);
    font-size: 0.83rem;
    line-height: 1.5;
    color: var(--red-deep, #C62828);
}

.cc-category__always {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--cc-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ── Toggle ──────────────────────────────────────────────────────────────── */

.cc-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex: 0 0 auto;
}

.cc-switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.cc-switch__track {
    position: absolute;
    inset: 0;
    background: #c8d1d0;
    border-radius: 999px;
    transition: background-color 0.18s ease;
    pointer-events: none;
}

.cc-switch__track::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.18s ease;
}

.cc-switch input:checked + .cc-switch__track {
    background: var(--cc-accent);
}

.cc-switch input:checked + .cc-switch__track::before {
    transform: translateX(22px);
}

.cc-switch input:focus-visible + .cc-switch__track {
    outline: 3px solid var(--red-coral, #FF6B6B);
    outline-offset: 2px;
}

.cc-switch input:disabled + .cc-switch__track {
    background: var(--cc-accent);
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Detalhe dos cookies declarados ──────────────────────────────────────── */

.cc-details {
    margin-top: 12px;
}

.cc-details > summary {
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--cc-ink);
    padding: 4px 0;
}

.cc-details > summary:focus-visible {
    outline: 3px solid var(--red-coral, #FF6B6B);
    outline-offset: 2px;
}

.cc-table-wrap {
    overflow-x: auto;
    margin-top: 10px;
}

.cc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    min-width: 460px;
}

.cc-table th,
.cc-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--cc-line);
    vertical-align: top;
}

.cc-table th {
    font-weight: 700;
    color: var(--cc-muted);
    white-space: nowrap;
}

.cc-table code {
    font-size: 0.8rem;
    background: rgba(25, 53, 50, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
}

/* ============================================================================
   BOTÃO PERSISTENTE NO RODAPÉ

   Obrigatório: retirar o consentimento tem de ser tão fácil como dá-lo (Art. 7(3)).
   Se este botão desaparecer do rodapé, o sistema deixa de ser conforme.
   ============================================================================ */

.cc-manage-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-decoration: none;
}

.cc-manage-link:hover {
    text-decoration: underline;
}

.cc-manage-link:focus-visible {
    outline: 3px solid var(--red-coral, #FF6B6B);
    outline-offset: 3px;
}

/* Impede scroll do fundo enquanto o modal está aberto. */
.cc-lock {
    overflow: hidden;
}
