/**
 * 京禾科技 - Stitch Design System Implementation
 * Based on DESIGN.md (Eco-Future Tech)
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@500;700;800&display=swap');

:root {
    /* 1. Tokens from DESIGN.md */

    /* Colors */
    --c-primary: #0B4F6C;
    --c-secondary: #01BAEF;
    --c-accent: #20BF55;
    --c-surface: #F8FAFC;
    --c-white: #ffffff;
    --c-glass: rgba(255, 255, 255, 0.85);

    --text-main: #1E293B;
    --text-muted: #64748B;
    --text-light: #94A3B8;

    /* Gradients */
    --grad-primary: linear-gradient(135deg, var(--c-primary) 0%, #004e92 100%);
    --grad-ocean: linear-gradient(135deg, var(--c-secondary) 0%, var(--c-primary) 100%);
    --grad-eco: linear-gradient(135deg, var(--c-accent) 0%, #01BAEF 100%);

    /* Typography */
    --f-heading: 'Outfit', sans-serif;
    --f-body: 'Inter', sans-serif;

    /* Spacing */
    --s-xs: 4px;
    --s-sm: 8px;
    --s-md: 16px;
    --s-lg: 24px;
    --s-xl: 32px;
    --s-2xl: 64px;
    --s-3xl: 128px;

    /* Effects */
    --r-card: 24px;
    --r-pill: 9999px;

    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    --shadow-float: 0 25px 50px -12px rgba(1, 186, 239, 0.25);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

    --trans-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Fixed Navbar Height for Anchor Offset */
    --navbar-height: 80px;
}

/* Global Anchor Scroll Offset - Prevents content from hiding behind fixed header */
html {
    scroll-padding-top: var(--navbar-height);
}

[id] {
    scroll-margin-top: var(--navbar-height);
}

/* Anchor offset for fixed navbar */
#filter {
    scroll-margin-top: 150px;
}

/* Brand tab hover effect */
.brand-tab {
    transition: all 0.2s ease;
    border-width: 2px !important;
}

.brand-tab:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 2. Reset & Scaffolding */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--f-body);
    color: var(--text-main);
    background-color: var(--c-surface);
    line-height: 1.6;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--f-heading);
    color: var(--c-primary);
    line-height: 1.1;
    font-weight: 700;
}

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

a {
    text-decoration: none;
    color: inherit;
    transition: var(--trans-base);
}

/* 3. Utility Components (Stitch Pattern) */

/* Layout */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--s-lg);
}

.section {
    padding: var(--s-3xl) 0;
    position: relative;
}

@media (max-width: 768px) {
    .section {
        padding: var(--s-xl) 0;
    }
}

/* Text */
.text-grad {
    background: var(--grad-ocean);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Header & Navigation (Stitch Design) */
.header-stitch {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    transition: var(--trans-base);
    background: var(--c-glass);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 15px 0;
}

@media (max-width: 1200px) {
    .header-stitch {
        padding: 10px 0;
    }

    .header-stitch .logo {
        flex-shrink: 0;
        /* 防止 Logo 被擠壓 */
    }

    .header-stitch .logo span {
        font-size: 1.15rem !important;
        /* 更小的 Logo 文字 */
        white-space: nowrap;
        /* 強制不換行 */
    }

    .header-stitch .logo img {
        height: 28px !important;
        /* 縮小圖示 */
    }

    .nav-item-stitch {
        padding: 0 2px !important;
        /* 最小化左右間距 */
    }

    .nav-link-stitch {
        font-size: 12px !important;
        /* 縮小到 12px */
        padding: 5px 6px !important;
        letter-spacing: -0.5px;
        /* 緊縮字距 */
    }
}

.header-stitch.scrolled {
    padding: 10px 0;
    background: var(--c-white);
    box-shadow: var(--shadow-soft);
}

.nav-item-stitch {
    position: relative;
    padding: 0 10px;
}

.nav-link-stitch {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.nav-link-stitch:hover,
.nav-link-stitch.active {
    color: var(--c-primary);
}

/* Desktop Dropdown */
.dropdown-menu-stitch {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--c-white);
    min-width: 180px;
    padding: 12px;
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.nav-item-stitch:hover .dropdown-menu-stitch,
.nav-item-stitch.show .dropdown-menu-stitch {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.dropdown-item-stitch {
    display: block;
    padding: 10px 15px;
    font-size: 14px;
    color: var(--text-muted);
    border-radius: 10px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.dropdown-item-stitch:hover {
    background: var(--c-surface);
    color: var(--c-primary);
    padding-left: 20px;
}

/* Mobile Nav */
.mobile-nav-link {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-main);
    padding: 15px 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: block;
    text-decoration: none;
}

.mobile-nav-sublink {
    font-size: 14px;
    color: var(--text-muted);
    padding: 12px 25px 12px 45px;
    display: block;
    text-decoration: none;
    transition: var(--trans-base);
}

.mobile-nav-sublink:hover {
    color: var(--c-primary);
    background: #f8f9fa;
}

.btn-menu-stitch {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--c-primary);
    padding: 0;
    display: flex;
    align-items: center;
}

/* Buttons & UI Elements */
.btn-stitch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 32px;
    font-weight: 600;
    border-radius: var(--r-pill);
    transition: var(--trans-base);
    letter-spacing: 0.5px;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--grad-ocean);
    color: white;
    box-shadow: 0 4px 15px rgba(11, 79, 108, 0.3);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(11, 79, 108, 0.4);
}

.btn-accent {
    background: var(--grad-eco);
    color: white;
    box-shadow: 0 4px 15px rgba(32, 191, 85, 0.3);
}

.btn-accent:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(32, 191, 85, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--c-primary);
    color: var(--c-primary);
}

.btn-outline:hover {
    background: var(--c-primary);
    color: white;
}

/* Cards */
.card-stitch {
    background: var(--c-white);
    border-radius: var(--r-card);
    padding: var(--s-xl);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: var(--trans-base);
    height: 100%;
}

.card-stitch:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-float);
}

.card-glass {
    background: var(--c-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-soft);
    border-radius: var(--r-card);
}

/* Header */
.header-stitch {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: var(--s-md) 0;
    transition: var(--trans-base);
}

.header-stitch.scrolled {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    box-shadow: var(--shadow-sm);
    padding: var(--s-sm) 0;
}

.nav-link {
    font-weight: 500;
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: var(--r-pill);
}

.nav-link:hover {
    color: var(--c-secondary);
    background: rgba(1, 186, 239, 0.1);
}

.nav-link.active {
    color: var(--c-primary);
    font-weight: 700;
}

/* Footer */
.footer-stitch {
    background: var(--c-primary);
    /* Deep Blue Background */
    color: white;
    /* White Text */
    padding-top: var(--s-3xl);
    padding-bottom: var(--s-xl);
    border-top-left-radius: 40px;
    border-top-right-radius: 40px;
    margin-top: var(--s-2xl);
    position: relative;
    overflow: hidden;
}

/* Animations */
.hover-scale img {
    transition: transform 0.5s ease;
}

.hover-scale:hover img {
    transform: scale(1.05);
}

/* 4. Page Specific Components */
.side-nav-modern {
    background: var(--c-white);
    border-radius: var(--r-card);
    padding: var(--s-md);
    position: sticky;
    top: 100px;
    display: flex;
    flex-direction: column;
    gap: var(--s-xs);
    z-index: 10;
}

.side-nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--r-pill);
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--trans-base);
}

.side-nav-link:hover {
    background: var(--c-surface);
    color: var(--c-primary);
    transform: translateX(4px);
}

.side-nav-link.active {
    background: var(--c-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(11, 79, 108, 0.2);
}

.side-nav-link.active i {
    color: white !important;
}

.content-card {
    background: var(--c-white);
    border-radius: var(--r-card);
    padding: var(--s-xl);
    position: relative;
    z-index: 5;
}

/* Timeline */
.timeline-modern {
    position: relative;
    border-left: 2px solid #e2e8f0;
    padding-left: 30px;
}

.timeline-item {
    position: relative;
    margin-bottom: 40px;
}

.timeline-dot {
    position: absolute;
    left: -37px;
    top: 0;
    width: 16px;
    height: 16px;
    background: var(--c-primary);
    border: 4px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--c-primary);
}

.timeline-year {
    font-family: var(--f-heading);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--c-secondary);
    margin-bottom: 8px;
}

/* Line Clamp Utilities */
.line-clamp-1,
.line-clamp-2,
.line-clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-1 {
    -webkit-line-clamp: 1;
}

.line-clamp-2 {
    -webkit-line-clamp: 2;
}

.line-clamp-3 {
    -webkit-line-clamp: 3;
}