/* talentX/css/fixes.css — Style Audit Patch v1.0
   Fixes all desktop & mobile style vulnerabilities found in audit.
   Load AFTER talentx.css and performance.css.
   ─────────────────────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════
   1. SAFE-AREA INSET — iPhone notch / Dynamic Island / Android bar
══════════════════════════════════════════════════════════════════ */
:root {
    --safe-top:    env(safe-area-inset-top,    0px);
    --safe-right:  env(safe-area-inset-right,  0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left,   0px);
}

.hub-nav {
    padding-left:  max(2rem, calc(var(--safe-left)  + 1rem));
    padding-right: max(2rem, calc(var(--safe-right) + 1rem));
}

.mobile-bottom-nav {
    padding-bottom: max(10px, var(--safe-bottom));
    height: calc(64px + var(--safe-bottom));
}

body {
    padding-bottom: calc(70px + var(--safe-bottom));
}

@media (min-width: 961px) {
    body { padding-bottom: 0; }
}

.filter-bottom-sheet {
    padding-bottom: max(16px, var(--safe-bottom));
}

.bottom-sheet-footer {
    padding-bottom: max(16px, var(--safe-bottom));
}

/* ══════════════════════════════════════════════════════════════════
   2. MINIMUM TAP TARGETS (WCAG 2.5.5 — 44x44px minimum)
══════════════════════════════════════════════════════════════════ */
.nav-icon-btn,
.mobile-nav-item,
.bookmark-btn,
.filter-clear-btn,
.ps-see-all {
    min-width: 44px;
    min-height: 44px;
}

.bookmark-btn {
    padding: 8px;
    margin: -4px;
}

@media (max-width: 640px) {
    .mobile-filter-btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    .nav-icon-btn {
        width: 44px;
        height: 44px;
    }

    .preview-close-btn {
        width: 44px;
        height: 44px;
    }
}

/* ══════════════════════════════════════════════════════════════════
   3. DUPLICATE SKELETON — Unified shimmer
══════════════════════════════════════════════════════════════════ */
.skeleton,
.skeleton-line,
.skeleton-banner {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.03) 25%,
        rgba(255,255,255,0.08) 50%,
        rgba(255,255,255,0.03) 75%
    );
    background-size: 400px 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
}

@keyframes skeletonShimmer {
    0%   { background-position: -400px 0; }
    100% { background-position:  400px 0; }
}

.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: none;
}

.skeleton-avatar {
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    flex-shrink: 0;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    background-size: 400px 100%;
}

/* ══════════════════════════════════════════════════════════════════
   4. MOBILE CARD — text overflow fixes
══════════════════════════════════════════════════════════════════ */
@media (max-width: 960px) {
    .card-body { min-width: 0; }
    .talent-name { max-width: 100%; display: block; }
    .talent-role {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
    }
    .card-actions { flex-wrap: wrap; gap: 4px; }
    .card-quick-btn { font-size: 0.68rem; padding: 4px 7px; }
    .availability-badge {
        overflow: hidden;
        max-width: 90px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .recommended-strip { overflow: hidden; }
    .ps-scroll { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 400px) {
    .talent-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .talent-skills { display: flex !important; }
    .hero-search-wrapper { flex-direction: column; gap: 6px; }
    .hero-search-btn { width: 100%; }
}

/* ══════════════════════════════════════════════════════════════════
   5. Z-INDEX LAYER SYSTEM
══════════════════════════════════════════════════════════════════ */
:root {
    --z-sticky:     100;
    --z-mobile-bar: 200;
    --z-dropdown:   600;
    --z-notif:      700;
    --z-sheet:      1200;
    --z-modal:      1500;
    --z-toast:      2000;
    --z-overlay:    3000;
}

.hub-nav               { z-index: var(--z-sticky); }
.mobile-filter-bar     { z-index: var(--z-mobile-bar); }
.categories-custom-dropdown,
.custom-sort-menu,
.profile-dropdown      { z-index: var(--z-dropdown); }
.notif-panel           { z-index: var(--z-notif); }
.filter-bottom-sheet-overlay { z-index: var(--z-sheet); }
.filter-bottom-sheet   { z-index: calc(var(--z-sheet) + 100); }
.preview-modal-overlay { z-index: var(--z-modal); }
.modal-overlay         { z-index: var(--z-modal); }
#onboarding-overlay    { z-index: var(--z-overlay); }

/* ══════════════════════════════════════════════════════════════════
   6. HERO SEARCH — Mobile layout fix
══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .hero-search-wrapper {
        flex-direction: column;
        padding: 8px;
        gap: 8px;
        border-radius: var(--radius);
    }
    .hero-search-btn {
        width: 100%;
        border-radius: var(--radius-sm);
        justify-content: center;
    }
    .hero-search-input-wrap { padding: 4px 8px; }
    .hub-hero h1 {
        font-size: clamp(1.3rem, 6vw, 1.6rem);
        line-height: 1.25;
    }
    .chip-btn { padding: 5px 10px; font-size: 0.78rem; }
}

/* ══════════════════════════════════════════════════════════════════
   7. MOBILE FILTER BAR — sticky top + overflow fix
══════════════════════════════════════════════════════════════════ */
.mobile-filter-bar {
    top: calc(56px + var(--safe-top));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
}
.mobile-filter-bar::-webkit-scrollbar { display: none; }

@media (min-width: 641px) {
    .mobile-filter-bar { top: calc(70px + var(--safe-top)); }
}

/* ══════════════════════════════════════════════════════════════════
   8. QUICK PREVIEW MODAL — Bottom sheet on mobile
══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .preview-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .preview-modal {
        border-radius: 24px 24px 0 0;
        max-height: 92vh;
        margin: 0;
        width: 100%;
        max-width: 100%;
        transform: translateY(100%);
    }
    .preview-modal-overlay.active .preview-modal {
        transform: translateY(0);
    }
}

/* ══════════════════════════════════════════════════════════════════
   9. NOTIFICATION PANEL — Off-screen fix on mobile
══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .notif-panel {
        width: calc(100vw - 2rem);
        right: -0.5rem;
        border-radius: 14px;
        max-height: 80vh;
    }
    .notif-list { max-height: calc(80vh - 120px); }
}

/* ══════════════════════════════════════════════════════════════════
   10. PROFILE DROPDOWN — Off-screen on mobile
══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .profile-dropdown {
        width: calc(100vw - 2rem);
        right: -0.25rem;
        max-height: 80vh;
        overflow-y: auto;
    }
    .custom-sort-menu {
        right: 0;
        left: auto;
        min-width: 160px;
    }
    .categories-custom-dropdown {
        left: 0;
        right: 0;
        width: calc(100vw - 2rem);
        max-height: 50vh;
    }
}

/* ══════════════════════════════════════════════════════════════════
   11. PERFORMANCE — Reduce blur on mobile
══════════════════════════════════════════════════════════════════ */
.hub-ambient-bg {
    isolation: isolate;
    contain: strict;
}

@media (max-width: 960px) {
    .hub-nav {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    .filter-bottom-sheet-overlay {
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
    .hub-ambient-glow-1,
    .hub-ambient-glow-2,
    .hub-ambient-glow-3 {
        display: none;
    }
}

/* ══════════════════════════════════════════════════════════════════
   12. SELECT APPEARANCE — iOS fix
══════════════════════════════════════════════════════════════════ */
.filter-group select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* ══════════════════════════════════════════════════════════════════
   13. HERO CHIPS — horizontal scroll on mobile, wrap on desktop
══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .hero-chips-container {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 0 0.85rem 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
        -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
    }
    .hero-chips-container::-webkit-scrollbar { display: none; }
}

/* ══════════════════════════════════════════════════════════════════
   14. FOCUS VISIBLE — Consistent on interactive elements
══════════════════════════════════════════════════════════════════ */
.chip-btn:focus-visible,
.mobile-filter-btn:focus-visible,
.bookmark-btn:focus-visible,
.card-quick-btn:focus-visible,
.filter-tag button:focus-visible,
.ps-see-all:focus-visible,
.view-toggle-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 6px;
}

/* ══════════════════════════════════════════════════════════════════
   15. RESULTS HEADER — Wrap gracefully at 375px
══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .results-header { gap: 8px; margin-bottom: 1rem; }
    .results-count { font-size: 0.82rem; }
    .results-actions { width: 100%; justify-content: space-between; }
    .view-toggle { flex: 1; justify-content: center; }
    .view-toggle-btn { flex: 1; }
}

/* ══════════════════════════════════════════════════════════════════
   16. BODY SCROLL LOCK — When modal/sheet is open
══════════════════════════════════════════════════════════════════ */
body.modal-open,
body.preview-open,
body.sheet-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ══════════════════════════════════════════════════════════════════
   17. MOBILE BOTTOM NAV — Active indicator not clipping
══════════════════════════════════════════════════════════════════ */
.mobile-bottom-nav { overflow: visible; }
.mobile-nav-item   { overflow: visible; padding: 0 4px; }

/* ══════════════════════════════════════════════════════════════════
   18. TOUCH DEVICE HOVER FIX — No hover flicker on tap
══════════════════════════════════════════════════════════════════ */
@media (hover: none) {
    .talent-card:hover {
        transform: none;
        box-shadow: var(--shadow-card);
        border-color: var(--border);
    }
    .talent-card:hover .card-avatar { transform: none; }
    .talent-card:hover .skill-pill {
        border-color: var(--border-light);
        color: var(--muted-light);
    }
    .ps-card:hover { transform: none; }
    .btn-primary:hover, .btn-secondary:hover {
        transform: none;
        filter: none;
    }
}

.talent-card:active {
    transform: scale(0.98);
    transition-duration: 60ms;
}

/* ══════════════════════════════════════════════════════════════════
   19. DESKTOP GRID BREAKPOINTS — Better column fill
══════════════════════════════════════════════════════════════════ */
@media (min-width: 961px) and (max-width: 1280px) {
    .talent-grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
}
@media (min-width: 1281px) {
    .talent-grid { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
}

/* ══════════════════════════════════════════════════════════════════
   20. QUICK PREVIEW — Action buttons stack on small phones
══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .preview-actions { flex-direction: column; }
    .preview-meta-grid { gap: 6px; padding: 8px; }
    .preview-meta-item strong { font-size: 0.9rem; }
    .preview-meta-item span   { font-size: 0.66rem; }
}

/* ══════════════════════════════════════════════════════════════════
   21. RIPPLE — Unified (removes duplicate definition conflict)
══════════════════════════════════════════════════════════════════ */
.ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: rippleUnified 500ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
    background: rgba(255, 111, 0, 0.18);
    pointer-events: none;
    z-index: 1;
}
@keyframes rippleUnified {
    to { transform: scale(2.8); opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════════
   22. AUTOFILL — Dark theme override for browser autofill yellow
══════════════════════════════════════════════════════════════════ */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #111118 inset !important;
    -webkit-text-fill-color: var(--text) !important;
    caret-color: var(--text);
    transition: background-color 9999s ease-in-out 0s;
}

/* ══════════════════════════════════════════════════════════════════
   23. HERO STATS — Responsive grid
══════════════════════════════════════════════════════════════════ */
.hero-stats {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

@media (max-width: 640px) {
    .hero-stats { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .hero-stat-card { padding: 0.9rem 0.75rem; }
    .hero-stat-card strong { font-size: 1.4rem; }
}

/* ══════════════════════════════════════════════════════════════════
   24. FONT FALLBACK — Reduce CLS (Cumulative Layout Shift)
══════════════════════════════════════════════════════════════════ */
@font-face {
    font-family: 'DM Sans Fallback';
    src: local('Arial');
    size-adjust: 99%;
    ascent-override: 92%;
    descent-override: 25%;
    line-gap-override: 0%;
}
@font-face {
    font-family: 'Plus Jakarta Sans Fallback';
    src: local('Arial');
    size-adjust: 101%;
    ascent-override: 95%;
    descent-override: 25%;
    line-gap-override: 0%;
}
body {
    font-family: 'DM Sans', 'DM Sans Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
h1, h2, h3, h4, h5, h6 {
    font-family: 'Plus Jakarta Sans', 'Plus Jakarta Sans Fallback', sans-serif;
}

/* ══════════════════════════════════════════════════════════════════
   25. HUB CONTAINER — Padding on very narrow screens
══════════════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
    .hub-container { padding: 0.75rem 0.65rem 3rem; }
    .hub-hero      { padding: 1rem 0.65rem 0.75rem; }
}

/* ══════════════════════════════════════════════════════════════════
   26. FILTER PANEL SCROLLBAR — Desktop polish
══════════════════════════════════════════════════════════════════ */
.filter-panel::-webkit-scrollbar       { width: 4px; }
.filter-panel::-webkit-scrollbar-track { background: transparent; }
.filter-panel::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
}
.filter-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 111, 0, 0.4);
}

/* ══════════════════════════════════════════════════════════════════
   27. TEXT SELECTION COLOR — Brand palette
══════════════════════════════════════════════════════════════════ */
::selection {
    background: rgba(255, 111, 0, 0.3);
    color: #fff;
}

/* ══════════════════════════════════════════════════════════════════
   28. BROKEN IMAGE PLACEHOLDER
══════════════════════════════════════════════════════════════════ */
img {
  background: rgba(255,255,255,0.03); width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
img[src=""], img:not([src]), img[src="#"] { visibility: hidden; }
.card-avatar, .ps-avatar, .preview-avatar { object-fit: cover; }

/* ══════════════════════════════════════════════════════════════════
   29. OVERSCROLL BEHAVIOR — Prevent scroll chaining through modals
══════════════════════════════════════════════════════════════════ */
.filter-bottom-sheet,
.preview-modal,
.notif-panel,
.notif-list,
.bottom-sheet-body {
    overscroll-behavior: contain;
}

/* ══════════════════════════════════════════════════════════════════
   30. IMPROVED CARD BANNER GRADIENT — More depth on mobile
══════════════════════════════════════════════════════════════════ */
@media (max-width: 960px) {
    .card-banner {
        background: linear-gradient(135deg, #1a0f26 0%, #220e04 50%, #14142a 100%);
    }
    .card-banner::after {
        background: linear-gradient(to top, rgba(12,12,20,1) 0%, transparent 65%);
    }
}
