/* ============================================
   BSG Design System - Laboratory Precision
   A refined biotech aesthetic
   ============================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Fraunces:ital,opsz,wght@0,9..144,100..900;1,9..144,100..900&display=swap');

/* ============================================
   Design Tokens
   ============================================ */
:root {
    /* ---- Color Palette ---- */
    --bsg-forest: #0D3B29;
    --bsg-forest-light: #1A5C40;
    --bsg-forest-dark: #082619;
    --bsg-sage: #2D5A47;

    --bsg-cream: #FAF6F1;
    --bsg-cream-dark: #F0EBE3;
    --bsg-white: #FFFFFF;
    --bsg-ivory: #FFFEF9;

    --bsg-amber: #D4A84B;
    --bsg-amber-light: #E8C06A;
    --bsg-amber-dark: #B8923D;

    --bsg-charcoal: #1A1A1A;
    --bsg-graphite: #2E2E2E;
    --bsg-slate: #5A5A5A;
    --bsg-stone: #8A8A8A;
    --bsg-silver: #C4C4C4;
    --bsg-mist: #E8E8E8;

    --bsg-success: #22A06B;
    --bsg-warning: #E5A324;
    --bsg-error: #CA3521;
    --bsg-info: #1E88E5;

    /* ---- Typography ---- */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Font Sizes - Fluid typography */
    --text-xs: clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);
    --text-sm: clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
    --text-base: clamp(0.95rem, 0.9rem + 0.25vw, 1rem);
    --text-lg: clamp(1.05rem, 1rem + 0.25vw, 1.125rem);
    --text-xl: clamp(1.2rem, 1.1rem + 0.5vw, 1.25rem);
    --text-2xl: clamp(1.4rem, 1.25rem + 0.75vw, 1.5rem);
    --text-3xl: clamp(1.75rem, 1.5rem + 1.25vw, 1.875rem);
    --text-4xl: clamp(2rem, 1.5rem + 2.5vw, 2.5rem);
    --text-5xl: clamp(2.5rem, 2rem + 2.5vw, 3rem);
    --text-6xl: clamp(3rem, 2.5rem + 2.5vw, 4rem);

    /* ---- Spacing ---- */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    --space-4xl: 6rem;
    --space-5xl: 8rem;

    /* ---- Border Radius ---- */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-3xl: 32px;
    --radius-full: 9999px;

    /* ---- Shadows ---- */
    --shadow-xs: 0 1px 2px rgba(13, 59, 41, 0.04);
    --shadow-sm: 0 2px 4px rgba(13, 59, 41, 0.06), 0 1px 2px rgba(13, 59, 41, 0.04);
    --shadow-md: 0 4px 12px rgba(13, 59, 41, 0.08), 0 2px 4px rgba(13, 59, 41, 0.04);
    --shadow-lg: 0 8px 24px rgba(13, 59, 41, 0.10), 0 4px 8px rgba(13, 59, 41, 0.06);
    --shadow-xl: 0 16px 48px rgba(13, 59, 41, 0.12), 0 8px 16px rgba(13, 59, 41, 0.08);
    --shadow-inner: inset 0 2px 4px rgba(13, 59, 41, 0.06);
    --shadow-glow: 0 0 24px rgba(212, 168, 75, 0.3);

    /* ---- Transitions ---- */
    --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-base: 250ms;
    --duration-slow: 400ms;
    --duration-slower: 600ms;

    /* ---- Z-Index Scale ---- */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-toast: 600;
    --z-tooltip: 700;
}

/* ============================================
   Base Styles
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--bsg-charcoal);
    background-color: var(--bsg-cream);
}

/* ---- Noise/Grain Texture Overlay ---- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.015;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 500;
    line-height: 1.2;
    margin: 0 0 var(--space-md) 0;
    color: var(--bsg-forest);
    letter-spacing: -0.02em;
}

h1 { font-size: var(--text-6xl); font-weight: 400; }
h2 { font-size: var(--text-5xl); font-weight: 400; }
h3 { font-size: var(--text-4xl); }
h4 { font-size: var(--text-3xl); }
h5 { font-size: var(--text-2xl); }
h6 { font-size: var(--text-xl); font-weight: 600; }

p {
    margin: 0 0 var(--space-md) 0;
    color: var(--bsg-graphite);
}

.text-display {
    font-family: var(--font-display);
    font-size: var(--text-6xl);
    font-weight: 300;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.text-lead {
    font-size: var(--text-xl);
    line-height: 1.7;
    color: var(--bsg-slate);
}

.text-small {
    font-size: var(--text-sm);
}

.text-caption {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--bsg-amber-dark);
}

/* ---- Links ---- */
a {
    color: var(--bsg-forest);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
    color: var(--bsg-amber-dark);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left var(--duration-slow) var(--ease-out);
}

.btn:hover::before {
    left: 100%;
}

/* Primary Button */
.btn-primary {
    background: var(--bsg-forest);
    color: var(--bsg-white);
    box-shadow: var(--shadow-md), 0 2px 0 var(--bsg-forest-dark);
}

.btn-primary:hover {
    background: var(--bsg-forest-light);
    color: var(--bsg-white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 4px 0 var(--bsg-forest-dark);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm), 0 1px 0 var(--bsg-forest-dark);
}

/* Secondary Button */
.btn-secondary {
    background: transparent;
    color: var(--bsg-forest);
    border: 2px solid var(--bsg-forest);
}

.btn-secondary:hover {
    background: var(--bsg-forest);
    color: var(--bsg-white);
    transform: translateY(-2px);
}

/* Accent Button */
.btn-accent {
    background: linear-gradient(135deg, var(--bsg-amber) 0%, var(--bsg-amber-dark) 100%);
    color: var(--bsg-forest-dark);
    box-shadow: var(--shadow-md), 0 2px 0 var(--bsg-amber-dark);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    color: var(--bsg-forest-dark);
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: var(--bsg-forest);
    padding: var(--space-sm) var(--space-md);
}

.btn-ghost:hover {
    background: rgba(13, 59, 41, 0.06);
    color: var(--bsg-forest);
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--text-sm);
}

.btn-lg {
    padding: var(--space-lg) var(--space-2xl);
    font-size: var(--text-lg);
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--bsg-graphite);
}

.form-input {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--bsg-charcoal);
    background: var(--bsg-white);
    border: 2px solid var(--bsg-mist);
    border-radius: var(--radius-lg);
    outline: none;
    transition: all var(--duration-fast) var(--ease-out);
}

.form-input::placeholder {
    color: var(--bsg-stone);
}

.form-input:hover {
    border-color: var(--bsg-silver);
}

.form-input:focus {
    border-color: var(--bsg-forest);
    box-shadow: 0 0 0 4px rgba(13, 59, 41, 0.1);
}

.form-hint {
    margin-top: var(--space-xs);
    font-size: var(--text-sm);
    color: var(--bsg-slate);
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bsg-white);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all var(--duration-base) var(--ease-out);
}

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

.card-padded {
    padding: var(--space-2xl);
}

.card-header {
    padding: var(--space-xl) var(--space-2xl);
    background: linear-gradient(135deg, var(--bsg-forest) 0%, var(--bsg-sage) 100%);
    color: var(--bsg-white);
}

.card-header * {
    color: var(--bsg-white);
}

.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5,
.card-header h6,
.card-header p,
.card-header span,
.card-header .card-title {
    color: var(--bsg-white);
}

.card-body {
    padding: var(--space-2xl);
}

.card-footer {
    padding: var(--space-lg) var(--space-2xl);
    background: var(--bsg-cream);
    border-top: 1px solid var(--bsg-mist);
}

/* Glass Card */
.card-glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* ============================================
   Navigation
   ============================================ */
.nav {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}

.nav-link {
    position: relative;
    padding: var(--space-sm) 0;
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--bsg-graphite);
    transition: color var(--duration-fast) var(--ease-out);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--bsg-amber);
    transition: width var(--duration-base) var(--ease-out);
}

.nav-link:hover,
.nav-link.active {
    color: var(--bsg-forest);
}

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

/* ============================================
   Badges & Tags
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-full);
}

.badge-primary {
    background: var(--bsg-forest);
    color: var(--bsg-white);
}

.badge-amber {
    background: var(--bsg-amber);
    color: var(--bsg-forest-dark);
}

.badge-outline {
    background: transparent;
    border: 1px solid var(--bsg-forest);
    color: var(--bsg-forest);
}

/* ============================================
   Layout Utilities
   ============================================ */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-xl);
}

.container-narrow {
    max-width: 800px;
}

.container-wide {
    max-width: 1440px;
}

.section {
    padding: var(--space-5xl) 0;
}

.section-sm {
    padding: var(--space-3xl) 0;
}

/* Grid */
.grid {
    display: grid;
    gap: var(--space-xl);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Flex Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* ============================================
   Decorative Elements
   ============================================ */

/* Dot Grid Pattern */
.bg-dots {
    background-image: radial-gradient(var(--bsg-mist) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Gradient Backgrounds */
.bg-gradient-forest {
    background: linear-gradient(135deg, var(--bsg-forest) 0%, var(--bsg-sage) 100%);
    color: var(--bsg-white);
}

/* Solid Forest Background */
.bg-forest {
    background: var(--bsg-forest);
    color: var(--bsg-white);
}

.bg-gradient-cream {
    background: linear-gradient(180deg, var(--bsg-cream) 0%, var(--bsg-white) 100%);
}

.bg-gradient-amber {
    background: linear-gradient(135deg, var(--bsg-amber-light) 0%, var(--bsg-amber) 100%);
}

/* Decorative Blob */
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.4;
    z-index: -1;
}

.blob-forest {
    background: var(--bsg-forest-light);
}

.blob-amber {
    background: var(--bsg-amber);
}

/* Molecule Pattern */
.molecule-decoration {
    position: absolute;
    width: 200px;
    height: 200px;
    opacity: 0.1;
    background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='50' cy='50' r='8' fill='%230D3B29'/%3E%3Ccircle cx='150' cy='50' r='12' fill='%230D3B29'/%3E%3Ccircle cx='100' cy='100' r='10' fill='%230D3B29'/%3E%3Ccircle cx='50' cy='150' r='6' fill='%230D3B29'/%3E%3Ccircle cx='150' cy='150' r='8' fill='%230D3B29'/%3E%3Cline x1='50' y1='50' x2='100' y2='100' stroke='%230D3B29' stroke-width='2'/%3E%3Cline x1='150' y1='50' x2='100' y2='100' stroke='%230D3B29' stroke-width='2'/%3E%3Cline x1='100' y1='100' x2='50' y2='150' stroke='%230D3B29' stroke-width='2'/%3E%3Cline x1='100' y1='100' x2='150' y2='150' stroke='%230D3B29' stroke-width='2'/%3E%3C/svg%3E");
}

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

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Animation Utilities */
.animate-fadeInUp {
    animation: fadeInUp var(--duration-slow) var(--ease-out) forwards;
}

.animate-fadeIn {
    animation: fadeIn var(--duration-slow) var(--ease-out) forwards;
}

.animate-slideInLeft {
    animation: slideInLeft var(--duration-slow) var(--ease-out) forwards;
}

.animate-slideInRight {
    animation: slideInRight var(--duration-slow) var(--ease-out) forwards;
}

/* Staggered Delays */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }

/* ============================================
   Loading States
   ============================================ */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--bsg-mist);
    border-top-color: var(--bsg-forest);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.skeleton {
    background: linear-gradient(90deg, var(--bsg-mist) 25%, var(--bsg-cream-dark) 50%, var(--bsg-mist) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   Alerts & Messages
   ============================================ */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
}

.alert-success {
    background: rgba(34, 160, 107, 0.1);
    border: 1px solid rgba(34, 160, 107, 0.3);
    color: var(--bsg-success);
}

.alert-error {
    background: rgba(202, 53, 33, 0.1);
    border: 1px solid rgba(202, 53, 33, 0.3);
    color: var(--bsg-error);
}

.alert-warning {
    background: rgba(229, 163, 36, 0.1);
    border: 1px solid rgba(229, 163, 36, 0.3);
    color: var(--bsg-warning);
}

.alert-info {
    background: rgba(30, 136, 229, 0.1);
    border: 1px solid rgba(30, 136, 229, 0.3);
    color: var(--bsg-info);
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bsg-cream);
}

::-webkit-scrollbar-thumb {
    background: var(--bsg-silver);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bsg-stone);
}

/* ============================================
   Selection Styling
   ============================================ */
::selection {
    background: var(--bsg-amber);
    color: var(--bsg-forest-dark);
}

/* ============================================
   Focus Styles (Accessibility)
   ============================================ */
:focus-visible {
    outline: 2px solid var(--bsg-amber);
    outline-offset: 2px;
}

/* ============================================
   Responsive Typography
   ============================================ */
@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    .section {
        padding: var(--space-3xl) 0;
    }

    .container {
        padding: 0 var(--space-lg);
    }
}
