/*
 * Cookie consent banner + preferences modal.
 * Colors reuse the theme's existing tokens ($primary #003366, $dark-blue #090F4E,
 * $primary-gray #63657E) and the site's own :focus-visible outline convention
 * (3px solid #003366) rather than Astra's, since this theme does not use Astra.
 */

.d2i-cookie-consent[hidden],
.d2i-cookie-preferences[hidden],
.d2i-cookie-settings-trigger[hidden] {
    display: none;
}

/* Banner (non-modal) */
.d2i-cookie-consent {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99998;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 24px rgba(9, 15, 78, 0.12);
    padding: 20px clamp(16px, 4vw, 32px);
    font-family: 'Poppins', sans-serif;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    /* On short/narrow viewports the content can exceed the screen height;
       cap it and scroll internally instead of letting it clip off the top
       (position: fixed has no other way to reach content taller than the viewport). */
    max-height: 90vh;
    overflow-y: auto;
}

.d2i-cookie-consent.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.d2i-cookie-consent__inner {
    max-width: 1224px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
}

.d2i-cookie-consent__content {
    flex: 1 1 420px;
    min-width: 0;
}

.d2i-cookie-consent__heading {
    font-size: 1.125rem;
    font-weight: 700;
    color: #090F4E;
    margin: 0 0 6px;
}

.d2i-cookie-consent__heading:focus-visible {
    outline: 2px solid #003366;
    outline-offset: 4px;
    border-radius: 2px;
}

.d2i-cookie-consent__text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #374151;
    margin: 0;
}

.d2i-cookie-consent__text a {
    color: #1e3adb;
    text-decoration: underline;
}

.d2i-cookie-consent__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex: 0 0 auto;
}

/* Buttons shared by banner + preferences modal */
.d2i-btn {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    line-height: 1.3;
    white-space: nowrap;
    background: none;
}

.d2i-btn:focus-visible {
    outline: 2px solid #003366;
    outline-offset: 2px;
}

.d2i-btn--primary {
    background: #003366 !important;
    color: #ffffff;
    border-color: #003366;
}

.d2i-btn--primary:hover {
    background: #1d4ed8 !important;
    border-color: #1d4ed8;
}

.d2i-btn--outline {
    background: #ffffff;
    color: #003366;
    border-color: #003366;
}

.d2i-btn--outline:hover {
    background: #E7EEFF;
}

.d2i-btn--secondary {
    background: transparent;
    color: #003366;
    border-color: transparent;
    text-decoration: underline;
}

.d2i-btn--secondary:hover {
    color: #002347;
}

/* "Cookie Settings" re-open control, rendered inline in the footer's Quick Links list */
.d2i-cookie-footer-trigger {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
    text-align: left;
    color: #003366;
}

.d2i-cookie-footer-trigger:focus-visible {
    outline: 2px solid #003366;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Preferences panel (true modal) */
.d2i-cookie-preferences {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.d2i-cookie-preferences__overlay {
    position: absolute;
    inset: 0;
    background: rgba(9, 15, 78, 0.55);
}

.d2i-cookie-preferences__dialog {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    font-family: 'Poppins', sans-serif;
}

.d2i-cookie-preferences__close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    border: 2px solid transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: #374151;
    cursor: pointer;
    padding: 2px 10px;
    border-radius: 6px;
}

.d2i-cookie-preferences__close:hover {
    background: #f3f7ff;
}

.d2i-cookie-preferences__close:focus-visible {
    outline: 2px solid #003366;
    outline-offset: 2px;
}

.d2i-cookie-preferences__heading {
    font-size: 1.375rem;
    font-weight: 700;
    color: #090F4E;
    margin: 0 0 8px;
    padding-right: 32px;
}

.d2i-cookie-preferences__intro {
    font-size: 0.95rem;
    color: #374151;
    line-height: 1.6;
    margin: 0 0 20px;
}

.d2i-cookie-preferences__list {
    list-style: none;
    margin: 0 0 24px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.d2i-cookie-toggle {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 16px;
}

.d2i-cookie-toggle:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.d2i-switch-label {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
}

.d2i-switch-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.d2i-switch-title {
    font-weight: 600;
    color: #090F4E;
    font-size: 0.95rem;
}

.d2i-switch-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: #0a58ca;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 4px;
}

.d2i-switch-desc {
    display: block;
    font-size: 0.85rem;
    color: #63657E;
    line-height: 1.5;
}

/* Visually hidden but still focusable/operable checkbox driving the switch */
.d2i-switch-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.d2i-switch-track {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 24px;
    margin-top: 1px;
    border-radius: 12px;
    background: #63657E;
    border: 2px solid #63657E;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.d2i-switch-thumb {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    transition: transform 0.2s ease;
}

.d2i-switch-input:checked + .d2i-switch-label .d2i-switch-track {
    background: #003366;
    border-color: #003366;
}

.d2i-switch-input:checked + .d2i-switch-label .d2i-switch-thumb {
    transform: translateX(20px);
}

.d2i-switch-input:disabled + .d2i-switch-label {
    cursor: default;
}

.d2i-switch-input:disabled + .d2i-switch-label .d2i-switch-track {
    opacity: 0.9;
}

.d2i-switch-input:focus-visible + .d2i-switch-label .d2i-switch-track {
    outline: 2px solid #003366;
    outline-offset: 2px;
}

.d2i-cookie-preferences__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .d2i-cookie-consent__inner {
        flex-direction: column;
        align-items: stretch;
    }

    .d2i-cookie-consent__content {
        flex: 1 1 auto;
        min-width: 0;
    }

    .d2i-cookie-consent__actions {
        justify-content: stretch;
    }

    .d2i-cookie-consent__actions .d2i-btn {
        flex: 1 1 auto;
    }

    .d2i-cookie-preferences__actions .d2i-btn {
        flex: 1 1 auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .d2i-cookie-consent {
        transition: none;
    }
}
