/* Texture grain argentique réutilisable (bruit SVG, très discret). */
:root {
    --film-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   ONGLETS DOSSIER — même style que les filtres writeups
   ============================================================ */

.dossier-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 36px 0 0;
    padding: 0 10px;
}

.dossier-tab {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-family: var(--font-pixel);
    font-size: 1.3rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: transparent;
    border: 2px solid var(--accent-color);
    color: var(--header-color);
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dossier-tab:hover,
.dossier-tab:focus-visible {
    background: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-hover);
    outline: none;
}

.dossier-tab.active {
    background: var(--accent-color);
    color: #ffffff;
    box-shadow: 0 0 10px var(--accent-hover);
}

.dossier-tab-count {
    font-size: 1rem;
    opacity: 0.65;
}

/* ============================================================
   GRILLE — masonry éditoriale
   ============================================================ */

.photo-grid {
    column-count: 1;
    column-gap: 22px;
    margin: 0 auto 70px;
    max-width: 1300px;
    padding: 34px 10px 0;
    border-top: 2px solid var(--accent-color);
    position: relative;
    z-index: 1;
}

@media (min-width: 640px) {
    .photo-grid { column-count: 2; }
}
@media (min-width: 1000px) {
    .photo-grid { column-count: 3; }
}
@media (min-width: 1500px) {
    .photo-grid { column-count: 4; }
}

.photo-thumb {
    display: block;
    width: 100%;
    break-inside: avoid;
    margin-bottom: 22px;
    padding: 0;
    border: none;
    background: #000;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    isolation: isolate;
    transition: box-shadow 0.3s ease;
}

.photo-thumb:hover,
.photo-thumb:focus-visible {
    box-shadow: 0 0 0 2px var(--accent-hover), 0 12px 30px rgba(0, 0, 0, 0.5);
    outline: none;
}

.photo-thumb img {
    display: block;
    width: 100%;
    height: auto;
    filter: saturate(0.92) contrast(1.04);
    transform: scale(1.001); /* évite un artefact de sous-pixel au survol */
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), filter 0.4s ease;
}

.photo-thumb:hover img {
    transform: scale(1.06);
    filter: saturate(1.02) contrast(1.08);
}

.photo-thumb-grain {
    position: absolute;
    inset: 0;
    background-image: var(--film-grain);
    opacity: 0.05;
    mix-blend-mode: overlay;
    pointer-events: none;
}

.photo-thumb::before {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 55%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.photo-thumb:hover::before,
.photo-thumb:focus-visible::before {
    opacity: 1;
}

.photo-thumb-tag {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 10px 14px;
    font-family: var(--font-pixel);
    color: var(--header-color);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.photo-thumb:hover .photo-thumb-tag,
.photo-thumb:focus-visible .photo-thumb-tag {
    opacity: 1;
    transform: translateY(0);
}

.photo-thumb-ref {
    font-size: 1.15rem;
    color: var(--accent-hover);
    letter-spacing: 1px;
}

.photo-thumb-album {
    font-size: 1rem;
    text-transform: uppercase;
    opacity: 0.75;
}

/* Révélation au scroll (JS ajoute .is-visible via IntersectionObserver) */
.reveal-item {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-item.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .reveal-item { opacity: 1; transform: none; transition: none; }
    .photo-thumb img { transition: none; }
    .photo-thumb:hover img { transform: none; }
}

.photo-note {
    font-size: 1.1rem;
    font-style: italic;
    color: var(--header-color);
    opacity: 0.55;
    margin-top: 8px;
}

.photo-empty {
    text-align: center;
    color: var(--accent-hover);
    font-family: var(--font-pixel);
    font-size: 1.6rem;
    margin: 60px 0;
}

/* ============================================================
   VISIONNEUSE "ANALYSE" — overlay plein écran
   ============================================================ */

.gallery-viewer {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(5, 2, 3, 0.97);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px 20px;
    isolation: isolate;
}

.gallery-viewer.active {
    display: flex;
}

.gallery-grain {
    position: absolute;
    inset: 0;
    background-image: var(--film-grain);
    opacity: 0.035;
    mix-blend-mode: overlay;
    pointer-events: none;
    z-index: 1;
}

.gallery-stage {
    position: relative;
    max-width: min(88vw, 1200px);
    max-height: 66vh;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--accent-color);
    overflow: hidden;
}

.gallery-stage img {
    max-width: 100%;
    max-height: 66vh;
    display: block;
}

.gallery-hud {
    width: 100%;
    max-width: min(88vw, 1200px);
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-pixel);
    font-size: 1.2rem;
    color: var(--header-color);
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}

.gallery-hud .gallery-index {
    color: var(--accent-hover);
}

.gallery-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}

.gallery-btn {
    font-family: var(--font-pixel);
    font-size: 1.4rem;
    background: transparent;
    border: 2px solid var(--accent-color);
    color: var(--header-color);
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gallery-btn:hover,
.gallery-btn:focus-visible {
    border-color: var(--accent-hover);
    color: var(--accent-hover);
    outline: none;
}

.gallery-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-family: var(--font-pixel);
    font-size: 1.6rem;
    background: transparent;
    border: 2px solid var(--accent-color);
    color: var(--header-color);
    width: 40px;
    height: 40px;
    line-height: 1;
    cursor: pointer;
    z-index: 5001;
}

.gallery-close:hover,
.gallery-close:focus-visible {
    border-color: var(--accent-hover);
    color: var(--accent-hover);
    outline: none;
}

/* Zones cliquables invisibles sur les bords pour naviguer, avec flèche au survol */
.gallery-edge {
    position: absolute;
    top: 0;
    bottom: 90px;
    width: 14%;
    min-width: 60px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    font-family: var(--font-pixel);
    font-size: 2rem;
    color: transparent;
    transition: color 0.2s ease, background 0.2s ease;
}

.gallery-edge-prev { left: 0; justify-content: flex-start; padding-left: 12px; }
.gallery-edge-next { right: 0; justify-content: flex-end; padding-right: 12px; }

.gallery-edge:hover,
.gallery-edge:focus-visible {
    color: var(--accent-hover);
    background: linear-gradient(to right, rgba(129, 30, 30, 0.15), transparent);
    outline: none;
}

.gallery-edge-next:hover,
.gallery-edge-next:focus-visible {
    background: linear-gradient(to left, rgba(129, 30, 30, 0.15), transparent);
}

/* Pellicule de vignettes en bas de la visionneuse */
.gallery-filmstrip {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding: 6px 2px;
    max-width: min(88vw, 1200px);
    width: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
    position: relative;
    z-index: 2;
}

.gallery-filmstrip img {
    height: 56px;
    width: auto;
    flex: none;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.5;
    filter: grayscale(0.4);
    transition: all 0.2s ease;
}

.gallery-filmstrip img:hover {
    opacity: 0.85;
}

.gallery-filmstrip img.active {
    border-color: var(--accent-hover);
    opacity: 1;
    filter: none;
}

@media (max-width: 640px) {
    .gallery-stage, .gallery-hud, .gallery-filmstrip { max-width: 100%; }
    .gallery-terminal { font-size: 1.1rem; }
    .gallery-edge { width: 20%; }
    .gallery-filmstrip img { height: 42px; }
    .photo-hero { margin: -12px -12px 0; padding: 50px 12px 36px; }
}

/* Le body force image-rendering: pixelated (style pixel du site) : les photos doivent rester lisses. */
.photo-thumb img,
.gallery-stage img,
.gallery-filmstrip img {
    image-rendering: auto;
}

/* Loupe de la visionneuse (clic maintenu sur la photo) */
.gallery-stage img {
    cursor: crosshair;
    touch-action: none;
}

.gallery-glass {
    position: fixed;
    width: 260px;
    height: 260px;
    border: 4px solid var(--accent-color);
    border-radius: 50%;
    background-color: #000;
    background-repeat: no-repeat;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    display: none;
    pointer-events: none;
    z-index: 6000;
    image-rendering: auto;
}
