/*
 * LMT Merch – cookie consent banner and settings dialog.
 * Follows the site design tokens: #000100 text, #e4e4e2 borders, 6px radius,
 * 48px buttons, primary #C8102E, secondary outlined black, grey focus outline.
 */

.lmt-cc {
    --lmt-cc-text: #000100;
    --lmt-cc-body: #3a3a3a;
    --lmt-cc-muted: #75787b; /* theme --color-muted (design grey) */
    --lmt-cc-label: #53565a;
    --lmt-cc-border: #e4e4e2;
    --lmt-cc-border-strong: #c8c9c7;
    --lmt-cc-surface: #f5f5f5;
    --lmt-cc-primary: #c8102e;
    --lmt-cc-primary-hover: #a70a25;
    --lmt-cc-primary-active: #930d22;
    --lmt-cc-focus: #8a8a8a;
    --lmt-cc-radius: 6px;
    --lmt-cc-z: 1000;

    /* The wrapper only holds fixed/hidden children; it must not add a box to the page layout */
    display: contents;
    font-family: 'Geometria Narrow', 'Poppins', sans-serif;
    color: var(--lmt-cc-text);
    -webkit-font-smoothing: antialiased;
}

.lmt-cc *,
.lmt-cc *::before,
.lmt-cc *::after {
    box-sizing: border-box;
}

.lmt-cc [hidden],
.lmt-cc-banner[hidden],
.lmt-cc-modal[hidden] {
    display: none !important;
}

.lmt-cc-sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Keep page content reachable above the fixed banner */
html.lmt-cc-banner-open body {
    padding-bottom: var(--lmt-cc-banner-h, 0px);
}

html.lmt-cc-lock,
html.lmt-cc-lock body {
    overflow: hidden;
}

/* Links */

.lmt-cc-link {
    color: var(--lmt-cc-text);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
}

.lmt-cc-link:hover {
    color: var(--lmt-cc-primary);
}

.lmt-cc-link:focus-visible {
    outline: 3px solid var(--lmt-cc-focus);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Buttons */

.lmt-cc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 28px;
    margin: 0;
    border: 1px solid transparent;
    border-radius: var(--lmt-cc-radius);
    font: inherit;
    font-size: 17px;
    font-weight: 400;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.lmt-cc-btn:focus {
    outline: none;
}

.lmt-cc-btn:focus-visible {
    outline: 4px solid var(--lmt-cc-focus);
    outline-offset: 2px;
}

.lmt-cc-btn--primary {
    background: var(--lmt-cc-primary);
    border-color: var(--lmt-cc-primary);
    color: #fff;
}

.lmt-cc-btn--primary:hover,
.lmt-cc-btn--primary:focus-visible {
    background: var(--lmt-cc-primary-hover);
    border-color: var(--lmt-cc-primary-hover);
}

.lmt-cc-btn--primary:active {
    background: var(--lmt-cc-primary-active);
    border-color: var(--lmt-cc-primary-active);
}

.lmt-cc-btn--secondary {
    background: #fff;
    border-color: var(--lmt-cc-text);
    color: var(--lmt-cc-text);
}

.lmt-cc-btn--secondary:hover {
    background: var(--lmt-cc-text);
    color: #fff;
}

.lmt-cc-btn--secondary:active {
    background: #2a2b2a;
    color: #fff;
}

/* Banner */

.lmt-cc-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--lmt-cc-z);
    background: #fff;
    border-top: 1px solid var(--lmt-cc-border);
    box-shadow: 0 -12px 32px rgba(0, 1, 0, 0.08);
    animation: lmt-cc-slide-up 0.28s ease-out;
}

.lmt-cc-banner__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    max-width: 1360px;
    margin: 0 auto;
    padding: 24px 40px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.lmt-cc-banner__body {
    min-width: 0;
    max-width: 760px;
}

.lmt-cc-banner__title {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.2px;
    color: var(--lmt-cc-text);
}

.lmt-cc-banner__text {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--lmt-cc-body);
    text-wrap: pretty;
}

.lmt-cc-banner__actions {
    display: grid;
    grid-template-columns: repeat(3, auto);
    gap: 12px;
    flex: none;
}

/* Dialog */

.lmt-cc-modal {
    position: fixed;
    inset: 0;
    z-index: calc(var(--lmt-cc-z) + 10);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.lmt-cc-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 1, 0, 0.45);
    animation: lmt-cc-fade-in 0.2s ease-out;
}

.lmt-cc-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 640px;
    max-height: min(88vh, 820px);
    background: #fff;
    border: 1px solid var(--lmt-cc-border);
    border-radius: var(--lmt-cc-radius);
    box-shadow: 0 24px 64px rgba(0, 1, 0, 0.18);
    overflow: hidden;
    animation: lmt-cc-pop-in 0.22s ease-out;
}

.lmt-cc-dialog:focus {
    outline: none;
}

.lmt-cc-dialog:focus-visible {
    outline: 3px solid var(--lmt-cc-focus);
    outline-offset: 2px;
}

.lmt-cc-dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--lmt-cc-border);
}

.lmt-cc-dialog__title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.3px;
    color: var(--lmt-cc-text);
}

.lmt-cc-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 48px;
    height: 48px;
    margin: -8px -12px -8px 0;
    padding: 0;
    border: 0;
    border-radius: var(--lmt-cc-radius);
    background: transparent;
    color: var(--lmt-cc-label);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.lmt-cc-close:hover {
    background: var(--lmt-cc-surface);
    color: var(--lmt-cc-text);
}

.lmt-cc-close:focus {
    outline: none;
}

.lmt-cc-close:focus-visible {
    outline: 3px solid var(--lmt-cc-focus);
    outline-offset: 0;
}

.lmt-cc-dialog__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px 24px 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.lmt-cc-dialog__text {
    margin: 0 0 16px;
    font-size: 15px;
    line-height: 1.55;
    color: var(--lmt-cc-body);
}

.lmt-cc-dialog__footer {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 16px 24px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--lmt-cc-border);
    background: #fff;
}

.lmt-cc-dialog__footer .lmt-cc-btn {
    padding: 0 16px;
}

/* Categories */

.lmt-cc-categories {
    margin: 0;
    padding: 0;
    list-style: none;
}

.lmt-cc-category {
    padding: 18px 0;
    border-top: 1px solid var(--lmt-cc-border);
}

.lmt-cc-category:first-child {
    border-top: 0;
    padding-top: 4px;
}

.lmt-cc-category__head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lmt-cc-category__name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--lmt-cc-text);
    cursor: pointer;
}

.lmt-cc-category__always {
    flex: none;
    font-size: 14px;
    color: var(--lmt-cc-muted);
}

.lmt-cc-category__description {
    margin: 8px 0 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--lmt-cc-body);
}

/* Switch (native checkbox with role="switch") */

.lmt-cc-switch {
    position: relative;
    display: inline-flex;
    flex: none;
    width: 48px;
    height: 28px;
}

.lmt-cc-switch__input {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.lmt-cc-switch__input:disabled {
    cursor: not-allowed;
}

.lmt-cc-switch__track {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 14px;
    background: var(--lmt-cc-border-strong);
    transition: background-color 0.18s ease;
}

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

.lmt-cc-switch__input:checked + .lmt-cc-switch__track {
    background: var(--lmt-cc-primary);
}

.lmt-cc-switch__input:checked + .lmt-cc-switch__track .lmt-cc-switch__thumb {
    transform: translateX(20px);
}

.lmt-cc-switch__input:disabled + .lmt-cc-switch__track {
    background: var(--lmt-cc-muted);
}

.lmt-cc-switch__input:not(:disabled):hover + .lmt-cc-switch__track {
    box-shadow: 0 0 0 4px var(--lmt-cc-surface);
}

.lmt-cc-switch__input:focus-visible + .lmt-cc-switch__track {
    outline: 3px solid var(--lmt-cc-focus);
    outline-offset: 2px;
}

/* Cookie details */

.lmt-cc-details {
    margin-top: 10px;
}

.lmt-cc-details__summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    font-size: 15px;
    color: var(--lmt-cc-text);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    list-style: none;
    border-radius: 2px;
}

.lmt-cc-details__summary::-webkit-details-marker {
    display: none;
}

.lmt-cc-details__summary:hover {
    color: var(--lmt-cc-primary);
}

.lmt-cc-details__summary:focus {
    outline: none;
}

.lmt-cc-details__summary:focus-visible {
    outline: 3px solid var(--lmt-cc-focus);
    outline-offset: 2px;
}

.lmt-cc-details__icon {
    flex: none;
    transition: transform 0.18s ease;
}

.lmt-cc-details[open] .lmt-cc-details__icon {
    transform: rotate(180deg);
}

.lmt-cc-cookies {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.lmt-cc-cookie {
    padding: 12px 14px;
    margin-top: 8px;
    background: var(--lmt-cc-surface);
    border: 1px solid var(--lmt-cc-border);
    border-radius: var(--lmt-cc-radius);
}

.lmt-cc-cookie:first-child {
    margin-top: 0;
}

.lmt-cc-cookie__name {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    word-break: break-all;
}

.lmt-cc-cookie__name code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
}

.lmt-cc-cookie__meta {
    margin: 0;
}

.lmt-cc-cookie__row {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 8px;
    padding: 3px 0;
    font-size: 14px;
    line-height: 1.5;
}

.lmt-cc-cookie__row dt {
    color: var(--lmt-cc-muted);
}

.lmt-cc-cookie__row dd {
    margin: 0;
    color: var(--lmt-cc-text);
}

.lmt-cc-cookies__empty {
    margin: 8px 0 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--lmt-cc-muted);
}

/* Tablet: stack banner text above the buttons */

@media (max-width: 1024px) {
    .lmt-cc-banner__inner {
        flex-direction: column;
        align-items: stretch;
        gap: 18px;
    }

    .lmt-cc-banner__body {
        max-width: none;
    }

    .lmt-cc-banner__actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Mobile: bottom sheets */

@media (max-width: 640px) {
    .lmt-cc-banner {
        border: 1px solid var(--lmt-cc-border);
        border-bottom: 0;
        border-radius: 14px 14px 0 0;
    }

    .lmt-cc-banner__inner {
        padding: 20px 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        gap: 16px;
    }

    .lmt-cc-banner__title {
        font-size: 18px;
    }

    .lmt-cc-banner__text {
        font-size: 14px;
    }

    .lmt-cc-banner__actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .lmt-cc-btn {
        padding: 0 12px;
        font-size: 16px;
    }

    .lmt-cc-btn--wide {
        grid-column: 1 / -1;
    }

    .lmt-cc-modal {
        align-items: flex-end;
        padding: 0;
    }

    .lmt-cc-dialog {
        max-width: none;
        max-height: 92vh;
        max-height: 92dvh;
        border-bottom: 0;
        border-radius: 14px 14px 0 0;
        animation-name: lmt-cc-slide-up;
    }

    .lmt-cc-dialog__header {
        padding: 16px 16px 12px;
    }

    .lmt-cc-dialog__title {
        font-size: 20px;
    }

    .lmt-cc-close {
        margin-right: -8px;
    }

    .lmt-cc-dialog__body {
        padding: 16px 16px 4px;
    }

    .lmt-cc-dialog__footer {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        gap: 10px;
    }

    .lmt-cc-dialog__footer [data-cc-action="save"] {
        grid-column: 1 / -1;
        order: 3;
    }

    .lmt-cc-cookie__row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }
}

/* Motion */

@keyframes lmt-cc-slide-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes lmt-cc-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes lmt-cc-pop-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Windows high contrast */

@media (forced-colors: active) {
    .lmt-cc-switch__track {
        border: 1px solid CanvasText;
    }

    .lmt-cc-switch__input:checked + .lmt-cc-switch__track {
        background: Highlight;
    }

    .lmt-cc-switch__thumb {
        background: CanvasText;
    }

    .lmt-cc-btn {
        border: 1px solid ButtonText;
    }
}

@media print {
    .lmt-cc {
        display: none !important;
    }

    html.lmt-cc-banner-open body {
        padding-bottom: 0;
    }
}
