/* ========================================
   NovaCanvas - Shared Styles & Theme Tokens
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');
/* Remix Icon - shared icon set (used across landing page & canvas) */
@import url('https://cdn.jsdelivr.net/npm/remixicon@4/fonts/remixicon.css');

/* ---------- Brand palette (static) ---------- */
:root {
    --nova-50: #f5f3ff;
    --nova-100: #ede9fe;
    --nova-200: #ddd6fe;
    --nova-300: #c4b5fd;
    --nova-400: #a78bfa;
    --nova-500: #8b5cf6;
    --nova-600: #7c3aed;
    --nova-700: #6d28d9;
    --nova-800: #5b21b6;
    --nova-900: #4c1d95;
    --nova-950: #030014;
}

/* ========================================
   Theme tokens (dark is the default)
   ======================================== */
:root,
:root[data-theme="dark"] {
    color-scheme: dark;

    /* page */
    --bg: #030014;
    --bg-canvas: #020205;
    --fg: #f8fafc;

    /* surfaces */
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.06);
    --panel-bg: rgba(5, 5, 12, 0.72);
    --panel-solid: #12121f;
    --panel-border: rgba(255, 255, 255, 0.08);
    --hover-bg: rgba(255, 255, 255, 0.06);
    --hover-border: rgba(255, 255, 255, 0.12);
    /* 抽屉式侧栏：阴影只朝画布方向投，scrim 用来压暗背景 */
    --drawer-shadow: rgba(0, 0, 0, 0.55);
    --scrim: rgba(3, 5, 12, 0.5);

    /* canvas */
    --node-bg: rgba(10, 10, 18, 0.85);
    --node-border: rgba(255, 255, 255, 0.08);
    --node-border-hover: rgba(255, 255, 255, 0.18);
    --node-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.70);
    --port-ring: #030014;

    --grid-dot: rgba(255, 255, 255, 0.30);
    --grid-glow: rgba(139, 92, 246, 0.08);

    --edge: rgba(255, 255, 255, 0.25);
    --edge-hover: rgba(255, 255, 255, 0.60);
    --edge-flow: rgba(255, 255, 255, 0.90);
    --edge-temp: rgba(255, 255, 255, 0.35);

    --tooltip-bg: rgba(10, 10, 20, 0.92);
    --tooltip-border: rgba(255, 255, 255, 0.12);
    --tooltip-fg: #e2e8f0;

    --scrollbar: rgba(255, 255, 255, 0.08);
    --scrollbar-hover: rgba(255, 255, 255, 0.15);

    /* "device screen" preview stays dark in both themes */
    --screen-bg: rgba(0, 0, 0, 0.40);

    /* RGB triplets consumed by Tailwind (see tailwind.config in each page) */
    --c-white: 255 255 255;
    --c-gray-300: 209 213 219;
    --c-gray-400: 156 163 175;
    --c-gray-500: 107 114 128;
    --c-gray-600: 75 85 99;
    --c-slate-200: 226 232 240;
    --c-slate-300: 203 213 225;
    --c-slate-400: 148 163 184;
    --c-slate-500: 100 116 139;
    --c-slate-600: 71 85 105;
}

:root[data-theme="light"] {
    color-scheme: light;

    /* page */
    --bg: #f5f6fa;
    --bg-canvas: #edeff5;
    --fg: #0f172a;

    /* surfaces */
    --glass-bg: rgba(255, 255, 255, 0.70);
    --glass-border: rgba(15, 23, 42, 0.08);
    --panel-bg: rgba(255, 255, 255, 0.88);
    --panel-solid: #ffffff;
    --panel-border: rgba(15, 23, 42, 0.08);
    --hover-bg: rgba(15, 23, 42, 0.05);
    --hover-border: rgba(15, 23, 42, 0.15);
    /* 浅色下阴影更轻，避免出现一块脏兮兮的灰 */
    --drawer-shadow: rgba(15, 23, 42, 0.20);
    --scrim: rgba(15, 23, 42, 0.30);

    /* canvas */
    --node-bg: rgba(255, 255, 255, 0.94);
    --node-border: rgba(15, 23, 42, 0.10);
    --node-border-hover: rgba(15, 23, 42, 0.22);
    --node-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.16);
    --port-ring: #ffffff;

    --grid-dot: rgba(15, 23, 42, 0.18);
    --grid-glow: rgba(124, 58, 237, 0.07);

    --edge: rgba(15, 23, 42, 0.28);
    --edge-hover: rgba(15, 23, 42, 0.60);
    --edge-flow: rgba(15, 23, 42, 0.85);
    --edge-temp: rgba(15, 23, 42, 0.35);

    --tooltip-bg: rgba(255, 255, 255, 0.96);
    --tooltip-border: rgba(15, 23, 42, 0.12);
    --tooltip-fg: #1e293b;

    --scrollbar: rgba(15, 23, 42, 0.15);
    --scrollbar-hover: rgba(15, 23, 42, 0.28);

    /* keep the preview screen deep & readable under the pale SVG */
    --screen-bg: rgba(15, 23, 42, 0.92);

    /* "white" flips to ink so translucent surfaces read correctly on light bg */
    --c-white: 15 23 42;
    --c-gray-300: 55 65 81;
    --c-gray-400: 71 85 105;
    --c-gray-500: 100 116 139;
    --c-gray-600: 148 163 184;
    --c-slate-200: 30 41 59;
    --c-slate-300: 51 65 85;
    --c-slate-400: 71 85 105;
    --c-slate-500: 100 116 139;
    --c-slate-600: 148 163 184;
}

/* ---------- Base ---------- */
html {
    background-color: var(--bg);
}

body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--fg);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Glass Effect - Shared across pages */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--panel-border);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.glass-hover:hover {
    background: var(--hover-bg);
    border-color: var(--hover-border);
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -10px rgba(139, 92, 246, 0.15);
}

/* Text Gradients */
.text-gradient {
    background: linear-gradient(135deg, #c4b5fd 0%, #e879f9 30%, #60a5fa 70%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-gradient-animate {
    background: linear-gradient(135deg, #a78bfa, #f472b6, #38bdf8, #a78bfa);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientMove 8s ease infinite;
}

/* Light theme needs deeper stops so gradient text stays legible */
[data-theme="light"] .text-gradient {
    background: linear-gradient(135deg, #6d28d9 0%, #db2777 45%, #2563eb 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="light"] .text-gradient-animate {
    background: linear-gradient(135deg, #7c3aed, #db2777, #2563eb, #7c3aed);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Text that must stay white because it sits on a colored/brand surface */
.text-on-accent {
    color: #ffffff;
}

@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Button Styles */
.btn-primary {
    background: linear-gradient(135deg, #7c3aed, #db2777);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #db2777, #7c3aed);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-primary:hover::before {
    opacity: 1;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -10px rgba(124, 58, 237, 0.5);
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Glow Effect */
.glow {
    box-shadow: 0 0 80px -20px rgba(139, 92, 246, 0.3);
}

/* ---------- Theme toggle ---------- */
.theme-toggle .icon-moon {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}

/* ---------- Themed popups rendered from JS ---------- */
.dropdown-panel {
    background: var(--panel-solid);
}

.dropdown-option {
    background: var(--panel-solid);
    color: var(--fg);
}

/* Always-dark preview surface (code/diagram stays light-on-dark) */
.screen-panel {
    background: var(--screen-bg);
}

/* Scroll Reveal Animation */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.delay-100 {
    transition-delay: 0.1s;
}

.delay-200 {
    transition-delay: 0.2s;
}

.delay-300 {
    transition-delay: 0.3s;
}

/* Respect users who prefer fewer animations */
@media (prefers-reduced-motion: reduce) {
    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

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

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

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

/* Selection */
::selection {
    background: rgba(139, 92, 246, 0.3);
    color: var(--fg);
}
