/**
 * Private Gallery Pro — Frontend Styles
 *
 * Stili per gallerie, griglia immagini, breadcrumb, paginazione,
 * sotto-gallerie, form accesso e layout responsive.
 *
 * @package PGP
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    --pgp-accent: #2563eb;
    --pgp-accent-hover: #1d4ed8;
    --pgp-text: #1a1a1a;
    --pgp-text-muted: #6b7280;
    --pgp-bg: #ffffff;
    --pgp-bg-alt: #f9fafb;
    --pgp-border: #e5e7eb;
    --pgp-radius: 8px;
    --pgp-radius-sm: 4px;
    --pgp-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --pgp-shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
    --pgp-transition: 0.2s ease;
    --pgp-gap: 12px;
    --pgp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* ==========================================================================
   Gallery Container
   ========================================================================== */

.pgp-site-content {
    --pgp-content-pad-y: 2rem;
    --pgp-content-pad-x: 1.5rem;
    width: 100%; /* Needed when parent is a flex-column container (e.g. Sunya/some themes make body flex) */
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--pgp-content-pad-y) var(--pgp-content-pad-x);
}

.pgp-gallery {
    font-family: var(--pgp-font);
    color: var(--pgp-text);
    line-height: 1.6;
}

/* ==========================================================================
   Branding Logo
   ========================================================================== */

.pgp-branding-logo {
    margin-bottom: 1.5rem;
}

.pgp-branding-logo img {
    max-width: 200px;
    max-height: 80px;
    width: auto;
    height: auto;
}

.pgp-logo-link {
    display: inline-block;
    text-decoration: none;
}

.pgp-logo-link:focus-visible {
    outline: 2px solid var(--pgp-accent);
    outline-offset: 4px;
    border-radius: 2px;
}

/* ==========================================================================
   Gallery Header
   ========================================================================== */

.pgp-gallery-header {
    margin-bottom: 2rem;
}

.pgp-gallery-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    line-height: 1.2;
}

.pgp-gallery-description {
    color: var(--pgp-text-muted);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.pgp-gallery-count {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--pgp-text-muted);
}

/* ==========================================================================
   Gallery Hero (Header Image)
   ========================================================================== */

/* Full-bleed: esce dal container .pgp-site-content (max-width 1400px).
   Tecnica 100vw + negative margin. Richiede che il tema NON forzi
   overflow-x bloccato: il body deve permettere clip dell'overflow
   (Sunya: ok, perché .sunya-site è flex column). */
.pgp-gallery-hero {
    position: relative;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    /* Compensa il padding-top di .pgp-site-content per attaccare
       l'hero al top del viewport (sotto l'header del tema). */
    margin-top: calc(-1 * var(--pgp-content-pad-y, 2rem));
    margin-bottom: 2rem;
    overflow: hidden;
    background: #0a0a0a;
    display: grid;
    place-items: center;
    isolation: isolate;
}

.pgp-hero--hero {
    min-height: 60vh;
}

@media (min-width: 1024px) {
    .pgp-hero--hero {
        min-height: 70vh;
    }
}

.pgp-hero--cover {
    min-height: 100vh;
}

.pgp-gallery-hero__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 0;
}

/* Compat wrapper di plugin terzi (v1.15.1).
   Plugin di image protection (es. Image Shield) wrappano ogni <img> in uno
   <span position:relative>: come grid item di un hero con place-items:center
   il wrapper si dimensiona a contenuto (solo figli absolute -> 0x0) e da
   positioned diventa il containing block dell'immagine -> hero invisibile.
   Qualunque figlio diretto dell'hero che non sia overlay o content viene
   quindi assolutizzato full-bleed: senza wrapper la regola coincide con
   .pgp-gallery-hero__image (no-op), con wrapper lo rende full-size e
   l'immagine (100% x 100%) riempie. NON aggiungere altri figli diretti
   all'hero senza estendere questa esclusione. */
.pgp-gallery-hero > :not(.pgp-gallery-hero__overlay):not(.pgp-gallery-hero__content) {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.pgp-gallery-hero__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.55) 100%);
    pointer-events: none;
    z-index: 1;
}

.pgp-gallery-hero__content {
    position: relative;
    z-index: 2;
    color: #fff;
    text-align: center;
    padding: 3rem 1.5rem;
    max-width: 900px;
    width: 100%;
}

.pgp-gallery-hero__title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    margin: 0 0 0.75rem;
    line-height: 1.1;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.pgp-gallery-hero__description {
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    margin: 0;
    line-height: 1.5;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    opacity: 0.95;
}

@media (max-width: 768px) {
    .pgp-hero--hero {
        min-height: 45vh;
    }
    .pgp-hero--cover {
        min-height: 80vh;
    }
}

/* Quando l'hero è attivo, il blocco header standard mostra solo il count. */
.pgp-gallery-header--minimal {
    margin-bottom: 1.5rem;
}

.pgp-gallery-header--minimal .pgp-gallery-count {
    display: inline-block;
}

/* ==========================================================================
   Breadcrumb
   ========================================================================== */

.pgp-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--pgp-text-muted);
}

.pgp-crumb {
    color: var(--pgp-accent);
    text-decoration: none;
    transition: color var(--pgp-transition);
}

.pgp-crumb:hover {
    color: var(--pgp-accent-hover);
    text-decoration: underline;
}

.pgp-crumb-current {
    color: var(--pgp-text);
    font-weight: 500;
}

.pgp-crumb-sep {
    margin: 0 0.25rem;
    color: var(--pgp-border);
    user-select: none;
}

/* ==========================================================================
   Image Grid — Base
   ========================================================================== */

.pgp-gallery-grid {
    gap: var(--pgp-gap);
}

/* Layout: Grid (default) */
.pgp-gallery-grid.pgp-layout-grid {
    display: grid;
}

.pgp-layout-grid.pgp-cols-1 { grid-template-columns: 1fr; }
.pgp-layout-grid.pgp-cols-2 { grid-template-columns: repeat(2, 1fr); }
.pgp-layout-grid.pgp-cols-3 { grid-template-columns: repeat(3, 1fr); }
.pgp-layout-grid.pgp-cols-4 { grid-template-columns: repeat(4, 1fr); }
.pgp-layout-grid.pgp-cols-5 { grid-template-columns: repeat(5, 1fr); }
.pgp-layout-grid.pgp-cols-6 { grid-template-columns: repeat(6, 1fr); }
.pgp-layout-grid.pgp-cols-7 { grid-template-columns: repeat(7, 1fr); }
.pgp-layout-grid.pgp-cols-8 { grid-template-columns: repeat(8, 1fr); }

/* ==========================================================================
   Grid Item
   ========================================================================== */

.pgp-grid-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--pgp-radius-sm);
    background-color: var(--pgp-bg-alt);
}

.pgp-layout-grid .pgp-grid-item {
    aspect-ratio: 4 / 3;
}

.pgp-image-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.pgp-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.pgp-gallery-grid.pgp-layout-masonry .pgp-image {
    height: auto;
    object-fit: cover;
}

.pgp-image-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background var(--pgp-transition);
    pointer-events: none;
}

.pgp-grid-item:hover .pgp-image {
    transform: scale(1.03);
}

.pgp-grid-item:hover .pgp-image-overlay {
    background: rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   Layout: Masonry (JS-positioned, absolute)
   ==========================================================================
   Pre-init: gli item sono in flex-wrap come fallback (no FOUC con buchi).
   Post-init: classe .pgp-masonry-ready applicata da pgp-gallery.js,
   gli item vengono posizionati in absolute riempiendo le colonne più corte.
   Vedi MasonryManager in pgp-gallery.js. */

.pgp-gallery-grid.pgp-layout-masonry {
    display: flex;
    flex-wrap: wrap;
    gap: var(--pgp-gap);
}

.pgp-gallery-grid.pgp-layout-masonry .pgp-grid-item {
    aspect-ratio: auto;
    flex: 0 0 auto;
}

.pgp-gallery-grid.pgp-layout-masonry.pgp-cols-1 .pgp-grid-item { width: 100%; }
.pgp-gallery-grid.pgp-layout-masonry.pgp-cols-2 .pgp-grid-item { width: calc((100% - var(--pgp-gap)) / 2); }
.pgp-gallery-grid.pgp-layout-masonry.pgp-cols-3 .pgp-grid-item { width: calc((100% - 2 * var(--pgp-gap)) / 3); }
.pgp-gallery-grid.pgp-layout-masonry.pgp-cols-4 .pgp-grid-item { width: calc((100% - 3 * var(--pgp-gap)) / 4); }
.pgp-gallery-grid.pgp-layout-masonry.pgp-cols-5 .pgp-grid-item { width: calc((100% - 4 * var(--pgp-gap)) / 5); }
.pgp-gallery-grid.pgp-layout-masonry.pgp-cols-6 .pgp-grid-item { width: calc((100% - 5 * var(--pgp-gap)) / 6); }
.pgp-gallery-grid.pgp-layout-masonry.pgp-cols-7 .pgp-grid-item { width: calc((100% - 6 * var(--pgp-gap)) / 7); }
.pgp-gallery-grid.pgp-layout-masonry.pgp-cols-8 .pgp-grid-item { width: calc((100% - 7 * var(--pgp-gap)) / 8); }

/* Override quando JS ha inizializzato il layout assoluto. */
.pgp-gallery-grid.pgp-layout-masonry.pgp-masonry-ready {
    display: block;
    position: relative;
    gap: 0;
}

.pgp-gallery-grid.pgp-layout-masonry.pgp-masonry-ready .pgp-grid-item {
    position: absolute;
    top: 0;
    left: 0;
    flex: none;
    transition: top 0.2s ease, left 0.2s ease;
}

/* Disabilita transizioni durante il primo layout per evitare animazione di entrata. */
.pgp-gallery-grid.pgp-layout-masonry.pgp-masonry-init .pgp-grid-item {
    transition: none;
}

/* ==========================================================================
   Layout: Justified (flexbox row-height)
   ==========================================================================
   Altezza riga configurabile via metabox: il renderer emette
   style="--pgp-justified-h:<N>px" sul container .pgp-gallery-grid.
   Il flex-grow allarga le ultime immagini di ogni riga per riempire
   la larghezza disponibile, mantenendo l'altezza costante. */

.pgp-gallery-grid.pgp-layout-justified {
    display: flex;
    flex-wrap: wrap;
    gap: var(--pgp-gap);
}

.pgp-gallery-grid.pgp-layout-justified .pgp-grid-item {
    flex: 1 1 auto;
    height: var(--pgp-justified-h, 280px);
    /* min/max-width permettono al flex-grow di allargarsi senza pasticci
       né con foto strette né con foto larghe; aspect-ratio: auto rispetta
       le proporzioni native dell'immagine sotto. */
    min-width: 200px;
    max-width: 700px;
    aspect-ratio: auto;
}

.pgp-gallery-grid.pgp-layout-justified .pgp-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mobile: altezza ridotta automaticamente per non rubare schermo. */
@media (max-width: 768px) {
    .pgp-gallery-grid.pgp-layout-justified .pgp-grid-item {
        height: calc(var(--pgp-justified-h, 280px) * 0.7);
        min-width: 140px;
    }
}

@media (max-width: 480px) {
    .pgp-gallery-grid.pgp-layout-justified .pgp-grid-item {
        height: calc(var(--pgp-justified-h, 280px) * 0.55);
        min-width: 100px;
    }
}

/* ==========================================================================
   Children (Sub-galleries)
   ========================================================================== */

.pgp-children {
    margin-bottom: 2.5rem;
}

.pgp-children-heading {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem;
}

.pgp-children-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--pgp-gap);
}

.pgp-child-item {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: var(--pgp-radius);
    overflow: hidden;
    background: var(--pgp-bg);
    border: 1px solid var(--pgp-border);
    transition: box-shadow var(--pgp-transition), transform var(--pgp-transition);
}

.pgp-child-item:hover {
    box-shadow: var(--pgp-shadow-lg);
    transform: translateY(-2px);
}

.pgp-child-cover {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--pgp-bg-alt);
}

.pgp-child-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.pgp-child-item:hover .pgp-child-cover img {
    transform: scale(1.05);
}

.pgp-child-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--pgp-border);
}

.pgp-child-placeholder .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
}

.pgp-child-info {
    padding: 0.75rem 1rem;
}

.pgp-child-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    line-height: 1.3;
    color: var(--pgp-text);
}

.pgp-child-meta {
    font-size: 0.8125rem;
    color: var(--pgp-text-muted);
}

/* ==========================================================================
   Archive Grid
   ========================================================================== */

.pgp-archive {
    font-family: var(--pgp-font);
    color: var(--pgp-text);
}

.pgp-archive-header {
    margin-bottom: 2rem;
}

.pgp-archive-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.pgp-archive-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ==========================================================================
   Tree Navigation
   ========================================================================== */

.pgp-tree {
    font-family: var(--pgp-font);
}

.pgp-tree-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pgp-tree-list .pgp-tree-list {
    padding-left: 1.25rem;
}

.pgp-tree-item {
    margin-bottom: 0.25rem;
}

.pgp-tree-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--pgp-radius-sm);
    color: var(--pgp-text);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: background var(--pgp-transition), color var(--pgp-transition);
}

.pgp-tree-link:hover {
    background: var(--pgp-bg-alt);
    color: var(--pgp-accent);
}

.pgp-tree-link.pgp-tree-current {
    background: var(--pgp-bg-alt);
    color: var(--pgp-accent);
    font-weight: 600;
}

.pgp-tree-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    font-size: 20px;
    color: var(--pgp-text-muted);
}

.pgp-tree-link:hover .pgp-tree-icon,
.pgp-tree-link.pgp-tree-current .pgp-tree-icon {
    color: var(--pgp-accent);
}

.pgp-tree-count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--pgp-text-muted);
    background: var(--pgp-bg-alt);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
}

.pgp-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    color: var(--pgp-text-muted);
    transition: transform var(--pgp-transition);
}

.pgp-tree-toggle[aria-expanded="true"] {
    transform: rotate(90deg);
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pgp-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2rem;
    gap: 0.25rem;
}

.pgp-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.75rem;
    border: 1px solid var(--pgp-border);
    border-radius: var(--pgp-radius-sm);
    background: var(--pgp-bg);
    color: var(--pgp-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all var(--pgp-transition);
}

.pgp-page-link:hover {
    background: var(--pgp-bg-alt);
    border-color: var(--pgp-accent);
    color: var(--pgp-accent);
}

.pgp-page-current {
    background: var(--pgp-accent);
    border-color: var(--pgp-accent);
    color: #fff;
    font-weight: 600;
}

.pgp-page-current:hover {
    background: var(--pgp-accent-hover);
    color: #fff;
}

.pgp-page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--pgp-text-muted);
}

/* Load More */
.pgp-pagination-loadmore {
    flex-direction: column;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.pgp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--pgp-radius-sm);
    font-family: var(--pgp-font);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--pgp-transition);
    line-height: 1.4;
}

.pgp-btn-primary {
    background: var(--pgp-accent);
    color: #fff;
    border-color: var(--pgp-accent);
}

.pgp-btn-primary:hover {
    background: var(--pgp-accent-hover);
    border-color: var(--pgp-accent-hover);
}

.pgp-btn-loadmore {
    background: var(--pgp-bg);
    color: var(--pgp-text);
    border-color: var(--pgp-border);
    padding: 0.75rem 2rem;
}

.pgp-btn-loadmore:hover {
    border-color: var(--pgp-accent);
    color: var(--pgp-accent);
}

/* ==========================================================================
   Access Denied / Login / Password
   ========================================================================== */

.pgp-access-denied {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.pgp-access-box {
    text-align: center;
    max-width: 440px;
    padding: 3rem 2rem;
    background: var(--pgp-bg);
    border: 1px solid var(--pgp-border);
    border-radius: var(--pgp-radius);
    box-shadow: var(--pgp-shadow);
}

.pgp-access-icon {
    margin-bottom: 1rem;
}

.pgp-access-icon .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: var(--pgp-text-muted);
}

.pgp-access-box h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.pgp-access-box p {
    color: var(--pgp-text-muted);
    margin: 0 0 1.5rem;
}

/* Password form */
.pgp-password-form {
    margin-top: 1rem;
}

.pgp-form-row {
    display: flex;
    gap: 0.5rem;
}

.pgp-input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--pgp-border);
    border-radius: var(--pgp-radius-sm);
    font-family: var(--pgp-font);
    font-size: 0.9375rem;
    background: var(--pgp-bg);
    color: var(--pgp-text);
    transition: border-color var(--pgp-transition);
}

.pgp-input:focus {
    outline: none;
    border-color: var(--pgp-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Login form override */
.pgp-login-form {
    text-align: left;
    margin-top: 1rem;
}

.pgp-login-form label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.pgp-login-form input[type="text"],
.pgp-login-form input[type="password"] {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--pgp-border);
    border-radius: var(--pgp-radius-sm);
    font-size: 0.9375rem;
    margin-bottom: 0.75rem;
    box-sizing: border-box;
}

.pgp-login-form input[type="submit"] {
    width: 100%;
    padding: 0.625rem;
    background: var(--pgp-accent);
    color: #fff;
    border: none;
    border-radius: var(--pgp-radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--pgp-transition);
}

.pgp-login-form input[type="submit"]:hover {
    background: var(--pgp-accent-hover);
}

/* ==========================================================================
   Notices
   ========================================================================== */

.pgp-notice {
    padding: 0.75rem 1rem;
    border-radius: var(--pgp-radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.pgp-notice-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.pgp-notice-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ==========================================================================
   Loading Spinner
   ========================================================================== */

.pgp-loading-spinner {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.pgp-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--pgp-border);
    border-top-color: var(--pgp-accent);
    border-radius: 50%;
    animation: pgp-spin 0.6s linear infinite;
}

@keyframes pgp-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.pgp-empty {
    text-align: center;
    color: var(--pgp-text-muted);
    padding: 3rem 1rem;
    font-size: 1rem;
}

/* Messaggio galleria vuota (opt-in) — sostituisce .pgp-empty quando attivo.
   Usa i token branding: si adatta al colore di sfondo per-galleria. */
.pgp-gallery-notice {
    display: flex;
    justify-content: center;
    padding: 2.5rem 1rem;
}

.pgp-gallery-notice__inner {
    max-width: 640px;
    width: 100%;
    text-align: center;
    color: var(--pgp-text);
    background: var(--pgp-bg-alt);
    border: 1px solid var(--pgp-border);
    border-radius: 8px;
    padding: 2rem 1.75rem;
    font-size: 1.05rem;
    line-height: 1.6;
}

.pgp-gallery-notice__inner :first-child {
    margin-top: 0;
}

.pgp-gallery-notice__inner :last-child {
    margin-bottom: 0;
}

.pgp-gallery-notice__inner a {
    color: var(--pgp-accent);
}

/* ==========================================================================
   Credits Footer
   ========================================================================== */

.pgp-credits {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 2rem;
    border-top: 1px solid var(--pgp-border);
    font-size: 0.8125rem;
    color: var(--pgp-text-muted);
}

.pgp-credits a {
    color: var(--pgp-accent);
    text-decoration: none;
    transition: color var(--pgp-transition);
}

.pgp-credits a:hover {
    color: var(--pgp-accent-hover);
    text-decoration: underline;
}

/* ==========================================================================
   WP Archive Pagination Override
   ========================================================================== */

.pgp-archive-pagination {
    margin-top: 2rem;
    text-align: center;
}

.pgp-archive-pagination .nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.pgp-archive-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.75rem;
    border: 1px solid var(--pgp-border);
    border-radius: var(--pgp-radius-sm);
    background: var(--pgp-bg);
    color: var(--pgp-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all var(--pgp-transition);
}

.pgp-archive-pagination .page-numbers:hover {
    border-color: var(--pgp-accent);
    color: var(--pgp-accent);
}

.pgp-archive-pagination .page-numbers.current {
    background: var(--pgp-accent);
    border-color: var(--pgp-accent);
    color: #fff;
    font-weight: 600;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1200px) {
    .pgp-layout-grid.pgp-cols-7,
    .pgp-layout-grid.pgp-cols-8 {
        grid-template-columns: repeat(5, 1fr);
    }
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-7 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-8 .pgp-grid-item {
        width: calc((100% - 4 * var(--pgp-gap)) / 5);
    }
}

@media (max-width: 992px) {
    .pgp-layout-grid.pgp-cols-5,
    .pgp-layout-grid.pgp-cols-6,
    .pgp-layout-grid.pgp-cols-7,
    .pgp-layout-grid.pgp-cols-8 {
        grid-template-columns: repeat(4, 1fr);
    }
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-5 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-6 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-7 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-8 .pgp-grid-item {
        width: calc((100% - 3 * var(--pgp-gap)) / 4);
    }
}

@media (max-width: 768px) {
    .pgp-site-content {
        padding: 1.5rem 1rem;
    }

    .pgp-gallery-title,
    .pgp-archive-title {
        font-size: 1.5rem;
    }

    .pgp-layout-grid.pgp-cols-3,
    .pgp-layout-grid.pgp-cols-4,
    .pgp-layout-grid.pgp-cols-5,
    .pgp-layout-grid.pgp-cols-6,
    .pgp-layout-grid.pgp-cols-7,
    .pgp-layout-grid.pgp-cols-8 {
        grid-template-columns: repeat(3, 1fr);
    }
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-3 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-4 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-5 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-6 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-7 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-8 .pgp-grid-item {
        width: calc((100% - 2 * var(--pgp-gap)) / 3);
    }

    .pgp-children-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .pgp-form-row {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .pgp-site-content {
        padding: 1rem 0.75rem;
    }

    .pgp-layout-grid.pgp-cols-2,
    .pgp-layout-grid.pgp-cols-3,
    .pgp-layout-grid.pgp-cols-4,
    .pgp-layout-grid.pgp-cols-5,
    .pgp-layout-grid.pgp-cols-6,
    .pgp-layout-grid.pgp-cols-7,
    .pgp-layout-grid.pgp-cols-8 {
        grid-template-columns: repeat(2, 1fr);
    }
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-2 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-3 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-4 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-5 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-6 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-7 .pgp-grid-item,
    .pgp-gallery-grid.pgp-layout-masonry.pgp-cols-8 .pgp-grid-item {
        width: calc((100% - var(--pgp-gap)) / 2);
    }

    .pgp-children-grid,
    .pgp-archive-grid {
        grid-template-columns: 1fr;
    }

    .pgp-access-box {
        padding: 2rem 1.25rem;
    }

    .pgp-page-link {
        min-width: 36px;
        height: 36px;
        font-size: 0.8125rem;
    }

    --pgp-gap: 8px;
}

/* ==========================================================================
   LIGHTBOX — PGP Toolbar Overlay (su GLightbox)
   ========================================================================== */

/* Toolbar PGP iniettata nel document.body (NON in .glightbox-container).
   Vedi commento in pgp-lightbox.js > injectPGPToolbar() per il motivo. */
.pgp-glb-toolbar {
    position: fixed;
    top: 0;
    right: 60px; /* Spazio per il close button di GLightbox */
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem 0.5rem;
    z-index: 9999999; /* Sopra GLightbox (~9999) */
}

.pgp-glb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.pgp-glb-btn:hover,
.pgp-glb-btn:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.pgp-glb-btn svg {
    display: block;
}

/* Favorite active */
.pgp-glb-btn-favorite.pgp-glb-fav-active {
    color: #ef4444;
}

.pgp-glb-btn-favorite.pgp-glb-fav-active:hover {
    color: #dc2626;
    background: rgba(255, 255, 255, 0.12);
}

/* Download dropdown */
.pgp-glb-dl-wrap {
    position: relative;
    display: inline-flex;
}

.pgp-glb-dl-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--pgp-radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    min-width: 150px;
    z-index: 20;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.pgp-glb-dl-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    font-family: var(--pgp-font);
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.85);
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.pgp-glb-dl-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Comment button + badge */
.pgp-glb-comment-wrap {
    position: relative;
    display: inline-flex;
}

.pgp-glb-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--pgp-accent);
    color: #fff;
    font-family: var(--pgp-font);
    font-size: 0.625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

/* ---- Comments Panel (slide-in da destra, dentro GLightbox) ---- */

.pgp-glb-comments {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 340px;
    max-width: 90vw;
    z-index: 20;
    display: flex;
    flex-direction: column;
    background: rgba(24, 24, 24, 0.96);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: #fff;
    font-family: var(--pgp-font);
    animation: pgp-panel-slide-in 0.25s ease;
}

@keyframes pgp-panel-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

.pgp-glb-comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pgp-glb-comments-title {
    font-size: 1rem;
    font-weight: 600;
}

.pgp-glb-comments-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.pgp-glb-comments-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.pgp-glb-comments-close svg {
    width: 18px;
    height: 18px;
}

.pgp-glb-comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    overscroll-behavior: contain;
}

.pgp-glb-comments-empty {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.875rem;
    text-align: center;
    margin: 2rem 0;
}

.pgp-glb-comments-loading {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.pgp-glb-comments-loading .pgp-spinner {
    width: 24px;
    height: 24px;
    border-color: rgba(255, 255, 255, 0.15);
    border-top-color: rgba(255, 255, 255, 0.7);
}

.pgp-glb-comment-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pgp-glb-comment-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.pgp-glb-comment-meta {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.pgp-glb-comment-author {
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.pgp-glb-comment-time {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.4);
}

.pgp-glb-comment-body {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.75);
    word-wrap: break-word;
}

.pgp-glb-comments-form {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.pgp-glb-comment-name {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--pgp-radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-family: var(--pgp-font);
    font-size: 0.8125rem;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.pgp-glb-comment-name:focus {
    outline: none;
    border-color: var(--pgp-accent);
}

.pgp-glb-comment-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.pgp-glb-comment-text {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--pgp-radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-family: var(--pgp-font);
    font-size: 0.8125rem;
    resize: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
    min-height: 38px;
}

.pgp-glb-comment-text:focus {
    outline: none;
    border-color: var(--pgp-accent);
}

.pgp-glb-comment-text::placeholder,
.pgp-glb-comment-name::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.pgp-glb-comment-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--pgp-radius-sm);
    background: var(--pgp-accent);
    color: #fff;
    cursor: pointer;
    transition: background var(--pgp-transition), opacity var(--pgp-transition);
}

.pgp-glb-comment-submit:hover {
    background: var(--pgp-accent-hover);
}

.pgp-glb-comment-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pgp-glb-comment-submit svg {
    display: block;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
    .pgp-glb-toolbar {
        right: 50px;
        padding: 0.75rem 0.25rem;
    }

    .pgp-glb-comments {
        width: 100%;
        max-width: 100vw;
    }
}

/* ==========================================================================
   DOWNLOAD UI (Modulo 7)
   ========================================================================== */

/* ---- Download Toolbar (sopra la griglia) ---- */

.pgp-download-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--pgp-bg-alt);
    border: 1px solid var(--pgp-border);
    border-radius: var(--pgp-radius);
}

.pgp-btn-zip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--pgp-accent);
    color: #fff;
    border: none;
    border-radius: var(--pgp-radius-sm);
    font-family: var(--pgp-font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--pgp-transition), opacity var(--pgp-transition);
    line-height: 1.4;
}

.pgp-btn-zip:hover {
    background: var(--pgp-accent-hover);
}

.pgp-btn-zip:disabled,
.pgp-btn-zip.pgp-btn-loading {
    opacity: 0.7;
    cursor: wait;
}

.pgp-btn-zip svg {
    display: block;
    flex-shrink: 0;
}

/* Spinner piccolo inline */
.pgp-spinner-sm {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pgp-spin 0.6s linear infinite;
    vertical-align: middle;
}

/* ---- Download button su grid item ---- */

.pgp-dl-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.pgp-dl-btn svg {
    display: block;
}

.pgp-grid-item:hover .pgp-dl-btn {
    opacity: 1;
    transform: translateY(0);
}

.pgp-dl-btn:hover {
    background: var(--pgp-accent);
}

.pgp-dl-btn:focus-visible {
    opacity: 1;
    transform: translateY(0);
    outline: 2px solid var(--pgp-accent);
    outline-offset: 2px;
}

/* ---- Resolution dropdown (grid) ---- */

.pgp-dl-dropdown {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 6px;
    background: #fff;
    border: 1px solid var(--pgp-border);
    border-radius: var(--pgp-radius-sm);
    box-shadow: var(--pgp-shadow-lg);
    min-width: 140px;
    z-index: 20;
    overflow: hidden;
    animation: pgp-dropdown-in 0.15s ease;
}

.pgp-dl-dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    color: var(--pgp-text);
    text-decoration: none;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.1s;
}

.pgp-dl-dropdown-item:hover {
    background: var(--pgp-bg-alt);
    color: var(--pgp-accent);
}

@keyframes pgp-dropdown-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Lightbox: download button + dropdown ---- */

.pgp-lightbox-dl-wrap {
    position: relative;
    display: inline-flex;
}

.pgp-lightbox-btn-download {
    width: 40px;
    height: 40px;
    margin-right: 0.25rem;
}

.pgp-lightbox-dl-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--pgp-radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    min-width: 150px;
    z-index: 20;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: pgp-dropdown-in 0.15s ease;
}

.pgp-lightbox-dl-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    font-family: var(--pgp-font);
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.85);
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.pgp-lightbox-dl-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ---- Toast notifications ---- */

.pgp-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 1000000;
    padding: 0.75rem 1.5rem;
    border-radius: var(--pgp-radius);
    font-family: var(--pgp-font);
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.pgp-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.pgp-toast-error {
    background: #dc2626;
}

.pgp-toast-info {
    background: var(--pgp-accent);
}

.pgp-toast-success {
    background: #16a34a;
}

/* ---- Download responsive ---- */

@media (max-width: 768px) {
    .pgp-download-toolbar {
        padding: 0.625rem 0.75rem;
    }

    .pgp-btn-zip {
        font-size: 0.8125rem;
        padding: 0.5rem 0.875rem;
    }

    .pgp-dl-btn {
        width: 32px;
        height: 32px;
        bottom: 6px;
        right: 6px;
    }

    /* Su mobile, mostra sempre il download button (no hover). */
    .pgp-grid-item .pgp-dl-btn {
        opacity: 0.85;
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .pgp-download-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .pgp-btn-zip {
        justify-content: center;
    }
}

/* ==========================================================================
   FAVORITES (Modulo 8)
   ========================================================================== */

/* ---- Heart button su grid item ---- */

.pgp-fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.pgp-fav-btn svg {
    display: block;
}

.pgp-grid-item:hover .pgp-fav-btn {
    opacity: 1;
    transform: translateY(0);
}

.pgp-fav-btn:hover {
    background: rgba(0, 0, 0, 0.65);
}

.pgp-fav-btn:focus-visible {
    opacity: 1;
    transform: translateY(0);
    outline: 2px solid var(--pgp-accent);
    outline-offset: 2px;
}

/* Active (filled heart) */
.pgp-fav-btn.pgp-fav-active {
    color: #ef4444;
    opacity: 1;
    transform: translateY(0);
    background: rgba(0, 0, 0, 0.55);
}

.pgp-fav-btn.pgp-fav-active:hover {
    color: #dc2626;
}

/* Pulse animation on toggle */
@keyframes pgp-heart-pulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.pgp-fav-btn.pgp-fav-active svg {
    animation: pgp-heart-pulse 0.35s ease;
}

/* ---- Favorites bar (barra fissa in basso) ---- */

.pgp-favorites-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.pgp-favorites-bar.pgp-bar-visible {
    transform: translateY(0);
    pointer-events: auto;
}

.pgp-favbar-inner {
    max-width: 600px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: rgba(26, 26, 26, 0.92);
    color: #fff;
    border-radius: var(--pgp-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-family: var(--pgp-font);
    font-size: 0.875rem;
}

.pgp-favbar-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
}

.pgp-favbar-info svg {
    color: #ef4444;
    flex-shrink: 0;
}

.pgp-favbar-count {
    font-weight: 700;
    font-size: 1rem;
}

.pgp-favbar-label {
    color: rgba(255, 255, 255, 0.7);
}

.pgp-favbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

/* Toggle "solo selezionate" */
.pgp-favbar-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--pgp-radius-sm);
    font-family: var(--pgp-font);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, opacity var(--pgp-transition);
    white-space: nowrap;
}

.pgp-favbar-filter:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.pgp-favbar-filter.pgp-filter-active {
    background: var(--pgp-accent);
    border-color: var(--pgp-accent);
    color: #fff;
}

.pgp-favbar-filter.pgp-btn-loading {
    opacity: 0.7;
    cursor: wait;
}

.pgp-favbar-filter svg {
    display: block;
    flex-shrink: 0;
}

/* Immagine in coda al loader controllato (data-src non ancora promosso a src):
   superficie neutra con altezza minima al posto del vuoto/icona broken.
   L'attributo data-src viene rimosso al load => lo stile decade da solo. */
.pgp-image[data-src] {
    display: block;
    min-height: 90px;
    background: var(--pgp-bg-alt, #f2f2f2);
}

/* Immagine fallita dopo tutti i retry del loader. */
.pgp-image.pgp-img-failed {
    min-height: 90px;
    background: var(--pgp-bg-alt, #f2f2f2);
    opacity: 0.5;
}

/* Item nascosto dal filtro "solo selezionate". display:none lo toglie dal
   flusso: il masonry JS lo ignora gia' (selector :not(.pgp-filtered-hidden)),
   per grid/justified semplicemente sparisce. */
.pgp-grid-item.pgp-filtered-hidden {
    display: none !important;
}

.pgp-favbar-dl {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.875rem;
    background: var(--pgp-accent);
    color: #fff;
    border: none;
    border-radius: var(--pgp-radius-sm);
    font-family: var(--pgp-font);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--pgp-transition), opacity var(--pgp-transition);
    white-space: nowrap;
}

.pgp-favbar-dl:hover {
    background: var(--pgp-accent-hover);
}

.pgp-favbar-dl:disabled,
.pgp-favbar-dl.pgp-btn-loading {
    opacity: 0.7;
    cursor: wait;
}

.pgp-favbar-dl svg {
    display: block;
    flex-shrink: 0;
}

.pgp-favbar-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.pgp-favbar-clear:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* ---- Lightbox: Favorite button ---- */

.pgp-lightbox-btn-favorite {
    width: 40px;
    height: 40px;
    margin-right: 0.125rem;
}

.pgp-lightbox-btn-favorite.pgp-lightbox-fav-active {
    color: #ef4444;
}

.pgp-lightbox-btn-favorite.pgp-lightbox-fav-active:hover {
    color: #dc2626;
    background: rgba(255, 255, 255, 0.12);
}

/* ==========================================================================
   COMMENTS (Modulo 8)
   ========================================================================== */

/* ---- Lightbox: Comment button + badge ---- */

.pgp-lightbox-comment-wrap {
    position: relative;
    display: inline-flex;
}

.pgp-lightbox-btn-comments {
    width: 40px;
    height: 40px;
    margin-right: 0.125rem;
}

.pgp-lightbox-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--pgp-accent);
    color: #fff;
    font-family: var(--pgp-font);
    font-size: 0.625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

/* ---- Comments panel (slide-in from right) ---- */

.pgp-lightbox-comments {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 340px;
    max-width: 90vw;
    z-index: 20;
    display: flex;
    flex-direction: column;
    background: rgba(24, 24, 24, 0.96);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: #fff;
    font-family: var(--pgp-font);
    animation: pgp-panel-slide-in 0.25s ease;
}

@keyframes pgp-panel-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* Comments header */
.pgp-comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pgp-comments-title {
    font-size: 1rem;
    font-weight: 600;
}

.pgp-comments-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.pgp-comments-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.pgp-comments-close svg {
    width: 18px;
    height: 18px;
}

/* Comments list */
.pgp-comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    overscroll-behavior: contain;
}

.pgp-comments-empty {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.875rem;
    text-align: center;
    margin: 2rem 0;
}

.pgp-comments-loading {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.pgp-comments-loading .pgp-spinner {
    width: 24px;
    height: 24px;
    border-color: rgba(255, 255, 255, 0.15);
    border-top-color: rgba(255, 255, 255, 0.7);
}

/* Single comment */
.pgp-comment-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pgp-comment-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.pgp-comment-meta {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.pgp-comment-author {
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.pgp-comment-time {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.4);
}

.pgp-comment-body {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.75);
    word-wrap: break-word;
}

/* Comment form */
.pgp-comments-form {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.pgp-comment-name {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--pgp-radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-family: var(--pgp-font);
    font-size: 0.8125rem;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.pgp-comment-name:focus {
    outline: none;
    border-color: var(--pgp-accent);
}

.pgp-comment-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.pgp-comment-text {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--pgp-radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-family: var(--pgp-font);
    font-size: 0.8125rem;
    resize: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
    min-height: 38px;
}

.pgp-comment-text:focus {
    outline: none;
    border-color: var(--pgp-accent);
}

.pgp-comment-text::placeholder,
.pgp-comment-name::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.pgp-comment-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--pgp-radius-sm);
    background: var(--pgp-accent);
    color: #fff;
    cursor: pointer;
    transition: background var(--pgp-transition), opacity var(--pgp-transition);
}

.pgp-comment-submit:hover {
    background: var(--pgp-accent-hover);
}

.pgp-comment-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pgp-comment-submit svg {
    display: block;
}

/* Lightbox layout shift when comments open */
.pgp-lightbox-comments-open .pgp-lightbox-stage {
    padding-right: 360px;
}

.pgp-lightbox-comments-open .pgp-lightbox-btn-next {
    right: 360px;
}

/* ---- Favorites & Comments Responsive ---- */

@media (max-width: 768px) {
    /* Mobile: hearts always visible */
    .pgp-grid-item .pgp-fav-btn {
        opacity: 0.85;
        transform: translateY(0);
    }

    .pgp-fav-btn {
        width: 32px;
        height: 32px;
        top: 6px;
        right: 6px;
    }

    .pgp-favbar-inner {
        margin: 0 0.5rem 0.5rem;
        padding: 0.625rem 1rem;
        gap: 0.75rem;
    }

    .pgp-favbar-label {
        display: none;
    }

    /* Comments panel full width on mobile */
    .pgp-lightbox-comments {
        width: 100%;
        max-width: 100vw;
    }

    .pgp-lightbox-comments-open .pgp-lightbox-stage {
        padding-right: 10px;
    }

    .pgp-lightbox-comments-open .pgp-lightbox-btn-next {
        right: auto;
    }
}

@media (max-width: 480px) {
    .pgp-favbar-inner {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .pgp-favbar-actions {
        margin-left: 0;
    }
}

/* ==========================================================================
   SLIDER INLINE (Componente Carousel)
   ========================================================================== */

.pgp-slider {
    position: relative;
    overflow: hidden;
    width: 100%;
    border-radius: var(--pgp-radius);
    background: var(--pgp-bg-alt);
}

.pgp-slider__track {
    display: flex;
    will-change: transform;
}

.pgp-slider__slide {
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.pgp-slider__slide img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
}

/* Frecce */
.pgp-slider__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.88);
    color: #222;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.25s, background 0.2s;
    padding: 0;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pgp-slider:hover .pgp-slider__arrow {
    opacity: 1;
}

.pgp-slider__arrow:hover {
    background: #fff;
}

.pgp-slider__arrow--prev { left: 14px; }
.pgp-slider__arrow--next { right: 14px; }

.pgp-slider__arrow--disabled {
    opacity: 0.2 !important;
    pointer-events: none;
}

.pgp-slider__arrow svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

/* Dots */
.pgp-slider__dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 7px;
    z-index: 10;
}

.pgp-slider__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 0;
    transition: background 0.25s, transform 0.25s;
}

.pgp-slider__dot.is-active {
    background: #fff;
    transform: scale(1.3);
}

/* Slider Responsive */
@media (max-width: 768px) {
    .pgp-slider__arrow {
        width: 36px;
        height: 36px;
        opacity: 0.7;
    }

    .pgp-slider__arrow--prev { left: 8px; }
    .pgp-slider__arrow--next { right: 8px; }

    .pgp-slider__arrow svg {
        width: 16px;
        height: 16px;
    }
}


/* ==========================================================================
   Filtro "solo selezionate" + spaziatura favbar fissa (v1.2.5)
   ========================================================================== */

/* Con filtro preferiti attivo tutte le pagine sono già in DOM e si mostra
   solo un sottoinsieme: la paginazione (numeri / "Carica altro" / trigger
   infinite) non ha più senso e va nascosta finché il filtro è attivo. */
.pgp-gallery.pgp-favfilter-on .pgp-pagination {
    display: none !important;
}

/* La barra preferiti è position:fixed in fondo al viewport: quando è visibile
   riserviamo spazio in coda alla galleria così non copre l'ultima riga della
   griglia, il pulsante "Carica altro" o la paginazione numerata. */
body.pgp-favbar-space .pgp-gallery {
    padding-bottom: 6rem;
}


/* ==========================================================================
   Invio selezione preferiti (submission) — pulsante favbar + modal (v1.3.0)
   ========================================================================== */

/* Pulsante "Invia selezione": azione primaria, usa il colore accent del branding. */
.pgp-favbar-submit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: var(--pgp-accent, #2563eb);
    transition: filter 0.2s, transform 0.1s;
}

.pgp-favbar-submit:hover { filter: brightness(1.08); }
.pgp-favbar-submit:active { transform: translateY(1px); }
.pgp-favbar-submit svg { pointer-events: none; }

/* Overlay modal */
.pgp-submit-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
    animation: pgp-submit-fade 0.15s ease-out;
}

@keyframes pgp-submit-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.pgp-submit-dialog {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    color: var(--pgp-text, #1a1a1a);
}

.pgp-submit-title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 700;
}

.pgp-submit-intro {
    margin: 0 0 16px;
    font-size: 0.9rem;
    opacity: 0.8;
    line-height: 1.4;
}

.pgp-submit-dialog input,
.pgp-submit-dialog textarea {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #d0d0d5;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    color: inherit;
    background: #fff;
}

.pgp-submit-dialog input:focus,
.pgp-submit-dialog textarea:focus {
    outline: none;
    border-color: var(--pgp-accent, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.pgp-submit-dialog textarea { resize: vertical; min-height: 64px; }

.pgp-submit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

.pgp-submit-cancel,
.pgp-submit-confirm {
    cursor: pointer;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.pgp-submit-cancel {
    background: transparent;
    border-color: #d0d0d5;
    color: inherit;
}

.pgp-submit-cancel:hover { background: #f2f2f4; }

.pgp-submit-confirm {
    background: var(--pgp-accent, #2563eb);
    color: #fff;
}

.pgp-submit-confirm:hover { filter: brightness(1.08); }
.pgp-submit-confirm:disabled { opacity: 0.6; cursor: default; }

@media (max-width: 600px) {
    .pgp-submit-dialog { padding: 20px; border-radius: 10px; }
}

/* Conferma di avvenuto invio (sostituisce il contenuto del dialog, resta centrata). */
.pgp-submit-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 14px 6px;
    gap: 10px;
}

.pgp-submit-success-icon {
    color: #16a34a;
    display: inline-flex;
    animation: pgp-submit-pop 0.28s ease-out;
}

.pgp-submit-success .pgp-submit-title { margin: 0; }

@keyframes pgp-submit-pop {
    from { transform: scale(0.6); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}


/* ==========================================================================
   Branding Logo (v1.8.0)
   ========================================================================== */

/* Hero (hero/cover): logo centrato sopra il titolo.
   .pgp-gallery-hero__content ha gia' text-align:center. */
.pgp-gallery-hero__content .pgp-branding-logo {
    margin: 0 0 1.25rem;
    line-height: 0;
}

.pgp-gallery-hero__content .pgp-branding-logo img {
    max-height: 90px;
    width: auto;
    height: auto;
    display: inline-block;
}

/* Header standard (no hero): logo thumbnail a sinistra del titolo. */
.pgp-gallery-header__brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.pgp-gallery-header__brand .pgp-branding-logo {
    flex: 0 0 auto;
    line-height: 0;
}

.pgp-gallery-header__brand .pgp-branding-logo img {
    max-height: 64px;
    width: auto;
    height: auto;
    display: block;
    border-radius: 4px;
}

.pgp-gallery-header__text {
    min-width: 0;
}

/* Titolo e descrizione dentro il wrapper testo non aggiungono margine
   sopra: l'allineamento verticale lo gestisce il flex del brand. */
.pgp-gallery-header__text .pgp-gallery-title {
    margin-top: 0;
}

/* ==========================================================================
   Standalone mode (template senza header/footer del tema) — v1.15.0
   ========================================================================== */

/* Baseline del body quando la pagina e' servita da standalone.php: senza
   il markup del tema non c'e' garanzia di reset, quindi si fissano margine,
   sfondo e tipografia sui token PGP. La regola per-galleria
   body.postid-{id} (v1.11.0, !important) continua a vincere sullo sfondo. */
body.pgp-standalone {
    margin: 0;
    min-height: 100vh;
    background-color: var(--pgp-bg);
    font-family: var(--pgp-font);
    color: var(--pgp-text);
}
