/* --- DESIGN SYSTEM --- */
:root {
    /* Light Mode Variables (Default) */
    --bg-body: #ffffff;
    --bg-card: #f9fafb;
    --bg-card-hover: #f3f4f6;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --accent: #0070f3;
    /* Professional Blue */
    --accent-glow: rgba(0, 112, 243, 0.15);
    --danger: #ef4444;
    --success: #10b981;

    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --max-width: 850px;
    --radius: 12px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Mode (System Preference) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #000000;
        --bg-card: #111111;
        --bg-card-hover: #1a1a1a;
        --text-main: #ededed;
        --text-muted: #a1a1a1;
        --border: #333333;
        --accent: #3291ff;
        --accent-glow: rgba(50, 145, 255, 0.2);
    }
}

/* Manual Theme Overrides */
[data-theme="light"] {
    --bg-body: #ffffff;
    --bg-card: #f9fafb;
    --bg-card-hover: #f3f4f6;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --accent: #0070f3;
    --accent-glow: rgba(0, 112, 243, 0.15);
}

[data-theme="dark"] {
    --bg-body: #000000;
    --bg-card: #111111;
    --bg-card-hover: #1a1a1a;
    --text-main: #ededed;
    --text-muted: #a1a1a1;
    --border: #333333;
    --accent: #3291ff;
    --accent-glow: rgba(50, 145, 255, 0.2);
}

/* Theme Toggle Button */
#theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s var(--ease);
    margin-left: 16px;
}

#theme-toggle:hover {
    background: var(--bg-card-hover);
    transform: scale(1.05);
}

/* --- GLOBAL RESET --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-stack);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-y: scroll;
    /* Prevent layout shift */
    transition: background 0.3s ease, color 0.3s ease;
}

a {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

a.link-accent {
    color: var(--accent);
    font-weight: 500;
}

a.link-accent:hover {
    text-decoration: underline;
}

/* --- LAYOUT WRAPPER --- */
.wrapper {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- NAVIGATION --- */
header {
    padding: 40px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#nav-toggle {
    display: none;
}

.brand {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
}

nav {
    display: flex;
    gap: 24px;
    background: var(--bg-card);
    padding: 8px 20px;
    border-radius: 99px;
    border: 1px solid var(--border);
}

.nav-item {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    position: relative;
}

.nav-item:hover {
    color: var(--text-main);
}

.nav-item.active {
    color: var(--text-main);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
}

/* --- TYPOGRAPHY --- */
h1 {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: 24px;
    line-height: 1.1;
}

h2 {
    margin: 40px 0 16px 0;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
}

h3 {
    margin: 24px 0 8px 0;
    font-size: 1.1rem;
}

p,
li {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 16px;
}

ul {
    margin-left: 20px;
    margin-bottom: 24px;
}

/* --- CARDS & GRID --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 32px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.3s var(--ease);
    display: flex;
    flex-direction: column;
    height: 100%;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-4px);
    background: var(--bg-card-hover);
    border-color: var(--accent);
    box-shadow: 0 12px 32px var(--accent-glow);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
    background: var(--bg-body);
    border: 1px solid var(--border);
}

.card h3 {
    margin: 0 0 8px 0;
    color: var(--text-main);
}

.card p {
    font-size: 0.95rem;
    flex: 1;
    margin-bottom: 16px;
}

.card-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- DEMO APP SPECIFIC --- */
.app-showcase {
    display: flex;
    gap: 20px;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.app-logo {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--accent), #9b51e0);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.app-details h3 {
    margin-top: 0;
}

.download-badge {
    display: inline-flex;
    align-items: center;
    background: var(--text-main);
    color: var(--bg-body);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 8px;
}

/* --- FOOTER --- */
footer {
    margin-top: 60px;
    padding: 40px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- UTILS --- */
.status-dot {
    height: 8px;
    width: 8px;
    background-color: var(--success);
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

/* --- ANIMATIONS --- */
.fade-in {
    animation: fadeIn 0.4s var(--ease);
}

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

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

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 640px) {

    /* Layout Wrapper */
    .wrapper {
        padding: 0 16px;
    }

    /* Header & Navigation */
    header {
        position: relative;
        flex-direction: row;
        /* Keep row to align Brand + Toggle + Menu Button */
        flex-wrap: wrap;
        /* Allow nav to break to new line */
        align-items: center;
        gap: 0;
        padding: 24px 0;
    }

    .brand {
        flex: 1;
        margin-bottom: 0;
    }

    /* Hamburger Button (Default Hidden on Desktop, Visible here) */
    #nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: 1px solid var(--border);
        color: var(--text-main);
        width: 40px;
        height: 40px;
        border-radius: 8px;
        font-size: 1.5rem;
        cursor: pointer;
        margin-left: 12px;
        z-index: 20;
        /* Above nav drawer */
    }

    /* Theme Toggle Position */
    #theme-toggle {
        position: static;
        /* Reset absolute */
        margin-left: auto;
        /* Push to right */
        width: 40px;
        height: 40px;
    }

    /* Nav Drawer */
    nav {
        display: none;
        /* Hidden by default on mobile */
        width: 100%;
        flex-direction: column;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 16px;
        gap: 8px;
        margin-top: 16px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        order: 3;
        /* Force to bottom of header */

        /* Animation */
        transform-origin: top;
        animation: slideDown 0.2s var(--ease);
    }

    nav.active {
        display: flex;
    }

    /* Reset scroll/overflow from previous iteration */
    nav {
        overflow-x: visible;
        overflow-y: visible;
        scrollbar-width: auto;
    }

    .nav-item {
        font-size: 1.1rem;
        padding: 12px 16px;
        border-radius: 8px;
        width: 100%;
        display: block;
        white-space: normal;
    }

    .nav-item:hover,
    .nav-item.active {
        background: var(--bg-card-hover);
    }

    .nav-item.active::after {
        display: none;
        /* Remove dot indicator */
    }

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

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

    /* Type Adjustments */
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    /* Grid */
    .grid {
        grid-template-columns: 1fr;
        /* Force single column */
        gap: 16px;
    }

    /* App Showcase */
    .app-showcase {
        flex-direction: column;
        text-align: center;
        padding: 24px 16px;
    }

    .app-logo {
        margin: 0 auto;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    }

    .app-details {
        width: 100%;
    }

    .app-details div {
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Footer */
    footer div {
        flex-wrap: wrap;
    }
}