/**
 * Consent Hub frontend styles.
 *
 * Scoped under .ch- prefixes and using custom properties so a site can restyle
 * the dialog without patching this file. Deliberately low-specificity.
 */

:root {
    --ch-accent: #0b6b5e;
    --ch-accent-contrast: #ffffff;
    --ch-bg: #ffffff;
    --ch-text: #1e2329;
    --ch-muted: #5b6672;
    --ch-border: #dfe4ea;
    --ch-radius: 10px;
    --ch-max-width: 460px;
    --ch-shadow: 0 12px 40px rgba(16, 24, 40, .18);
}

/* Die Browserregel fuer [hidden] ist display:none aus dem UA-Stylesheet und
   verliert damit gegen jede Themeregel, die etwa `section { display: block }`
   setzt -- dann stuenden Einstiegs- und Detailansicht gleichzeitig im Dialog.
   Deshalb hier eine eigene Regel mit hoeherer Spezifitaet. */
.ch-dialog[hidden],
.ch-reopen[hidden],
.ch-dialog .ch-view[hidden],
.ch-dialog [hidden] { display: none; }

.ch-dialog { position: fixed; inset: 0; z-index: 999999; }

.ch-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 40, .45);
}

.ch-panel {
    position: absolute;
    background: var(--ch-bg);
    color: var(--ch-text);
    border-radius: var(--ch-radius);
    box-shadow: var(--ch-shadow);
    width: min(var(--ch-max-width), calc(100vw - 2rem));
    max-height: min(80vh, 44rem);
    overflow-y: auto;
    padding: 1.5rem;
    font-size: .9375rem;
    line-height: 1.55;
}

.ch-dialog--bottom-right .ch-panel { right: 1rem; bottom: 1rem; }
.ch-dialog--bottom-left  .ch-panel { left: 1rem;  bottom: 1rem; }
.ch-dialog--top-right    .ch-panel { right: 1rem; top: 1rem; }
.ch-dialog--top-left     .ch-panel { left: 1rem;  top: 1rem; }

.ch-dialog--top-center    .ch-panel { left: 50%; top: 1rem;    transform: translateX(-50%); }
.ch-dialog--bottom-center .ch-panel { left: 50%; bottom: 1rem; transform: translateX(-50%); }
.ch-dialog--center        .ch-panel { left: 50%; top: 50%;     transform: translate(-50%, -50%); }

.ch-dialog--bar .ch-panel {
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: none;
    border-radius: 0;
}

/* Quiet inline trigger: reads as body text, behaves as a link. */
.ch-inline-trigger {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: .15em;
    cursor: pointer;
}

.ch-inline-trigger:hover,
.ch-inline-trigger:focus-visible { text-decoration-thickness: 2px; }

/*
 * The footer trigger has to look like the links beside it. Size, weight and
 * underline come from the theme untouched; only two things are set here.
 *
 * Border: themes commonly decorate placeholder anchors -- Divi draws a dotted
 * underline on every `a[href="#"]` -- and the trigger carries that href because
 * it is a script trigger, not a destination.
 *
 * Colour: footer links often carry their colour inline, per element, which the
 * trigger cannot match. Left alone it falls back to the theme's link colour --
 * on one site green on green, unreadable. Inheriting takes the colour of the
 * surrounding text, which is what the neighbouring links were given too.
 */
.consent-hub-reopen a {
    border: 0;
    color: inherit;
}

/* Logo sits above the first view, so it stays put when switching views. */
.ch-logo {
    display: block;
    width: auto;
    max-width: min(70%, 220px);
    height: auto;
    margin: 0 0 1rem;
    object-fit: contain;
}

.ch-dialog--center .ch-logo,
.ch-dialog--top-center .ch-logo,
.ch-dialog--bottom-center .ch-logo { margin-inline: auto; }

.ch-headline { margin: 0 0 .5rem; font-size: 1.125rem; font-weight: 600; }
.ch-description { margin: 0 0 1rem; color: var(--ch-muted); }

.ch-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }

.ch-btn {
    flex: 1 1 auto;
    min-height: 2.75rem; /* touch target */
    padding: .625rem 1rem;
    border: 1px solid transparent;
    border-radius: calc(var(--ch-radius) - 4px);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.ch-btn--primary   { background: var(--ch-accent); color: var(--ch-accent-contrast); }
.ch-btn--secondary { background: transparent; color: var(--ch-text); border-color: var(--ch-text); }
.ch-btn--ghost     { background: transparent; color: var(--ch-muted); border-color: transparent; text-decoration: underline; }

/* Annehmen und Ablehnen teilen sich eine Zeile zu gleichen Teilen. Laege das
   Annehmen allein auf voller Breite, waere es auch bei gleicher Knopfform die
   auffaelligere Wahl -- und die Einwilligung damit nicht mehr freiwillig.
   Der Weg in die Einstellungen bekommt eine eigene Zeile: er ist eine dritte
   Handlung, nicht das Gegenstueck zur Zustimmung. */
.ch-btn--ghost { flex: 1 0 100%; }

.ch-btn--primary,
.ch-btn--secondary { flex: 1 1 0; min-width: 12rem; }

.ch-btn:focus-visible,
.ch-link:focus-visible,
.ch-reopen:focus-visible { outline: 2px solid var(--ch-accent); outline-offset: 2px; }

.ch-link {
    background: none; border: 0; padding: 0;
    color: var(--ch-muted); font: inherit; text-decoration: underline; cursor: pointer;
}

.ch-legal { margin: .75rem 0 0; font-size: .8125rem; color: var(--ch-muted); }
.ch-legal a { color: inherit; }

.ch-group { padding: .75rem 0; border-top: 1px solid var(--ch-border); }
.ch-group:first-child { border-top: 0; }
.ch-group__header { display: flex; align-items: center; }
.ch-group__name { font-weight: 600; }
.ch-group__description { margin: .375rem 0 0; font-size: .8125rem; color: var(--ch-muted); }
.ch-group__services { margin-top: .5rem; font-size: .8125rem; }
.ch-group__services summary { cursor: pointer; color: var(--ch-muted); }

.ch-switch { display: flex; align-items: center; gap: .625rem; cursor: pointer; }
.ch-switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.ch-switch__track {
    flex: 0 0 auto;
    width: 2.5rem; height: 1.375rem;
    border-radius: 1rem;
    background: var(--ch-border);
    position: relative;
    transition: background .15s ease;
}

.ch-switch__track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 1.125rem; height: 1.125rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .15s ease;
}

.ch-switch input:checked + .ch-switch__track { background: var(--ch-accent); }
.ch-switch input:checked + .ch-switch__track::after { transform: translateX(1.125rem); }
.ch-switch input:disabled + .ch-switch__track { opacity: .55; }

.ch-service { padding: .5rem 0; border-top: 1px dashed var(--ch-border); }
.ch-service__name { margin: 0; font-weight: 600; }
.ch-service__purpose { margin: .125rem 0 0; color: var(--ch-muted); }
.ch-service__cookies { width: 100%; margin-top: .375rem; border-collapse: collapse; font-size: .75rem; }
.ch-service__cookies th { text-align: left; font-weight: 500; padding: .125rem .5rem .125rem 0; }
.ch-service__cookies td { color: var(--ch-muted); }

.ch-reopen {
    position: fixed;
    bottom: 1rem;
    z-index: 999998;
    min-height: 2.5rem;
    padding: .5rem .875rem;
    background: var(--ch-bg);
    color: var(--ch-text);
    border: 1px solid var(--ch-border);
    border-radius: 2rem;
    box-shadow: 0 4px 16px rgba(16, 24, 40, .14);
    font: inherit;
    font-size: .8125rem;
    cursor: pointer;
}

.ch-reopen--left  { left: 1rem; }
.ch-reopen--right { right: 1rem; }

/* Placeholder shown where a gated embed would be. */
.ch-blocked {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 12rem;
    padding: 1.5rem;
    background: #f4f6f8;
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
    text-align: center;
}

.ch-blocked--inline {
    min-height: 0;
    padding: 1rem;
    text-align: left;
    justify-content: flex-start;
}

.ch-blocked--inline .ch-blocked__headline { font-size: .9375rem; margin-bottom: .5rem; }
.ch-blocked--inline .ch-blocked__inner { max-width: none; }
.ch-blocked--inline .ch-blocked__text { font-size: .8125rem; margin-bottom: .625rem; }
.ch-blocked--inline .ch-blocked__button { min-height: 2.25rem; padding: .4rem .875rem; font-size: .875rem; }

.ch-blocked__inner { max-width: 34rem; }
.ch-blocked__headline { margin: 0 0 .375rem; font-weight: 600; }
.ch-blocked__text { margin: 0 0 .875rem; color: var(--ch-muted); font-size: .875rem; }

.ch-blocked__button {
    min-height: 2.75rem;
    padding: .625rem 1.25rem;
    background: var(--ch-accent);
    color: var(--ch-accent-contrast);
    border: 0;
    border-radius: calc(var(--ch-radius) - 4px);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

html.ch-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .ch-switch__track,
    .ch-switch__track::after { transition: none; }
}

@media (prefers-color-scheme: dark) {
    :root:not(.ch-force-light) {
        --ch-bg: #1a1f26;
        --ch-text: #eef1f5;
        --ch-muted: #a3adba;
        --ch-border: #333c47;
    }

    .ch-blocked { background: #232932; }
}
