/* Modal de detalle de proyecto — casi pantalla completa.
 *
 * Reemplaza al antiguo `.modal-content-proyect`, que era una caja de 1000px
 * con todo el contenido en una columna y los colores escritos en línea.
 *
 * Estructura:
 *   .pj            capa
 *   └ .pj__panel   rejilla de tres filas: cabecera fija, cuerpo, pie fijo
 *      ├ .pj__head    título, estado y cerrar — no se mueve al desplazar
 *      ├ .pj__body    dos columnas en escritorio: galería | ficha
 *      └ .pj__pie     acciones
 *
 * Misma escala de grises que el resto (--pf-*), cuerpo monoespaciado y
 * títulos en system-ui.
 */

.pj {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2vh 2vw;
    box-sizing: border-box;
    background: var(--pf-overlay);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.22s ease;
    overscroll-behavior: contain;
}

.pj[hidden] { display: none; }
.pj.is-open { opacity: 1; }

.pj__panel {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: min(1280px, 96vw);
    height: min(94vh, 900px);
    background: var(--pf-surface);
    color: var(--pf-text);
    border: 1px solid var(--pf-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
    opacity: 0;
    transform: translateY(16px) scale(0.985);
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

body.active_dark .pj__panel {
    background: #131313;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.pj.is-open .pj__panel {
    opacity: 1;
    transform: none;
}


/* ---------------------------------------------------------------- */
/*  Cabecera fija                                                    */
/* ---------------------------------------------------------------- */

.pj__head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--pf-border);
    background: var(--pf-surface);
}

body.active_dark .pj__head {
    background: #171717;
}

.pj__titulos {
    flex: 1 1 auto;
    min-width: 0;
}

.pj__titulo {
    margin: 0;
    font-size: clamp(1.05rem, 2.4vw, 1.45rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--pf-text);
    text-wrap: balance;
}

.pj__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
}

.pj__chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--pf-text-muted);
    border: 1px solid var(--pf-border);
    border-radius: 999px;
}

.pj__chip svg {
    width: 11px;
    height: 11px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* Un punto de color dice el estado sin gritar. */
.pj__chip--estado::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--pf-text-faint);
}

.pj__chip--estado.is-publico::before { background: #2f7d54; }
body.active_dark .pj__chip--estado.is-publico::before { background: #6bbd92; }

.pj__cerrar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--pf-text-muted);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pj__cerrar:hover {
    background: var(--pf-surface-2);
    border-color: var(--pf-border);
    color: var(--pf-text);
}

body.active_dark .pj__cerrar:hover {
    background: rgba(255, 255, 255, 0.07);
}

.pj__cerrar svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
}


/* ---------------------------------------------------------------- */
/*  Cuerpo                                                           */
/* ---------------------------------------------------------------- */

.pj__body {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 0;
    min-height: 0;
}

.pj__galeria,
.pj__ficha {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.pj__galeria {
    padding: 18px 14px 18px 20px;
    border-right: 1px solid var(--pf-border);
}

.pj__ficha {
    padding: 18px 20px 18px 18px;
}

@media (max-width: 900px) {
    /* En una columna deja de ser rejilla: como grid item cada bloque hereda
       `min-height: 0` y el navegador los encoge por debajo de su contenido
       para caber en la fila, y con overflow visible el contenido se salía
       encima del texto. Con `display: block` cada bloque ocupa lo suyo. */
    .pj__body {
        display: block;
        overflow-y: auto;
    }

    .pj__galeria,
    .pj__ficha {
        overflow: visible;
        min-height: auto;
    }

    .pj__galeria {
        border-right: none;
        border-bottom: 1px solid var(--pf-border);
        padding: 16px;
    }

    .pj__ficha { padding: 16px; }

    .pj__panel {
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }

    .pj { padding: 0; }

    .pj__head { padding: 14px 16px; }
    .pj__pie { padding: 12px 16px; }
}

@media (max-width: 520px) {
    /* Las flechas del visor viven en :hover, que en táctil no existe. */
    .pj__nav,
    .pj__ampliar { opacity: 1; }

    .pj__pie .pd-btn {
        flex: 1 1 140px;
        justify-content: center;
    }

    .pj__mini {
        width: 60px;
        height: 40px;
    }
}


/* ---------------------------------------------------------------- */
/*  Galería                                                          */
/* ---------------------------------------------------------------- */

.pj__visor {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--pf-surface-2);
    border: 1px solid var(--pf-border);
    aspect-ratio: 16 / 10;
    display: grid;
    place-items: center;
    cursor: zoom-in;
}

body.active_dark .pj__visor { background: #0d0d0d; }

.pj__visor img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Flechas y contador flotan sobre la imagen, no ocupan sitio. */
.pj__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.pj__visor:hover .pj__nav,
.pj__nav:focus-visible { opacity: 1; }

.pj__nav:hover { background: rgba(0, 0, 0, 0.8); }
.pj__nav--prev { left: 10px; }
.pj__nav--next { right: 10px; }

.pj__nav svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pj__contador {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 3px 9px;
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 999px;
    pointer-events: none;
}

.pj__ampliar {
    position: absolute;
    left: 10px;
    top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    border-radius: 999px;
    cursor: zoom-in;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.pj__visor:hover .pj__ampliar,
.pj__ampliar:focus-visible { opacity: 1; }

.pj__ampliar svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Miniaturas --------------------------------------------------- */

.pj__tiras {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-bottom: 4px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}

.pj__mini {
    flex: 0 0 auto;
    width: 72px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--pf-border);
    border-radius: 7px;
    overflow: hidden;
    background: var(--pf-surface-2);
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.2s ease, border-color 0.2s ease;
}

.pj__mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pj__mini:hover { opacity: 0.85; }

.pj__mini.is-activa {
    opacity: 1;
    border-color: var(--pf-accent);
}


/* ---------------------------------------------------------------- */
/*  Ficha                                                            */
/* ---------------------------------------------------------------- */

.pj__seccion + .pj__seccion {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--pf-border);
}

.pj__etiqueta {
    margin: 0 0 8px;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--pf-text-faint);
}

.pj__texto {
    margin: 0;
    font-size: 0.83rem;
    line-height: 1.65;
    color: var(--pf-text-muted);
    text-wrap: pretty;
}

.pj__lista {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.pj__lista li {
    position: relative;
    padding-left: 16px;
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--pf-text-muted);
}

.pj__lista li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 0.62em;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--pf-text-faint);
}

.pj__tecnologias {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pj__tec {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--pf-text-muted);
    background: var(--pf-surface-2);
    border: 1px solid var(--pf-border);
    border-radius: 7px;
}

body.active_dark .pj__tec { background: rgba(255, 255, 255, 0.04); }

.pj__tec svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}


/* ---------------------------------------------------------------- */
/*  Pie fijo                                                         */
/* ---------------------------------------------------------------- */

.pj__pie {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 13px 20px;
    border-top: 1px solid var(--pf-border);
    background: var(--pf-surface-2);
}

body.active_dark .pj__pie { background: #171717; }


/* ---------------------------------------------------------------- */
/*  Visor a pantalla completa                                        */
/* ---------------------------------------------------------------- */

.lb {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: rgba(0, 0, 0, 0.97);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.lb[hidden] { display: none; }
.lb.is-open { opacity: 1; }

.lb__barra {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #eaeaea;
}

.lb__titulo {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.86rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb__contador {
    font-size: 0.74rem;
    font-variant-numeric: tabular-nums;
    color: #9a9a9a;
}

.lb__btn {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 9px;
    color: #eaeaea;
    cursor: pointer;
    transition: background 0.18s ease;
}

.lb__btn:hover { background: rgba(255, 255, 255, 0.18); }
.lb__btn[aria-pressed="true"] { background: #eaeaea; color: #111; }

.lb__btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.1;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.lb__escena {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 0;
    padding: 0 16px;
    overflow: hidden;
}

.lb__escena img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    cursor: zoom-in;
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: center center;
}

.lb.is-zoom .lb__escena {
    overflow: auto;
    place-items: start center;
}

.lb.is-zoom .lb__escena img {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    cursor: grab;
}

.lb.is-zoom .lb__escena img:active { cursor: grabbing; }

.lb__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: background 0.18s ease;
}

.lb__nav:hover { background: rgba(255, 255, 255, 0.22); }
.lb__nav--prev { left: 16px; }
.lb__nav--next { right: 16px; }

.lb__nav svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.lb__tiras {
    display: flex;
    justify-content: center;
    gap: 7px;
    padding: 12px 16px;
    overflow-x: auto;
}

.lb__mini {
    flex: 0 0 auto;
    width: 62px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    overflow: hidden;
    background: #000;
    cursor: pointer;
    opacity: 0.45;
    transition: opacity 0.18s ease, border-color 0.18s ease;
}

.lb__mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lb__mini:hover { opacity: 0.8; }

.lb__mini.is-activa {
    opacity: 1;
    border-color: #fff;
}


/* ---------------------------------------------------------------- */

.pj :focus-visible,
.lb :focus-visible {
    outline: 2px solid var(--pf-accent);
    outline-offset: 2px;
}

.lb :focus-visible { outline-color: #fff; }

.pj__panel:focus,
.pj__panel:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
    .pj, .pj__panel, .lb, .lb__escena img { transition: none; }
    .pj__panel { transform: none; }
}
