/* ============================================================
   Portfolio — public styles
   BEM: .portfolio-nav, .portfolio-subnav, .portfolio-row, .portfolio-lightbox
   ============================================================ */

/* ── CSS variables (overridden inline from DB settings) ────── */
:root {
    --portfolio-gap:    16px;
    --portfolio-radius: 8px;
}

/* ── Nav band (dcecf9 container below the page title) ──────── */
.portfolio-nav-band {
    background: #dcecf9;
    border-radius: 10px;
    margin-bottom: 28px;
    overflow: hidden;
}

/* ── Portfolio content area ─────────────────────────────────── */
.portfolio-content {
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Top navigation ─────────────────────────────────────────── */
.portfolio-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 14px 16px;
}

.portfolio-nav__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 22px;
    font-weight: 500;
    color: #444;
    text-decoration: none;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s, border-color .15s;
    white-space: nowrap;
}

.portfolio-nav__item:hover {
    background: rgba(255,255,255,0.6);
    color: #2074a4;
}

.portfolio-nav__item--active {
    background: #ffffff;
    color: #2074a4;
    border-color: #a8d0ef;
    font-weight: 600;
}

.portfolio-nav__arrow {
    font-size: 10px;
    transition: transform .2s;
    display: inline-block;
}

.portfolio-nav__item[aria-expanded="true"] .portfolio-nav__arrow {
    transform: rotate(180deg);
}

/* ── Sub-navigation panel ───────────────────────────────────── */
.portfolio-subnav {
    background: rgba(255,255,255,0.35);
    border-top: 1px solid rgba(255,255,255,0.6);
    padding: 16px 16px 20px;
    animation: subnav-reveal .15s ease;
}

@keyframes subnav-reveal {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.portfolio-subnav__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px 16px;
    max-width: 1400px;
    margin: 0 auto;
}

.portfolio-subnav__link {
    display: block;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 21px;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    background: #fff;
    border: 1px solid #e0e5ec;
    transition: background .15s, color .15s, border-color .15s;
    text-align: center;
}

.portfolio-subnav__link:hover {
    background: #e8f2fa;
    color: #2074a4;
    border-color: #b8d8f0;
}

/* ── Page body rows ─────────────────────────────────────────── */
.portfolio-page {
    width: 100%;
}

/* Title row */
.portfolio-row--title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 0 12px;
    border-bottom: 2px solid #eef0f3;
    margin-bottom: 20px;
}

.portfolio-row__title {
    font-size: 28px;
    font-weight: 700;
    color: #2074a4;
    margin: 0;
}

.portfolio-row__back-to-top {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #eef0f3;
    color: #666;
    text-decoration: none;
    font-size: 16px;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}

.portfolio-row__back-to-top:hover {
    background: #2074a4;
    color: #fff;
}

/* Image row */
.portfolio-row--images {
    margin-bottom: 32px;
}

.portfolio-row__images {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--portfolio-gap);
}

.portfolio-row__image-wrap {
    flex-shrink: 0;
    overflow: hidden;
    line-height: 0;
}

.portfolio-row__image-wrap.portfolio-img--expandable {
    cursor: zoom-in;
}

.portfolio-row__img {
    display: block;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    vertical-align: bottom;
}

/* ── Website screenshot row ─────────────────────────────────── */
.portfolio-row--website {
    margin-bottom: 32px;
}

.portfolio-row__images--ws {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}

.portfolio-ws-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0; /* allow grid item to shrink below content size */
}

.portfolio-ws-link {
    display: block;
    text-align: center;
    font-size: 17px;
    font-weight: 500;
    color: #2074a4;
    text-decoration: none;
    padding: 2px 0;
    transition: color .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portfolio-ws-link:hover {
    color: #1557a4;
    text-decoration: underline;
}

.portfolio-ws-img-wrap {
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: var(--ws-aspect, 2/3);
    position: relative;
    outline: 1px solid #e4e7ea;
    transition: outline .1s;
}

.portfolio-ws-img-wrap:hover {
    outline: 2px solid #c8ced4;
}

.portfolio-ws-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

/* ── Website screenshot lightbox ─────────────────────────────── */
.portfolio-ws-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.portfolio-ws-lightbox.is-open {
    opacity: 1;
    pointer-events: auto;
}

.portfolio-ws-lightbox__img {
    display: block;
    max-width: calc(100% - 40px);
    height: auto;
    margin: 60px auto 48px;
    border-radius: 4px;
}

.portfolio-ws-lightbox__visit {
    position: fixed;
    top: 16px;
    left: 20px;
    max-width: calc(50vw - 50px); /* never overlap the close button */
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    padding: 0 18px;
    height: 40px;
    line-height: 40px;
    border-radius: 20px;
    white-space: nowrap;
    transition: background .15s;
    z-index: 10000;
}

.portfolio-ws-lightbox__visit:hover {
    background: rgba(255,255,255,.28);
}

.portfolio-ws-lightbox__close {
    position: fixed;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    z-index: 10000;
    font-family: inherit;
}

.portfolio-ws-lightbox__close:hover {
    background: rgba(255,255,255,.3);
}

/* ── Lightbox ───────────────────────────────────────────────── */
.portfolio-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s ease;
}

.portfolio-lightbox.is-open {
    opacity: 1;
}

.portfolio-lightbox__img {
    max-width: 92vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 48px rgba(0,0,0,.5);
    display: block;
}

.portfolio-lightbox__close {
    position: fixed;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    z-index: 10000;
}

.portfolio-lightbox__close:hover {
    background: rgba(255,255,255,.3);
}

/* ── Empty state ────────────────────────────────────────────── */
.portfolio-empty {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .portfolio-subnav__grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .portfolio-row__images--ws {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    .portfolio-nav {
        gap: 4px;
        padding: 10px 12px;
    }

    .portfolio-nav__item {
        padding: 11px 20px;
        font-size: 20px;
    }

    .portfolio-subnav__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .portfolio-subnav__link {
        font-size: 14px;
        padding: 8px 10px;
    }

    /* ── Mobile website grid ────────────────────────── */
    .portfolio-row__images--ws {
        grid-template-columns: repeat(2, 1fr);
    }

    /* ── Mobile image grid ──────────────────────────── */
    /* Switch from flex to grid; ignore fixed px heights */
    .portfolio-row__images {
        display: grid;
        justify-content: unset;
    }

    .portfolio-row__image-wrap {
        width: 100%;
    }

    /* Let images scale naturally to column width */
    .portfolio-row__img {
        width: 100% !important;
        height: auto !important;
    }

    /* Column count driven by data attribute set from DB per row type */
    .portfolio-row__images[data-mobile-cols="1"] { grid-template-columns: repeat(1, 1fr); }
    .portfolio-row__images[data-mobile-cols="2"] { grid-template-columns: repeat(2, 1fr); }
    .portfolio-row__images[data-mobile-cols="3"] { grid-template-columns: repeat(3, 1fr); }

    /* Fallback if attribute missing */
    .portfolio-row__images:not([data-mobile-cols]) { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .portfolio-subnav__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .portfolio-nav__item {
        font-size: 18px;
        padding: 10px 14px;
    }

    .portfolio-subnav__link {
        font-size: 13px;
        padding: 7px 8px;
    }
}
