/**
 * GilGamez Platform — Legal Documents & Policies Stylesheet
 * Covers: Privacy Policy, Terms and Conditions, and Cookie Consent & Controls.
 * 100% Theme-Adaptive (CSS Custom Properties), Glassmorphism, 5-Tier Responsive.
 * Enforces Rule #1, Rule #4, Rule #6, and Rule #11.
 */

.legal-view-wrapper {
    max-width: 1180px;
    margin: 20px auto 48px;
    padding: 0 16px;
    position: relative;
    z-index: 2;
}

/* ─── Universal Button Appearance Reset for Legal Interactive Controls ─────── */
.legal-view-wrapper button,
.legal-toc-btn,
.legal-mode-btn,
.btn-stage-nav,
.legal-action-btn,
.btn-cookie-action,
.btn-cookie-primary,
.btn-cookie-secondary,
.btn-cookie-save {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
    font-family: inherit;
    border: none;
    background: transparent;
}

/* ─── Compact Hero Header Card ─────────────────────────────────────────────── */
.legal-hero-card {
    background: rgba(13, 17, 28, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 22px 28px 18px;
    margin-bottom: 16px;
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    position: relative;
    overflow: hidden;
}

.legal-hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #00f0ff 0%, #38bdf8 40%, #fbbf24 100%);
}

.legal-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.70rem;
    font-weight: 800;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    padding: 4px 11px;
    border-radius: 999px;
    background: rgba(0, 240, 255, 0.1);
    color: #38bdf8;
    border: 1px solid rgba(0, 240, 255, 0.25);
    margin-bottom: 10px;
}

.legal-hero-title {
    font-size: clamp(1.4rem, 2.8vw, 2.0rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0 0 8px;
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 60%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.legal-hero-subtitle {
    font-size: 0.90rem;
    line-height: 1.5;
    color: #94a3b8;
    max-width: 860px;
    margin: 0 0 14px;
}

.legal-meta-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.80rem;
    color: #64748b;
}

.legal-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legal-meta-item strong {
    color: #cbd5e1;
    font-weight: 600;
}

.legal-actions-group {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.legal-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.legal-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

/* ─── Compact Document Nav Tabs Switcher ───────────────────────────────────── */
.legal-doc-tabs {
    display: flex;
    gap: 8px;
    padding: 4px;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.legal-doc-tabs::-webkit-scrollbar {
    display: none;
}

.legal-tab-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 16px;
    border-radius: 9px;
    font-size: 0.84rem;
    font-weight: 600;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    border: 1px solid transparent;
}

.legal-tab-item:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.04);
}

.legal-tab-item.is-active {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.18) 0%, rgba(56, 189, 248, 0.12) 100%);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.35);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15);
}

/* ─── Main Interactive Two-Column Layout (Master-Detail) ──────────────────── */
.legal-layout-grid {
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: 20px;
    align-items: start;
}

/* ─── Left Topic Selector Rail ─────────────────────────────────────────────── */
.legal-toc-rail {
    position: sticky;
    top: 86px;
    background: rgba(13, 17, 28, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.legal-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.legal-toc-title {
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #64748b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.legal-toc-badge {
    font-size: 0.68rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-weight: 700;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.legal-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legal-toc-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.83rem;
    font-weight: 500;
    color: #94a3b8;
    background: transparent;
    border: 1px solid transparent;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.legal-toc-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.legal-toc-btn.is-active {
    color: #38bdf8;
    font-weight: 700;
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.14) 0%, rgba(56, 189, 248, 0.04) 100%);
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: inset 2px 0 0 #00f0ff;
}

.legal-toc-num {
    font-size: 0.70rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
    color: #64748b;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 6px;
    flex-shrink: 0;
}

.legal-toc-btn.is-active .legal-toc-num {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.2);
}

.legal-toc-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
}

.legal-toc-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Right Dynamic Content Stage ─────────────────────────────────────────── */
.legal-interactive-stage {
    min-height: 480px;
    display: flex;
    flex-direction: column;
}

.legal-stage-card {
    background: rgba(13, 17, 28, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 24px 28px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    animation: legalTopicFadeIn 0.22s ease-out;
    position: relative;
}

@keyframes legalTopicFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.legal-stage-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-wrap: wrap;
    gap: 10px;
}

.legal-stage-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.legal-topic-idx-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.18) 0%, rgba(56, 189, 248, 0.08) 100%);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: #38bdf8;
    font-size: 0.82rem;
    font-weight: 800;
    font-family: ui-monospace, SFMono-Regular, monospace;
}

.legal-topic-counter {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #94a3b8;
}

.legal-view-mode-toggle {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.legal-mode-btn {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.legal-mode-btn.is-active {
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
    font-weight: 700;
}

.legal-section-title {
    font-size: 1.28rem;
    font-weight: 800;
    color: #f8fafc;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}

.legal-section-summary {
    font-size: 0.86rem;
    color: #94a3b8;
    margin: 0 0 18px;
    line-height: 1.5;
}

.legal-body-prose {
    color: #cbd5e1;
    font-size: 0.92rem;
    line-height: 1.7;
}

.legal-body-prose p {
    margin: 0 0 14px;
}

.legal-body-prose p:last-child {
    margin-bottom: 0;
}

.legal-body-prose strong {
    color: #f1f5f9;
    font-weight: 600;
}

.legal-body-prose ul, .legal-body-prose ol {
    margin: 12px 0 18px 20px;
    padding: 0;
}

.legal-body-prose li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.legal-body-prose li::marker {
    color: #38bdf8;
}

/* Callout Highlight Box */
.legal-callout-box {
    background: rgba(30, 41, 59, 0.6);
    border-left: 3px solid #38bdf8;
    border-radius: 0 12px 12px 0;
    padding: 14px 18px;
    margin: 16px 0;
    font-size: 0.88rem;
    line-height: 1.6;
    color: #e2e8f0;
}

.legal-callout-box.gold {
    border-left-color: #fbbf24;
    background: rgba(45, 34, 18, 0.45);
}

.legal-callout-box.cyan {
    border-left-color: #00f0ff;
    background: rgba(8, 47, 73, 0.4);
}

.legal-callout-box.emerald {
    border-left-color: #10b981;
    background: rgba(6, 44, 32, 0.4);
}

/* Interactive Stage Footer Navigation */
.legal-stage-footer-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    gap: 12px;
}

.btn-stage-nav {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 9px;
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-stage-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.btn-stage-nav:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

.legal-progress-strip {
    flex: 1;
    max-width: 220px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.legal-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00f0ff 0%, #38bdf8 100%);
    border-radius: 999px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Full Stream Mode Container (When toggled) */
.legal-stream-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ─── Compact, Modern Cookie Consent Matrix ────────────────────────────────── */
.cookie-controls-card {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59, 0.75) 100%);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.cookie-controls-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.cookie-controls-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cookie-categories-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.cookie-category-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: all 0.2s ease;
}

.cookie-category-item:hover {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(15, 23, 42, 0.75);
}

.cookie-cat-info {
    flex: 1;
}

.cookie-cat-name {
    font-size: 0.90rem;
    font-weight: 700;
    color: #f1f5f9;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cookie-cat-desc {
    font-size: 0.79rem;
    color: #94a3b8;
    line-height: 1.45;
    margin: 0;
}

.cookie-locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #34d399;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.cookie-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.cookie-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.cookie-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.12);
    transition: 0.25s;
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.cookie-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.25s;
    border-radius: 50%;
}

.cookie-switch input:checked + .cookie-slider {
    background-color: #0284c7;
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.cookie-switch input:checked + .cookie-slider:before {
    transform: translateX(20px);
    background-color: #ffffff;
}

/* ─── Polished, Sleek Cookie Action Buttons (Zero Primitive Buttons) ─────── */
.cookie-actions-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 16px;
}

.btn-cookie-reject {
    background: rgba(239, 68, 68, 0.08);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.25);
    padding: 8px 16px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-cookie-reject:hover {
    background: rgba(239, 68, 68, 0.18);
    color: #ffffff;
    border-color: rgba(239, 68, 68, 0.45);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
    transform: translateY(-1px);
}

.btn-cookie-accept-all {
    background: rgba(56, 189, 248, 0.1);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 8px 16px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-cookie-accept-all:hover {
    background: rgba(56, 189, 248, 0.2);
    color: #ffffff;
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25);
    transform: translateY(-1px);
}

.btn-cookie-save {
    background: linear-gradient(135deg, #00f0ff 0%, #0284c7 100%);
    color: #0b1329;
    font-weight: 800;
    border: 1px solid rgba(0, 240, 255, 0.5);
    padding: 8px 20px;
    border-radius: 9px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 14px rgba(0, 240, 255, 0.25);
}

.btn-cookie-save:hover {
    background: linear-gradient(135deg, #38bdf8 0%, #0369a1 100%);
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.4);
    transform: translateY(-1px);
}

/* ─── Compact Data Tables ─────────────────────────────────────────────────── */
.legal-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 16px 0;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.4);
}

.legal-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    text-align: left;
}

.legal-data-table th {
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-transform: uppercase;
    font-size: 0.70rem;
    letter-spacing: 0.8px;
}

.legal-data-table td {
    padding: 10px 14px;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: top;
    line-height: 1.5;
}

.legal-data-table tr:last-child td {
    border-bottom: none;
}

.legal-data-table code {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.76rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
}

/* ─── Responsive Adjustments (5-Tier) ─────────────────────────────────────── */
@media (max-width: 900px) {
    .legal-layout-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .legal-toc-rail {
        position: relative;
        top: 0;
    }

    .legal-toc-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 6px;
    }
}

@media (max-width: 640px) {
    .legal-hero-card {
        padding: 18px 18px 14px;
    }

    .legal-hero-title {
        font-size: 1.35rem;
    }

    .legal-actions-group {
        width: 100%;
        margin-left: 0;
        margin-top: 8px;
    }

    .cookie-category-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .cookie-switch {
        align-self: flex-end;
    }

    .cookie-actions-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-cookie-reject, .btn-cookie-accept-all, .btn-cookie-save {
        width: 100%;
        justify-content: center;
    }
}
