/* Hero artwork for the portfolio page */
#portfolio-hero {
    --hero-image: none;
    --hero-accent: rgba(255, 255, 255, 0.78);
}

#portfolio-hero.page-hero {
    min-height: 100dvh;
    padding: clamp(108px, 11vw, 152px) 0 clamp(60px, 6vw, 88px);
}

#portfolio-hero.page-hero::before {
    background:
        linear-gradient(90deg, rgba(17, 14, 20, 0.38) 0%, rgba(17, 14, 20, 0.2) 36%, rgba(17, 14, 20, 0.08) 72%, rgba(17, 14, 20, 0.22) 100%),
        radial-gradient(circle at 18% 18%, rgba(200, 192, 197, 0.1), transparent 28%),
        radial-gradient(circle at 82% 72%, rgba(255, 255, 255, 0.05), transparent 24%);
    z-index: 1;
}

#portfolio-hero.page-hero::after {
    inset: auto -8rem -8rem auto;
    width: 24rem;
    height: 24rem;
    background: radial-gradient(circle, rgba(200, 192, 197, 0.14) 0%, rgba(200, 192, 197, 0) 72%);
}

#portfolio-hero .container {
    position: relative;
    z-index: 2;
}

#portfolio-hero .page-hero__panel {
    max-width: 860px;
    background: linear-gradient(180deg, rgba(20, 16, 22, 0.58), rgba(20, 16, 22, 0.34));
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.28);
}

.portfolio-grid {
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 40px;
}

.portfolio-hero__collage {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: repeat(12, minmax(0, 1fr));
    grid-auto-flow: dense;
    gap: 10px;
    padding: 10px;
    box-sizing: border-box;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 18%, rgba(200, 192, 197, 0.11), transparent 28%),
        radial-gradient(circle at 82% 72%, rgba(255, 255, 255, 0.06), transparent 24%),
        linear-gradient(180deg, #171318 0%, #130f16 100%);
    pointer-events: none;
    opacity: 0;
    animation: portfolioCollageFade 420ms ease-out both;
}

.portfolio-hero__tile {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(18, 14, 20, 0.96));
    border-radius: clamp(12px, 1.2vw, 22px);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
    transform: translate3d(0, 18px, 0) scale(0.965);
    opacity: 0.14;
    transform-origin: center;
    backface-visibility: hidden;
    will-change: transform, opacity;
    animation: portfolioTileEnter 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--tile-index) * 16ms);
}

/* Loading Shimmer for Tiles */
.portfolio-hero__tile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 22%, rgba(255, 255, 255, 0.06) 50%, transparent 78%);
    background-size: 200% 100%;
    animation: tileShimmer 1.35s infinite linear;
    z-index: 1;
    pointer-events: none;
    opacity: 0.9;
    transition: opacity 0.45s ease-out;
}

.portfolio-hero__tile.is-loaded::before {
    opacity: 0;
}

.portfolio-hero__tile::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(31, 27, 31, 0.22));
    pointer-events: none;
    opacity: 0.45;
    z-index: 2;
}

.portfolio-hero__tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transform: scale(1.06);
    filter: blur(8px) saturate(1.04) contrast(1.05) brightness(0.97);
    opacity: 0;
    transition:
        opacity 0.68s cubic-bezier(0.4, 0, 0.2, 1),
        filter 0.95s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.95s cubic-bezier(0.16, 1, 0.3, 1);
}

.portfolio-hero__tile.is-loaded img {
    opacity: 1;
    transform: scale(1.02);
    filter: saturate(1.08) contrast(1.05) brightness(0.98);
}

@keyframes tileShimmer {
    0% {
        background-position: -150% 0;
    }

    100% {
        background-position: 150% 0;
    }
}

.portfolio-hero__tile--0 img {
    object-position: center 14%;
}

.portfolio-hero__tile--1 img {
    object-position: center 28%;
}

.portfolio-hero__tile--2 img {
    object-position: center 42%;
}

.portfolio-hero__tile--3 img {
    object-position: center 56%;
}

.portfolio-hero__tile--4 img {
    object-position: center 70%;
}

.portfolio-hero__tile--5 img {
    object-position: center 38%;
}

.portfolio-hero__tile--6 img {
    object-position: center 22%;
}

.portfolio-hero__tile--7 img {
    object-position: center 62%;
}

@keyframes portfolioCollageFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes portfolioTileEnter {
    0% {
        opacity: 0;
        transform: translate3d(0, 22px, 0) scale(0.94);
    }

    65% {
        opacity: 1;
        transform: translate3d(0, -1px, 0) scale(1.006);
    }

    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

#portfolio-hero.page-hero--quick .portfolio-hero__collage {
    animation-duration: 220ms;
}

#portfolio-hero.page-hero--quick .portfolio-hero__tile {
    animation-duration: 420ms;
    animation-delay: calc(var(--tile-index) * 8ms);
}

#portfolio-hero.page-hero--quick .portfolio-hero__tile img {
    transition:
        opacity 0.36s cubic-bezier(0.4, 0, 0.2, 1),
        filter 0.48s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.48s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 1100px) {
    #portfolio-hero.page-hero {
        padding: 104px 0 76px;
    }

    #portfolio-hero .page-hero__panel {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    #portfolio-hero.page-hero {
        padding: 96px 0 68px;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    #portfolio-filters .archive-controls__inner {
        flex-direction: column;
        align-items: stretch;
        gap: 18px;
    }

    #portfolio-filters .categories {
        justify-content: flex-start;
    }

    #portfolio-filters .archive-controls__sorting {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    #portfolio-filters select {
        width: 100%;
    }

    .portfolio-item-content {
        padding: 24px 18px;
    }

    .portfolio-card-media {
        height: auto;
        aspect-ratio: 4 / 5;
    }

    .detail-sidebar {
        padding: 24px 20px;
    }

    .detail-gallery {
        padding: 24px 20px 32px;
    }

    .detail-sidebar h1 {
        font-size: clamp(2rem, 8vw, 2.8rem);
        overflow-wrap: anywhere;
    }

    .sidebar-navigation {
        flex-direction: column;
        gap: 12px;
    }

    .sidebar-nav-link {
        opacity: 1;
    }

    .sidebar-nav-title {
        white-space: normal;
    }
}

/* Custom Select Dropdown */
.custom-select {
    position: relative;
    font-family: 'Poppins', sans-serif;
    min-width: 220px;
    z-index: 10;
}

.custom-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.custom-select-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.custom-select-trigger i {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    margin-left: 12px;
    opacity: 0.7;
    color: var(--primary);
}

.custom-select.active .custom-select-trigger i {
    transform: rotate(180deg);
}

.custom-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(23, 19, 24, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    overflow: hidden;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.98);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    padding: 6px;
}

.custom-select.active .custom-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.custom-option {
    padding: 12px 18px;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 12px;
    font-size: 0.92rem;
    font-weight: 400;
}

.custom-option:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.custom-option.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
    font-weight: 500;
}

@media (max-width: 768px) {
    .custom-select {
        width: 100%;
    }
}

@media (max-width: 520px) {
    #portfolio-hero.page-hero {
        padding: 88px 0 60px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .portfolio-hero__collage,
    .portfolio-hero__tile {
        animation: none !important;
        opacity: 1;
        transform: none;
    }

    .portfolio-hero__tile::before {
        animation: none;
        opacity: 0;
    }

    .portfolio-hero__tile img {
        transition: none !important;
        transform: none !important;
        filter: none !important;
        opacity: 1;
    }
}

/* Detail Modal Styles */
.detail-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    background-color: var(--bg-dark);
    color: var(--text-dark);
    min-height: 100vh;
    padding: var(--site-header-height, 72px) 0 0;
}

.detail-sidebar {
    position: relative;
    padding: 60px 40px;
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.detail-sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(31, 27, 31, 0.95) 0%, rgba(31, 27, 31, 0.3) 100%);
    z-index: 1;
    border-radius: inherit;
}

.sidebar-content {
    position: relative;
    z-index: 2;
}

.meta-tag {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 99px;
    font-size: 0.9em;
    margin: 0 5px 15px 0;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.meta-category {
    color: var(--bg-dark);
    background: rgba(200, 192, 197, 0.9);
}

.meta-date,
.meta-location {
    color: var(--text-dark);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(31, 27, 31, 0.74);
    backdrop-filter: blur(5px);
}

.detail-gallery {
    padding: 40px;
    flex: 1;
}

.gallery-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.gallery-grid>* {
    width: 100%;
    margin-bottom: 0px;
}

.portfolio-gallery-media {
    width: 100%;
    aspect-ratio: 4/5;
    object-fit: cover;
    border-radius: var(--radius-sm);
    display: block;
}

#global-modal .portfolio-gallery-media {
    opacity: 0;
    transform: translate3d(0, 24px, 0) scale(0.975);
    filter: blur(10px) saturate(0.9) brightness(0.92);
    transition:
        opacity 720ms ease,
        transform 900ms cubic-bezier(0.16, 1, 0.3, 1),
        filter 900ms ease,
        box-shadow 900ms ease;
    transition-delay: calc(var(--media-index, 0) * 80ms);
    will-change: opacity, transform, filter;
}

#global-modal .portfolio-gallery-media.is-loaded {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    filter: blur(0) saturate(1) brightness(1);
}

#global-modal img.portfolio-gallery-media {
    cursor: zoom-in;
}

#global-modal img.portfolio-gallery-media.is-loaded:hover {
    transform: translate3d(0, 0, 0) scale(1.015);
}

#global-modal .portfolio-gallery-media[role="button"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
}

.sidebar-navigation {
    margin-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 30px;
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.sidebar-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    text-decoration: none !important;
    transition: opacity 0.3s ease;
    opacity: 0.7;
    min-width: 0;
}

.sidebar-nav-link:hover {
    opacity: 1;
}

.sidebar-nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    margin-bottom: 4px;
    font-weight: 600;
}

.sidebar-nav-title {
    font-size: 0.95rem;
    font-weight: 400;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav-next {
    text-align: right;
}

@media (min-width: 1000px) {
    .detail-shell {
        flex-direction: row;
    }

    .detail-sidebar {
        width: 450px;
        height: calc(100vh - var(--site-header-height, 72px));
        position: sticky;
        top: var(--site-header-height, 72px);
        border-radius: 0;
        align-self: flex-start;
    }

    .detail-gallery {
        padding: 60px;
    }

    .gallery-grid>* {
        width: calc((100% - 40px) / 3);
    }

    body.has-admin-toolbar .detail-sidebar {
        top: calc(var(--admin-toolbar-height, 0px) + var(--site-header-height, 72px));
        height: calc(100vh - (var(--admin-toolbar-height, 0px) + var(--site-header-height, 72px)));
    }
}

@media (prefers-reduced-motion: reduce) {
    #global-modal .portfolio-gallery-media {
        opacity: 1;
        transform: none;
        filter: none;
        transition: none;
    }
}

/* Portfolio Archive List Styles */
.portfolio-item {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    margin-bottom: 0;
}

.portfolio-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(31, 27, 31, 0.9) 0%, rgba(31, 27, 31, 0) 50%);
    pointer-events: none;
    opacity: 0.8;
    transition: opacity 0.4s ease;
}

.portfolio-item:hover::after {
    opacity: 0.95;
}

.portfolio-item-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px;
    z-index: 2;
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.portfolio-item:hover .portfolio-item-content {
    transform: translateY(0);
}

.portfolio-card-media {
    width: 100%;
    height: 600px;
    object-fit: cover;
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.portfolio-item:hover .portfolio-card-media {
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    #portfolio-filters .archive-controls__inner {
        flex-direction: column;
        align-items: stretch;
        gap: 18px;
    }

    #portfolio-filters .categories {
        justify-content: flex-start;
    }

    #portfolio-filters .archive-controls__sorting {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    #portfolio-filters select {
        width: 100%;
    }

    .portfolio-item-content {
        padding: 24px 18px;
    }

    .portfolio-card-media {
        height: auto;
        aspect-ratio: 4 / 5;
    }

    .detail-sidebar {
        padding: 24px 20px;
    }

    .detail-gallery {
        padding: 24px 20px 32px;
    }

    .detail-sidebar h1 {
        font-size: clamp(2rem, 8vw, 2.8rem);
        overflow-wrap: anywhere;
    }

    .sidebar-navigation {
        flex-direction: column;
        gap: 12px;
    }

    .sidebar-nav-link {
        opacity: 1;
    }

    .sidebar-nav-title {
        white-space: normal;
    }
}