/**
 * Public Styles for OCD Location Navigator
 * 
 * @package OCDLocationNavigator
 * @author Kevin Witting
 * @version 1.0.4
 */

/* CSS Custom Properties for OCD Anxiety Centers Brand */
:root {
    /* Official Brand Colors - can be overridden by admin settings */
    --ocd-primary-color: #708FA6;        /* Blue-gray from logo text */
    --ocd-primary-dark: #557085;         /* Darker blue-gray shade */
    --ocd-secondary-color: #D4B896;      /* Warm beige from logo curve */
    --ocd-accent-color: #8FA6C1;         /* Light blue-gray accent */
    
    /* Text Colors */
    --ocd-text-primary: #333333;         /* Dark gray text */
    --ocd-text-secondary: #666666;       /* Medium gray text */
    
    /* Background Colors */
    --ocd-background-light: #f8f9fa;     /* Light background */
    --ocd-border-color: #e1e8ed;         /* Light border */
    
    /* Interactive Colors */
    --ocd-hover-bg: rgba(112, 143, 166, 0.08); /* Light primary hover */
    
    /* Default sizing */
    --ocd-font-size: 16px;
    --ocd-border-radius: 8px;
}

/* WordPress font stack */
.location-navigator,
.location-navigator * {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.location-navigator {
    background: white;
    border-radius: var(--ocd-border-radius, 8px);
    border: 1px solid var(--ocd-border-color, #e1e8ed);
    overflow: hidden;
    position: relative;
    contain: layout style; /* CSS containment for performance */
    font-size: var(--ocd-font-size, 16px);
    line-height: 1.4;
}

.current-location {
    background: linear-gradient(135deg, var(--ocd-primary-color, #708FA6) 0%, var(--ocd-primary-dark, #557085) 100%);
    color: white;
    padding: 16px 20px;
    font-weight: 600;
    font-size: var(--ocd-font-size, 16px);
    display: flex;
    align-items: center;
    gap: 8px;
}

.location-icon {
    font-size: calc(var(--ocd-font-size) + 2px);
}

.browse-header {
    background: #f1f5f9;
    border: none;
    width: 100%;
    padding: 16px 20px;
    text-align: left;
    font-size: var(--ocd-font-size, 16px);
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s ease;
    outline: none;
}

.browse-header:hover,
.browse-header:focus {
    background: #e2e8f0;
    outline: 2px solid var(--ocd-primary-color, #708FA6);
    outline-offset: -2px;
}

.browse-header.expanded {
    background: #e2e8f0;
    border-bottom: 1px solid #cbd5e1;
}

.expand-icon {
    transition: transform 0.3s ease;
    font-size: calc(var(--ocd-font-size) * 0.75);
    color: #64748b;
}

.browse-header.expanded .expand-icon {
    transform: rotate(180deg);
}

.locations-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.locations-list.expanded {
    max-height: min(60vh, 400px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth momentum scrolling on iOS */
}

.state-section {
    border-bottom: 1px solid #f1f5f9;
}

.state-header {
    background: #f8fafc;
    border: none;
    width: 100%;
    padding: 12px 20px;
    text-align: left;
    font-size: calc(var(--ocd-font-size) * 0.875);
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s ease;
    outline: none;
}

.state-header:hover,
.state-header:focus {
    background: #f1f5f9;
    outline: 2px solid var(--ocd-primary-color);
    outline-offset: -2px;
}

.state-header.expanded {
    background: #f1f5f9;
}

.state-icon {
    transition: transform 0.3s ease;
    font-size: calc(var(--ocd-font-size) * 0.625);
    color: #94a3b8;
}

.state-header.expanded .state-icon {
    transform: rotate(180deg);
}

.city-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* FIX v1.0.4: Changed overflow from 'visible' to 'hidden' to prevent
   city links from visually bleeding over the next state section.
   max-height set high to avoid clipping even with many cities per state.
   Uses hidden (not auto) to prevent nested scroll conflicts on iOS. */
.city-list.expanded {
    max-height: 2000px;
    overflow: hidden;
}

.city-link {
    display: block;
    padding: 12px 20px 12px 40px;
    color: var(--ocd-primary-color);
    text-decoration: none;
    font-size: calc(var(--ocd-font-size) * 0.875);
    border-bottom: 1px solid #f8fafc;
    transition: all 0.2s ease;
    min-height: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    outline: none;
}

.city-link:hover,
.city-link:focus {
    background: var(--ocd-hover-bg);
    color: var(--ocd-primary-dark);
    outline: 2px solid var(--ocd-primary-color);
    outline-offset: -2px;
    text-decoration: none;
}

/* Remove trailing border on the last city in each state */
.city-link:last-child {
    border-bottom: none;
}

.city-link.current {
    background: var(--ocd-hover-bg);
    color: var(--ocd-primary-color);
    font-weight: 600;
    position: relative;
}

.city-link.current::after {
    content: "← Current";
    margin-left: auto;
    font-size: calc(var(--ocd-font-size) * 0.75);
    color: var(--ocd-accent-color);
    font-weight: 500;
}

/* Scroll indicator chevron styling */
.location-scroll-indicator {
    position: absolute;
    bottom: 8px;
    right: 12px;
    color: var(--ocd-primary-color);
    opacity: 0.7;
    font-size: calc(var(--ocd-font-size) + 2px);
    font-weight: 900;
    cursor: pointer;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
    background: var(--ocd-background-light);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(112, 143, 166, 0.15);
    outline: none;
}

.location-scroll-indicator:hover,
.location-scroll-indicator:focus {
    opacity: 1;
    outline: 2px solid var(--ocd-primary-color);
    box-shadow: 0 4px 12px rgba(112, 143, 166, 0.2);
}

.location-scroll-indicator.visible {
    pointer-events: auto;
}

/* Custom scrollbar styling for webkit browsers */
.locations-list::-webkit-scrollbar {
    width: 8px;
}

.locations-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.locations-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.locations-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .locations-list.expanded {
        max-height: min(50vh, 300px);
    }
    
    .location-scroll-indicator {
        bottom: 6px;
        right: 10px;
        font-size: calc(var(--ocd-font-size) + 4px);
        width: 32px;
        height: 32px;
    }
    
    .current-location {
        padding: 14px 16px;
        font-size: calc(var(--ocd-font-size) * 0.875);
    }
    
    .browse-header {
        padding: 14px 16px;
        font-size: calc(var(--ocd-font-size) * 0.875);
    }
    
    .state-header {
        padding: 10px 16px;
    }
    
    .city-link {
        padding: 10px 16px 10px 32px;
        min-height: 44px; /* Ensure touch targets are adequate */
    }
}

@media (max-width: 480px) {
    .current-location {
        padding: 12px 14px;
        font-size: calc(var(--ocd-font-size) * 0.8125);
    }
    
    .browse-header {
        padding: 12px 14px;
        font-size: calc(var(--ocd-font-size) * 0.8125);
    }
    
    .state-header {
        padding: 10px 14px;
        font-size: calc(var(--ocd-font-size) * 0.8125);
    }
    
    .city-link {
        padding: 10px 14px 10px 28px;
        font-size: calc(var(--ocd-font-size) * 0.8125);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --ocd-primary-color: #4A6B7A; /* Darker for better contrast */
        --ocd-text-primary: #000000;
        --ocd-border-color: #999999;
    }
    
    .city-link:focus,
    .state-header:focus,
    .browse-header:focus,
    .location-scroll-indicator:focus {
        outline: 3px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .expand-icon,
    .state-icon,
    .locations-list,
    .city-list,
    .city-link,
    .state-header,
    .browse-header,
    .location-scroll-indicator {
        transition: none;
    }
}

/* Focus management for keyboard navigation */
.location-navigator:focus-within {
    outline: 2px solid var(--ocd-primary-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .location-navigator {
        break-inside: avoid;
        border: 1px solid #000;
    }
    
    .location-scroll-indicator {
        display: none;
    }
    
    .locations-list.expanded {
        max-height: none;
        overflow: visible;
    }
    
    .city-list.expanded {
        max-height: none;
        overflow: visible;
    }
}
