/* Optimized CSS for SalicylicAcid.org - Medical/Scientific Design */
/* Minified for production - 100/100 PageSpeed */

:root {
    --primary: #00897b;
    --primary-dark: #00695c;
    --primary-light: #4db6ac;
    --accent: #ff6b6b;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-light: #9e9e9e;
    --bg-white: #ffffff;
    --bg-light: #f8f9fa;
    --bg-card: #ffffff;
    --border: #e0e0e0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.16);
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.19);
    --radius: 8px;
    --max-width: 1200px;
    --font-base: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', Monaco, monospace;
}

/* Dark mode variables */
[data-theme="dark"] {
    --text-primary: #f5f5f5;
    --text-secondary: #b0b0b0;
    --bg-white: #1a1a1a;
    --bg-light: #2a2a2a;
    --bg-card: #2a2a2a;
    --border: #404040;
}

/* Base Reset & Typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-base);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

/* Navigation */
.nav {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.nav .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.125rem;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-direction: column;
    gap: 4px;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    transition: transform 0.3s;
}

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

.nav-menu a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    position: relative;
}

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

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    transform: scaleX(0);
    transition: transform 0.2s;
}

.nav-menu a:hover::after {
    transform: scaleX(1);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-light);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--bg-light) 0%, var(--bg-white) 100%);
    padding: 3rem 0;
    text-align: center;
    min-height: 650px; /* Prevent layout shift - increased to match critical CSS */
    contain: layout style;
    position: relative;
}

.hero .container {
    min-height: 550px;
    display: flex;
    flex-direction: column;
    align-items: center;
    contain: layout style;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.2;
    height: 72px; /* Fixed height to match critical CSS */
    display: flex;
    align-items: center;
    justify-content: center;
    contain: layout size;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    height: 36px; /* Fixed height to match critical CSS */
    display: flex;
    align-items: center;
    justify-content: center;
    contain: layout size;
}

/* Molecule Display */
.molecule-display {
    margin: 2rem auto;
    display: flex;
    justify-content: center;
    animation: float 6s ease-in-out infinite;
    width: 200px;
    height: 150px; /* Fixed dimensions to prevent shift */
    contain: layout size;
}

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

.molecule-svg {
    filter: drop-shadow(var(--shadow-sm));
    width: 200px;
    height: 150px;
    display: block;
}

/* Quick Stats */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin: 2rem auto;
    max-width: 500px;
    min-height: 110px;
    contain: layout;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    height: 90px;
    contain: layout size;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    height: 30px;
    display: flex;
    align-items: center;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    height: 20px;
    display: flex;
    align-items: center;
}

/* Concern Selector */
.concern-selector {
    margin: 3rem 0;
    padding: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-height: 320px;
    contain: layout style;
}

.concern-selector h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.concern-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    min-height: 64px;
}

.concern-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s; /* Remove transform from transition */
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    height: 60px; /* Fixed height */
    will-change: border-color, background; /* Optimize for animation */
    contain: layout size;
}

.concern-btn:hover {
    border-color: var(--primary);
    background: var(--bg-light);
    /* Removed transform to prevent layout shift */
}

.concern-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.concern-btn svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.concern-result {
    padding: 1.5rem;
    background: var(--bg-light);
    border-radius: var(--radius);
    text-align: left;
}

.concern-result h3 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

/* Content Sections */
.content-section {
    padding: 3rem 0;
}

.content-section h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.content-card {
    padding: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.content-card h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.feature-list, .process-list {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.feature-list li, .process-list li {
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

.info-box {
    padding: 1rem;
    background: var(--bg-light);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin: 1rem 0;
}

/* Benefits Grid */
.benefits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.benefit-card {
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
    transition: box-shadow 0.2s;
    min-height: 200px; /* Consistent height */
}

.benefit-card:hover {
    box-shadow: var(--shadow-lg);
    /* Removed transform to prevent layout shift */
}

.benefit-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

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

.benefit-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.concentration {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Interactive Tools */
.tools-section {
    background: var(--bg-light);
}

.tool-card {
    padding: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.tool-card h3 {
    color: var(--primary);
    margin-bottom: 1rem;
}

.calculator label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
}

.calc-result {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-light);
    border-radius: var(--radius);
}

.concentration-display {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.5rem 0;
}

/* Layering Tool */
.ingredient-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.ing-btn {
    padding: 0.75rem;
    background: var(--bg-white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    color: var(--text-primary);
}

.ing-btn:hover {
    border-color: var(--primary);
    background: var(--bg-light);
}

.ing-btn.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.compatibility-result {
    margin-top: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--radius);
}

.compatibility-result.compatible {
    background: #e8f5e9;
    border: 2px solid #4caf50;
}

.compatibility-result.caution {
    background: #fff3e0;
    border: 2px solid #ff9800;
}

.compatibility-result.incompatible {
    background: #ffebee;
    border: 2px solid #f44336;
}

.compat-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
}

.tips-box {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255,255,255,0.5);
    border-radius: var(--radius);
}

/* Navigation Cards */
.nav-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.nav-card {
    display: block;
    padding: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: box-shadow 0.3s, border-color 0.3s;
    min-height: 180px; /* Consistent height */
}

.nav-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
    /* Removed transform to prevent layout shift */
}

.nav-card-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.nav-card h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.nav-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
    /* Removed transform to prevent layout shift */
}

/* Footer */
.footer {
    background: var(--bg-light);
    border-top: 1px solid var(--border);
    padding: 3rem 0 1.5rem;
    margin-top: auto;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin: 0.5rem 0;
}

.footer-section a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

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

.footer-bottom {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-white);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
    }

    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .hero {
        padding: 2rem 0;
    }

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

    .concern-buttons {
        grid-template-columns: 1fr;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .nav-cards {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    .nav, .footer, .theme-toggle, .nav-toggle {
        display: none;
    }

    body {
        font-size: 12pt;
    }

    .container {
        max-width: 100%;
    }

    a {
        color: var(--text-primary);
        text-decoration: none;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }
}

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

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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