/* Material You & Space-Themed Design System */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - Space Blue Theme (Light) */
    --md-ref-palette-primary40: #4F5CD9;
    --md-ref-palette-primary90: #E0E2FF;
    --md-ref-palette-secondary40: #555DA2;
    --md-ref-palette-secondary90: #E3E5FF;
    --md-ref-palette-neutral10: #1B1B1F;
    --md-ref-palette-neutral90: #E4E2E6;
    --md-ref-palette-neutral95: #F2F0F4;
    --md-ref-palette-neutral99: #FEFBFF;
    --md-ref-palette-neutral-variant30: #46464F;
    --md-ref-palette-neutral-variant90: #E4E2E6;

    /* Semantic Tokens (Light) */
    --md-sys-color-primary: #4651C4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #DEE0FF;
    --md-sys-color-on-primary-container: #000F5C;

    --md-sys-color-secondary: #5A5D72;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #DFE1F9;
    --md-sys-color-on-secondary-container: #171A2C;

    --md-sys-color-tertiary: #76546F;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #FFD7F5;
    --md-sys-color-on-tertiary-container: #2C1229;

    --md-sys-color-background: #FEFBFF;
    --md-sys-color-on-background: #1B1B1F;

    --md-sys-color-surface: #FEFBFF;
    --md-sys-color-on-surface: #1B1B1F;
    --md-sys-color-surface-variant: #E3E1EC;
    --md-sys-color-on-surface-variant: #46464F;

    --md-sys-color-outline: #767680;

    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 9999px;

    --font-family-base: 'Outfit', sans-serif;

    /* Legacy Compatibility */
    --primary: var(--md-sys-color-primary);
    --text-secondary: var(--md-sys-color-on-surface-variant);
    --text: var(--md-sys-color-on-surface);
}

[data-theme='dark'] {
    /* Color Palette - Space Blue Theme (Dark) */
    --md-sys-color-primary: #BAC3FF;
    --md-sys-color-on-primary: #081691;
    --md-sys-color-primary-container: #2C38A8;
    --md-sys-color-on-primary-container: #DEE0FF;

    --md-sys-color-secondary: #C3C5DD;
    --md-sys-color-on-secondary: #2C2F42;
    --md-sys-color-secondary-container: #424559;
    --md-sys-color-on-secondary-container: #DFE1F9;

    --md-sys-color-tertiary: #E5BAD9;
    --md-sys-color-on-tertiary: #452640;
    --md-sys-color-tertiary-container: #5D3C57;
    --md-sys-color-on-tertiary-container: #FFD7F5;

    --md-sys-color-background: #1B1B1F;
    --md-sys-color-on-background: #E4E2E6;

    --md-sys-color-surface: #1B1B1F;
    --md-sys-color-on-surface: #E4E2E6;
    --md-sys-color-surface-variant: #46464F;
    --md-sys-color-on-surface-variant: #C7C5D0;

    --md-sys-color-outline: #90909A;
}

/* Global Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    min-height: 100%;
    font-family: var(--font-family-base);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    transition: background-color 0.4s cubic-bezier(0.2, 0, 0, 1), color 0.4s cubic-bezier(0.2, 0, 0, 1);
    /* scroll-behavior: smooth; - Removed to allow instant jump on nav */
    overflow-x: hidden;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 {
    font-size: 3.5rem;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 2.5rem;
    letter-spacing: -0.015em;
}

h3 {
    font-size: 1.75rem;
}

p {
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 1rem;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center the nav-container */
    background: rgba(255, 255, 255, 0.01);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid transparent;
    z-index: 1000;
    transition: background 0.3s, border-color 0.3s;
}

/* Glassmorphism adjustment on scroll */
.navbar.scrolled {
    background: color-mix(in srgb, var(--md-sys-color-surface) 80%, transparent);
    border-bottom: 1px solid var(--md-sys-color-outline);
}

.nav-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.01em;
}

.nav-logo svg {
    color: var(--md-sys-color-primary);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.nav-link {
    color: var(--md-sys-color-on-surface-variant);
    text-decoration: none;
    font-weight: 500;
    padding: 0.75rem 1.25rem;
    border-radius: var(--md-sys-shape-corner-full);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.nav-link:hover {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
}

.nav-link.active {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    font-weight: 600;
}

/* Animations & Transitions */
.page-section {
    opacity: 0;
    filter: blur(10px);
    transform: translateY(20px);
    display: none;
    /* Controlled by JS, but we use this for state */
    transition: none;
    /* Handled by JS manual animation frames usually, but we define classes */
}

.page-section.active {
    display: block;
    animation: fadeSlideIn 0.5s cubic-bezier(0.2, 0, 0, 1) forwards;
}

@keyframes fadeSlideIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
        filter: blur(10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.page-section.exiting {
    animation: fadeSlideOut 0.4s cubic-bezier(0.2, 0, 0, 1) forwards;
    display: block;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    width: 100%;
}

@keyframes fadeSlideOut {
    0% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-20px);
        filter: blur(10px);
    }
}

/* Material Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 24px;
    border-radius: var(--md-sys-shape-corner-full);
    font-family: var(--font-family-base);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    border: none;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    text-align: center;
    line-height: normal;
    min-height: 48px;
    height: auto;
    padding: 0.5rem 1.5rem;
    /* Ensure padding for multiline */
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 92%, white);
}

.btn-secondary {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.btn-secondary:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    background-color: color-mix(in srgb, var(--md-sys-color-secondary-container) 92%, black);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--md-sys-color-outline);
    color: var(--md-sys-color-primary);
}

.btn-outline:hover {
    background-color: var(--md-sys-color-surface-variant);
    border-color: var(--md-sys-color-primary);
}

/* Cards */
.card-container,
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.products-section {
    padding: 4rem 1.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    scroll-margin-top: 80px;
    /* Offset for fixed navbar */
}

.section-header {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 3rem auto;
}

.product-card {
    background-color: var(--md-sys-color-surface-variant);
    /* Improved visibility for dark mode */
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);

    [data-theme='light'] & {
        background: linear-gradient(145deg, #ffffff, #f8f9fa);
        border: 1px solid var(--md-sys-color-outline);
        border-color: rgba(0, 0, 0, 0.05);
    }

    border-radius: var(--md-sys-shape-corner-extra-large);
    padding: 2rem;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
    border-color: var(--md-sys-color-primary);
}

.product-icon {
    width: 64px;
    height: 64px;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-radius: var(--md-sys-shape-corner-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.product-actions {
    margin-top: auto;
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Hero Section */
.hero-section {
    min-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-top: 72px;
    overflow: hidden;
}

.hero-content {
    text-align: center;
    max-width: 800px;
    padding: 2rem;
    z-index: 2;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Decorations */
.blob {
    position: absolute;
    filter: blur(80px);
    z-index: 1;
    opacity: 0.6;
    animation: blobFloat 20s infinite alternate;
}

@keyframes blobFloat {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, -30px) scale(1.1);
    }
}

/* Features */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 3rem;
}

.feature-item {
    padding: 1.5rem;
    border-radius: var(--md-sys-shape-corner-large);
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-style: dashed;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s;
}

.feature-item:hover {
    border-style: solid;
    border-color: var(--md-sys-color-primary);
    transform: scale(1.02);
}

/* Dark Mode Toggle */
#dark-mode-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

#dark-mode-toggle:hover {
    background-color: var(--md-sys-color-surface-variant);
}

#dark-mode-toggle svg {
    fill: currentColor;
    width: 24px;
    height: 24px;
}

[data-theme='light'] .cs-moon {
    display: block;
}

[data-theme='light'] .cs-sun {
    display: none;
}

[data-theme='dark'] .cs-moon {
    display: none;
}

[data-theme='dark'] .cs-sun {
    display: block;
}

/* Sections */
.about-container {
    max-width: 1000px;
    margin: 80px auto;
    padding: 0 1.5rem;
}

.about-header {
    text-align: center;
    margin-bottom: 3rem;
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    .hero-actions {
        flex-direction: column;
    }

    .nav-links {
        display: none;
        position: static;
        transform: none;
    }

    .nav-hamburger {
        display: block;
        color: var(--md-sys-color-on-background);
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
    }

    .nav-links.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 72px;
        left: 0;
        right: 0;
        background: var(--md-sys-color-surface);
        padding: 1rem;
        border-bottom: 1px solid var(--md-sys-color-outline);
        animation: slideDown 0.3s ease-out;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (min-width: 769px) {
    .nav-hamburger {
        display: none;
    }
}

/* Ripple */
.ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s linear;
    background-color: rgba(255, 255, 255, 0.3);
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Modal */
.modal {
    display: none;
    /* Hidden by default, toggled by JS */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    /* Handled by animation */
}

.modal-content {
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    padding: 2.5rem;
    border-radius: var(--md-sys-shape-corner-extra-large);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    border: 1px solid var(--md-sys-color-outline);
    position: relative;
    opacity: 0;
    /* Handled by animation */
    transform: scale(0.9);
    /* Handled by animation */
}

/* Fix for buttons in modal if needed */
#syncspace-modal-cancel.btn-outline-primary {
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-primary);
}

#syncspace-modal-cancel.btn-outline-primary:hover {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

/* Fixed Footer */
.fixed-footer {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
    border-radius: var(--md-sys-shape-corner-full);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    z-index: 100;
    border: 1px solid transparent;
}

.fixed-footer:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    background: var(--md-sys-color-surface);
    border-color: var(--md-sys-color-outline);
}

.fixed-footer svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    color: var(--md-sys-color-primary);
}

/* Mobile check for footer */
@media (max-width: 768px) {
    .fixed-footer {
        bottom: 1rem;
        right: 1rem;
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
}