/* DESIGN ÉDITORIAL SUISSE - TABLEAU DE BORD FIXE */
:root {
    --bg: #ffffff;
    --text: #000000;
    --accent: #ff0000;
    --line: rgba(0, 0, 0, 0.2);
    --text-light: #777777;

    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-6: 48px;
    --space-8: 64px;

    --hairline: 1px;

    --unit-height: calc(100vh / 15);
    --nav-height: calc(var(--unit-height) * 2);
    --breadcrumb-height: var(--unit-height);
    --photo-height: calc(var(--unit-height) * 3);
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    :root { --hairline: 0.5px; }
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Helvetica Neue', 'Nimbus Sans', Helvetica, Arial, sans-serif;
    margin: 0; padding: 0;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    line-height: 1.5;
}

/* ── NAVIGATION ── */
nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(5, minmax(0, 1fr));
    height: var(--nav-height);
    position: fixed;
    top: 0; left: 0; width: 100%;
    background: var(--bg);
    z-index: 50;
    border-bottom: var(--hairline) solid var(--line);
}

.nav-btn {
    background: var(--bg);
    border: none;
    border-right: var(--hairline) solid var(--line);
    color: var(--text);
    padding: 0 var(--space-3);
    display: flex; align-items: center; justify-content: flex-start;
    cursor: pointer;
    font-size: 11px; font-weight: bold;
    text-transform: uppercase; letter-spacing: -0.02em;
    white-space: nowrap;
}
.nav-btn:first-child { }
.nav-btn:hover { background: #fafafa; color: var(--accent); }
.nav-btn.active-nav { background: var(--bg); color: var(--accent); box-shadow: none; }
.nav-btn.active-nav:hover { background: var(--bg); color: var(--accent); }

/* Stats dans la nav */
.global-stats-wrapper {
    display: none;
    align-items: center;
    justify-content: flex-end;
    padding: 0 var(--space-3);
    border-left: var(--hairline) solid var(--line);
    grid-column: -2 / -1;
}
.global-stats-wrapper.visible { display: flex; }
.global-stats {
    display: flex; gap: var(--space-3);
    font-size: 11px; font-weight: bold;
    text-transform: uppercase; letter-spacing: -0.02em;
    color: var(--text);
}
.stat-accent { color: var(--accent); }

/* ── SECTIONS ── */
.view-section {
    display: none;
    height: calc(100vh - var(--nav-height));
    margin-top: var(--nav-height);
    overflow: hidden;
}
.view-section.active { display: block; }

/* ── EXPLORATEUR (INDEX) ── */
.explorer-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(5, minmax(0, 1fr));
    height: 100%;
}

.explorer-sidebar {
    border-right: var(--hairline) solid var(--line);
    overflow-y: auto;
    background: var(--bg);
}
.explorer-sidebar::-webkit-scrollbar { width: 3px; }
.explorer-sidebar::-webkit-scrollbar-thumb { background: var(--line); }

.sidebar-item {
    border-bottom: var(--hairline) solid var(--line);
    cursor: pointer;
    font-size: 11px; font-weight: bold;
    letter-spacing: -0.02em;
    line-height: 1.4;
    overflow: hidden;
    position: relative;
    display: flex; align-items: center;
    height: var(--unit-height);
    padding: 0 var(--space-2);
}
.sidebar-item-meta {
    font-size: 10px; font-weight: normal;
    color: var(--text-light); letter-spacing: 0;
    margin-top: 2px; line-height: 1.3;
}
.sidebar-item img {
    width: auto;
    height: auto;
    max-width: 50px;
    max-height: 70%;
    object-fit: contain;
    margin-right: var(--space-2);
}
.sidebar-item:hover { background: #fafafa; color: var(--accent); }
.sidebar-item:hover img { opacity: 0.8; }
.sidebar-item.active-vol { background: #e0e0e0; color: var(--text); }
.sidebar-item.active-vol span { color: var(--text-light); }
.sidebar-item.active-vol img { filter: none; }

.explorer-main {
    display: flex; flex-direction: column;
    overflow: hidden; height: 100%;
    grid-column: 2 / -1;
}

.breadcrumb-bar {
    height: var(--breadcrumb-height);
    padding: 0 var(--space-3);
    border-bottom: var(--hairline) solid var(--line);
    font-size: 11px; font-weight: bold; text-transform: uppercase; letter-spacing: -0.02em;
    display: flex; align-items: center;
    flex-shrink: 0;
    background: var(--bg);
}
.breadcrumb-link { cursor: pointer; color: var(--text-light); }
.breadcrumb-link:hover { color: var(--accent); }
.breadcrumb-current { color: var(--text); }

/* ── GRILLE PRINCIPALE ── */
#sd-content-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-auto-rows: var(--photo-height);
    gap: 0;
    overflow-y: auto;
    height: 100%;
}

.desktop-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, var(--photo-height));
    gap: 0;
    overflow: hidden;
}

/* ── CASES (dossiers & photos) ── */
.sub-folder, .photo-card {
    background: var(--bg);
    border-right: var(--hairline) solid var(--line);
    border-bottom: var(--hairline) solid var(--line);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.sub-folder {
    display: flex; flex-direction: column;
    justify-content: flex-end; align-items: flex-start;
    padding: var(--space-2);
}
.sub-folder:hover, .photo-card:hover { z-index: 10; }
.sub-folder-icon {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -60%);
    color: var(--text-light);
    opacity: 0.35;
    pointer-events: none;
}
.sub-folder:hover .sub-folder-icon { opacity: 0.65; }
.sd-id {
    font-size: 11px; font-weight: bold;
    letter-spacing: -0.02em; text-transform: uppercase;
    position: relative; z-index: 1;
}

.photo-card img, .photo-card video {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    background: #f0f0f0;
}
.photo-data {
    position: absolute; bottom: 0; left: 0; width: 100%;
    background: var(--bg);
    padding: 7px 10px;
    font-size: 9px; font-family: 'Courier New', monospace;
    font-weight: bold; letter-spacing: 0.04em;
    display: none;
    border-top: var(--hairline) solid var(--line);
}
.photo-card:hover .photo-data { display: block; }

.data-label {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
}

/* ── PAGINATION ── */
.pagination-controls {
    display: flex; align-items: center;
    gap: 8px;
    margin-left: auto;
    font-size: 11px; font-weight: bold;
}
.page-btn {
    background: transparent;
    border: var(--hairline) solid var(--line);
    color: var(--text); padding: 3px 10px;
    cursor: pointer; font-family: inherit;
    font-size: 11px; font-weight: bold;
    line-height: 1;
}
.page-btn:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.page-btn:disabled { opacity: 0.25; pointer-events: none; }

/* ── TAGS ── */
#tags.view-section.active {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
#tags-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.tags-cloud {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    align-items: start;
    gap: var(--space-4) var(--space-3);
    overflow-y: auto;
    min-height: 0;
    padding: var(--space-3);
}
.tags-cloud::-webkit-scrollbar { width: 3px; }
.tags-cloud::-webkit-scrollbar-thumb { background: var(--line); }

.tag-category-block {
    break-inside: avoid;
    margin-bottom: var(--space-4);
}
.tag-category-name {
    font-size: 11px; font-weight: bold;
    text-transform: uppercase; letter-spacing: -0.02em;
    color: var(--text);
    border-bottom: var(--hairline) solid var(--line);
    padding-bottom: 6px;
    margin-bottom: 6px;
}
.tag-item {
    display: block;
    width: 100%;
    font-size: 11px; font-weight: bold;
    text-transform: uppercase; letter-spacing: -0.02em;
    color: var(--text);
    background: none; border: none;
    padding: 2px 0;
    cursor: pointer;
    text-align: left;
    line-height: 1.7;
}
.tag-item:hover { color: var(--accent); }
.tag-item.active-tag { color: var(--accent); }
.tag-item .tag-count { opacity: 0.4; font-size: 10px; margin-left: 4px; font-weight: normal; }

#tags-validate-bar {
    height: var(--breadcrumb-height);
    border-bottom: var(--hairline) solid var(--line);
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(5, minmax(0, 1fr));
    align-items: stretch;
    flex-shrink: 0;
}
#tags-selection-info {
    grid-column: 1 / 5;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    color: var(--text);
    display: flex;
    align-items: center;
    padding: 0 var(--space-3);
}
#tags-deselect-btn {
    grid-column: 5 / 6;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    color: var(--text);
    background: transparent;
    border: none;
    border-left: var(--hairline) solid var(--line);
    cursor: pointer;
    padding: 0 var(--space-2);
}
#tags-deselect-btn:disabled { opacity: 0.25; cursor: default; }
#tags-deselect-btn:not(:disabled):hover { background: #fafafa; }
#tags-validate-btn {
    grid-column: 6 / 7;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    color: var(--bg);
    background: var(--text);
    border: none;
    border-left: var(--hairline) solid var(--line);
    cursor: pointer;
    padding: 0;
}
#tags-validate-btn:disabled { opacity: 0.3; cursor: default; }
#tags-validate-btn:not(:disabled):hover { background: var(--accent); }

#tags-results-panel {
    position: absolute;
    inset: 0;
    background: var(--bg);
    display: none;
    flex-direction: column;
    z-index: 5;
}
#tags-results-panel.visible { display: flex; }
#tags-results-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(5, minmax(0, 1fr));
    align-items: stretch;
    padding: 0;
}
#tags-results-breadcrumb {
    grid-column: 1 / 6;
    display: flex;
    align-items: center;
    padding: 0 var(--space-3);
}
#tags-back-btn {
    grid-column: 6 / 7;
    border: none;
    border-left: var(--hairline) solid var(--line);
    background: var(--text);
    color: var(--bg);
    height: 100%;
    border-radius: 0;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0;
}
#tags-back-btn:hover { background: var(--accent); border-color: var(--accent); }
#tags-results {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: var(--photo-height);
    gap: 0;
    overflow-y: auto;
    min-height: 0;
}

/* ── LIGHTBOX ── */
.lightbox {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 10000;
    display: none; flex-direction: column;
    align-items: center; justify-content: center;
}
.lightbox-img {
    display: none;
    max-width: 85vw; max-height: 72vh;
    object-fit: contain;
    border: var(--hairline) solid var(--line);
}
#lightbox-video {
    display: none;
    max-width: 85vw; max-height: 72vh;
    border: var(--hairline) solid var(--line);
}
.lightbox-audio-container {
    display: none;
    flex-direction: column; align-items: center;
    padding: var(--space-4);
}
.lightbox-meta {
    margin-top: var(--space-3);
    font-family: 'Courier New', monospace;
    font-size: 11px; font-weight: bold;
    width: 85vw; max-width: 1200px;
    border-top: var(--hairline) solid var(--line);
    padding-top: var(--space-2);
}
.close-lightbox {
    position: absolute; top: var(--space-3); right: var(--space-3);
    background: none; border: none; font-size: 48px;
    cursor: pointer; z-index: 10001; line-height: 1;
}

/* ── EXTRACTION ALÉATOIRE ── */
#random.view-section.active { display: flex; flex-direction: column; }
.random-source-bar {
    height: var(--breadcrumb-height);
    border-bottom: var(--hairline) solid var(--line);
    display: flex;
    align-items: center;
    padding: 0 var(--space-3);
    gap: var(--space-3);
    flex-shrink: 0;
}
.random-showcase {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    flex: 1;
    overflow: hidden;
}
.random-media-wrapper {
    grid-column: 1 / 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f8f8;
    overflow: hidden;
}
.random-media-wrapper img, .random-media-wrapper video {
    max-width: 100%; max-height: 100%; object-fit: contain;
}
.random-meta-box {
    grid-column: 5 / 7;
    padding: var(--space-4);
    border-left: var(--hairline) solid var(--line);
    display: flex; flex-direction: column;
    justify-content: space-between; overflow: hidden;
}
.random-meta-content {
    font-family: 'Courier New', monospace;
    font-size: 11px; font-weight: bold;
    line-height: 1.6; letter-spacing: 0.05em;
    color: var(--text);
}
.random-card-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.random-card-btn {
    background: transparent;
    border: var(--hairline) solid var(--line);
    color: var(--text);
    font-size: 11px; font-weight: bold;
    letter-spacing: -0.02em;
    padding: 4px 8px;
    cursor: pointer;
    text-transform: uppercase;
}
.random-card-btn:hover { border-color: var(--text); }
.random-card-btn.active { background: #e0e0e0; color: var(--text); border-color: #e0e0e0; }

.random-action-btn {
    background: var(--text); color: var(--bg);
    border: none; padding: var(--space-2) var(--space-3);
    cursor: pointer; text-transform: uppercase;
    font-size: 11px; font-weight: bold;
    width: 100%; letter-spacing: -0.02em;
}
.random-action-btn:hover { background: var(--accent); }

/* ── CHRONOLOGIE ── */
#timeline.view-section.active { display: block; overflow-y: auto; }
#timeline-container {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: var(--breadcrumb-height);
}

.timeline-year-header {
    grid-column: 1 / -1;
    height: var(--breadcrumb-height);
    padding: 0 var(--space-3);
    font-size: 11px; font-weight: bold;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    color: var(--text);
    border-top: var(--hairline) solid var(--line);
    border-bottom: var(--hairline) solid var(--line);
    background: var(--bg);
    display: flex; align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    overflow: clip;
}

.timeline-photo-cell {
    grid-row: span 2;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border-right: var(--hairline) solid var(--line);
    border-bottom: var(--hairline) solid var(--line);
    background: #f0f0f0;
    content-visibility: auto;
    contain-intrinsic-size: 0 calc(var(--unit-height) * 2);
}

.timeline-photo-cell img,
.timeline-photo-cell video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── CARTE ── */
#carte.view-section.active { display: block; position: relative; overflow: hidden; }
#map-container { width: 100%; height: 100%; }
.leaflet-layer { filter: grayscale(1) opacity(0.65) contrast(1.2); }

#map-gallery-panel {
    position: absolute;
    top: 0; right: 0;
    width: calc(100% / 3);
    height: 100%;
    background: var(--bg);
    border-left: var(--hairline) solid var(--line);
    display: none;
    flex-direction: column;
    z-index: 1000;
}
#map-gallery-panel.visible { display: flex; }
#map-gallery-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: var(--photo-height);
    gap: 0;
    overflow-y: auto;
    min-height: 0;
}

/* ── CONTEXTE ── */
#contexte.view-section.active { display: block; overflow-y: auto; }
.contexte-content {
    padding: var(--space-8); max-width: 1200px; margin: 0 auto;
}
.manifesto {
    font-size: clamp(18px, 2.5vw, 32px); line-height: 1.15;
    font-weight: bold; margin-bottom: var(--space-8);
    text-transform: uppercase;
}
.contexte-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: var(--space-6); border-top: var(--hairline) solid var(--line);
    padding-top: var(--space-4);
}
.contexte-column h3 {
    font-size: 11px; font-weight: bold;
    text-transform: uppercase; letter-spacing: -0.02em;
    margin: 0 0 var(--space-2);
}
.contexte-column p {
    font-size: 13px; color: var(--text-light); line-height: 1.7; margin: 0;
}

/* ── LOADING ── */
#loading-screen {
    position: fixed; inset: 0; background: var(--bg);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-6);
}
.loading-title {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: clamp(80px, 15vw, 220px);
    font-weight: 700;
    letter-spacing: -0.04em;
    text-transform: uppercase;
    line-height: 0.85;
    color: var(--text);
}
.loading-status {
    font-size: 11px; font-weight: bold;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    color: var(--text);
    padding-bottom: var(--space-3);
    border-bottom: var(--hairline) solid var(--line);
}

/* ── MOBILE ── */
@media (max-width: 900px) {
    .nav-btn:first-child { width: auto; flex: 1; }
    .explorer-layout { grid-template-columns: 1fr; grid-template-rows: 180px 1fr; }
    .explorer-sidebar { border-right: none; border-bottom: var(--hairline) solid var(--line); overflow-x: auto; overflow-y: hidden; display: flex; }
    .sidebar-item { flex-shrink: 0; border-bottom: none; border-right: var(--hairline) solid var(--line); }
    .desktop-grid { grid-template-columns: repeat(3, 1fr); }
    .random-showcase { flex-direction: column; }
    .random-meta-box { flex: auto; border-left: none; border-top: var(--hairline) solid var(--line); }
    .contexte-grid { grid-template-columns: 1fr; }
}
