/* ============================================================
   TSUKI — Legal Pages (Shared)
   ============================================================ */

:root {
    --bg-deep:       #09090b;
    --bg-base:       #0f0f11;
    --bg-card:       #151517;
    --bg-card-hover: #1b1b1e;
    --border-subtle: #1f1f23;
    --border-active: #333338;
    --text-primary:  #d4d4d8;
    --text-heading:  #ededef;
    --text-secondary:#8a8a92;
    --text-muted:    #5a5a63;
    --text-body:     #a1a1a8;
    --accent:        #7c8cf8;
    --accent-dim:    #7c8cf8;
    --nav-bg:        #09090b;
    --bg-elevated:   #1a1a1e;
    --star-color:    255,255,255;
    --star-cover-top:#111118;
    --star-cover-mid:#0a0a0d;
    --logo-invert:   0;
    --font-sans:     'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Light Theme ── */
[data-theme="light"] {
    --bg-deep:       #f5f5f7;
    --bg-base:       #ebebef;
    --bg-card:       #ffffff;
    --bg-card-hover: #f0f0f4;
    --border-subtle: #d8d8de;
    --border-active: #c0c0c8;
    --text-primary:  #2a2a32;
    --text-heading:  #111118;
    --text-secondary:#55555e;
    --text-muted:    #88889a;
    --text-body:     #444450;
    --accent:        #5b6be8;
    --accent-dim:    #5b6be8;
    --nav-bg:        #ffffff;
    --bg-elevated:   #ededf2;
    --star-color:    30,30,50;
    --star-cover-top:#f0f0f5;
    --star-cover-mid:#e8e8f0;
    --logo-invert:   1;
}

/* Smooth theme transition — scoped to key elements to avoid lag */
body.theme-ready,
body.theme-ready .nav-bar,
body.theme-ready .admin-sidebar,
body.theme-ready .admin-card,
body.theme-ready .sc,
body.theme-ready .site-footer,
body.theme-ready .auth-card,
body.theme-ready .nav-links a,
body.theme-ready .sidebar-link,
body.theme-ready .form-control,
body.theme-ready .f-input {
    transition: background-color 0.25s ease, color 0.2s ease, border-color 0.25s ease !important;
}

/* Logo adjustment for light mode — keep purple, just add contrast */
[data-theme="light"] .nav-brand img,
[data-theme="light"] .footer-logo img { filter: none; opacity: 0.85; }
[data-theme="light"] .nav-brand:hover img {
    filter: drop-shadow(0 0 10px rgba(91,107,232,0.7)) drop-shadow(0 0 25px rgba(91,107,232,0.4));
}

/* Light mode starfield cover */
[data-theme="light"] .star-cover {
    background: linear-gradient(to bottom, var(--star-cover-top) 0%, var(--star-cover-mid) 40%, transparent 100%);
}

/* Light mode body gradient */
[data-theme="light"] body {
    background-image: linear-gradient(to bottom, #e8e8f0 0%, var(--bg-deep) 600px);
}
[data-theme="light"] .starfield { display: none !important; }

/* Light mode scrollbar */
[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg-deep); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c0c0c8; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #a0a0a8; }

/* Light mode selection */
[data-theme="light"] ::selection { background: var(--accent); color: #fff; }

*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg-deep);
    background-image: linear-gradient(to bottom, #111118 0%, var(--bg-deep) 600px);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: #fff; }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-active); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* STARFIELD */
.starfield {
    position: fixed; inset: 0; z-index: 0;
    pointer-events: none; overflow: hidden;
}

.starfield canvas {
    display: block; width: 100%; height: 100%;
}

.star-cover {
    position: fixed; top: 0; left: 0; right: 0;
    height: 350px;
    background: linear-gradient(to bottom, #111118 0%, #0a0a0d 40%, transparent 100%);
    pointer-events: none; z-index: 0;
}

a { color: inherit; text-decoration: none; }

/* NAV */
.nav-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    background: rgba(9,9,11,0.88);
    backdrop-filter: blur(24px) saturate(1.2); -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border-bottom: 1px solid rgba(255,255,255,0.035);
    height: 58px;
    display: flex; align-items: center;
}
[data-theme="light"] .nav-bar { background: rgba(255,255,255,0.9); border-bottom-color: rgba(0,0,0,0.06); }
.nav-inner {
    width: 100%; max-width: 1140px;
    margin: 0 auto; padding: 0 0.75rem;
    display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
    font-size: 1.05rem; font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-heading);
    text-decoration: none; text-transform: uppercase;
    display: flex; align-items: center; gap: 0.5rem;
}
.nav-brand img { display: block; transition: filter 0.3s ease; }
.nav-brand:hover img {
    filter: drop-shadow(0 0 10px rgba(124,140,248,0.7)) drop-shadow(0 0 25px rgba(124,140,248,0.4)) drop-shadow(0 0 45px rgba(124,140,248,0.15));
}
.nav-links { display: flex; align-items: center; gap: 0.1rem; }
.nav-links a {
    font-size: 0.85rem; font-weight: 500;
    color: var(--text-muted); text-decoration: none;
    padding: 0.38rem 0.7rem; border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: var(--text-secondary); background: rgba(255,255,255,0.03); }
.nav-links a.active { color: var(--text-heading); position: relative; font-weight: 600; }
.nav-links a.active::after {
    content: ''; position: absolute; bottom: -3px; left: 50%; transform: translateX(-50%);
    width: 18px; height: 2px; border-radius: 1px; background: var(--accent);
}
[data-theme="light"] .nav-links a:hover { background: rgba(0,0,0,0.04); }

/* Spacer pushes right-side items */
.nav-spacer { flex: 1; }

/* Icon buttons (Discord, theme) */
.nav-icon {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 6px;
    font-size: 1rem; color: var(--text-muted);
    background: none; border: none; cursor: pointer;
    transition: color 0.15s, background 0.15s;
    text-decoration: none; padding: 0;
    font-family: inherit;
}
.nav-icon:hover { color: var(--text-secondary); background: rgba(255,255,255,0.04); }
.nav-icon[title="Discord"]:hover { color: #5865F2; }
[data-theme="light"] .nav-icon:hover { background: rgba(0,0,0,0.04); }

/* Sign In / Sign Up (logged out) */
.nav-links .nav-signin {
    font-size: 0.82rem; font-weight: 500; color: var(--text-muted);
    padding: 0.35rem 0.75rem; border-radius: 6px; text-decoration: none;
    transition: color 0.15s;
}
.nav-links .nav-signin:hover { color: var(--text-primary); }
.nav-links a.nav-signup {
    font-size: 0.78rem; font-weight: 600; color: #fff;
    background: var(--accent); padding: 0.35rem 0.9rem; border-radius: 6px;
    text-decoration: none; transition: opacity 0.15s;
}
.nav-links a.nav-signup:hover { opacity: 0.85; color: #fff; background: var(--accent); }

/* Account dropdown */
.nav-dropdown { position: relative; margin-left: 0.25rem; }
.nav-avatar-btn {
    display: flex; align-items: center; gap: 0.4rem;
    background: none; border: 1px solid transparent; border-radius: 8px;
    padding: 0.25rem 0.55rem 0.25rem 0.25rem;
    cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.nav-avatar-btn:hover { border-color: var(--border-subtle); background: rgba(255,255,255,0.02); }
.nav-dropdown.open .nav-avatar-btn { border-color: var(--border-active); background: rgba(255,255,255,0.03); }
.nav-av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.nav-av-name { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); }
.nav-av-chev { font-size: 0.6rem; color: var(--text-muted); transition: transform 0.15s; }
.nav-dropdown.open .nav-av-chev { transform: rotate(180deg); }

/* Dropdown menu */
.nav-dropdown-menu {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    min-width: 180px; background: var(--bg-card);
    border: 1px solid var(--border-subtle); border-radius: 10px;
    padding: 0.35rem; box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    z-index: 1001;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; animation: ddIn 0.15s ease; }
@keyframes ddIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
[data-theme="light"] .nav-dropdown-menu { box-shadow: 0 8px 30px rgba(0,0,0,0.1); }

.nav-dd-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.65rem; border-radius: 6px;
    font-size: 0.82rem; font-weight: 500; color: var(--text-secondary);
    text-decoration: none; transition: all 0.1s;
}
/* Match <button.nav-dd-item> to <a.nav-dd-item>. The logout item is a
   form+button for CSRF reasons, so we strip the browser's default button
   chrome here instead of via inline styles. */
button.nav-dd-item {
    background: none; border: 0; margin: 0;
    font-family: inherit; line-height: 1.3;
    text-align: left; width: 100%; cursor: pointer;
}
.nav-dd-item:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.nav-dd-item i { font-size: 0.85rem; width: 16px; text-align: center; color: var(--text-muted); }
.nav-dd-admin { color: var(--accent); }
.nav-dd-admin i { color: var(--accent); }
.nav-dd-admin:hover { background: rgba(124,140,248,0.06); }
.nav-dd-sep { height: 1px; background: var(--border-subtle); margin: 0.25rem 0.4rem; }
.nav-dd-logout { color: var(--text-muted); }
.nav-dd-logout:hover { color: #f87171; background: rgba(239,68,68,0.06); }
.nav-dd-logout:hover i { color: #f87171; }
[data-theme="light"] .nav-dd-item:hover { background: rgba(0,0,0,0.04); }
[data-theme="light"] .nav-dd-admin:hover { background: rgba(91,107,232,0.06); }
[data-theme="light"] .nav-dd-logout:hover { background: rgba(239,68,68,0.04); }

/* Theme toggle icons */
.theme-toggle-light { display: none; }
.theme-toggle-dark  { display: inline; }
[data-theme="light"] .theme-toggle-light { display: inline; }
[data-theme="light"] .theme-toggle-dark  { display: none; }

.nav-hamburger {
    display: none; background: none; border: none;
    color: var(--text-secondary); font-size: 1.15rem;
    cursor: pointer; padding: 0.25rem;
    transition: color 0.15s;
    position: relative; z-index: 1001;
}
.nav-hamburger:hover { color: var(--text-heading); }

/* Desktop: nav-group wrappers are transparent */
.nav-group { display: contents; }

@media (max-width: 640px) {
    .nav-brand span { display: none; }
    .nav-hamburger { display: block; }
    .nav-spacer { display: none; }

    /* When menu is open, remove backdrop-filter from nav-bar.
       backdrop-filter creates a containing block that traps
       position:fixed children inside the 58px bar. */
    .nav-bar.menu-open {
        backdrop-filter: none; -webkit-backdrop-filter: none;
        background: var(--bg-deep);
    }
    [data-theme="light"] .nav-bar.menu-open { background: #fff; }

    /* Full-screen overlay */
    .nav-links {
        display: none;
        position: fixed; top: 58px; left: 0; right: 0; bottom: 0;
        z-index: 999;
        background: var(--bg-deep);
        flex-direction: column;
        align-items: stretch;
        padding: 1.5rem 1.5rem 2rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .nav-links.open {
        display: flex;
        animation: navSlideIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    }
    @keyframes navSlideIn {
        from { opacity: 0; transform: translateY(-12px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    [data-theme="light"] .nav-links {
        background: #fff;
    }

    /* Groups become visible containers */
    .nav-group {
        display: flex; flex-direction: column;
        width: 100%;
    }

    /* Main nav links */
    .nav-group-main {
        gap: 0.15rem;
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    [data-theme="light"] .nav-group-main { border-bottom-color: rgba(0,0,0,0.06); }

    .nav-group-main a {
        display: block;
        font-size: 1.1rem; font-weight: 600;
        color: var(--text-secondary);
        padding: 0.75rem 0.8rem;
        border-radius: 10px;
        transition: color 0.12s, background 0.12s;
        text-decoration: none;
    }
    .nav-group-main a:hover { color: var(--text-heading); background: rgba(255,255,255,0.04); }
    [data-theme="light"] .nav-group-main a:hover { background: rgba(0,0,0,0.04); }
    .nav-group-main a.active {
        color: var(--text-heading); font-weight: 700;
        background: rgba(124,140,248,0.08);
    }
    .nav-group-main a.active::after { display: none; }

    /* Secondary row */
    .nav-group-secondary {
        flex-direction: row; gap: 0.4rem;
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    [data-theme="light"] .nav-group-secondary { border-bottom-color: rgba(0,0,0,0.06); }
    .nav-group-secondary .nav-icon {
        width: auto; height: auto;
        padding: 0.6rem 1rem; font-size: 0.88rem;
        border-radius: 8px;
        background: rgba(255,255,255,0.03);
        border: 1px solid rgba(255,255,255,0.06);
        color: var(--text-secondary);
        display: inline-flex; align-items: center; gap: 0.4rem;
    }
    [data-theme="light"] .nav-group-secondary .nav-icon {
        background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.06);
    }
    .nav-group-secondary .nav-icon:hover { border-color: var(--accent); color: var(--text-heading); }

    /* Account section — pushed to bottom */
    .nav-group-account {
        gap: 0.15rem;
        margin-top: auto;
        padding-top: 1.25rem;
        border-top: 1px solid rgba(255,255,255,0.06);
    }
    [data-theme="light"] .nav-group-account { border-top-color: rgba(0,0,0,0.06); }
    .nav-group-account .nav-dropdown { margin-left: 0; width: 100%; }
    .nav-group-account .nav-avatar-btn {
        width: 100%; padding: 0.65rem 0.8rem; border-radius: 10px;
        font-size: 0.92rem;
    }
    .nav-group-account .nav-dropdown-menu {
        position: static; border: none; box-shadow: none;
        padding: 0.25rem 0 0 1.2rem; min-width: 0; background: transparent;
    }
    .nav-group-account .nav-dropdown.open .nav-dropdown-menu { animation: none; }
    .nav-group-account .nav-dd-item {
        padding: 0.6rem 0.6rem; font-size: 0.88rem; border-radius: 8px;
    }

    /* Auth buttons — pushed to bottom */
    .nav-group-auth {
        gap: 0.5rem;
        margin-top: auto;
        padding-top: 1.25rem;
        border-top: 1px solid rgba(255,255,255,0.06);
    }
    [data-theme="light"] .nav-group-auth { border-top-color: rgba(0,0,0,0.06); }
    .nav-group-auth .nav-signin {
        display: block; text-align: center;
        padding: 0.7rem; font-size: 0.92rem; font-weight: 500;
        border-radius: 10px; color: var(--text-secondary);
    }
    .nav-group-auth .nav-signup {
        display: block; text-align: center;
        padding: 0.7rem; font-size: 0.92rem; font-weight: 600;
        border-radius: 10px;
    }
}

/* CONTAINER — shared across all pages for footer and sections */
.container {
    width: 100%; max-width: 1140px;
    margin: 0 auto; padding: 0 0.75rem;
    position: relative; z-index: 1;
}

/* FOOTER — dimmed so it doesn't compete with main content */
.site-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 2rem 0 1.25rem;
    position: relative; z-index: 1;
}
.footer-top {
    display: flex; justify-content: space-between;
    gap: 2rem; padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}
.footer-brand-col { max-width: 260px; }
.footer-logo {
    display: flex; align-items: center; gap: 0.5rem;
    text-decoration: none; color: var(--text-muted);
    font-size: 0.85rem; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
    margin-bottom: 0.4rem; transition: color 0.15s;
}
.footer-logo:hover { color: var(--text-secondary); }
.footer-logo img { opacity: 0.4; transition: opacity 0.2s; }
.footer-logo:hover img { opacity: 0.6; }
.footer-tagline { font-size: 0.7rem; color: var(--text-muted); line-height: 1.5; margin: 0; opacity: 0.7; }
.footer-nav { display: flex; gap: 2.5rem; }
.footer-nav-group { display: flex; flex-direction: column; gap: 0.3rem; }
.footer-nav-title {
    font-size: 0.58rem; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 0.2rem; opacity: 0.7;
}
.footer-link {
    font-size: 0.72rem; font-weight: 400;
    color: var(--text-muted); text-decoration: none;
    transition: color 0.15s; opacity: 0.7;
}
.footer-link:hover { color: var(--text-secondary); opacity: 1; }
.footer-bottom {
    display: flex; align-items: center;
    justify-content: space-between;
    padding-top: 0.85rem;
}
.footer-copy { font-size: 0.6rem; color: var(--text-muted); opacity: 0.6; }
.footer-social {
    font-size: 1rem; color: var(--text-muted); opacity: 0.5;
    text-decoration: none; transition: all 0.2s;
    padding: 0.25rem;
}
.footer-social:hover { color: #5865F2; opacity: 1; }
@media (max-width: 640px) {
    .footer-top {
        flex-direction: column;
        gap: 1.5rem;
        align-items: center;
        text-align: center;
    }
    .footer-brand-col {
        max-width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .footer-logo { justify-content: center; }
    .footer-nav {
        gap: 1.75rem;
        width: 100%;
        justify-content: space-around;
        flex-wrap: wrap;
    }
    .footer-nav-group { align-items: center; }
    .footer-bottom {
        flex-direction: column-reverse;
        gap: 0.75rem;
        align-items: center;
        text-align: center;
    }
    .footer-copy { order: 2; }
}

/* LEGAL CONTENT */
.legal-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 0.75rem;
    position: relative; z-index: 1;
}

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

.legal-header {
    padding: 2.5rem 0 1.5rem;
    animation: legalIn 0.4s ease both;
}
.legal-title {
    color: var(--text-heading);
    font-size: 1.8rem;
    font-weight: 700; letter-spacing: -0.025em;
    margin: 0 0 0.4rem;
}
.legal-updated {
    font-size: 0.75rem; color: var(--text-muted);
}

.legal-body {
    padding-bottom: 4rem;
    animation: legalIn 0.4s ease both; animation-delay: 0.08s;
}
.legal-body h2 {
    font-size: 1.05rem; font-weight: 700;
    margin: 2.2rem 0 0.6rem;
    letter-spacing: -0.01em;
    color: var(--text-heading);
}
.legal-body h2:first-child { margin-top: 0; }
.legal-body p {
    font-size: 0.84rem; font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.7; margin: 0 0 0.8rem;
}
.legal-body ul {
    list-style: none; padding: 0; margin: 0 0 0.8rem;
}
.legal-body ul li {
    font-size: 0.84rem; color: var(--text-secondary);
    padding: 0.2rem 0 0.2rem 1.2rem;
    position: relative; line-height: 1.65;
}
.legal-body ul li::before {
    content: ''; position: absolute;
    left: 0; top: 0.65rem;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--border-active);
}
.legal-body a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity 0.15s;
}
.legal-body a:hover { opacity: 0.75; }

/* FOOTER */
/* Heading brightness overrides */
.legal-title, .legal-body h2, .nav-brand, .footer-nav-title { color: var(--text-heading); }

/* Light mode: invert subtle rgba overlays */
[data-theme="light"] .nav-links a:hover { background: rgba(0,0,0,0.04); }
