/* ============================================
   CatastrophicInjury.org — Safe Upgrade Layer
   Load AFTER main.css and responsive.css
   File: upgrades-2026.css
   ============================================ */

/* 
   STRATEGY: Everything here is ADDITIVE or OVERRIDING.
   Remove this file to instantly revert all changes.
   Zero risk to existing functionality.
*/

/* ─────────────────────────────────────────────
   1. FIX: Complete the truncated .contact-button 
   from main.css (line ~480 was cut off)
   ───────────────────────────────────────────── */
.contact-button {
    background: var(--primary-red);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.contact-button:hover {
    background: var(--primary-red-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.contact-button:active {
    transform: scale(0.98);
    transition-duration: 0.05s;
}

/* ─────────────────────────────────────────────
   2. FIX: Remove persistent :focus outlines
   Replace with :focus-visible (keyboard-only)
   ───────────────────────────────────────────── */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-red);
    outline-offset: 2px;
}

/* ─────────────────────────────────────────────
   3. PERFORMANCE: content-visibility for cards
   Massive rendering speedup on large directories
   ───────────────────────────────────────────── */
.lawyer-card,
.card {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
    contain: layout style paint;
}

/* Disable content-visibility for cards above the fold */
#lawyer-cards > *:nth-child(-n+3) {
    content-visibility: visible;
}

/* ─────────────────────────────────────────────
   4. UX: Button press states (micro-interaction)
   ───────────────────────────────────────────── */
.btn-primary:active,
.view-profile-button:active {
    transform: scale(0.98);
    transition-duration: 0.05s;
}

/* ─────────────────────────────────────────────
   5. UX: Sticky search/filter bar on scroll
   ───────────────────────────────────────────── */
#search-section {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--gray-200);
    transition: box-shadow 0.3s ease;
}

#search-section.is-scrolled {
    box-shadow: var(--shadow-lg);
}

/* ─────────────────────────────────────────────
   6. LOADING: Skeleton screens (better than spinner)
   Use: <div class="skeleton skeleton-card"></div>
   ───────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(
        90deg, 
        var(--gray-100) 25%, 
        var(--gray-200) 50%, 
        var(--gray-100) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 0.75rem;
}

@keyframes skeleton-loading {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    height: 420px;
    width: 100%;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
}

.skeleton-text.short  { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long   { width: 90%; }

.skeleton-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────
   7. ACCESSIBILITY: Skip link for keyboard users
   Add to HTML: <a href="#search-section" class="skip-link">Skip to search</a>
   ───────────────────────────────────────────── */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-red);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0 0 0.5rem 0.5rem;
    font-weight: 600;
    text-decoration: none;
    z-index: 9999;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    outline: none;
}

/* ─────────────────────────────────────────────
   8. UX: Smooth card entrance animations
   ───────────────────────────────────────────── */
#lawyer-cards > * {
    animation: card-enter 0.4s ease-out backwards;
}

#lawyer-cards > *:nth-child(1)  { animation-delay: 0.05s; }
#lawyer-cards > *:nth-child(2)  { animation-delay: 0.10s; }
#lawyer-cards > *:nth-child(3)  { animation-delay: 0.15s; }
#lawyer-cards > *:nth-child(4)  { animation-delay: 0.20s; }
#lawyer-cards > *:nth-child(5)  { animation-delay: 0.25s; }
#lawyer-cards > *:nth-child(6)  { animation-delay: 0.30s; }
#lawyer-cards > *:nth-child(7)  { animation-delay: 0.35s; }
#lawyer-cards > *:nth-child(8)  { animation-delay: 0.40s; }
#lawyer-cards > *:nth-child(9)  { animation-delay: 0.45s; }
#lawyer-cards > *:nth-child(10) { animation-delay: 0.50s; }

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ─────────────────────────────────────────────
   9. UX: Active filter pills (visual feedback)
   Add class "active-filter" via JS when filter applied
   ───────────────────────────────────────────── */
.active-filter {
    background: var(--primary-red) !important;
    color: white !important;
    position: relative;
    padding-right: 2rem !important;
}

.active-filter::after {
    content: "×";
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    cursor: pointer;
}

/* ─────────────────────────────────────────────
   10. UX: "Back to top" floating button
   Add to HTML: <button class="back-to-top" aria-label="Back to top">↑</button>
   ───────────────────────────────────────────── */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-red);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top:hover {
    background: var(--primary-red-dark);
    transform: translateY(-2px);
}

.back-to-top:active {
    transform: scale(0.95);
}

/* ─────────────────────────────────────────────
   11. TRUST: Verified badge styling
   Add: <span class="verified-badge">Verified</span>
   ───────────────────────────────────────────── */
.verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #10b981;
    color: white;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    line-height: 1;
}

.verified-badge::before {
    content: "✓";
    font-size: 0.875rem;
}

/* ─────────────────────────────────────────────
   12. TRUST: "Free Consultation" ribbon
   Add: <span class="consultation-ribbon">Free Consultation</span>
   ───────────────────────────────────────────── */
.consultation-ribbon {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--primary-red);
    color: white;
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    box-shadow: var(--shadow-md);
    z-index: 10;
    white-space: nowrap;
    line-height: 1;
}

/* ─────────────────────────────────────────────
   13. MOBILE: Better touch targets (48px min)
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .practice-tag,
    .practice-area-tag,
    .contact-button,
    .view-profile-button,
    .btn-primary,
    .btn-secondary {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    select,
    input[type="text"] {
        min-height: 48px;
        font-size: 16px;
    }
}

/* ─────────────────────────────────────────────
   14. DARK MODE: Complete the broken implementation
   ───────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #0f172a;
        --gray-100: #1e293b;
        --gray-200: #334155;
        --gray-300: #475569;
        --gray-400: #64748b;
        --gray-500: #94a3b8;
        --gray-600: #cbd5e1;
        --gray-700: #e2e8f0;
        --gray-800: #f1f5f9;
        --gray-900: #f8fafc;
    }
    
    body {
        background-color: var(--gray-50);
        color: var(--gray-800);
    }
    
    .card,
    .lawyer-card,
    .admin-card {
        background-color: var(--gray-100);
        border-color: var(--gray-300);
    }
    
    nav {
        background: rgba(15, 23, 42, 0.95);
        border-bottom-color: var(--gray-300);
    }
    
    #search-section {
        background: rgba(15, 23, 42, 0.95);
        border-bottom-color: var(--gray-300);
    }
    
    input, select, textarea {
        background-color: var(--gray-100);
        border-color: var(--gray-300);
        color: var(--gray-800);
    }
    
    .practice-tag,
    .practice-area-tag {
        background: rgba(220, 38, 38, 0.2);
    }
    
    .skeleton {
        background: linear-gradient(
            90deg, 
            var(--gray-200) 25%, 
            var(--gray-300) 50%, 
            var(--gray-200) 75%
        );
    }
    
    .stats-section {
        background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-50) 100%);
    }
    
    .filter-section {
        background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
        border-color: var(--gray-300);
    }
    
    .results-counter {
        background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-50) 100%);
    }
    
    .admin-table th {
        background-color: var(--gray-200);
    }
    
    .admin-table tr:hover {
        background-color: var(--gray-200);
    }
    
    .upload-zone {
        border-color: var(--gray-300);
    }
    
    .upload-zone:hover {
        background-color: rgba(220, 38, 38, 0.05);
    }
    
    .modal-content {
        background: var(--gray-100);
    }
    
    footer {
        background: var(--gray-900);
        border-top-color: var(--gray-800);
    }
}

/* ─────────────────────────────────────────────
   15. UTILITY: Visually hidden (screen readers)
   ───────────────────────────────────────────── */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ─────────────────────────────────────────────
   16. UTILITY: Reduced motion respect
   ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    #lawyer-cards > * {
        animation: none;
    }
    
    .skeleton {
        animation: none;
        background: var(--gray-200);
    }
    
    .back-to-top {
        transition: none;
    }
}