/* TTP Tools Design System - Silicon Valley Edition */
/* Brand: Technology Transfer Platform */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Source+Sans+3:wght@400;500;600;700&family=Syne:wght@500;600;700;800&display=swap');

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */
:root {
    /* Brand Colors */
    --primary-dark: #112118;
    --secondary-dark: #1b3325;
    --mint: #9cccb0;
    --accent: #e1ff00;
    --cream: #e0dbc6;
    --light-gray: #efefef;
    --white: #ffffff;
    
    /* Regional Colors */
    --americas: #2d8a6e;
    --americas-light: #3ba884;
    --europe: #4a6fa5;
    --europe-light: #6b8fc5;
    --asia-pacific: #8b5cf6;
    --asia-pacific-light: #a78bfa;
    --science-parks: #f59e0b;
    --science-parks-light: #fbbf24;
    
    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Typography */
    --font-display: 'Syne', sans-serif;
    --font-body: 'Source Sans 3', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(17, 33, 24, 0.06);
    --shadow-md: 0 4px 24px rgba(17, 33, 24, 0.08);
    --shadow-lg: 0 12px 48px rgba(17, 33, 24, 0.12);
    --shadow-glow: 0 0 40px rgba(225, 255, 0, 0.2);
    
    /* Borders */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--primary-dark);
    background: var(--light-gray);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }
h4 { font-size: 1.125rem; }

p { margin-bottom: var(--space-md); }
p:last-child { margin-bottom: 0; }

.text-mono {
    font-family: var(--font-mono);
}

.text-muted {
    color: #666;
}

.text-accent {
    color: var(--accent);
}

/* ============================================
   NAVIGATION
   ============================================ */
.nav {
    background: var(--primary-dark);
    padding: var(--space-md) var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

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

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--white);
    text-decoration: none;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
}

.nav-brand .dot {
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.nav-links {
    display: flex;
    gap: var(--space-lg);
    list-style: none;
}

.nav-links a {
    color: var(--mint);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--transition-fast);
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width var(--transition-base);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

/* Mobile Nav Toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary-dark);
        flex-direction: column;
        padding: var(--space-lg);
        gap: var(--space-md);
    }
    .nav-links.open { display: flex; }
}

/* ============================================
   HERO SECTIONS
   ============================================ */
.hero {
    position: relative;
    padding: var(--space-3xl) var(--space-lg);
    text-align: center;
    color: var(--white);
    overflow: hidden;
}

.hero--americas {
    background: linear-gradient(135deg, var(--americas) 0%, var(--secondary-dark) 100%);
}

.hero--europe {
    background: linear-gradient(135deg, var(--europe) 0%, var(--secondary-dark) 100%);
}

.hero--asia-pacific {
    background: linear-gradient(135deg, var(--asia-pacific) 0%, var(--secondary-dark) 100%);
}

.hero--science-parks {
    background: linear-gradient(135deg, var(--science-parks) 0%, var(--secondary-dark) 100%);
}

/* Noise texture overlay */
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
}

/* Floating geometric shapes */
.hero::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(225, 255, 0, 0.1) 0%, transparent 70%);
    right: -100px;
    top: 50%;
    transform: translateY(-50%);
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    50% { transform: translateY(-50%) translateX(-20px); }
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    margin-bottom: var(--space-md);
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
}

.hero p {
    font-size: 1.15rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-xl);
    font-size: 0.85rem;
    margin-bottom: var(--space-lg);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ============================================
   STAT CARDS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin: calc(var(--space-xl) * -1) auto var(--space-xl);
    position: relative;
    z-index: 10;
    padding: 0 var(--space-lg);
    max-width: 1000px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    text-align: center;
    box-shadow: var(--shadow-md);
    border-top: 3px solid var(--accent);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    opacity: 0;
    transform: translateY(20px);
}

.stat-card.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}

.stat-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.stat-card .value {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--secondary-dark);
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.stat-card .label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.stat-card .trend {
    font-size: 0.75rem;
    margin-top: var(--space-xs);
}

.trend-up { color: var(--success); }
.trend-down { color: var(--error); }
.trend-stable { color: var(--warning); }

/* Regional color variants */
.stat-card--americas { border-top-color: var(--americas); }
.stat-card--europe { border-top-color: var(--europe); }
.stat-card--asia-pacific { border-top-color: var(--asia-pacific); }
.stat-card--science-parks { border-top-color: var(--science-parks); }

/* ============================================
   CONTENT SECTIONS
   ============================================ */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--light-gray);
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ============================================
   TAB NAVIGATION
   ============================================ */
.tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: var(--space-sm);
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    padding: var(--space-sm) var(--space-md);
    color: #666;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color var(--transition-fast);
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: calc(var(--space-sm) * -1 - 2px);
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform var(--transition-base);
}

.tab-btn:hover {
    color: var(--primary-dark);
}

.tab-btn.active {
    color: var(--primary-dark);
}

.tab-btn.active::after {
    transform: scaleX(1);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ============================================
   COUNTRY CARDS
   ============================================ */
.country-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.country-card {
    background: var(--light-gray);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.country-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.country-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--secondary-dark);
    color: var(--white);
}

.country-card-header .flag {
    font-size: 2rem;
}

.country-card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.country-card-header .source {
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.7;
}

.country-card-body {
    padding: var(--space-lg);
}

.mini-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.mini-stat {
    background: var(--white);
    padding: var(--space-sm) var(--space-xs);
    border-radius: var(--radius-sm);
    text-align: center;
}

.mini-stat .value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--secondary-dark);
}

.mini-stat .label {
    font-size: 0.65rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Ratio Bar */
.ratio-bar {
    margin-top: var(--space-md);
}

.ratio-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: var(--space-xs);
    color: #666;
}

.ratio-bar-track {
    height: 8px;
    background: var(--cream);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
}

.ratio-bar-fill {
    height: 100%;
    transition: width 1s ease;
}

.ratio-bar-fill--resident {
    background: var(--accent);
}

.ratio-bar-fill--nonresident {
    background: var(--mint);
}

/* Key Points List */
.key-points {
    list-style: none;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--cream);
}

.key-points li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
    font-size: 0.9rem;
}

.key-points li::before {
    content: '→';
    color: var(--accent);
    font-weight: bold;
}

/* ============================================
   DATA TABLES
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    margin: var(--space-lg) 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    background: var(--secondary-dark);
    color: var(--white);
    font-family: var(--font-display);
    font-weight: 600;
    padding: var(--space-md);
    text-align: left;
    white-space: nowrap;
}

thead th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

thead th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

tbody td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--cream);
}

tbody tr:hover {
    background: var(--light-gray);
}

tbody tr:last-child td {
    border-bottom: none;
}

.table-value {
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ============================================
   INSIGHT BOXES
   ============================================ */
.insight-box {
    background: linear-gradient(135deg, rgba(225, 255, 0, 0.08), rgba(156, 204, 176, 0.08));
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: var(--space-lg);
    margin: var(--space-lg) 0;
}

.insight-box strong {
    color: var(--secondary-dark);
    font-weight: 700;
}

/* ============================================
   CTA SECTION
   ============================================ */
.cta-section {
    background: var(--secondary-dark);
    color: var(--white);
    padding: var(--space-2xl);
    border-radius: var(--radius-lg);
    text-align: center;
    margin: var(--space-xl) 0;
    position: relative;
    overflow: hidden;
}

.cta-section::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(225, 255, 0, 0.15) 0%, transparent 70%);
    top: -150px;
    right: -150px;
}

.cta-section h2 {
    margin-bottom: var(--space-sm);
}

.cta-section p {
    opacity: 0.9;
    margin-bottom: var(--space-lg);
}

.btn-group {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    border: none;
    cursor: pointer;
}

.btn--primary {
    background: var(--accent);
    color: var(--primary-dark);
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(225, 255, 0, 0.3);
}

.btn--outline {
    background: transparent;
    color: var(--white);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn--outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

/* ============================================
   SOURCES / FOOTER
   ============================================ */
.sources-section {
    background: var(--cream);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-top: var(--space-xl);
}

.sources-section h3 {
    margin-bottom: var(--space-md);
    font-size: 1rem;
}

.sources-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-sm);
}

.sources-list li {
    padding: var(--space-sm) 0;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(17, 33, 24, 0.1);
}

.sources-list a {
    color: var(--secondary-dark);
    text-decoration: none;
    font-weight: 600;
}

.sources-list a:hover {
    color: var(--americas);
    text-decoration: underline;
}

.footer {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: #666;
    font-size: 0.85rem;
}

.footer a {
    color: var(--secondary-dark);
    text-decoration: none;
}

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

.footer-links {
    margin-top: var(--space-md);
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Stagger animations */
.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }
.stat-card:nth-child(5) { animation-delay: 0.5s; }

.country-card {
    opacity: 0;
    transform: translateY(20px);
}

.country-card.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-lg { margin-top: var(--space-lg); }
.mb-lg { margin-bottom: var(--space-lg); }
