/* Critical Path CSS for Visit Arbroath - Above the Fold Content */

/* CSS Custom Properties - Load First */
:root {
    --primary-color: #1a365d;
    --primary-light: #2d5278;
    --secondary-color: #2c5a9e;
    --accent-color: #e53e3e;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --bg-white: #ffffff;
    --bg-light: #f7fafc;
    --bg-gray: #edf2f7;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --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);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
}

/* Critical Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-light);
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container - Critical for layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header - Above the fold */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    padding: 3rem 0;
    position: relative;
    overflow: hidden;
}

.logo {
    position: relative;
    z-index: 1;
    text-align: center;
}

.logo h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

.tagline {
    font-size: 1.2rem;
    opacity: 0.95;
    max-width: 800px;
    margin: 0 auto;
    font-weight: 300;
    line-height: 1.7;
}

/* Navigation - Critical for UX */
nav {
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
    padding: 0;
    border-bottom: 1px solid var(--border-color);
}

.nav-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
}

.nav-container a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 1rem 1.5rem;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    font-size: 0.95rem;
}

.nav-container a:hover,
.nav-container a.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: rgba(26, 54, 93, 0.02);
}

/* Main Content Area */
main {
    padding: 4rem 0;
    min-height: 60vh;
}

/* Critical Business Grid - Above the fold */
#business-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

/* Critical Business Card Styles */
.business-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.business-header {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.business-header h3 {
    color: var(--primary-color);
    margin: 0 0 0.75rem 0;
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.business-category {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
    letter-spacing: 0.025em;
}

.business-details {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.business-address,
.business-phone {
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-weight: 500;
}

/* Critical Image Handling */
.business-image-container {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.placeholder-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.business-logo {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg-white);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    z-index: 10;
}

.business-logo img {
    height: 32px;
    width: auto;
    max-width: 80px;
    object-fit: contain;
}

.fallback-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 8px;
    font-size: 24px;
    border: 1px solid #e2e8f0;
}

/* Filter Panel - Critical for functionality */
.filter-panel {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.filter-header {
    background: var(--primary-color);
    color: white;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.filter-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Loading States - Critical for UX */
.loading-state {
    animation: fadeIn 0.3s ease-out;
}

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

.lazy-image {
    transition: opacity 0.3s ease;
}

.lazy-image.loading {
    opacity: 0.6;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

.lazy-image.loaded {
    opacity: 1;
}

/* Critical Mobile Styles */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .logo h1 {
        font-size: 2.5rem;
    }
    
    .tagline {
        font-size: 1.1rem;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 0;
    }
    
    .nav-container a {
        padding: 1rem;
        text-align: center;
        width: 100%;
        border-bottom: 1px solid var(--border-color);
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #business-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .business-card {
        padding: 1.25rem;
    }
    
    .business-header h3 {
        font-size: 1.15rem;
    }
    
    .business-category {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    main {
        padding: 2rem 0;
    }
}

/* Extra Small Mobile */
@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }
    
    .logo h1 {
        font-size: 2rem;
        margin-bottom: 0.75rem;
    }
    
    .tagline {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    header {
        padding: 2rem 0;
    }
    
    .business-card {
        padding: 1rem;
    }
    
    .business-header h3 {
        font-size: 1.1rem;
    }
    
    .business-category {
        font-size: 0.75rem;
        padding: 0.35rem 0.7rem;
    }
    
    #business-grid {
        gap: 1.25rem;
    }
    
    main {
        padding: 1.5rem 0;
    }
}

/* Preload Critical Animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Critical hover states for immediate feedback */
.business-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

/* Performance optimizations */
.business-card,
.filter-panel,
.nav-container a {
    contain: layout style;
}

/* Critical loading indicators */
.btn-loading {
    position: relative;
    color: transparent;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Ensure critical content is visible during font load */
.logo h1,
.business-header h3 {
    font-display: swap;
}

/* Optimize repaints for scrolling */
.business-card,
.business-logo,
.filter-panel {
    will-change: transform;
}

/* Critical focus styles for accessibility */
.nav-container a:focus,
.business-card:focus-within {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}