﻿/* ============================================================
   COMMON.CSS — Design Tokens, Reset, Base, Utilities
   ============================================================
   Art direction: Celestial observatory — dark, atmospheric, cosmic.
   Palette: Deep cosmic violet + golden starlight accents.
   Vibe: Midnight observatory × celestial cartography × premium.
   ============================================================ */

/* --- CSS Custom Properties (Dark-First — default) --- */
:root {
    /* Brand — celestial violet spectrum */
    --color-primary: #A78BFA;
    --color-primary-hover: #C4B5FD;
    --color-primary-deep: #7C3AED;
    --color-primary-light: rgba(167, 139, 250, 0.12);

    /* Accent — golden starlight */
    --color-accent: #D4AF37;
    --color-accent-hover: #E5C458;
    --color-accent-light: rgba(212, 175, 55, 0.12);
    --color-accent-glow: rgba(212, 175, 55, 0.15);

    /* Celestial — secondary palette */
    --color-celestial-teal: #2DD4BF;
    --color-celestial-teal-light: rgba(45, 212, 191, 0.1);
    --color-celestial-rose: #F472B6;
    --color-celestial-rose-light: rgba(244, 114, 182, 0.1);
    --color-celestial-blue: #60A5FA;
    --color-nebula: #2D1B69;

    /* Semantic */
    --color-success: #34D399;
    --color-success-bg: rgba(52, 211, 153, 0.1);
    --color-warning: #FBBF24;
    --color-warning-bg: rgba(251, 191, 36, 0.1);
    --color-error: #F87171;
    --color-error-bg: rgba(248, 113, 113, 0.1);
    --color-info: #60A5FA;
    --color-info-bg: rgba(96, 165, 250, 0.1);

    /* Neutrals (Cosmic dark — deep blue-violet undertone) */
    --color-bg: #0A0810;
    --color-bg-subtle: #110E1A;
    --color-bg-muted: #1A1628;
    --color-bg-elevated: #221E34;
    --color-border: rgba(167, 139, 250, 0.1);
    --color-border-strong: rgba(167, 139, 250, 0.22);
    --color-border-glow: rgba(167, 139, 250, 0.15);
    --color-text: #EDEBF4;
    --color-text-secondary: #A09CB2;
    --color-text-muted: #6B6681;
    --color-text-inverse: #0A0810;

    /* Glow effects */
    --glow-primary: rgba(167, 139, 250, 0.18);
    --glow-primary-strong: rgba(167, 139, 250, 0.35);
    --glow-primary-subtle: rgba(167, 139, 250, 0.06);
    --glow-accent: rgba(212, 175, 55, 0.12);
    --glow-accent-strong: rgba(212, 175, 55, 0.25);
    --glow-nebula: rgba(45, 27, 105, 0.4);

    /* AI Disclosure */
    --color-ai-badge-bg: rgba(167, 139, 250, 0.08);
    --color-ai-badge-text: #A09CB2;
    --color-ai-badge-icon: #6B6681;

    /* Glass */
    --glass-bg: rgba(17, 14, 26, 0.8);
    --glass-border: rgba(167, 139, 250, 0.08);
    --glass-blur: 20px;
    --glass-bg-strong: rgba(17, 14, 26, 0.92);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    --text-hero: clamp(2.25rem, 5vw, 3.75rem);
    --text-h1: clamp(1.75rem, 3.5vw, 2.75rem);
    --text-h2: clamp(1.5rem, 2.5vw, 2rem);
    --text-h3: clamp(1.25rem, 2vw, 1.5rem);
    --text-h4: clamp(1rem, 1.5vw, 1.125rem);
    --text-body: 1rem;
    --text-body-lg: clamp(1.125rem, 1.5vw, 1.25rem);
    --text-small: 0.875rem;
    --text-xs: 0.75rem;

    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;

    --tracking-tight: -0.025em;
    --tracking-normal: 0;
    --tracking-wide: 0.05em;

    /* Spacing (4px base) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;

    /* Layout */
    --max-width-content: 720px;
    --max-width-wide: 1080px;
    --max-width-full: 1280px;
    --sidebar-width: 260px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows (dark ambient + cosmic glow) */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(167, 139, 250, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(167, 139, 250, 0.08);
    --shadow-glow: 0 0 24px var(--glow-primary), 0 0 80px rgba(167, 139, 250, 0.06);
    --shadow-glow-accent: 0 0 20px var(--glow-accent), 0 0 60px rgba(212, 175, 55, 0.06);
    --shadow-focus: 0 0 0 3px rgba(167, 139, 250, 0.35);
    --shadow-celestial: 0 0 40px var(--glow-primary), 0 0 120px rgba(45, 27, 105, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    --transition-celestial: 600ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Scrollbar */
    --scrollbar-width: 6px;
    --scrollbar-width-thin: 4px;
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(167, 139, 250, 0.18);
    --scrollbar-thumb-hover: rgba(167, 139, 250, 0.32);
    --scrollbar-thumb-active: rgba(167, 139, 250, 0.44);
    --scrollbar-radius: 9999px;
}

/* --- Light Mode Override --- */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --color-primary: #7C3AED;
        --color-primary-hover: #6D28D9;
        --color-primary-deep: #5B21B6;
        --color-primary-light: rgba(124, 58, 237, 0.08);
        --color-accent: #B8941E;
        --color-accent-hover: #A07D16;
        --color-accent-light: rgba(184, 148, 30, 0.08);
        --color-accent-glow: rgba(184, 148, 30, 0.08);

        --color-success: #059669;
        --color-success-bg: #ECFDF5;
        --color-warning: #D97706;
        --color-warning-bg: #FFFBEB;
        --color-error: #DC2626;
        --color-error-bg: #FEF2F2;
        --color-info: #2563EB;
        --color-info-bg: #EFF6FF;

        --color-bg: #FAF9FC;
        --color-bg-subtle: #F3F1F8;
        --color-bg-muted: #E8E5F0;
        --color-bg-elevated: #FFFFFF;
        --color-border: #E8E5F0;
        --color-border-strong: #D4D0E0;
        --color-text: #1A1625;
        --color-text-secondary: #5B5672;
        --color-text-muted: #9490A6;
        --color-text-inverse: #FFFFFF;

        --glow-primary: rgba(124, 58, 237, 0.08);
        --glow-primary-strong: rgba(124, 58, 237, 0.15);

        --color-ai-badge-bg: #F3F1F8;
        --color-ai-badge-text: #5B5672;

        --glass-bg: rgba(250, 249, 252, 0.85);
        --glass-border: rgba(124, 58, 237, 0.06);
        --glass-bg-strong: rgba(250, 249, 252, 0.95);

        --shadow-sm: 0 1px 2px rgba(26, 22, 37, 0.06);
        --shadow-md: 0 4px 16px rgba(26, 22, 37, 0.08);
        --shadow-lg: 0 12px 32px rgba(26, 22, 37, 0.12);
        --shadow-glow: none;
        --shadow-focus: 0 0 0 3px rgba(124, 58, 237, 0.25);

        --scrollbar-thumb: rgba(124, 58, 237, 0.16);
        --scrollbar-thumb-hover: rgba(124, 58, 237, 0.28);
        --scrollbar-thumb-active: rgba(124, 58, 237, 0.38);
    }
}

[data-theme="light"] {
    --scrollbar-thumb: rgba(124, 58, 237, 0.16);
    --scrollbar-thumb-hover: rgba(124, 58, 237, 0.28);
    --scrollbar-thumb-active: rgba(124, 58, 237, 0.38);

    --color-primary: #7C3AED;
    --color-primary-hover: #6D28D9;
    --color-primary-deep: #5B21B6;
    --color-primary-light: rgba(124, 58, 237, 0.08);
    --color-accent: #D97706;
    --color-accent-light: rgba(217, 119, 6, 0.08);

    --color-success: #059669;
    --color-success-bg: #ECFDF5;
    --color-warning: #D97706;
    --color-warning-bg: #FFFBEB;
    --color-error: #DC2626;
    --color-error-bg: #FEF2F2;
    --color-info: #2563EB;
    --color-info-bg: #EFF6FF;

    --color-bg: #FAF9FC;
    --color-bg-subtle: #F3F1F8;
    --color-bg-muted: #E8E5F0;
    --color-bg-elevated: #FFFFFF;
    --color-border: #E8E5F0;
    --color-border-strong: #D4D0E0;
    --color-text: #1A1625;
    --color-text-secondary: #5B5672;
    --color-text-muted: #9490A6;
    --color-text-inverse: #FFFFFF;

    --glow-primary: rgba(124, 58, 237, 0.08);
    --glow-primary-strong: rgba(124, 58, 237, 0.15);

    --color-ai-badge-bg: #F3F1F8;
    --color-ai-badge-text: #5B5672;

    --glass-bg: rgba(250, 249, 252, 0.85);
    --glass-border: rgba(124, 58, 237, 0.06);
    --glass-bg-strong: rgba(250, 249, 252, 0.95);

    --shadow-sm: 0 1px 2px rgba(26, 22, 37, 0.06);
    --shadow-md: 0 4px 16px rgba(26, 22, 37, 0.08);
    --shadow-lg: 0 12px 32px rgba(26, 22, 37, 0.12);
    --shadow-glow: none;
    --shadow-focus: 0 0 0 3px rgba(124, 58, 237, 0.25);
}


/* --- Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

/* --- Global Scrollbar Styling --- */

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* WebKit / Blink (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--scrollbar-radius);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-thumb:active {
    background: var(--scrollbar-thumb-active);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Chat pages: lock viewport — all scroll inside .chat__messages only */
html:has(.chat),
html:has(.chat) > body {
    overflow: hidden;
    height: 100dvh;
    height: 100vh;
    scroll-behavior: auto;
}

/* Hide any footer on chat pages (both marketing and app layouts) */
body:has(.chat) > footer {
    display: none !important;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-body);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

ul, ol {
    list-style: none;
}

button {
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

h1, h2, h3, h4, h5, h6 {
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--color-text);
}

h1 { font-size: var(--text-h1); font-weight: 700; }
h2 { font-size: var(--text-h2); font-weight: 600; }
h3 { font-size: var(--text-h3); font-weight: 600; }
h4 { font-size: var(--text-h4); font-weight: 600; }

p {
    margin-bottom: var(--space-4);
}

p:last-child {
    margin-bottom: 0;
}


/* --- Layout Utilities --- */
.container {
    width: 100%;
    max-width: var(--max-width-full);
    margin-inline: auto;
    padding-inline: var(--space-4);
}

.container--narrow {
    max-width: var(--max-width-content);
}

.container--wide {
    /* max-width: var(--max-width-wide); */
}

.section {
    padding-block: var(--space-16);
}

.section--sm {
    padding-block: var(--space-8);
}

.section--lg {
    padding-block: var(--space-24);
}

.section--subtle {
    background-color: var(--color-bg-subtle);
}


/* --- Flex / Grid Helpers --- */
.flex {
    display: flex;
}

.flex--center {
    align-items: center;
    justify-content: center;
}

.flex--between {
    align-items: center;
    justify-content: space-between;
}

.flex--col {
    flex-direction: column;
}

.flex--gap-2 { gap: var(--space-2); }
.flex--gap-4 { gap: var(--space-4); }
.flex--gap-6 { gap: var(--space-6); }
.flex--gap-8 { gap: var(--space-8); }

.grid {
    display: grid;
    gap: var(--space-6);
}

.grid--2 {
    grid-template-columns: 1fr;
}

.grid--3 {
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .grid--2 {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid--3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 960px) {
    .grid--3 {
        grid-template-columns: repeat(3, 1fr);
    }
}


/* --- Text Utilities --- */
.text-center { text-align: center; }
.text-small { font-size: var(--text-small); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-primary { color: var(--color-primary); }
.text-error { color: var(--color-error); }

.lead {
    font-size: var(--text-body-lg);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
}


/* --- Spacing Utilities --- */
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.gap-4 { gap: var(--space-4); }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }


/* --- Visibility --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 639px) {
    .hide-mobile { display: none !important; }
}

@media (min-width: 640px) {
    .hide-desktop { display: none !important; }
}


/* --- Skeleton Loader --- */
.skeleton {
    background: var(--color-bg-muted);
    border-radius: var(--radius-md);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton--text {
    height: 1em;
    width: 80%;
    margin-bottom: var(--space-2);
}

.skeleton--heading {
    height: 1.5em;
    width: 60%;
    margin-bottom: var(--space-4);
}

.skeleton--block {
    height: 120px;
    width: 100%;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}


/* --- Celestial Animations --- */
@keyframes celestial-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

@keyframes celestial-glow {
    0%, 100% { box-shadow: 0 0 20px var(--glow-primary), 0 0 60px rgba(167, 139, 250, 0.05); }
    50% { box-shadow: 0 0 30px var(--glow-primary-strong), 0 0 80px rgba(167, 139, 250, 0.12); }
}

@keyframes orbit-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes orbit-spin-reverse {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

@keyframes star-twinkle {
    0%, 100% { opacity: 0.2; transform: scale(0.8); }
    50% { opacity: 0.8; transform: scale(1.2); }
}

@keyframes float-up {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}


/* --- Celestial Decorative Utilities --- */

/* Gradient text for headings */
.text-gradient {
    background: linear-gradient(135deg, var(--color-text) 0%, var(--color-primary) 50%, var(--color-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-gradient--primary {
    background: linear-gradient(135deg, var(--color-primary-hover), var(--color-primary), var(--color-primary-deep));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Celestial divider — line with diamond center */
.celestial-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--color-text-muted);
    margin-block: var(--space-6);
}

.celestial-divider::before,
.celestial-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-border-strong), transparent);
}

.celestial-divider__star {
    width: 6px;
    height: 6px;
    background: var(--color-primary);
    transform: rotate(45deg);
    border-radius: 1px;
    box-shadow: 0 0 8px var(--glow-primary);
    flex-shrink: 0;
}

/* Starfield background — subtle animated dots */
.starfield {
    position: relative;
    overflow: hidden;
}

.starfield::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(167, 139, 250, 0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 30% 80%, rgba(212, 175, 55, 0.25) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 50% 40%, rgba(167, 139, 250, 0.2) 0%, transparent 100%),
        radial-gradient(1px 1px at 70% 15%, rgba(212, 175, 55, 0.2) 0%, transparent 100%),
        radial-gradient(1px 1px at 85% 60%, rgba(167, 139, 250, 0.25) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 20% 55%, rgba(45, 212, 191, 0.15) 0%, transparent 100%),
        radial-gradient(1px 1px at 60% 90%, rgba(167, 139, 250, 0.2) 0%, transparent 100%),
        radial-gradient(1px 1px at 90% 35%, rgba(212, 175, 55, 0.15) 0%, transparent 100%),
        radial-gradient(1px 1px at 40% 10%, rgba(244, 114, 182, 0.12) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 15% 70%, rgba(167, 139, 250, 0.18) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
    animation: celestial-pulse 8s ease-in-out infinite;
}

.starfield > * {
    position: relative;
    z-index: 1;
}

/* Orbital ring — decorative rotating circle */
.orbital-ring {
    position: absolute;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    pointer-events: none;
}

.orbital-ring--sm {
    width: 200px;
    height: 200px;
    animation: orbit-spin 30s linear infinite;
}

.orbital-ring--md {
    width: 400px;
    height: 400px;
    border-style: dashed;
    animation: orbit-spin-reverse 45s linear infinite;
}

.orbital-ring--lg {
    width: 600px;
    height: 600px;
    animation: orbit-spin 60s linear infinite;
}

/* Nebula glow — radial gradient blob */
.nebula-glow {
    position: absolute;
    border-radius: var(--radius-full);
    pointer-events: none;
    filter: blur(60px);
    opacity: 0.5;
}

.nebula-glow--primary {
    background: radial-gradient(circle, var(--glow-primary-strong) 0%, transparent 70%);
}

.nebula-glow--accent {
    background: radial-gradient(circle, var(--glow-accent-strong) 0%, transparent 70%);
}


.mobile-nav.is-open {
    min-height: fit-content;
}