/*
 * Cookie consent — storefront styles.
 * Colours, radius and fonts follow the active theme tokens with neutral fallbacks,
 * so the banner works in the default, Aurora and MoonCart themes.
 */

.cc-root,
.cc-preview-stage {
    --cc-primary: var(--color-theme-primary, var(--theme-primary, #18181b));
    --cc-on-primary: var(--color-theme-on-primary, var(--theme-on-primary, #ffffff));
    --cc-surface: var(--color-theme-surface, var(--theme-surface, #ffffff));
    --cc-text: var(--color-theme-text, var(--theme-text, #18181b));
    --cc-muted: var(--color-theme-muted, var(--theme-text-muted, #52525b));
    --cc-border: var(--color-theme-border, var(--theme-border, #d4d4d8));
    --cc-track: var(--color-theme-border, var(--theme-border, #a1a1aa));
    --cc-title-font: var(--font-title, inherit);
    --cc-radius: var(--theme-radius, 0.75rem);
    --cc-shadow: 0 12px 48px rgb(0 0 0 / 0.18);
    --cc-speed: 200ms;
    color: var(--cc-text);
    font: inherit;
    line-height: 1.5;
}

.cc-root *,
.cc-root *::before,
.cc-root *::after,
.cc-preview-stage *,
.cc-preview-stage *::before,
.cc-preview-stage *::after {
    box-sizing: border-box;
}

.cc-root [hidden] {
    display: none !important;
}

/* ---------- Typography ---------- */

.cc-title {
    margin: 0 0 0.5rem;
    font-family: var(--cc-title-font);
    font-size: 1.125rem;
    font-weight: 650;
    line-height: 1.3;
    color: var(--cc-text);
}

.cc-body {
    margin: 0 0 0.5rem;
    font-size: 0.9375rem;
    color: var(--cc-muted);
}

.cc-policy-link,
.cc-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cc-muted {
    color: var(--cc-muted);
    font-size: 0.875rem;
}

.cc-error {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #b91c1c;
}

/* ---------- Banner ---------- */

.cc-banner {
    position: fixed;
    z-index: 2147483100;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100dvh - 2rem);
    overflow: auto;
    padding: 1.25rem 1.5rem;
    background: var(--cc-surface);
    color: var(--cc-text);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
    box-shadow: var(--cc-shadow);
    animation: cc-enter var(--cc-speed) ease-out;
}

.cc-box {
    width: min(30rem, calc(100% - 2rem));
}

.cc-bar {
    left: 1rem;
    right: 1rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.cc-bar .cc-banner-text {
    max-width: 48rem;
}

.cc-bottom-left {
    bottom: 1rem;
    left: 1rem;
}

.cc-bottom-right {
    bottom: 1rem;
    right: 1rem;
}

.cc-top-left {
    top: 1rem;
    left: 1rem;
}

.cc-top-right {
    top: 1rem;
    right: 1rem;
}

.cc-banner-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.cc-bar .cc-banner-actions {
    flex-shrink: 0;
    align-items: center;
}

/* ---------- Buttons ---------- */

.cc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cc-actions .cc-button {
    flex: 1 1 0;
    white-space: nowrap;
}

/* Accept and reject share one style so neither is visually preferred. */
.cc-button {
    min-height: 44px;
    padding: 0.625rem 1.125rem;
    border: 1px solid var(--cc-primary);
    border-radius: calc(var(--cc-radius) * 0.66);
    background: var(--cc-primary);
    color: var(--cc-on-primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--cc-speed) ease;
}

.cc-button:hover {
    opacity: 0.9;
}

.cc-button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.cc-button-secondary {
    background: transparent;
    color: var(--cc-text);
    border-color: var(--cc-border);
}

.cc-link {
    align-self: center;
    min-height: 44px;
    padding: 0.5rem;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.9375rem;
    cursor: pointer;
}

.cc-button:focus-visible,
.cc-link:focus-visible,
.cc-close:focus-visible,
.cc-reopen:focus-visible,
.cc-policy-link:focus-visible,
.cc-cookie-details summary:focus-visible,
.cc-switch-input:focus-visible + .cc-switch-track {
    outline: 3px solid var(--cc-primary);
    outline-offset: 3px;
}

/* ---------- Preferences dialog ---------- */

.cc-dialog {
    width: min(40rem, calc(100% - 2rem));
    max-height: calc(100dvh - 2rem);
    padding: 0;
    overflow: hidden;
    background: var(--cc-surface);
    color: var(--cc-text);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
    box-shadow: var(--cc-shadow);
}

.cc-dialog[open] {
    display: flex;
    flex-direction: column;
    animation: cc-enter var(--cc-speed) ease-out;
}

.cc-dialog::backdrop {
    background: rgb(0 0 0 / 0.55);
}

.cc-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--cc-border);
}

.cc-dialog-header .cc-title {
    margin: 0;
}

.cc-dialog-header .cc-title:focus {
    outline: none;
}

.cc-dialog-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.cc-dialog-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid var(--cc-border);
}

.cc-dialog-footer .cc-policy-link {
    align-self: center;
    font-size: 0.875rem;
}

.cc-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-right: -0.625rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

/* ---------- Categories and toggle switches ---------- */

.cc-category {
    padding: 1rem 0;
    border-bottom: 1px solid var(--cc-border);
}

.cc-category:last-child {
    border-bottom: 0;
}

.cc-category-title {
    font-weight: 600;
    color: var(--cc-text);
}

.cc-category-description {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--cc-muted);
}

.cc-always-on {
    display: block;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--cc-muted);
}

.cc-switch {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 44px;
    cursor: pointer;
}

.cc-switch-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.cc-switch-track {
    position: relative;
    flex-shrink: 0;
    width: 2.75rem;
    height: 1.5rem;
    border-radius: 999px;
    background: var(--cc-track);
    transition: background-color var(--cc-speed) ease;
}

.cc-switch-thumb {
    position: absolute;
    top: 0.1875rem;
    left: 0.1875rem;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
    transition: transform var(--cc-speed) ease;
}

.cc-switch-input:checked + .cc-switch-track {
    background: var(--cc-primary);
}

.cc-switch-input:checked + .cc-switch-track .cc-switch-thumb {
    transform: translateX(1.25rem);
}

.cc-switch-input:disabled + .cc-switch-track {
    opacity: 0.55;
}

.cc-switch:has(.cc-switch-input:disabled) {
    cursor: default;
}

/* ---------- Cookie tables ---------- */

.cc-cookie-details {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.cc-cookie-details summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.25rem 0;
}

.cc-cookie-table-wrapper {
    margin-top: 0.5rem;
    overflow-x: auto;
}

.cc-cookie-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

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

.cc-cookie-table th {
    font-weight: 600;
}

.cc-cookie-table code {
    font-size: 0.8125rem;
    word-break: break-all;
}

.cc-cookie-list-section {
    margin-bottom: 2rem;
}

/* ---------- Reopen button ---------- */

.cc-reopen {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 2147483000;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 36px;
    padding: 0.375rem 0.75rem;
    background: var(--cc-surface);
    color: var(--cc-text);
    border: 1px solid var(--cc-border);
    border-radius: 999px;
    box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

/* ---------- Admin preview ---------- */

.cc-preview-stage {
    position: relative;
    display: flex;
    min-height: 22rem;
    padding: 1rem;
    border-radius: 0.75rem;
    background: repeating-linear-gradient(45deg, #f4f4f5, #f4f4f5 12px, #fafafa 12px, #fafafa 24px);
}

.cc-preview-stage[data-position^="top"] {
    align-items: flex-start;
}

.cc-preview-stage[data-position^="bottom"] {
    align-items: flex-end;
}

.cc-preview-stage[data-position$="right"] {
    justify-content: flex-end;
}

.cc-preview {
    position: static;
    animation: none;
}

.cc-preview.cc-bar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
}

/* ---------- Motion and small screens ---------- */

@keyframes cc-enter {
    from {
        opacity: 0;
        transform: translateY(0.75rem);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cc-root *,
    .cc-root *::before,
    .cc-root *::after,
    .cc-root .cc-banner,
    .cc-root .cc-dialog[open] {
        animation: none !important;
        transition: none !important;
    }
}

@media (max-width: 900px) {
    .cc-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .cc-bar .cc-banner-actions {
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .cc-banner,
    .cc-box {
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
        padding: 1rem;
    }

    .cc-top-left,
    .cc-top-right {
        top: 0.5rem;
    }

    .cc-bottom-left,
    .cc-bottom-right {
        bottom: 0.5rem;
    }

    .cc-dialog {
        width: 100%;
        max-width: none;
        max-height: 100dvh;
        margin: auto 0 0;
        border-radius: var(--cc-radius) var(--cc-radius) 0 0;
    }

    .cc-dialog-header,
    .cc-dialog-body,
    .cc-dialog-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .cc-cookie-table thead {
        display: none;
    }

    .cc-cookie-table tr {
        display: block;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--cc-border);
    }

    .cc-cookie-table td {
        display: grid;
        grid-template-columns: 7rem 1fr;
        gap: 0.5rem;
        padding: 0.25rem 0;
        border: 0;
    }

    .cc-cookie-table td::before {
        content: attr(data-label);
        font-weight: 600;
    }
}
