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

:root {
    /* Colors - refined light palette */
    --primary-color: #1e293b;            /* accents & buttons */
    --primary-hover: #0f172a;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #059669;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --background-color: #f8fafc;        /* page background */
    --surface-color: #ffffff;            /* cards */
    --border-color: #eef2f7;            /* subtle */
    --border-strong: #e5e7eb;           /* layout-defining */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    /* 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;
    
    /* Shadows - Subtle and minimal */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.03);
    --shadow-md: 0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-lg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2xl);
}

/* Header */
.header {
    text-align: center;
    padding: var(--spacing-2xl) 0 var(--spacing-xl) 0;
    margin-bottom: var(--spacing-xl);
}

.title {
    font-size: var(--font-size-3xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.025em;
}

.subtitle {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: var(--spacing-sm);
}

/* Cards */
.filter-card,
.results-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: none;
    padding: var(--spacing-2xl);
    border: 1px solid var(--border-strong); /* prominent borders to define layout */
}

.filter-title,
.results-title {
    font-size: var(--font-size-xl);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xl);
    letter-spacing: -0.025em;
}

/* Filter Grid */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.filter-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.filter-input,
.filter-select {
    padding: var(--spacing-md) var(--spacing-lg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    background: var(--surface-color);
    color: var(--text-primary);
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgb(30 41 59 / 0.05);
}

.filter-hint {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-style: italic;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-xl);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    justify-content: center;
    min-height: 44px; /* Touch-friendly */
    letter-spacing: -0.025em;
}

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

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

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--text-secondary);
    color: white;
    border-color: var(--text-secondary);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: var(--font-size-lg);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
    justify-content: flex-start;
}

/* Results */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.results-stats {
    display: flex;
    gap: var(--spacing-lg);
    align-items: center;
}

.results-count {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: -0.025em;
}

.results-time {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.results-container {
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    background: var(--background-color);
}

.results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    text-align: center;
}

.placeholder-text {
    font-size: var(--font-size-lg);
    font-weight: 500;
    margin: var(--spacing-sm) 0;
}

/* Name List */
.name-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.name-item {
    padding: var(--spacing-lg);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
    letter-spacing: -0.025em;
}

.name-item:hover {
    border-color: var(--primary-color);
    background: var(--background-color);
}

.name-item::before {
    content: attr(data-gender);
    position: absolute;
    top: var(--spacing-xs);
    right: var(--spacing-xs);
    font-size: var(--font-size-xs);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: var(--background-color);
    color: var(--text-muted);
    font-weight: 400;
}

.name-item[data-gender="m"]::before {
    background: #dbeafe;
    color: #1e40af;
}

.name-item[data-gender="w"]::before {
    background: #fce7f3;
    color: #be185d;
}

/* Load More */
.load-more-container {
    text-align: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

/* Status Bar */
.status-bar {
    background: var(--surface-color);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin-top: auto;
}

.status-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.status-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: -0.025em;
}

.total-names {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Site Footer */
.site-footer {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
}

.site-credit {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    letter-spacing: -0.01em;
    transition: color var(--transition-fast), opacity var(--transition-fast);
    opacity: 0.9;
}

.site-credit:hover {
    color: var(--text-primary);
    opacity: 1;
}
.footer-icon {
    display: inline-flex;
    color: var(--text-muted);
}

.footer-icon.external {
    margin-left: var(--spacing-xs);
    color: var(--text-muted);
}

.footer-text {
    color: var(--text-secondary);
}


.site-credit:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    background: var(--surface-color);
    padding: var(--spacing-2xl);
    border-radius: var(--radius-xl);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-md);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: var(--font-size-lg);
    font-weight: 500;
    color: var(--text-primary);
}

/* Responsive Design */
@media (min-width: 640px) {
    .container {
        padding: var(--spacing-lg);
    }
    
    .filter-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
    
    .action-buttons {
        justify-content: flex-start;
    }
}

@media (min-width: 768px) {
    .container {
        padding: var(--spacing-xl);
    }
    
    .filter-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
    
    .name-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (min-width: 1024px) {
    .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    
    .name-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* Dark mode - strong, high-contrast palette without noisy lines */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #0b1220;     /* page bg */
        --surface-color: #0f172a;         /* cards */
        --border-color: #1f2a44;          /* subtle */
        --border-strong: #22314f;         /* layout */
        --text-primary: #e5e7eb;
        --text-secondary: #cbd5e1;
        --text-muted: #8aa0b6;
        --primary-color: #9fb4ff;
        --primary-hover: #c7d3ff;
    }
}

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

/* Focus styles for keyboard navigation */
.btn:focus-visible,
.filter-input:focus-visible,
.filter-select:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }
}

/* Mobile tweaks */
@media (max-width: 480px) {
    .action-buttons { flex-direction: column; }
    .btn { width: 100%; }
    .results-container { max-height: 60vh; }
}
