/* ==========================================================
   CH NET GUARD — Legal & Cookie Banner (Phase 2)
   Loaded after base.css + animations.css; uses existing tokens.
   ========================================================== */

/* ----------------------------------------------------------
   LEGAL PAGES (Privacy / Terms)
   ---------------------------------------------------------- */
.legal-page {
    position: relative;
    padding-top: 120px;        /* clear the fixed nav */
    padding-bottom: 96px;
    overflow: hidden;
}

.legal-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(15,181,164,0.08), transparent 70%),
        radial-gradient(ellipse 40% 30% at 90% 20%, rgba(201,162,39,0.05), transparent 70%);
    pointer-events: none;
}
.legal-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(0deg,  rgba(255,255,255,0.014) 0 1px, transparent 1px 80px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.014) 0 1px, transparent 1px 80px);
    pointer-events: none;
}

.legal-hero {
    position: relative;
    z-index: 1;
    padding-block: 32px 56px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 56px;
}

.legal-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    margin: 0 0 16px;
    opacity: 0.85;
}
.legal-eyebrow .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent-teal);
    box-shadow: 0 0 12px var(--accent-teal);
}
.legal-eyebrow .bar {
    width: 24px; height: 1px;
    background: var(--border-strong);
}

.legal-title {
    font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
    font-size: clamp(2.25rem, 5vw, 3.75rem);
    font-weight: 700;
    line-height: 1.05;
    margin: 0 0 16px;
    color: var(--text-primary);
}

.legal-meta {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

.legal-body {
    position: relative;
    z-index: 1;
    max-width: 900px;
}

/* Table of contents */
.legal-toc {
    background: rgba(8, 10, 18, 0.45);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    padding: 28px 32px;
    margin-bottom: 48px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.legal-toc-title {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    margin: 0 0 16px;
    font-weight: 500;
}
.legal-toc ol {
    columns: 2;
    column-gap: 32px;
    margin: 0;
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 14.5px;
    line-height: 1.9;
}
.legal-toc ol li::marker { color: var(--accent-teal); }
.legal-toc a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--d-base) var(--ease-out);
    border-bottom: 1px solid transparent;
}
.legal-toc a:hover {
    color: var(--accent-teal-2);
    border-bottom-color: var(--accent-teal);
}
@media (max-width: 640px) {
    .legal-toc ol { columns: 1; }
    .legal-toc { padding: 22px 24px; }
}

/* Sections */
.legal-section {
    margin-bottom: 56px;
    scroll-margin-top: 100px;   /* anchored jumps clear the nav */
}
.legal-section h2 {
    font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
    font-size: clamp(1.4rem, 2.5vw, 1.85rem);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-soft);
    position: relative;
}
.legal-section h2::before {
    content: '';
    position: absolute;
    bottom: -1px; left: 0;
    width: 48px; height: 2px;
    background: linear-gradient(90deg, var(--accent-teal), var(--accent-gold));
}
.legal-section h3 {
    font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 28px 0 12px;
}
.legal-section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px;
}
.legal-section p,
.legal-section ul,
.legal-section ol {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.75;
    margin: 0 0 16px;
}
.legal-section ul,
.legal-section ol {
    padding-left: 24px;
}
.legal-section li { margin-bottom: 8px; }
.legal-section li::marker { color: var(--accent-teal); }
.legal-section strong { color: var(--text-primary); font-weight: 600; }
.legal-section a {
    color: var(--accent-teal-2);
    text-decoration: none;
    border-bottom: 1px solid rgba(20, 215, 195, 0.3);
    transition: all var(--d-base) var(--ease-out);
}
.legal-section a:hover {
    color: var(--text-primary);
    border-bottom-color: var(--accent-teal);
}

/* Placeholder marker — visually flagged so lawyers/owners see what to replace */
.legal-placeholder {
    display: inline-block;
    background: rgba(201, 162, 39, 0.12);
    color: var(--accent-gold-2);
    padding: 2px 8px;
    border-radius: var(--r-sm);
    border: 1px dashed rgba(201, 162, 39, 0.45);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 13px;
}

/* Callout boxes */
.legal-callout {
    background: rgba(15, 181, 164, 0.06);
    border-left: 3px solid var(--accent-teal);
    padding: 20px 24px;
    border-radius: 0 var(--r-md) var(--r-md) 0;
    margin: 20px 0;
}
.legal-callout p { margin: 0; color: var(--text-secondary); }
.legal-callout p + p { margin-top: 8px; }
.legal-callout-label {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 11px !important;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-teal-2) !important;
    margin-bottom: 8px !important;
}

/* Table */
.legal-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    margin: 20px 0;
}
.legal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14.5px;
}
.legal-table th,
.legal-table td {
    text-align: left;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-secondary);
}
.legal-table th {
    background: rgba(8, 10, 18, 0.6);
    color: var(--text-primary);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}
.legal-table tr:last-child td { border-bottom: none; }

/* Rights grid */
.legal-rights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin: 20px 0 24px;
}
.legal-right {
    background: rgba(8, 10, 18, 0.45);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 18px 20px;
    transition: all var(--d-base) var(--ease-out);
}
.legal-right:hover {
    border-color: var(--accent-teal);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -8px rgba(15, 181, 164, 0.2);
}
.legal-right h4 {
    color: var(--accent-teal-2);
    margin-bottom: 6px;
    font-size: 14.5px;
}
.legal-right p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text-muted);
}

/* Inline preference-opener button (used inside privacy.php text) */
.legal-inline-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent-teal-2);
    font: inherit;
    cursor: pointer;
    border-bottom: 1px solid rgba(20, 215, 195, 0.3);
    transition: all var(--d-base) var(--ease-out);
}
.legal-inline-link:hover {
    color: var(--text-primary);
    border-bottom-color: var(--accent-teal);
}

.legal-back {
    margin-top: 56px;
    padding-top: 32px;
    border-top: 1px solid var(--border-soft);
    text-align: center;
}

/* ----------------------------------------------------------
   COOKIE BANNER + PREFERENCES
   ---------------------------------------------------------- */
[x-cloak] { display: none !important; }

.cookie-banner-root {
    position: fixed;
    z-index: 9000;
    bottom: 24px;
    right: 24px;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;          /* children re-enable */
}
.cookie-banner,
.cookie-prefs {
    position: relative;
    pointer-events: auto;
    background: rgba(3, 4, 10, 0.92);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    padding: 22px 24px;
    box-shadow:
        0 24px 60px -16px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(15, 181, 164, 0.08) inset;
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    overflow: hidden;
}
.cookie-banner-glow {
    position: absolute;
    inset: -50%;
    background:
        radial-gradient(circle at 80% 0%, rgba(15, 181, 164, 0.15), transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(201, 162, 39, 0.10), transparent 50%);
    pointer-events: none;
    z-index: 0;
}
.cookie-banner > *,
.cookie-prefs > * { position: relative; z-index: 1; }

.cookie-banner-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.cookie-banner-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(15,181,164,0.20), rgba(201,162,39,0.15));
    border: 1px solid rgba(15, 181, 164, 0.30);
    color: var(--accent-gold-2);
    font-size: 16px;
}
.cookie-banner-title {
    font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.cookie-banner-body {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0 0 18px;
}
.cookie-banner-link {
    color: var(--accent-teal-2);
    text-decoration: none;
    border-bottom: 1px solid rgba(20, 215, 195, 0.3);
    transition: all var(--d-base) var(--ease-out);
    white-space: nowrap;
}
.cookie-banner-link:hover {
    color: var(--text-primary);
    border-bottom-color: var(--accent-teal);
}

.cookie-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.cookie-banner-actions .btn { flex: 1 1 auto; min-width: 120px; justify-content: center; }

.cookie-banner-customize {
    background: none;
    border: none;
    padding: 6px 8px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color var(--d-base) var(--ease-out);
    flex: 1 1 100%;
    justify-content: center;
    margin-top: 4px;
}
.cookie-banner-customize:hover { color: var(--accent-teal-2); }

/* Preferences panel */
.cookie-prefs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.cookie-prefs-close {
    background: none;
    border: 1px solid var(--border-soft);
    color: var(--text-secondary);
    width: 32px; height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--d-base) var(--ease-out);
}
.cookie-prefs-close:hover {
    color: var(--text-primary);
    border-color: var(--accent-teal);
    background: rgba(15, 181, 164, 0.08);
}
.cookie-prefs-intro {
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0 0 16px;
}

.cookie-prefs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}
.cookie-cat {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-soft);
    background: rgba(8, 10, 18, 0.35);
    cursor: pointer;
    transition: border-color var(--d-base) var(--ease-out);
}
.cookie-cat:hover { border-color: var(--border-strong); }
.cookie-cat--locked { cursor: default; }

.cookie-cat-text { flex: 1; min-width: 0; }
.cookie-cat-name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.cookie-cat-name i { color: var(--accent-teal); font-size: 12px; }
.cookie-cat-required {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-teal-2);
    background: rgba(15, 181, 164, 0.10);
    border: 1px solid rgba(15, 181, 164, 0.30);
    padding: 2px 6px;
    border-radius: var(--r-sm);
    font-weight: 500;
}
.cookie-cat-desc {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-muted);
}

/* Switches */
.cookie-switch {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-strong);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
    transition: background var(--d-base) var(--ease-out),
                border-color var(--d-base) var(--ease-out);
    padding: 0;
}
.cookie-switch-knob {
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: transform var(--d-base) var(--ease-out),
                background var(--d-base) var(--ease-out);
}
.cookie-switch.is-on {
    background: rgba(15, 181, 164, 0.25);
    border-color: var(--accent-teal);
}
.cookie-switch.is-on .cookie-switch-knob {
    background: var(--accent-teal-2);
    transform: translateX(20px);
    box-shadow: 0 0 8px var(--accent-teal);
}
.cookie-switch--locked {
    cursor: not-allowed;
    background: rgba(15, 181, 164, 0.20);
    border-color: var(--accent-teal);
}
.cookie-switch--locked .cookie-switch-knob {
    background: var(--accent-teal-2);
    transform: translateX(20px);
    opacity: 0.7;
}

.cookie-prefs-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.cookie-prefs-actions .btn { flex: 1 1 auto; min-width: 130px; justify-content: center; }
.cookie-prefs-link {
    font-size: 12.5px;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all var(--d-base) var(--ease-out);
    margin-left: auto;
    padding: 6px 4px;
}
.cookie-prefs-link:hover {
    color: var(--accent-teal-2);
    border-bottom-color: var(--accent-teal);
}

/* Alpine transition classes */
.cb-transition-enter  { transition: opacity 320ms var(--ease-out), transform 320ms var(--ease-out); }
.cb-transition-leave  { transition: opacity 220ms var(--ease-in-out), transform 220ms var(--ease-in-out); }
.cb-enter-start       { opacity: 0; transform: translateY(20px) scale(0.96); }
.cb-enter-end         { opacity: 1; transform: translateY(0) scale(1); }
.cb-leave-start       { opacity: 1; transform: translateY(0) scale(1); }
.cb-leave-end         { opacity: 0; transform: translateY(20px) scale(0.96); }

/* Mobile: full-width sheet at the bottom */
@media (max-width: 640px) {
    .cookie-banner-root {
        bottom: 12px;
        right: 12px;
        left: 12px;
        width: auto;
    }
    .cookie-banner,
    .cookie-prefs { padding: 20px 18px; }
    .cookie-banner-actions .btn,
    .cookie-prefs-actions .btn { flex: 1 1 100%; }
    .cookie-prefs-link { margin: 4px auto 0; }
}

/* Footer legal links */
.footer-legal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    font-size: 13px;
}
.footer-legal-links a,
.footer-legal-links button {
    color: var(--text-muted);
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    transition: color var(--d-base) var(--ease-out);
}
.footer-legal-links a:hover,
.footer-legal-links button:hover { color: var(--accent-teal-2); }
.footer-legal-sep {
    color: var(--border-strong);
    user-select: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .cb-transition-enter,
    .cb-transition-leave { transition: none !important; }
    .cb-enter-start,
    .cb-leave-end { transform: none !important; }
    .legal-right:hover { transform: none; }
}
