/*
====================================
   Gallery — Horizontal Quiet Grid v2
   
   Structure : rangées (hq-row) en flexbox
   chaque rangée occupe exactement 100% de largeur
   
   Pattern de rangées :
     A : H + H        (4+4 = 8 parts)
     B : H + V + V    (4+2+2 = 8 parts)
     C : V + V + H    (2+2+4 = 8 parts)
   
   → alignement parfait, mélange naturel
====================================
*/

.gallery-single {
    padding-top: 0;
    background: #ffffff !important;
}

/* Forcer le blanc sur tout ce qui entoure la grille */
.gallery-single .gallery-grid-wrapper,
.gallery-single .gallery-horizontal-quiet,
.gallery-single .hq-row {
    background: #ffffff !important;
}

/* ── PASSWORD PROTECTION ── */
.gallery-password-form {
    display: flex; align-items: center; justify-content: center;
    min-height: 60vh; padding: var(--spacing-lg) var(--spacing-md);
}
.password-form-container {
    max-width: 500px; width: 100%; text-align: center;
    padding: var(--spacing-lg); background: #fff;
    border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.1);
}
.password-form-container h2 { font-size: 2rem; font-weight: 300; margin-bottom: 1rem; }
.password-form-container p  { color: var(--color-text-light); margin-bottom: 2rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group input {
    width: 100%; padding: 1rem;
    border: 2px solid var(--color-border); border-radius: 5px; font-size: 1rem;
}
.form-group input:focus { outline: none; border-color: var(--color-accent); }
.btn {
    padding: 1rem 3rem; border: none; border-radius: 5px;
    font-size: 1rem; font-weight: 500; letter-spacing: .05em;
    text-transform: uppercase; cursor: pointer; transition: all .3s;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-accent); }
.form-message { margin-top: 1rem; padding: .75rem; border-radius: 5px; font-size: .9rem; display: none; }
.form-message.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.form-message.error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ══════════════════════════════════════════
   WRAPPER
   ══════════════════════════════════════════ */

.gallery-grid-wrapper {
    width: 100%;
    padding: 40px 5vw 80px;
    box-sizing: border-box;
    background: #ffffff;
}

/* Conteneur : empilement de rangées */
.gallery-horizontal-quiet {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    background: #ffffff;
}

/* ── Rangée : flex, occupe toute la largeur ── */
.hq-row {
    display: flex;
    gap: 12px;
    width: 100%;
    align-items: stretch;
    background: #ffffff;
}

/* Espacement uniforme entre toutes les rangées — géré par gap sur .gallery-horizontal-quiet */

/* ══════════════════════════════════════════
   CELLULES
   ══════════════════════════════════════════ */

.hq-item {
    position: relative;
    overflow: hidden;
    background: #f0ede8;
    flex-shrink: 0;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><circle cx="14" cy="14" r="8" fill="none" stroke="white" stroke-width="2"/><line x1="20" y1="20" x2="28" y2="28" stroke="white" stroke-width="3" stroke-linecap="round"/><line x1="14" y1="10" x2="14" y2="18" stroke="white" stroke-width="2"/><line x1="10" y1="14" x2="18" y2="14" stroke="white" stroke-width="2"/></svg>') 16 16, pointer;
}

/*
  H3 : 3 horizontales par rangée — flex égal, ratio 3/2
  Plus légères visuellement que 2 pleine largeur
*/
.hq-h3 {
    flex: 1;  /* les 3 occupent exactement la même part */
}
.hq-h3::before {
    content: '';
    display: block;
    padding-top: calc(2 / 3 * 100%);   /* ratio 3:2 */
}

/*
  Horizontale classique (2 par rangée) : flex égal
*/
.hq-horizontal {
    flex: 1;
}
.hq-horizontal::before {
    content: '';
    display: block;
    padding-top: calc(2 / 3 * 100%);   /* ratio 3:2 = 66.67% */
}

/*
  Verticale : moitié de la largeur d'une horizontale
*/
.hq-vertical {
    flex: 0.5;
}

/* Rangée mixte (H + V + V ou V + V + H) :
   La H doit avoir la même largeur absolue qu'en rangée 2H.
   Rangée 2H  : (100% - 12px) / 2
   Rangée HVV : on force la H à cette même largeur exacte */
.hq-row:has(.hq-vertical) .hq-horizontal {
    flex: none;
    width: calc(50% - 6px);
}
.hq-row:has(.hq-vertical) .hq-vertical {
    flex: 1;
}
.hq-vertical::before {
    content: '';
    display: block;
    padding-top: calc(5 / 4 * 100%);   /* ratio 4:5 = 125% */
}

/* ──
   Dans les rangées mixtes (B: H+V+V ou C: V+V+H),
   les verticales s'étendent en hauteur pour matcher la horizontale.
   On force la hauteur de la cellule V à suivre celle de la H via flex stretch.
   Le ::before donne la hauteur MINIMALE, flex-grow + align-items:stretch font le reste.
── */
.hq-row .hq-vertical {
    display: flex;
    flex-direction: column;
}
.hq-row .hq-vertical::before {
    /* Hauteur min = ratio 4:5, mais la cellule peut grandir via stretch */
    flex-shrink: 0;
}

/* Contenu absolu par-dessus le pseudo-élément */
.gallery-item-inner {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
}

.hq-item img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform .5s cubic-bezier(.4,0,.2,1);
    display: block;
    will-change: transform;
}

.hq-item:hover img { transform: scale(1.03); }

.gallery-item-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,.15);
    opacity: 0;
    transition: opacity .3s ease;
    z-index: 5;
    pointer-events: none;
}
.hq-item:hover .gallery-item-overlay { opacity: 1; }

/* ── Download ── */
.gallery-actions {
    padding: var(--spacing-lg) var(--spacing-md);
    text-align: center; background: #fdfbfa;
}
.btn-download-all {
    display: inline-flex; align-items: center; gap: .75rem;
    padding: 1rem 2.5rem; background: var(--color-primary); color: #fff;
    border: none; border-radius: 5px; font-size: 1rem;
    font-weight: 500; letter-spacing: .05em; cursor: pointer; transition: all .3s;
}
.btn-download-all:hover {
    background: var(--color-accent);
    transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.2);
}

/* ── Protection — public & privé ── */
.gallery-public .hq-item,
.gallery-private .hq-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    position: relative;
}
.gallery-public .hq-item img,
.gallery-private .hq-item img {
    pointer-events: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}
/* Overlay transparent captant tous les events souris/tactile */
.gallery-public .hq-item::after,
.gallery-private .hq-item::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 5;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><circle cx="14" cy="14" r="8" fill="none" stroke="white" stroke-width="2"/><line x1="20" y1="20" x2="28" y2="28" stroke="white" stroke-width="3" stroke-linecap="round"/><line x1="14" y1="10" x2="14" y2="18" stroke="white" stroke-width="2"/><line x1="10" y1="14" x2="18" y2="14" stroke="white" stroke-width="2"/></svg>') 16 16, pointer;
}
/* Toast copyright */
#gallery-copyright-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,.82);
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    letter-spacing: .06em;
    padding: 10px 22px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 99999;
    white-space: nowrap;
}
#gallery-copyright-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

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

@media (max-width: 1100px) {
    .gallery-grid-wrapper { padding: 30px 3vw 60px; }
}

@media (max-width: 768px) {
    .gallery-grid-wrapper { padding: 0; }
    .gallery-horizontal-quiet { gap: 6px; }
    .hq-row {
        gap: 6px;
        flex-wrap: wrap;
    }
    /* margin-top nth-child(3n) removed — espacement uniforme via gap */

    .hq-horizontal,
    .hq-h3        { flex: 0 0 100%; }
    .hq-vertical  { flex: 0 0 calc(50% - 2px); }

    .hq-horizontal::before,
    .hq-h3::before        { padding-top: calc(9 / 16 * 100%); }
    .hq-vertical::before  { padding-top: calc(5 / 4 * 100%); }
}

@media (max-width: 480px) {
    .gallery-grid-wrapper { padding: 0; }
    .hq-horizontal,
    .hq-h3,
    .hq-vertical { flex: 0 0 100%; }
    .hq-horizontal::before,
    .hq-h3::before,
    .hq-vertical::before   { padding-top: calc(9 / 16 * 100%); }
}

/* ── Désactiver lightbox & animation survol ── */
.no-lightbox-hover .hq-item,
.no-lightbox-hover .gallery-item {
    cursor: default;
}

/* Supprimer la loupe sur le pseudo-élément ::after (gallery-public / gallery-private) */
.no-lightbox-hover .hq-item::after,
.no-lightbox-hover .gallery-item::after {
    cursor: default !important;
}

.no-lightbox-hover .hq-item img,
.no-lightbox-hover .gallery-item img {
    transform: none !important;
    transition: none !important;
}

.no-lightbox-hover .hq-item:hover img,
.no-lightbox-hover .gallery-item:hover img {
    transform: none !important;
}

.no-lightbox-hover .gallery-item-overlay,
.no-lightbox-hover .hq-item .gallery-item-overlay {
    display: none !important;
}

.no-lightbox-hover .hq-item:hover .gallery-item-overlay,
.no-lightbox-hover .gallery-item:hover .gallery-item-overlay {
    opacity: 0 !important;
}

