/* =============================================================================
   portfolio.css — Galerie photos avec sidebar arborescence + lightbox
   ============================================================================= */

.portfolio-wrap {
    --pf-text:      #1b1b1b;
    --pf-text-soft: #5a6271;
    --pf-bg-card:   #ffffff;
    --pf-bg-soft:   #f0f2f5;
    --pf-bg-sidebar: #f7f8fa;
    --pf-border:    #d8dde3;
    --pf-accent:    #0078d4;
    --pf-active-bg: rgba(0, 120, 212, 0.10);
}

.portfolio-wrap {
    max-width: 1300px;
    margin: 0 auto;
    color: var(--pf-text);
}

.portfolio-intro {
    padding: 14px 18px;
    background: rgba(0, 120, 212, 0.08);
    border-left: 4px solid var(--pf-accent);
    border-radius: 0 6px 6px 0;
    margin: 0 0 20px;
    line-height: 1.55;
}
.portfolio-alert {
    padding: 20px 24px;
    background: rgba(255, 185, 0, 0.12);
    border-left: 4px solid #ffb900;
    border-radius: 0 8px 8px 0;
    margin: 20px 0;
    line-height: 1.6;
}
.portfolio-alert code {
    background: #fff; padding: 2px 6px; border-radius: 3px; font-size: 12px;
}
.portfolio-empty {
    text-align: center; padding: 50px 20px;
    color: var(--pf-text-soft); background: var(--pf-bg-soft);
    border-radius: 10px;
}

/* ============ LAYOUT ============ */
.portfolio-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
    align-items: flex-start;
}

/* ============ SIDEBAR ============ */
.portfolio-sidebar {
    background: var(--pf-bg-sidebar);
    border: 1px solid var(--pf-border);
    border-radius: 8px;
    overflow: hidden;
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
}
.portfolio-sidebar-toggle {
    display: none;
    width: 100%; padding: 12px 14px;
    background: var(--pf-accent); color: #fff;
    border: none; cursor: pointer;
    font-size: 14px; font-weight: 700; text-align: left;
    align-items: center; justify-content: space-between;
}
.portfolio-sidebar-toggle-arrow { transition: transform 0.2s; }
.portfolio-sidebar.is-open .portfolio-sidebar-toggle-arrow {
    transform: rotate(180deg);
}

.portfolio-tree { padding: 8px 0; }
.portfolio-tree-root,
.pf-tree-children {
    list-style: none; padding: 0; margin: 0;
}

.pf-tree-item { margin: 0; }
.pf-tree-row { display: flex; align-items: stretch; }

.pf-tree-link {
    flex: 1;
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    color: var(--pf-text);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.12s;
    min-width: 0;
}
.pf-tree-link:hover { background: rgba(0, 120, 212, 0.07); }
.pf-tree-link.active {
    background: var(--pf-active-bg);
    color: var(--pf-accent);
    font-weight: 700;
    border-left: 3px solid var(--pf-accent);
    padding-left: 9px;
}
.pf-tree-link-static {
    cursor: default;
    color: var(--pf-text-soft);
    font-weight: 600;
}
.pf-tree-link-static:hover { background: transparent; }

.pf-tree-icon {
    flex-shrink: 0; font-size: 14px; line-height: 1;
    width: 18px; text-align: center;
}
.pf-tree-label {
    flex: 1; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.pf-tree-count {
    flex-shrink: 0; font-size: 11px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.07);
    color: var(--pf-text-soft);
    border-radius: 10px; font-weight: 600;
}
.pf-tree-link.active .pf-tree-count {
    background: var(--pf-accent); color: #fff;
}
.pf-tree-count-total {
    background: transparent; padding: 0; font-style: italic;
}

.pf-tree-toggle {
    flex-shrink: 0; background: transparent; border: none;
    width: 32px; cursor: pointer;
    color: var(--pf-text-soft); font-size: 12px;
    transition: transform 0.2s; padding: 0;
}
.pf-tree-toggle:hover { color: var(--pf-text); }
.pf-tree-parent.open .pf-tree-toggle {
    transform: rotate(180deg);
}

.pf-tree-children {
    background: rgba(0, 0, 0, 0.03);
    border-top: 1px solid var(--pf-border);
    border-bottom: 1px solid var(--pf-border);
}
.pf-tree-children .pf-tree-link {
    padding-left: 32px; font-size: 12px;
}
.pf-tree-children .pf-tree-link.active {
    padding-left: 29px;
}
.pf-tree-children .pf-tree-icon {
    font-size: 10px; opacity: 0.6;
}

.pf-tree-root-item {
    border-bottom: 1px solid var(--pf-border);
    margin-bottom: 4px; padding-bottom: 4px;
}

/* ============ CONTENT (droite) ============ */
.portfolio-content { min-width: 0; }

.portfolio-breadcrumb {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    padding: 10px 14px;
    background: var(--pf-bg-soft);
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px; color: var(--pf-text-soft);
}
.portfolio-breadcrumb a {
    color: var(--pf-accent); text-decoration: none; font-weight: 600;
}
.portfolio-breadcrumb a:hover { text-decoration: underline; }
.portfolio-breadcrumb-count {
    margin-left: auto; font-style: italic; font-size: 12px;
}

/* ============ GRILLE ============ */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.portfolio-item {
    position: relative; aspect-ratio: 4 / 3;
    overflow: hidden; border-radius: 6px;
    background: #000; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.portfolio-item:hover,
.portfolio-item:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.portfolio-item img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    transition: transform 0.4s ease, opacity 0.3s;
    opacity: 0.95;
}
.portfolio-item:hover img,
.portfolio-item:focus-visible img {
    transform: scale(1.08); opacity: 1;
}

.portfolio-item-caption {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 10px 12px 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    color: #fff; font-size: 12px; font-weight: 600;
    line-height: 1.3;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    pointer-events: none;
}
.portfolio-item:hover .portfolio-item-caption,
.portfolio-item:focus-visible .portfolio-item-caption {
    transform: translateY(0);
}

/* ============ LIGHTBOX ============ */
.portfolio-lightbox {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.93);
    z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    padding: 60px 40px;
}
.portfolio-lightbox[hidden] { display: none !important; }
.portfolio-lb-content {
    max-width: 100%; max-height: 100%;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
}
#portfolioLbImg {
    max-width: 100%; max-height: calc(100vh - 160px);
    object-fit: contain;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    background: #000;
}
.portfolio-lb-info {
    display: flex; align-items: center; gap: 16px;
    color: #fff; font-size: 13px;
}
.portfolio-lb-caption { font-weight: 600; }
.portfolio-lb-counter {
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 12px; border-radius: 12px;
    font-weight: 700; font-size: 11px; letter-spacing: 0.5px;
}

.portfolio-lb-close {
    position: absolute; top: 16px; right: 20px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff; border: none; border-radius: 50%;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    z-index: 100001;
}
.portfolio-lb-close:hover,
.portfolio-lb-close:focus-visible {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

.portfolio-lb-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.12);
    color: #fff; border: none; border-radius: 50%;
    width: 56px; height: 56px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    z-index: 100001;
}
.portfolio-lb-arrow:hover,
.portfolio-lb-arrow:focus-visible {
    background: rgba(255, 255, 255, 0.25);
}
.portfolio-lb-prev { left: 20px; }
.portfolio-lb-next { right: 20px; }
.portfolio-lb-prev:hover { transform: translateY(-50%) scale(1.08); }
.portfolio-lb-next:hover { transform: translateY(-50%) scale(1.08); }

/* ============ MODE PAGE DIRECTE + SOMBRE ============ */
body.page-portfolio:not(.light) .portfolio-wrap {
    --pf-text:      #ffffff;
    --pf-text-soft: rgba(255, 255, 255, 0.7);
    --pf-bg-card:   #2d3a4a;
    --pf-bg-soft:   rgba(255, 255, 255, 0.06);
    --pf-bg-sidebar: rgba(255, 255, 255, 0.04);
    --pf-border:    rgba(255, 255, 255, 0.15);
    --pf-accent:    #4ba3e0;
    --pf-active-bg: rgba(75, 163, 224, 0.18);
}
body.page-portfolio:not(.light) .pf-tree-children {
    background: rgba(255, 255, 255, 0.03);
}
body.page-portfolio:not(.light) .pf-tree-count {
    background: rgba(255, 255, 255, 0.10);
    color: rgba(255, 255, 255, 0.8);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .portfolio-layout { grid-template-columns: 200px 1fr; gap: 14px; }
}
@media (max-width: 700px) {
    .portfolio-layout { grid-template-columns: 1fr; gap: 12px; }
    .portfolio-sidebar { position: static; max-height: none; }
    .portfolio-sidebar-toggle { display: flex; }
    .portfolio-tree { display: none; max-height: 50vh; overflow-y: auto; }
    .portfolio-sidebar.is-open .portfolio-tree { display: block; }

    .portfolio-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 6px;
    }
    .portfolio-lightbox { padding: 50px 8px; }
    .portfolio-lb-arrow { width: 44px; height: 44px; }
    .portfolio-lb-prev { left: 4px; }
    .portfolio-lb-next { right: 4px; }
    .portfolio-lb-info { font-size: 11px; padding: 0 16px; text-align: center; }
}
