/*
 * 805 LifeGuard — Cookie Consent Banner & Preferences Modal
 * Self-hosted CCPA/CPRA-compliant consent UI
 * Version: 1.0.0
 *
 * Uses the existing luxury-theme design tokens (CSS custom properties).
 * Falls back to literal values so the banner still renders correctly
 * if loaded before luxury-theme.css.
 */

/* ============================================================
   ROOT TOKENS (scoped fallbacks)
   ============================================================ */
.cc-root {
    --cc-black: var(--color-primary-darkest, #1A1A1A);
    --cc-dark: var(--color-primary-dark, #2F2F2F);
    --cc-gold: var(--color-secondary, #B8A082);
    --cc-gold-light: var(--color-secondary-light, #D4C4A8);
    --cc-gold-dark: var(--color-secondary-dark, #A0876C);
    --cc-white: #FFFFFF;
    --cc-text: #1A1A1A;
    --cc-text-muted: #666666;
    --cc-border: #E8E8E8;
    --cc-bg-modal: #FFFFFF;
    --cc-shadow: 0 -2px 24px rgba(0, 0, 0, 0.15);
    --cc-shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.35);
    --cc-font-serif: var(--font-family-serif, 'Playfair Display', Georgia, serif);
    --cc-font-sans: var(--font-family-sans, 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
    --cc-z-banner: 9998;
    --cc-z-modal: 9999;
    --cc-z-toast: 10000;
}

/* Reset within the consent UI so site CSS can't bleed in weird ways */
.cc-root *,
.cc-root *::before,
.cc-root *::after {
    box-sizing: border-box;
}

/* ============================================================
   BANNER (bottom of viewport)
   ============================================================ */
.cc-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--cc-z-banner);
    background: var(--cc-white);
    color: var(--cc-text);
    box-shadow: var(--cc-shadow);
    border-top: 3px solid var(--cc-gold);
    font-family: var(--cc-font-sans);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.cc-banner.cc-visible {
    transform: translateY(0);
}

.cc-banner-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1.75rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.cc-banner-content {
    flex: 1 1 480px;
    min-width: 0;
}

.cc-banner-title {
    font-family: var(--cc-font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--cc-black);
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.cc-banner-text {
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--cc-text-muted);
    margin: 0;
}

.cc-banner-text a {
    color: var(--cc-black);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
    transition: color 0.2s ease;
}

.cc-banner-text a:hover,
.cc-banner-text a:focus-visible {
    color: var(--cc-gold-dark);
}

/* Button group */
.cc-banner-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* ============================================================
   BUTTONS (shared between banner & modal)
   ============================================================ */
.cc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-family: var(--cc-font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    line-height: 1.2;
    border: 2px solid transparent;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
    min-height: 44px;  /* touch target */
}

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

.cc-btn-primary {
    background: var(--cc-black);
    color: var(--cc-white);
    border-color: var(--cc-black);
}

.cc-btn-primary:hover {
    background: var(--cc-gold-dark);
    border-color: var(--cc-gold-dark);
}

.cc-btn-secondary {
    background: transparent;
    color: var(--cc-black);
    border-color: var(--cc-black);
}

.cc-btn-secondary:hover {
    background: var(--cc-black);
    color: var(--cc-white);
}

.cc-btn-link {
    background: transparent;
    color: var(--cc-text-muted);
    border-color: transparent;
    padding: 0.75rem 0.5rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    min-height: auto;
}

.cc-btn-link:hover {
    color: var(--cc-black);
}

/* ============================================================
   MODAL (preferences)
   ============================================================ */
.cc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: var(--cc-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cc-modal-overlay.cc-visible {
    opacity: 1;
    visibility: visible;
}

.cc-modal {
    background: var(--cc-bg-modal);
    color: var(--cc-text);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    border-radius: 4px;
    box-shadow: var(--cc-shadow-modal);
    display: flex;
    flex-direction: column;
    font-family: var(--cc-font-sans);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.cc-modal-overlay.cc-visible .cc-modal {
    transform: translateY(0);
}

.cc-modal-header {
    padding: 1.75rem 2rem 1rem 2rem;
    border-bottom: 1px solid var(--cc-border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
}

.cc-modal-title {
    font-family: var(--cc-font-serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--cc-black);
    margin: 0;
    line-height: 1.3;
}

.cc-modal-close {
    background: transparent;
    border: none;
    color: var(--cc-text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 2px;
    font-size: 1.5rem;
    line-height: 1;
    transition: color 0.2s ease, background 0.2s ease;
}

.cc-modal-close:hover {
    color: var(--cc-black);
    background: var(--cc-border);
}

.cc-modal-close:focus-visible {
    outline: 2px solid var(--cc-gold);
    outline-offset: 2px;
}

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

.cc-modal-intro {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--cc-text-muted);
    margin: 0 0 1.5rem 0;
}

.cc-modal-intro a {
    color: var(--cc-black);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
}

.cc-modal-footer {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--cc-border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* ============================================================
   CATEGORY ROWS WITH TOGGLES
   ============================================================ */
.cc-category {
    border: 1px solid var(--cc-border);
    border-radius: 3px;
    padding: 1.125rem 1.25rem;
    margin-bottom: 0.875rem;
    background: #FAFAFA;
}

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

.cc-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.cc-category-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--cc-black);
    margin: 0;
    line-height: 1.3;
}

.cc-category-desc {
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--cc-text-muted);
    margin: 0.5rem 0 0 0;
}

/* Toggle switch */
.cc-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.cc-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.cc-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #CCC;
    transition: background 0.25s ease;
    border-radius: 24px;
}

.cc-toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: var(--cc-white);
    transition: transform 0.25s ease;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.cc-toggle input:checked + .cc-toggle-slider {
    background: var(--cc-black);
}

.cc-toggle input:checked + .cc-toggle-slider::before {
    transform: translateX(20px);
}

.cc-toggle input:focus-visible + .cc-toggle-slider {
    outline: 2px solid var(--cc-gold);
    outline-offset: 2px;
}

.cc-toggle input:disabled + .cc-toggle-slider {
    background: var(--cc-gold);
    cursor: not-allowed;
    opacity: 0.7;
}

.cc-toggle-locked-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cc-gold-dark);
    font-weight: 600;
    margin-left: 0.5rem;
}

/* ============================================================
   TOAST (DNS confirmation)
   ============================================================ */
.cc-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--cc-black);
    color: var(--cc-white);
    padding: 1rem 1.5rem;
    border-radius: 3px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-left: 3px solid var(--cc-gold);
    font-family: var(--cc-font-sans);
    font-size: 0.9375rem;
    line-height: 1.4;
    z-index: var(--cc-z-toast);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 90vw;
    text-align: center;
}

.cc-toast.cc-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   FOOTER LINKS (the trigger buttons we add to the legal-links block)
   Mirror the existing .legal-links a styling EXACTLY so the two new
   buttons are visually indistinguishable from the <a> tags around them.
   ============================================================ */
.legal-links .cc-footer-trigger {
    /* button reset */
    background: none;
    border: none;
    margin: 0;
    cursor: pointer;
    font-family: inherit;
    line-height: inherit;
    text-align: left;
    /* Match .legal-links a from luxury-theme.css (with hardcoded fallbacks) */
    color: var(--color-text-inverse, #FFFFFF);
    text-decoration: none;
    font-size: var(--font-size-sm, 0.875rem);
    transition: var(--transition-fast, 200ms cubic-bezier(0.4, 0, 0.2, 1));
    padding: var(--spacing-1, 0.25rem) var(--spacing-2, 0.5rem);
    border-radius: var(--radius-base, 0.25rem);
}

.legal-links .cc-footer-trigger:hover {
    color: var(--color-secondary-light, #D4C4A8);
    background: rgba(255, 255, 255, 0.1);
}

.legal-links .cc-footer-trigger:focus-visible {
    outline: 2px solid var(--color-secondary, #B8A082);
    outline-offset: 2px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .cc-banner-inner {
        padding: 1.25rem 1.25rem;
        gap: 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    .cc-banner-content {
        flex: 1 1 auto;
    }

    .cc-banner-actions {
        width: 100%;
        flex-direction: column;
    }

    .cc-btn {
        width: 100%;
    }

    .cc-banner-title {
        font-size: 1.125rem;
    }

    .cc-banner-text {
        font-size: 0.875rem;
    }

    .cc-modal-header,
    .cc-modal-body,
    .cc-modal-footer {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .cc-modal-title {
        font-size: 1.25rem;
    }

    .cc-modal-footer {
        flex-direction: column-reverse;
    }

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

@media (max-width: 480px) {
    .cc-banner-inner {
        padding: 1rem;
    }
}

/* ============================================================
   ACCESSIBILITY — reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .cc-banner,
    .cc-modal-overlay,
    .cc-modal,
    .cc-toast,
    .cc-toggle-slider,
    .cc-toggle-slider::before {
        transition: none !important;
    }
}

/* ============================================================
   PRINT — hide consent UI
   ============================================================ */
@media print {
    .cc-banner,
    .cc-modal-overlay,
    .cc-toast {
        display: none !important;
    }
}
