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

:root {
    --primary: #00d4aa;
    --primary-dark: #00a080;
    --secondary: #6366f1;
    --bg-dark: #0a0f1a;
    --bg-card: rgba(20, 30, 50, 0.8);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --gradient-1: linear-gradient(135deg, #00d4aa 0%, #6366f1 100%);
    --nav-height: 70px;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--nav-height);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.content-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding-top: var(--nav-height);
}

/* Navigation */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(10, 15, 26, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    min-height: var(--nav-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    z-index: 1001;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.3s ease;
    position: relative;
    padding: 8px 0;
}

.nav-link:hover {
    color: var(--primary);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1002;
    width: 40px;
    height: 40px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Hero Section */
.hero {
    min-height: calc(100vh - var(--nav-height));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.hero-content {
    text-align: center;
    max-width: 900px;
    width: 100%;
}

.hero-title {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 20px;
}

.gradient-text {
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--text-secondary);
    margin-bottom: 32px;
    padding: 0 10px;
}

.hero-search {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 48px;
    flex-wrap: wrap;
    padding: 0 10px;
}

.search-input {
    width: 100%;
    max-width: 400px;
    padding: 14px 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(20, 30, 50, 0.7);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease, background 0.3s ease;
    -webkit-appearance: none;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-input:focus {
    border-color: var(--primary);
    background: rgba(20, 30, 50, 0.9);
}

.search-btn {
    padding: 14px 28px;
    background: var(--gradient-1);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.search-btn:hover,
.search-btn:active {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 212, 170, 0.3);
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
    min-width: 80px;
}

.stat-number {
    display: block;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Sections */
.section {
    padding: 80px 20px;
}

.section-alt {
    background: rgba(20, 30, 50, 0.3);
}

.section-header {
    text-align: center;
    margin-bottom: 48px;
}

.section-icon {
    font-size: clamp(2rem, 5vw, 3rem);
    display: block;
    margin-bottom: 12px;
}

.section-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 12px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    padding: 0 20px;
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 10px;
}

.card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 24px;
    transition: transform 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.card:hover,
.card:active {
    transform: translateY(-6px);
    border-color: var(--primary);
}

.card-icon {
    font-size: 2.2rem;
    margin-bottom: 16px;
}

.card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.card p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.card-action {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Terminology Preview */
.term-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    max-width: 1000px;
    margin: 0 auto 32px;
    padding: 0 10px;
}

.term-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.3s ease;
    gap: 10px;
}

.term-card:hover,
.term-card:active {
    border-color: var(--primary);
}

.term-en {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.term-zh {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.section-link {
    display: block;
    text-align: center;
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    margin-top: 16px;
    padding: 10px;
}

/* Resources List */
.resource-list {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 10px;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px 20px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.resource-item:hover,
.resource-item:active {
    border-color: var(--primary);
}

.resource-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.resource-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.resource-name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.resource-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Footer */
.footer {
    padding: 40px 20px;
    background: rgba(10, 15, 26, 0.9);
    text-align: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.footer-copy {
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.footer-note {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    :root {
        --nav-height: 60px;
    }

    .nav {
        padding: 12px 16px;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        background: rgba(10, 15, 26, 0.98);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 24px;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 999;
        padding: 60px 20px;
        overflow-y: auto;
    }

    .nav-links.active {
        opacity: 1;
        visibility: visible;
    }

    .nav-link {
        font-size: 1.2rem;
        padding: 12px 24px;
    }

    .hero {
        padding: 30px 16px;
        min-height: auto;
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 24px;
    }

    .hero-search {
        flex-direction: column;
        margin-bottom: 32px;
        padding: 0;
    }

    .search-input {
        padding: 14px 18px;
    }

    .search-btn {
        width: 100%;
        padding: 14px;
    }

    .hero-stats {
        gap: 24px;
    }

    .stat-number {
        font-size: 1.6rem;
    }

    .section {
        padding: 50px 16px;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .card {
        padding: 20px;
    }

    .term-preview {
        grid-template-columns: 1fr 1fr;
    }

    .term-card {
        padding: 16px;
    }

    .term-en, .term-zh {
        font-size: 0.85rem;
    }
}

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

    .logo-text {
        font-size: 1.1rem;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .hero-stats {
        gap: 20px;
    }

    .stat {
        min-width: 70px;
    }

    .stat-number {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .card-icon {
        font-size: 1.8rem;
    }

    .card h3 {
        font-size: 1.1rem;
    }

    .term-preview {
        grid-template-columns: 1fr;
    }

    .resource-item {
        padding: 14px 16px;
    }

    .resource-icon {
        font-size: 1.5rem;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .card:hover {
        transform: none;
    }

    .card:active {
        transform: translateY(-4px);
    }

    .search-btn:hover {
        transform: none;
    }

    .search-btn:active {
        transform: translateY(-2px);
    }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 20px 16px;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .hero-subtitle {
        margin-bottom: 16px;
    }

    .hero-stats {
        margin-top: 24px;
    }

    .nav-links {
        padding: 40px 20px;
    }

    .nav-link {
        font-size: 1rem;
        padding: 8px 16px;
    }
}

/* Smooth scroll for mobile */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Better tap targets for iOS */
@media (pointer: coarse) {
    .nav-link,
    .card,
    .resource-item,
    .term-card,
    .search-btn {
        min-height: 44px;
    }
}
