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

/* ============================================
   CSS Custom Properties (Design Tokens)
   SCIENCE-TECH PALETTE
   ============================================ */
:root {
    /* Colors - Primary (Deep Space Navy) */
    --color-primary: #0f172a;
    --color-primary-light: #1e293b;
    --color-primary-dark: #020617;

    /* Colors - Accent (Lab Teal) */
    --color-accent: #0d9488;
    --color-accent-light: #14b8a6;
    --color-accent-dark: #0f766e;

    /* Colors - Secondary (Electric Blue for highlights) */
    --color-secondary: #3b82f6;
    --color-secondary-light: #60a5fa;

    /* Colors - Neutral (Improved contrast) */
    --color-text: #0f172a;
    --color-text-muted: #475569;
    --color-text-light: #64748b;
    --color-bg: #f8fafc;
    --color-bg-white: #ffffff;
    --color-bg-cool: #f1f5f9;
    --color-border: #e2e8f0;

    /* Semantic Colors */
    --color-success: #22c55e;
    --color-success-light: #4ade80;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #0ea5e9;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows (updated for teal glow) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(13, 148, 136, 0.4);
    --shadow-glow-success: 0 0 20px rgba(34, 197, 94, 0.4);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
    --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Sticky footer layout */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Push footer to bottom */
chem-footer {
    margin-top: auto;
}

/* ============================================
   Typography (Improved contrast)
   ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.3;
    font-weight: 600;
    color: var(--color-text);
}

h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.025em;
}

h2 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    letter-spacing: -0.02em;
}

h3 {
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
}

h4 {
    font-size: 1.125rem;
}

p {
    margin-bottom: var(--spacing-md);
    color: var(--color-text-muted);
}

.prose {
    max-width: 65ch;
}

.prose p {
    margin-bottom: var(--spacing-lg);
}

/* ============================================
   Layout
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

@media (min-width: 768px) {
    .container {
        padding: 0 var(--spacing-xl);
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Staggered page animations */
.container {
    animation: fadeInUp 0.5s ease-out;
}

.container>* {
    animation: fadeInUp 0.5s ease-out backwards;
}

.container>*:nth-child(1) {
    animation-delay: 0.1s;
}

.container>*:nth-child(2) {
    animation-delay: 0.2s;
}

.container>*:nth-child(3) {
    animation-delay: 0.3s;
}

.container>*:nth-child(4) {
    animation-delay: 0.4s;
}

/* ============================================
   Background Utilities
   ============================================ */
.bg-gray-50 {
    background-color: var(--color-bg);
}

.bg-blue-50 {
    background-color: #f0fdfa;
    /* Teal tinted */
}

.bg-green-50 {
    background-color: #f0fdf4;
}

.bg-yellow-50 {
    background-color: #fefce8;
}

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

/* ============================================
   Shadows & Border Radius
   ============================================ */
.shadow-md {
    box-shadow: var(--shadow-md);
}

.shadow-lg {
    box-shadow: var(--shadow-lg);
}

.rounded-xl {
    border-radius: var(--radius-xl);
}

.rounded-lg {
    border-radius: var(--radius-lg);
}

/* ============================================
   Cards & Content Blocks (Enhanced)
   ============================================ */
.bg-white,
.card {
    transition: box-shadow var(--transition-slow), transform var(--transition-slow);
    border: 1px solid var(--color-border);
}

.bg-white:hover,
.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* ============================================
   Formula/Calculation Cards (Major Enhancement)
   ============================================ */
.calculation-text {
    font-family: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 1.125rem;
    line-height: 1.75;
    color: var(--color-text);
    background: linear-gradient(135deg, var(--color-bg-cool) 0%, var(--color-bg-white) 100%);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-accent);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.calculation-text::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
}

/* Formula container enhancement */
.bg-gray-50 .calculation-text,
.bg-blue-50 .calculation-text {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-accent);
}

/* Key formula highlight */
.formula-highlight {
    background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
    border: 2px solid var(--color-accent);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    position: relative;
}

.formula-highlight::after {
    content: '📐';
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    font-size: 1.25rem;
    opacity: 0.5;
}

/* ============================================
   Buttons (Enhanced Micro-interactions)
   ============================================ */
button,
[type='button'],
[type='reset'],
[type='submit'],
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-weight: 600;
    font-size: 1rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-spring);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

/* Ripple effect container */
button::before,
.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

button:active::before,
.btn:active::before {
    width: 300px;
    height: 300px;
}

button:hover,
.btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

button:active,
.btn:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: var(--shadow-md);
}

/* Primary button style (Teal gradient) */
.btn-primary,
button.bg-blue-600,
a.bg-blue-600 {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
    color: white;
    text-decoration: none;
}

.btn-primary:hover,
button.bg-blue-600:hover,
a.bg-blue-600:hover {
    background: linear-gradient(135deg, var(--color-accent-light) 0%, var(--color-accent) 100%);
    box-shadow: var(--shadow-glow);
}

/* Tailwind overrides for buttons */
.bg-blue-600 {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%) !important;
}

.hover\:bg-blue-700:hover {
    background: linear-gradient(135deg, var(--color-accent-light) 0%, var(--color-accent) 100%) !important;
    box-shadow: var(--shadow-glow);
}

/* Success button */
.btn-success {
    background: linear-gradient(135deg, var(--color-success) 0%, #16a34a 100%);
    color: white;
}

.btn-success:hover {
    box-shadow: var(--shadow-glow-success);
}

/* Secondary/outline button */
.btn-secondary {
    background-color: var(--color-bg-white);
    color: var(--color-text);
    border: 2px solid var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-bg);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* ============================================
   Links
   ============================================ */
a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

/* Navigation links */
nav a {
    position: relative;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--color-accent-light);
    transition: all var(--transition-normal);
    transform: translateX(-50%);
}

nav a:hover::after {
    width: 100%;
}

/* ============================================
   Form Inputs (Enhanced)
   ============================================ */
input[type='number'],
input[type='text'],
input[type='email'],
textarea,
select {
    border: 2px solid var(--color-border);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-normal);
    background-color: var(--color-bg-white);
}

input:hover,
textarea:hover,
select:hover {
    border-color: var(--color-text-light);
}

input[type='number']:focus,
input[type='text']:focus,
input[type='email']:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

/* Success state for inputs */
input.success,
input:valid:not(:placeholder-shown) {
    border-color: var(--color-success);
}

/* Error state for inputs */
input.error,
input:invalid:not(:placeholder-shown) {
    border-color: var(--color-error);
}

/* ============================================
   Accessibility - Focus States
   ============================================ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    z-index: 9999;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: var(--spacing-md);
}

/* ============================================
   Tables
   ============================================ */
table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    font-weight: 600;
    color: var(--color-text);
    background-color: var(--color-bg);
}

tr:hover {
    background-color: rgba(13, 148, 136, 0.05);
}

/* ============================================
   Lists
   ============================================ */
ol,
ul {
    padding-left: var(--spacing-lg);
}

li {
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-muted);
}

li::marker {
    color: var(--color-accent);
}

/* ============================================
   Custom Elements
   ============================================ */
chem-header {
    display: block;
    margin-bottom: var(--spacing-xl);
}

/* ============================================
   Utility Classes
   ============================================ */

/* Text gradient (teal) */
.text-gradient {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-success) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Subtle pulse animation for important elements */
@keyframes subtle-pulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: var(--shadow-md);
    }

    50% {
        opacity: 0.95;
        box-shadow: var(--shadow-glow);
    }
}

.pulse {
    animation: subtle-pulse 2s ease-in-out infinite;
}

/* Glow effect */
@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(13, 148, 136, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(13, 148, 136, 0.5);
    }
}

.glow {
    animation: glow 2s ease-in-out infinite;
}

/* Loading state */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Step indicator badge */
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
    border-radius: var(--radius-full);
    margin-right: var(--spacing-sm);
}

/* Info/tip boxes */
.info-box {
    background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    position: relative;
}

.info-box::before {
    content: '💡';
    position: absolute;
    top: -0.75rem;
    left: var(--spacing-md);
    background: var(--color-bg-white);
    padding: 0 var(--spacing-xs);
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--spacing-md);
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    .calculation-text {
        font-size: 1rem;
        padding: var(--spacing-sm) var(--spacing-md);
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    body {
        background: white;
        color: black;
    }

    .container {
        max-width: none;
    }

    nav,
    button,
    .btn {
        display: none;
    }
}