/* ==========================================================================
   LCEAP – Global Volunteer Directory  |  volunteer-directory.css
   ========================================================================== */

/* ── Root variables ────────────────────────────────────────────────────── */
.lvd-wrapper {
    --lvd-bg:            #f4f6fb;
    --lvd-card-bg:       #ffffff;
    --lvd-text:          #111827;
    --lvd-muted:         #6b7280;
    --lvd-accent:        #2563eb;
    --lvd-border:        #e5e7eb;
    --lvd-shadow-sm:     0 1px 6px rgba(0,0,0,.06), 0 4px 18px rgba(0,0,0,.06);
    --lvd-shadow-hover:  0 8px 32px rgba(0,0,0,.13);
    --lvd-shadow-modal:  0 24px 80px rgba(0,0,0,.28);
    --lvd-radius:        14px;
    --lvd-ease:          cubic-bezier(.4,0,.2,1);
    --lvd-dur:           .26s;
    --lvd-badge-bg:      #eff6ff;
    --lvd-badge-color:   #1d4ed8;
    font-family: inherit;
    box-sizing:  border-box;
}
.lvd-wrapper *, .lvd-wrapper *::before, .lvd-wrapper *::after { box-sizing: inherit; }

/* Dark mode */
.lvd-wrapper.lvd-mode-dark {
    --lvd-bg:           #0d1117;
    --lvd-card-bg:      #161b22;
    --lvd-text:         #e6edf3;
    --lvd-muted:        #8b949e;
    --lvd-accent:       #58a6ff;
    --lvd-border:       #30363d;
    --lvd-shadow-sm:    0 1px 6px rgba(0,0,0,.4), 0 4px 18px rgba(0,0,0,.4);
    --lvd-shadow-hover: 0 8px 32px rgba(0,0,0,.55);
    --lvd-badge-bg:     #1a2a4a;
    --lvd-badge-color:  #79b8ff;
    background-color:   var(--lvd-bg);
    color:              var(--lvd-text);
}

/* ═══════════════════════════════════════════════
   FLAG NAVIGATION
═══════════════════════════════════════════════ */
.lvd-nav {
    display:         flex;
    flex-wrap:       wrap;
    justify-content: center;
    align-items:     flex-start;
    gap:             10px;
    margin-bottom:   36px;
    padding:         4px 0;
}

/* Scroll mode */
.lvd-nav.lvd-nav-scroll {
    flex-wrap:    nowrap;
    overflow-x:   auto;
    padding-bottom: 10px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--lvd-border) transparent;
}
.lvd-nav.lvd-nav-scroll::-webkit-scrollbar { height: 3px; }
.lvd-nav.lvd-nav-scroll::-webkit-scrollbar-track { background: transparent; }
.lvd-nav.lvd-nav-scroll::-webkit-scrollbar-thumb { background: var(--lvd-border); border-radius: 2px; }

/* Individual tab */
.lvd-tab {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            7px;
    padding:        10px 14px;
    border:         2px solid var(--lvd-border);
    border-radius:  12px;
    background:     var(--lvd-card-bg);
    cursor:         pointer;
    flex-shrink:    0;
    scroll-snap-align: start;
    position:       relative;
    outline:        none;
    transition:
        border-color var(--lvd-dur) var(--lvd-ease),
        background   var(--lvd-dur) var(--lvd-ease),
        box-shadow   var(--lvd-dur) var(--lvd-ease),
        transform    var(--lvd-dur) var(--lvd-ease);
    box-shadow: var(--lvd-shadow-sm);
}
.lvd-tab:hover {
    border-color: var(--lvd-accent);
    transform:    translateY(-3px) scale(1.02);
    box-shadow:   0 6px 20px rgba(37,99,235,.16);
}
.lvd-tab:focus-visible {
    outline:        3px solid var(--lvd-accent);
    outline-offset: 3px;
}
.lvd-tab.is-active {
    border-color: var(--lvd-accent);
    background:   var(--lvd-card-bg);
    box-shadow:   0 0 0 3px rgba(37,99,235,.15), var(--lvd-shadow-sm);
    transform:    translateY(-3px);
}
.lvd-tab.is-active::after {
    content:        '';
    position:       absolute;
    bottom:         -2px;
    left:           50%;
    transform:      translateX(-50%);
    width:          24px;
    height:         3px;
    background:     var(--lvd-accent);
    border-radius:  2px;
}

/* Flag image */
.lvd-tab-flag {
    display:       flex;
    align-items:   center;
    justify-content: center;
    width:          52px;
    height:         36px;
    border-radius:  6px;
    overflow:       hidden;
    flex-shrink:    0;
    background:     var(--lvd-border);
}
.lvd-tab-flag img {
    width:      100%;
    height:     100%;
    object-fit: cover;
    display:    block;
}
.lvd-flag-emoji {
    font-size:   28px;
    line-height: 1;
}

/* Country label */
.lvd-tab-label {
    font-size:      10px;
    font-weight:    700;
    color:          var(--lvd-muted);
    white-space:    nowrap;
    letter-spacing: .4px;
    text-transform: uppercase;
    transition:     color var(--lvd-dur) var(--lvd-ease);
    line-height:    1;
}
.lvd-tab.is-active .lvd-tab-label { color: var(--lvd-accent); }

/* ═══════════════════════════════════════════════
   COUNTRY SECTIONS & GRID
═══════════════════════════════════════════════ */
.lvd-panel { position: relative; }

.lvd-country-section        { display: none; }
.lvd-country-section.is-visible {
    display:   block;
    animation: lvd-section-in .3s ease both;
}
@keyframes lvd-section-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.lvd-grid {
    display:               grid;
    grid-template-columns: repeat(4, 1fr);
    gap:                   24px;
}

/* ═══════════════════════════════════════════════
   EMPTY STATE CARD
═══════════════════════════════════════════════ */
.lvd-empty-card {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    justify-content:center;
    text-align:     center;
    padding:        56px 32px;
    background:     var(--lvd-card-bg);
    border-radius:  var(--lvd-radius);
    border:         2px dashed var(--lvd-border);
    gap:            16px;
    animation:      lvd-section-in .3s ease both;
}
.lvd-empty-icon {
    width:           72px;
    height:          72px;
    border-radius:   50%;
    background:      var(--lvd-bg);
    display:         flex;
    align-items:     center;
    justify-content: center;
    flex-shrink:     0;
}
.lvd-empty-icon svg { color: var(--lvd-border); }
.lvd-empty-card h4 {
    margin:      0;
    font-size:   16px;
    font-weight: 700;
    color:       var(--lvd-text);
}
.lvd-empty-card p {
    margin:      0;
    font-size:   14px;
    color:       var(--lvd-muted);
    max-width:   300px;
    line-height: 1.65;
}

/* ═══════════════════════════════════════════════
   VOLUNTEER CARD
═══════════════════════════════════════════════ */
.lvd-card {
    background:    var(--lvd-card-bg);
    border-radius: var(--lvd-radius);
    overflow:      hidden;
    box-shadow:    var(--lvd-shadow-sm);
    border:        1px solid var(--lvd-border);
    cursor:        pointer;
    outline:       none;
    animation:     lvd-card-in .4s ease both;
    animation-delay: var(--lvd-card-delay, 0s);
    transition:
        transform  var(--lvd-dur) var(--lvd-ease),
        box-shadow var(--lvd-dur) var(--lvd-ease);
}
@keyframes lvd-card-in {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.lvd-card:hover {
    transform:  translateY(-6px);
    box-shadow: var(--lvd-shadow-hover);
}
.lvd-card:focus-visible {
    outline:        3px solid var(--lvd-accent);
    outline-offset: 3px;
}

/* Image */
.lvd-card-img-wrap {
    position:    relative;
    padding-top: 100%;
    overflow:    hidden;
    background:  var(--lvd-border);
}
.lvd-card-img {
    position:   absolute;
    inset:      0;
    width:      100%;
    height:     100%;
    object-fit: cover;
    display:    block;
    transition: transform .55s var(--lvd-ease);
}
.lvd-card:hover .lvd-card-img { transform: scale(1.07); }

.lvd-card-overlay {
    position:        absolute;
    inset:           0;
    background:      linear-gradient(to top, rgba(0,0,0,.55) 0%, rgba(0,0,0,.1) 40%, transparent 70%);
    display:         flex;
    align-items:     center;
    justify-content: center;
    opacity:         0;
    transition:      opacity var(--lvd-dur) var(--lvd-ease);
}
.lvd-card:hover .lvd-card-overlay { opacity: 1; }
.lvd-card-view-icon { color: #fff; display: flex; }

/* Body */
.lvd-card-body { padding: 16px; text-align: center; }
.lvd-card-name {
    margin:           0 0 4px;
    font-size:        15px;
    font-weight:      700;
    color:            var(--lvd-text);
    line-height:      1.3;
    display:          -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow:         hidden;
}
.lvd-card-role {
    margin:           0 0 8px;
    font-size:        12px;
    color:            var(--lvd-muted);
    line-height:      1.4;
    display:          -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow:         hidden;
}
.lvd-card-country-badge {
    display:       inline-block;
    padding:       3px 10px;
    background:    var(--lvd-badge-bg);
    color:         var(--lvd-badge-color);
    border-radius: 20px;
    font-size:     11px;
    font-weight:   600;
    line-height:   1.5;
}

/* ═══════════════════════════════════════════════
   MODAL — TRUE LANDSCAPE SPLIT
═══════════════════════════════════════════════ */
.lvd-modal {
    position:        fixed;
    inset:           0;
    z-index:         99999;
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         20px;
}
.lvd-modal[hidden] { display: none; }

.lvd-modal-backdrop {
    position:                absolute;
    inset:                   0;
    background:              rgba(0,0,0,.65);
    backdrop-filter:         blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation:               lvd-bd-in .24s ease both;
}
@keyframes lvd-bd-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.lvd-modal-content {
    position:       relative;
    background:     var(--lvd-card-bg);
    border-radius:  20px;
    width:          100%;
    max-width:      820px;
    /* Fixed height so both panels are equal */
    height:         480px;
    max-height:     90vh;
    overflow:       hidden;
    box-shadow:     var(--lvd-shadow-modal);
    animation:      lvd-modal-in .32s cubic-bezier(.34,1.4,.64,1) both;
    display:        flex;
    flex-direction: row;   /* LANDSCAPE always on desktop */
}
@keyframes lvd-modal-in {
    from { opacity: 0; transform: scale(.9) translateY(20px); }
    to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.lvd-modal--closing .lvd-modal-content  { animation: lvd-modal-out .2s ease both; }
.lvd-modal--closing .lvd-modal-backdrop { animation: lvd-bd-in .2s ease reverse both; }
@keyframes lvd-modal-out {
    to { opacity: 0; transform: scale(.92) translateY(10px); }
}

/* ── Close button (top-right corner, over image) */
.lvd-modal-close {
    position:        absolute;
    top:             12px;
    right:           12px;
    z-index:         20;
    width:           36px;
    height:          36px;
    border-radius:   50%;
    border:          none;
    background:      rgba(0,0,0,.35);
    color:           #fff;
    cursor:          pointer;
    display:         flex;
    align-items:     center;
    justify-content: center;
    transition:
        background var(--lvd-dur) var(--lvd-ease),
        transform  var(--lvd-dur) var(--lvd-ease),
        color      var(--lvd-dur) var(--lvd-ease);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.lvd-modal-close:hover    { background: rgba(0,0,0,.55); transform: scale(1.1) rotate(90deg); }
.lvd-modal-close:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ── Left: image panel */
.lvd-modal-img-panel {
    flex:       0 0 300px;
    width:      300px;
    background: #1a1a2e;
    overflow:   hidden;
    position:   relative;
}
.lvd-modal-img {
    width:           100%;
    height:          100%;
    object-fit:      cover;
    object-position: center top;
    display:         block;
}

/* ── Right: info panel */
.lvd-modal-info {
    flex:           1;
    min-width:      0;
    display:        flex;
    flex-direction: column;
    overflow-y:     auto;
    scrollbar-width:thin;
    scrollbar-color:var(--lvd-border) transparent;
}

/* Meta block at top of info — sticky so name stays visible on scroll */
.lvd-modal-meta {
    padding:       32px 32px 20px;
    border-bottom: 1px solid var(--lvd-border);
    flex-shrink:   0;
    position:      sticky;
    top:           0;
    z-index:       2;
    background:    var(--lvd-card-bg);
}

/* When NO details exist, centre content vertically inside the info panel */
.lvd-modal-info.has-no-details {
    justify-content: center;
}
.lvd-modal-info.has-no-details .lvd-modal-meta {
    border-bottom: none;
    text-align:    center;
    padding:       40px 32px;
}
.lvd-modal-info.has-no-details .lvd-modal-meta .lvd-modal-country-badge {
    display: inline-flex;
}

.lvd-modal-name {
    margin:      0 0 6px;
    font-size:   22px;
    font-weight: 800;
    color:       var(--lvd-text);
    line-height: 1.2;
}
.lvd-modal-position {
    margin:      0 0 12px;
    font-size:   14px;
    color:       var(--lvd-muted);
    line-height: 1.4;
}
.lvd-modal-country-badge {
    display:       inline-flex;
    align-items:   center;
    gap:           5px;
    padding:       5px 13px;
    background:    var(--lvd-badge-bg);
    color:         var(--lvd-badge-color);
    border-radius: 20px;
    font-size:     12px;
    font-weight:   700;
}

/* Sections below meta */
.lvd-modal-sections {
    padding:        20px 32px 28px;
    display:        flex;
    flex-direction: column;
    gap:            14px;
    flex:           1;
}
.lvd-modal-section { display: flex; flex-direction: column; }

.lvd-modal-bio,
.lvd-modal-desc {
    margin:      0;
    color:       var(--lvd-muted);
    font-size:   14px;
    line-height: 1.75;
}

/* Social links */
.lvd-modal-socials {
    display:   flex;
    gap:       8px;
    flex-wrap: wrap;
}
.lvd-modal-social-link {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    width:           36px;
    height:          36px;
    border-radius:   50%;
    border:          1px solid var(--lvd-border);
    background:      var(--lvd-bg);
    color:           var(--lvd-text);
    text-decoration: none;
    transition:
        background   var(--lvd-dur) var(--lvd-ease),
        color        var(--lvd-dur) var(--lvd-ease),
        border-color var(--lvd-dur) var(--lvd-ease),
        transform    var(--lvd-dur) var(--lvd-ease);
}
.lvd-modal-social-link:hover {
    background:   var(--lvd-accent);
    color:        #fff;
    border-color: var(--lvd-accent);
    transform:    scale(1.1);
}

/* CTA button */
.lvd-modal-btn {
    display:         inline-flex;
    align-items:     center;
    padding:         10px 24px;
    background:      var(--lvd-accent);
    color:           #fff;
    border-radius:   50px;
    text-decoration: none;
    font-size:       13px;
    font-weight:     700;
    width:           fit-content;
    transition:
        background var(--lvd-dur) var(--lvd-ease),
        transform  var(--lvd-dur) var(--lvd-ease),
        box-shadow var(--lvd-dur) var(--lvd-ease);
}
.lvd-modal-btn:hover {
    background:  #1d4ed8;
    transform:   translateY(-2px);
    box-shadow:  0 8px 20px rgba(37,99,235,.3);
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */

/* Tablet: 769 – 1024 */
@media (max-width: 1024px) {
    .lvd-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Mobile-large: 481 – 768 */
@media (max-width: 768px) {
    .lvd-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .lvd-nav  { gap: 8px; margin-bottom: 24px; }

    /* Modal stacks vertically */
    .lvd-modal-content {
        flex-direction: column;
        height:         auto;
        max-height:     90vh;
        overflow-y:     auto;
        border-radius:  16px;
    }
    .lvd-modal-img-panel {
        flex:   0 0 auto;
        width:  100%;
        height: 240px;
    }
    .lvd-modal-img { object-position: center 20%; }
    .lvd-modal-info { overflow-y: visible; }
    .lvd-modal-info.has-no-details { justify-content: flex-start; }
    .lvd-modal-meta { padding: 24px 20px 16px; }
    .lvd-modal-sections { padding: 16px 20px 24px; }
    .lvd-modal-name { font-size: 19px; }
    /* Reposition close button for stacked layout */
    .lvd-modal-close { top: 10px; right: 10px; }
}

/* Mobile-small: ≤ 480 */
@media (max-width: 480px) {
    .lvd-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .lvd-nav  { gap: 7px; }
    .lvd-tab  { padding: 8px 10px; }
    .lvd-tab-flag { width: 42px; height: 30px; }
    .lvd-tab-label { font-size: 9px; }
    .lvd-modal-content { border-radius: 14px; }
    .lvd-modal-img-panel { height: 200px; }
    .lvd-modal-name { font-size: 17px; }
    .lvd-modal-meta { padding: 18px 16px 14px; }
    .lvd-modal-sections { padding: 14px 18px 24px; }
}

/* ── Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .lvd-card,
    .lvd-card-img,
    .lvd-modal-content,
    .lvd-modal-backdrop,
    .lvd-country-section,
    .lvd-modal-close { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   PAGINATION  — Load More + Numbered (added v2.0)
   ========================================================================== */
.lvd-pagination {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* Showing count */
.lvd-showing-count {
    font-size: 13px;
    color: var(--lvd-muted);
    margin: 0;
}

/* Load More button */
.lvd-btn-load-more {
    display:         inline-flex;
    align-items:     center;
    gap:             8px;
    padding:         12px 32px;
    background:      var(--lvd-accent);
    color:           #fff;
    border:          none;
    border-radius:   50px;
    font-size:       14px;
    font-weight:     700;
    cursor:          pointer;
    transition:      background 0.2s, transform 0.2s, box-shadow 0.2s;
    outline-offset:  3px;
}
.lvd-btn-load-more:hover:not(:disabled) {
    background:  color-mix(in srgb, var(--lvd-accent) 85%, #000);
    transform:   translateY(-2px);
    box-shadow:  0 6px 20px rgba(0,0,0,0.2);
}
.lvd-btn-load-more:disabled {
    opacity: 0.7;
    cursor:  wait;
}

/* Loading indicator dots */
.lvd-btn-load-more::after {
    content:    '';
    display:    none;
    width:      14px; height: 14px;
    border:     2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation:  lvd-spin 0.6s linear infinite;
}
.lvd-btn-load-more:disabled::after { display: inline-block; }
@keyframes lvd-spin {
    to { transform: rotate(360deg); }
}

/* Numbered pagination */
.lvd-numbered-pagination { flex-direction: row; flex-wrap: wrap; }
.lvd-page-list {
    display:     flex;
    gap:         6px;
    list-style:  none;
    margin:      0;
    padding:     0;
}
.lvd-page-btn {
    display:      flex;
    align-items:  center;
    justify-content: center;
    min-width:    38px;
    height:       38px;
    padding:      0 10px;
    border:       2px solid var(--lvd-border);
    border-radius: 8px;
    background:   var(--lvd-card-bg);
    color:        var(--lvd-text);
    font-size:    14px;
    font-weight:  600;
    cursor:       pointer;
    transition:   border-color 0.2s, background 0.2s, color 0.2s;
}
.lvd-page-btn:hover:not(:disabled) {
    border-color: var(--lvd-accent);
    color:        var(--lvd-accent);
}
.lvd-page-btn.is-active,
.lvd-page-btn[aria-current="page"] {
    background:   var(--lvd-accent);
    border-color: var(--lvd-accent);
    color:        #fff;
    cursor:       default;
}
.lvd-page-btn:disabled {
    opacity: 0.45;
    cursor:  not-allowed;
}

/* Body scroll lock for modal — use class instead of inline style */
body.lvd-modal-open {
    overflow: hidden;
}

/* ==========================================================================
   RESPONSIVE — Pagination
   ========================================================================== */
@media (max-width: 480px) {
    .lvd-btn-load-more { padding: 11px 24px; font-size: 13px; }
    .lvd-page-btn { min-width: 34px; height: 34px; font-size: 13px; }
}

/* ── Extra-small phones (≤360px) ─────────────────────────────── */
@media (max-width: 360px) {
    .lvd-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .lvd-modal-img-panel { height: 180px; }
    .lvd-modal-name      { font-size: 16px; }
    .lvd-modal-meta      { padding: 16px 14px 12px; }
    .lvd-modal-sections  { padding: 12px 14px 18px; }
}
