/* =====================================================================
   WLM · Perfil social V3
   Portada tipo Facebook + galería personal tipo Instagram.
   Se carga después de profile.css y solo toca clases del perfil.
   ===================================================================== */

/* ======================== Portada del perfil propio ======================== */
.wlm-account-page .wlm-account-hero {
    min-height: 0;
    overflow: visible;
    border-radius: 30px;
}

.wlm-account-page .wlm-account-cover {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 820 / 312;
    max-height: 624px;
    border-radius: 30px 30px 0 0;
    background: linear-gradient(135deg, #f7f7f8, #fff4f5);
}

.wlm-account-page .wlm-account-cover > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.wlm-account-page .wlm-account-cover::after {
    background: linear-gradient(180deg, transparent 70%, rgba(0,0,0,.12));
    pointer-events: none;
}

.wlm-account-page .wlm-account-cover-orb,
.wlm-account-page .wlm-account-cover-grid {
    display: none;
}

.wlm-account-page .wlm-cover-media-control {
    top: clamp(18px, 2.2vw, 30px);
    right: clamp(18px, 2.2vw, 30px);
    z-index: 6;
}

.wlm-account-page .wlm-account-identity-card {
    grid-template-columns: 168px minmax(0, 1fr);
    align-items: end;
    gap: 24px;
    padding: 0 30px 22px;
    margin-top: -82px;
}

.wlm-account-page .wlm-profile-avatar-xl {
    width: 168px;
    height: 168px;
    border-width: 7px;
    border-radius: 40px;
}

.wlm-account-page .wlm-account-identity-main {
    padding: 94px 0 4px;
}

.wlm-account-page .wlm-account-identity-main h1 {
    font-size: clamp(38px, 4.4vw, 66px);
}

.wlm-account-page .wlm-profile-stat-strip {
    margin-top: 2px;
}

/* ======================== Portada del perfil público ======================= */

.wlm-profile-public .wlm-profile-minimal-cover {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 820 / 312;
    max-height: 624px;
    overflow: hidden;
}

.wlm-profile-public .wlm-profile-minimal-cover > img,
.wlm-profile-public .wlm-profile-cover-fallback {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================== Fotos ==================================== */
.wlm-profile-photos-section {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--border, rgba(17,17,17,.1));
    border-radius: 30px;
    background: #fff;
    box-shadow: var(--shadow-sm, 0 12px 36px rgba(0,0,0,.06));
    scroll-margin-top: 110px;
}

.wlm-profile-public .wlm-profile-photos-section {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.wlm-profile-photos-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    margin-bottom: 18px;
}

.wlm-profile-photos-head-copy > span {
    display: block;
    margin-bottom: 5px;
    color: var(--brand, #ff385c);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .045em;
    text-transform: uppercase;
}

.wlm-profile-photos-head h2 {
    margin: 0;
    color: var(--ink, #111);
    font-family: var(--font-display, "Plus Jakarta Sans", sans-serif);
    font-size: clamp(25px, 3vw, 36px);
    line-height: 1;
    letter-spacing: -.05em;
}

.wlm-profile-photos-head p {
    margin: 7px 0 0;
    color: var(--muted, #6f7078);
    font-size: 13px;
    line-height: 1.5;
}

.wlm-profile-photo-upload-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--brand, #ff385c);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(255,56,92,.22);
}

.wlm-profile-photo-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    overflow: hidden;
    border-radius: 20px;
    background: #f1f1f3;
}

.wlm-profile-photo-card {
    position: relative;
    min-width: 0;
    aspect-ratio: 1;
    margin: 0;
    overflow: hidden;
    background: #e7e7ea;
    isolation: isolate;
}

.wlm-profile-photo-card img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform .3s ease;
}

.wlm-profile-photo-card:hover img { transform: scale(1.025); }

.wlm-profile-photo-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    background: rgba(0,0,0,.38);
    color: #fff;
    opacity: 0;
    transition: opacity .18s ease;
    pointer-events: none;
}

.wlm-profile-photo-card:hover .wlm-profile-photo-overlay,
.wlm-profile-photo-card:focus-within .wlm-profile-photo-overlay { opacity: 1; }

.wlm-profile-photo-overlay span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    font-weight: 900;
}

.wlm-profile-photo-visibility {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;
    min-width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(17,17,17,.72);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 11px;
}

.wlm-profile-photo-empty,
.wlm-profile-photo-loading {
    min-height: 280px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    padding: 32px;
    border: 1px dashed rgba(17,17,17,.15);
    border-radius: 24px;
    color: var(--muted, #73747c);
    text-align: center;
}

.wlm-profile-photo-empty i,
.wlm-profile-photo-loading i {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: rgba(255,56,92,.09);
    color: var(--brand, #ff385c);
    font-size: 21px;
}

.wlm-profile-photo-empty strong { color: var(--ink, #111); font-size: 17px; }
.wlm-profile-photo-empty p { max-width: 460px; margin: 0; font-size: 13px; line-height: 1.5; }

/* ============================= Modal upload ============================== */
.wlm-photo-upload-modal[hidden] { display: none !important; }
.wlm-photo-upload-modal {
    position: fixed;
    inset: 0;
    z-index: 880;
    display: grid;
    place-items: center;
    padding: 20px;
}

.wlm-photo-upload-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12,12,16,.72);
    backdrop-filter: blur(10px);
}

.wlm-photo-upload-dialog {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    max-height: min(88dvh, 840px);
    display: grid;
    grid-template-rows: auto minmax(0,1fr) auto;
    overflow: hidden;
    border-radius: 28px;
    background: #fff;
    box-shadow: 0 36px 120px rgba(0,0,0,.38);
}

.wlm-photo-upload-head,
.wlm-photo-upload-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(17,17,17,.1);
}

.wlm-photo-upload-foot { border-top: 1px solid rgba(17,17,17,.1); border-bottom: 0; }
.wlm-photo-upload-head h2 { margin: 0; font-size: 20px; letter-spacing: -.035em; }
.wlm-photo-upload-head button {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 999px;
    background: #f3f3f5;
    cursor: pointer;
}

.wlm-photo-upload-body {
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
}

.wlm-photo-upload-previews {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 8px;
    margin-bottom: 18px;
}

.wlm-photo-upload-preview {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 14px;
    background: #eee;
}

.wlm-photo-upload-preview img { width: 100%; height: 100%; object-fit: cover; }

.wlm-photo-upload-fields { display: grid; gap: 14px; }
.wlm-photo-upload-fields label { display: grid; gap: 7px; color: #25252a; font-size: 12px; font-weight: 850; }
.wlm-photo-upload-fields textarea,
.wlm-photo-upload-fields select {
    width: 100%;
    border: 1px solid rgba(17,17,17,.14);
    border-radius: 16px;
    outline: 0;
    background: #f8f8f9;
    font: inherit;
}

.wlm-photo-upload-fields textarea { min-height: 100px; padding: 13px; resize: vertical; }
.wlm-photo-upload-fields select { height: 46px; padding: 0 12px; }
.wlm-photo-upload-toggle { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 10px !important; }

.wlm-photo-upload-status { min-height: 20px; color: #72727a; font-size: 12px; }
.wlm-photo-upload-status.is-error { color: #d82f51; }
.wlm-photo-upload-actions { display: flex; gap: 9px; margin-left: auto; }
.wlm-photo-upload-actions button {
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid rgba(17,17,17,.12);
    border-radius: 999px;
    background: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 850;
    cursor: pointer;
}

.wlm-photo-upload-actions .is-primary { border-color: #ff385c; background: #ff385c; color: #fff; }
.wlm-photo-upload-actions button:disabled { opacity: .55; cursor: wait; }

/* Botón peligroso del menú existente de avatar/portada. */
.wlm-media-context-menu button.is-danger { color: #d82f51; }

@media (max-width: 800px) {
    .wlm-account-page .wlm-account-cover,
    .wlm-profile-public .wlm-profile-minimal-cover,
    .wlm-profile-private .wlm-profile-minimal-cover {
        aspect-ratio: 16 / 9;
        border-radius: 22px 22px 0 0;
    }

    .wlm-account-page .wlm-account-identity-card {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        margin-top: -62px;
        padding: 0 18px 20px;
    }

    .wlm-account-page .wlm-profile-avatar-xl {
        width: 132px;
        height: 132px;
        border-radius: 34px;
    }

    .wlm-account-page .wlm-account-identity-main { padding-top: 0; }
    .wlm-account-page .wlm-account-kicker-row,
    .wlm-account-page .wlm-profile-meta-row,
    .wlm-account-page .wlm-profile-actions { justify-content: center; }

    .wlm-profile-photos-section { padding: 16px; border-radius: 24px; }
    .wlm-profile-photos-head { align-items: start; }
    .wlm-profile-photo-grid { gap: 3px; border-radius: 14px; }
    .wlm-profile-photo-overlay { display: none; }
    .wlm-photo-upload-previews { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 520px) {
    .wlm-profile-photos-head { display: grid; }
    .wlm-profile-photo-upload-button { width: 100%; }
    .wlm-photo-upload-modal { padding: 0; }
    .wlm-photo-upload-dialog { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; }
    .wlm-photo-upload-previews { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    .wlm-profile-photo-card img,
    .wlm-profile-photo-overlay { transition: none; }
}

/* ==================== Perfil privado actual (layout minimal) ==================== */

.wlm-profile-private .wlm-profile-minimal-cover {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 820 / 312;
    max-height: 624px;
    overflow: hidden;
}

.wlm-profile-private .wlm-profile-minimal-cover > img,
.wlm-profile-private .wlm-profile-cover-fallback {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wlm-profile-private .wlm-cover-media-control {
    top: clamp(18px, 2.2vw, 30px);
    right: clamp(18px, 2.2vw, 30px);
    z-index: 6;
}

@media (max-width: 720px) {
    .wlm-profile-private .wlm-profile-minimal-cover,
    .wlm-profile-public .wlm-profile-minimal-cover,
    .wlm-account-page .wlm-account-cover {
        aspect-ratio: 16 / 9;
        max-height: none;
    }
}

/* El contador de fotos se integra sin reemplazar métricas existentes. */
.wlm-profile-private .wlm-profile-minimal-stats,
.wlm-profile-public .wlm-profile-minimal-stats {
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
}

.wlm-account-page .wlm-profile-stat-strip {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* ================= Avatar 160 px + visor ampliado ================= */
.wlm-account-page .wlm-profile-avatar-xl,
.wlm-profile-private .wlm-profile-minimal-avatar,
.wlm-profile-public .wlm-profile-minimal-avatar {
    width: 160px !important;
    height: 160px !important;
    min-width: 160px;
    flex: 0 0 160px;
}

.wlm-account-page .wlm-account-identity-card {
    grid-template-columns: 160px minmax(0, 1fr);
}

.wlm-profile-avatar-xl.is-avatar-viewable,
.wlm-profile-minimal-avatar.is-avatar-viewable,
#wlmProfileAvatarPreview.is-avatar-viewable {
    cursor: zoom-in;
}

.wlm-profile-avatar-xl.is-avatar-viewable:focus-visible,
.wlm-profile-minimal-avatar.is-avatar-viewable:focus-visible,
#wlmProfileAvatarPreview.is-avatar-viewable:focus-visible {
    outline: 3px solid var(--brand, #ff385c);
    outline-offset: 4px;
}

.wlm-avatar-viewer {
    position: fixed;
    inset: 0;
    z-index: 950;
    display: none;
    place-items: center;
    padding: 28px;
}

.wlm-avatar-viewer.is-open {
    display: grid;
}

body.wlm-avatar-viewer-open {
    overflow: hidden;
}

.wlm-avatar-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 9, 13, .92);
    backdrop-filter: blur(14px);
}

.wlm-avatar-viewer-dialog {
    position: relative;
    z-index: 1;
    width: min(720px, 92vw);
    height: min(720px, 82vh);
    display: grid;
    place-items: center;
    margin: 0;
}

.wlm-avatar-viewer-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: clamp(22px, 4vw, 42px);
    background: #111218;
    box-shadow: 0 40px 120px rgba(0, 0, 0, .58);
    animation: wlm-avatar-viewer-in .22s ease-out;
    user-select: none;
    -webkit-user-drag: none;
}

.wlm-avatar-viewer-close {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(255,255,255,.96);
    color: #111;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 14px 38px rgba(0,0,0,.34);
}

.wlm-avatar-viewer-close:hover {
    transform: scale(1.06);
}

.wlm-avatar-viewer-close:focus-visible {
    outline: 3px solid var(--brand, #ff385c);
    outline-offset: 3px;
}

@keyframes wlm-avatar-viewer-in {
    from { opacity: 0; transform: scale(.96); }
    to { opacity: 1; transform: scale(1); }
}

@media (max-width: 800px) {
    .wlm-account-page .wlm-account-identity-card {
        grid-template-columns: 1fr;
    }

    .wlm-account-page .wlm-profile-avatar-xl,
    .wlm-profile-private .wlm-profile-minimal-avatar,
    .wlm-profile-public .wlm-profile-minimal-avatar {
        width: 132px !important;
        height: 132px !important;
        min-width: 132px;
        flex-basis: 132px;
    }

    .wlm-avatar-viewer {
        padding: 18px;
    }

    .wlm-avatar-viewer-dialog {
        width: 94vw;
        height: 78vh;
    }

    .wlm-avatar-viewer-close {
        top: 14px;
        right: 14px;
        width: 44px;
        height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wlm-avatar-viewer-image { animation: none; }
}

/* ================= V3.4 · Avatar sin invadir la identidad =================
   El avatar creció de 124 px a 160 px, por lo que también deben crecer:
   1) la primera columna del grid y 2) el wrapper del avatar privado.
   Sin esto, la imagen ocupa 160 px dentro de una columna de 124 px y se
   superpone sobre el nombre, el handle y la biografía.
   ========================================================================== */

.wlm-profile-private .wlm-profile-minimal-identity,
.wlm-profile-public .wlm-profile-minimal-identity {
    grid-template-columns: 160px minmax(0, 1fr) auto;
    column-gap: 26px;
}

.wlm-profile-minimal .wlm-profile-avatar-wrap {
    width: 160px !important;
    height: 160px !important;
    min-width: 160px;
    flex: 0 0 160px;
}

.wlm-profile-private .wlm-profile-minimal-copy,
.wlm-profile-public .wlm-profile-minimal-copy {
    min-width: 0;
}

@media (max-width: 980px) {
    .wlm-profile-private .wlm-profile-minimal-identity,
    .wlm-profile-public .wlm-profile-minimal-identity {
        grid-template-columns: 132px minmax(0, 1fr);
        column-gap: 22px;
    }

    .wlm-profile-minimal .wlm-profile-avatar-wrap {
        width: 132px !important;
        height: 132px !important;
        min-width: 132px;
        flex-basis: 132px;
    }

    .wlm-profile-private .wlm-profile-minimal-actions,
    .wlm-profile-public .wlm-profile-minimal-actions {
        padding-left: 154px;
    }
}

@media (max-width: 720px) {
    .wlm-profile-private .wlm-profile-minimal-identity,
    .wlm-profile-public .wlm-profile-minimal-identity {
        display: block;
    }

    .wlm-profile-minimal .wlm-profile-avatar-wrap {
        width: 132px !important;
        height: 132px !important;
        min-width: 132px;
    }

    .wlm-profile-private .wlm-profile-minimal-actions,
    .wlm-profile-public .wlm-profile-minimal-actions {
        padding-left: 0;
    }
}