/* ============================================================
   OpenTCAD — Shared Stylesheet
   Light theme, engineering SaaS aesthetic (SimScale-inspired)
   ============================================================ */

/* —— Google Fonts loaded in HTML <head>:
   DM Sans (300,400,500,600,700) + JetBrains Mono (400,500,600)
   —— */

:root {
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f7f8fa;
    --bg-tertiary: #eef1f6;
    --bg-card: #ffffff;
    --bg-card-hover: #f7f8fa;
    --bg-nav: rgba(255, 255, 255, 0.92);
    --bg-code: #f4f5f7;
    --bg-dark: #0f1729;

    /* Text */
    --text-primary: #1a1f36;
    --text-secondary: #4e5a6e;
    --text-muted: #8d95a3;
    --text-on-dark: #ffffff;
    --text-on-accent: #ffffff;

    /* Accent — SimScale-style blue */
    --accent: #0066ff;
    --accent-hover: #0052cc;
    --accent-light: #e8f0ff;
    --accent-subtle: rgba(0, 102, 255, 0.06);

    /* Semantic colors */
    --green: #00a878;
    --green-light: #e6f7f2;
    --amber: #e5920a;
    --red: #e5352b;

    /* Borders */
    --border: #e2e5eb;
    --border-light: #eef1f6;
    --border-accent: rgba(0, 102, 255, 0.2);

    /* Radii */
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
    --shadow-nav: 0 1px 0 rgba(0, 0, 0, 0.06);

    /* Sizing */
    --nav-height: 60px;
    --max-width: 1120px;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

code, pre {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ============================================================
   Navigation
   ============================================================ */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--nav-height);
    background: var(--bg-nav);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-nav);
    display: flex;
    align-items: center;
    padding: 0 2rem;
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
}

.nav-logo {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.nav-logo .logo-accent {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.nav-links a.active {
    color: var(--accent);
    background: var(--accent-light);
}

/* Tab separator (Workspace nav — before Docs) */
.nav-tab-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.25rem;
    list-style: none;
}

/* Project name badge (Workspace nav) */
.nav-project-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-light);
    padding: 0.25rem 0.65rem;
    border-radius: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Auth button in nav */
.nav-auth-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.nav-auth-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-sm);
}

.nav-auth-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* User avatar when signed in */
.nav-user {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem 0.3rem 0.3rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.15s;
}

.nav-user:hover {
    border-color: var(--border-accent);
}

.nav-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
}

/* User dropdown */
.nav-user-dropdown {
    position: absolute;
    top: calc(var(--nav-height) - 4px);
    right: 2rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    min-width: 180px;
    display: none;
    z-index: 1001;
}

.nav-user-dropdown.show {
    display: block;
}

.nav-user-dropdown a,
.nav-user-dropdown button {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.nav-user-dropdown a:hover,
.nav-user-dropdown button:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.nav-user-dropdown .dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0.4rem 0;
}

/* Hamburger menu (mobile) */
.nav-hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    cursor: pointer;
    background: none;
    border: none;
}

.nav-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: transform 0.2s;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: 0 1px 3px rgba(0, 102, 255, 0.2);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 8px rgba(0, 102, 255, 0.25);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--border-accent);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.45rem 1rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.8rem 2rem;
    font-size: 1rem;
    border-radius: var(--radius);
}

/* ============================================================
   Section layout
   ============================================================ */
.section {
    padding: 5rem 2rem;
    max-width: var(--max-width);
    margin: 0 auto;
}

.section-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.section-title {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

.section-desc {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 560px;
    font-weight: 400;
    line-height: 1.65;
    margin-bottom: 2.5rem;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-card);
}

.card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.footer a {
    color: var(--text-secondary);
    transition: color 0.15s;
}

.footer a:hover {
    color: var(--accent);
}

/* ============================================================
   Utility classes
   ============================================================ */
.mono {
    font-family: 'JetBrains Mono', monospace;
}

.text-center {
    text-align: center;
}

.bg-secondary {
    background: var(--bg-secondary);
}

/* Spacer for fixed nav */
.nav-spacer {
    height: var(--nav-height);
}

/* ============================================================
   Code block
   ============================================================ */
.code-inline {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    background: var(--bg-code);
    color: var(--accent);
    padding: 0.15em 0.45em;
    border-radius: 4px;
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.anim-fade-up {
    animation: fadeInUp 0.5s ease both;
}

.anim-fade-up-d1 { animation-delay: 0.1s; }
.anim-fade-up-d2 { animation-delay: 0.2s; }
.anim-fade-up-d3 { animation-delay: 0.3s; }
.anim-fade-up-d4 { animation-delay: 0.4s; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .nav {
        padding: 0 1.25rem;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border);
        padding: 0.5rem;
        box-shadow: var(--shadow-md);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        padding: 0.7rem 1rem;
    }

    .nav-hamburger {
        display: flex;
    }

    .section {
        padding: 3.5rem 1.25rem;
    }

    .section-title {
        font-size: clamp(1.4rem, 5vw, 1.8rem);
    }
}

@media (max-width: 480px) {
    :root {
        --nav-height: 54px;
    }

    html {
        font-size: 15px;
    }
}
