/* ==========================================================================
   APAKONICS — Portfolio Stylesheet (Phase 6)
   Loaded on /portfolio and /portfolio/{slug} pages. Depends on app.css tokens.
   ========================================================================== */

/* ==========================================================================
   FILTER PILLS (category chips above the grid)
   ========================================================================== */

.apk-portfolio-filter-wrap {
    padding: var(--apk-space-6) 0 var(--apk-space-2);
    background: var(--apk-white);
    border-bottom: 1px solid var(--apk-gray-200);
}

.apk-portfolio-filter {
    display: flex;
    flex-wrap: wrap;
    gap: var(--apk-space-2);
    margin-bottom: var(--apk-space-3);
}

.apk-portfolio-filter__pill {
    display: inline-flex;
    align-items: center;
    gap: var(--apk-space-2);
    padding: 10px var(--apk-space-4);
    background: var(--apk-gray-100);
    color: var(--apk-gray-700);
    border: 1.5px solid transparent;
    border-radius: var(--apk-radius-pill);
    font-size: var(--apk-text-sm);
    font-weight: 600;
    text-decoration: none;
    transition: all var(--apk-duration-fast) var(--apk-ease);
}
.apk-portfolio-filter__pill:hover {
    background: var(--apk-white);
    color: var(--apk-primary);
    border-color: var(--apk-primary);
    transform: translateY(-1px);
}
.apk-portfolio-filter__pill.is-active {
    background: var(--apk-primary);
    color: var(--apk-white);
    border-color: var(--apk-primary);
    box-shadow: var(--apk-shadow-red);
}
.apk-portfolio-filter__pill i {
    font-size: 12px;
    opacity: .85;
}

.apk-portfolio-filter__count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    background: rgba(0,0,0,.08);
    color: inherit;
    border-radius: var(--apk-radius-pill);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}
.apk-portfolio-filter__pill.is-active .apk-portfolio-filter__count {
    background: rgba(255,255,255,.22);
    color: var(--apk-white);
}

.apk-portfolio-filter__meta {
    font-size: var(--apk-text-sm);
    color: var(--apk-gray-500);
}
.apk-portfolio-filter__meta strong { color: var(--apk-gray-900); }

/* ==========================================================================
   PORTFOLIO LISTING GRID
   ========================================================================== */

.apk-portfolio-section { padding-top: var(--apk-space-8); }

.apk-portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--apk-space-5);
}

/* --- Project Card --- */
.apk-portfolio-card {
    position: relative;
    background: var(--apk-white);
    border-radius: var(--apk-radius-lg);
    overflow: hidden;
    box-shadow: var(--apk-shadow-sm);
    transition: transform var(--apk-duration-normal), box-shadow var(--apk-duration-normal);
}
.apk-portfolio-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--apk-shadow-lg);
}
.apk-portfolio-card--featured {
    grid-column: span 2;
}
@media (max-width: 899px) {
    .apk-portfolio-card--featured { grid-column: span 1; }
}

.apk-portfolio-card__link {
    display: block;
    color: inherit;
    text-decoration: none;
}
.apk-portfolio-card__media {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: var(--apk-gray-100);
}
.apk-portfolio-card--featured .apk-portfolio-card__media {
    aspect-ratio: 16/9;
}
.apk-portfolio-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--apk-duration-slow) var(--apk-ease);
}
.apk-portfolio-card:hover .apk-portfolio-card__media img {
    transform: scale(1.06);
}

/* Status + featured badges over the image */
.apk-portfolio-card__badge,
.apk-portfolio-card__status {
    position: absolute;
    top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: var(--apk-radius-pill);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
    z-index: 2;
}
.apk-portfolio-card__badge {
    left: 12px;
    background: var(--apk-primary);
    color: var(--apk-white);
    box-shadow: var(--apk-shadow-red);
}
.apk-portfolio-card__status {
    right: 12px;
    background: rgba(0,0,0,.7);
    color: var(--apk-white);
}
.apk-portfolio-card__status--renovation {
    background: rgba(0,0,0,.7);
}
.apk-portfolio-card__status--ongoing {
    background: #f59e0b;
    top: 48px; /* stack below other badges */
}
.apk-portfolio-card__badge + .apk-portfolio-card__status--renovation {
    top: 48px;
    right: 12px;
}

/* Hover overlay */
.apk-portfolio-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(254,0,0,.75), rgba(0,0,0,0) 55%);
    opacity: 0;
    transition: opacity var(--apk-duration-normal);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: var(--apk-space-4);
}
.apk-portfolio-card:hover .apk-portfolio-card__overlay { opacity: 1; }
.apk-portfolio-card__cta {
    width: 44px;
    height: 44px;
    background: var(--apk-white);
    color: var(--apk-primary);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 14px;
    transform: translateX(10px);
    transition: transform var(--apk-duration-normal) var(--apk-duration-fast);
}
.apk-portfolio-card:hover .apk-portfolio-card__cta {
    transform: translateX(0);
}

.apk-portfolio-card__body {
    padding: var(--apk-space-4) var(--apk-space-5) var(--apk-space-5);
}
.apk-portfolio-card__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--apk-space-2);
    margin-bottom: var(--apk-space-2);
    font-size: var(--apk-text-xs);
}
.apk-portfolio-card__category {
    color: var(--apk-primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.apk-portfolio-card__year {
    color: var(--apk-gray-500);
    font-weight: 600;
}
.apk-portfolio-card__title {
    font-family: var(--apk-font-body);
    font-size: var(--apk-text-lg);
    font-weight: 700;
    color: var(--apk-gray-900);
    letter-spacing: 0;
    line-height: 1.3;
    margin-bottom: 6px;
}
.apk-portfolio-card:hover .apk-portfolio-card__title {
    color: var(--apk-primary);
    transition: color var(--apk-duration-fast);
}
.apk-portfolio-card__location {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--apk-gray-500);
    font-size: var(--apk-text-xs);
}
.apk-portfolio-card__location i { color: var(--apk-primary); }

/* ==========================================================================
   PROJECT DETAIL LAYOUT
   ========================================================================== */

.apk-project-detail__layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: var(--apk-space-8);
    align-items: start;
}
@media (max-width: 1023px) {
    .apk-project-detail__layout { grid-template-columns: 1fr; }
}

.apk-project-detail__main {
    min-width: 0;
}

.apk-project-detail__lead {
    font-size: var(--apk-text-lg);
    line-height: 1.6;
    color: var(--apk-gray-700);
    font-weight: 500;
    margin-bottom: var(--apk-space-5);
    padding-bottom: var(--apk-space-5);
    border-bottom: 1px solid var(--apk-gray-200);
}

.apk-section__divider {
    margin-top: var(--apk-space-8);
    margin-bottom: var(--apk-space-5);
    padding-bottom: var(--apk-space-3);
    border-bottom: 1px solid var(--apk-gray-200);
}
.apk-section__divider h3 {
    font-family: var(--apk-font-body);
    font-size: var(--apk-text-xl);
    font-weight: 700;
    color: var(--apk-gray-900);
    letter-spacing: 0;
    margin: 4px 0 6px;
}
.apk-section__divider p {
    color: var(--apk-gray-500);
    font-size: var(--apk-text-sm);
    margin: 0;
}

/* ==========================================================================
   BEFORE / AFTER SLIDER
   ========================================================================== */

.apk-ba-slider {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--apk-radius-lg);
    overflow: hidden;
    user-select: none;
    cursor: col-resize;
    background: var(--apk-gray-900);
    box-shadow: var(--apk-shadow-lg);
    outline: none;
}
.apk-ba-slider:focus-visible {
    box-shadow: 0 0 0 3px var(--apk-primary);
}
.apk-ba-slider.is-dragging {
    cursor: grabbing;
}

.apk-ba-slider__before,
.apk-ba-slider__after {
    position: absolute;
    inset: 0;
}
.apk-ba-slider__before img,
.apk-ba-slider__after img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}
.apk-ba-slider__after {
    clip-path: inset(0 0 0 50%);
    will-change: clip-path;
}

.apk-ba-slider__label {
    position: absolute;
    bottom: 16px;
    padding: 6px 14px;
    background: rgba(0,0,0,.75);
    color: var(--apk-white);
    border-radius: var(--apk-radius-pill);
    font-size: var(--apk-text-xs);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    pointer-events: none;
}
.apk-ba-slider__label--before { left: 16px; }
.apk-ba-slider__label--after  { right: 16px; background: var(--apk-primary); }

.apk-ba-slider__handle {
    position: absolute;
    top: 0; bottom: 0;
    left: 50%;
    width: 2px;
    background: var(--apk-white);
    transform: translateX(-50%);
    pointer-events: none;
    will-change: left;
}
.apk-ba-slider__handle-line {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.85);
    box-shadow: 0 0 12px rgba(0,0,0,.35);
}
.apk-ba-slider__handle-grip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    background: var(--apk-white);
    border-radius: 50%;
    display: grid;
    place-items: center;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    pointer-events: auto;
    cursor: grab;
    color: var(--apk-primary);
    font-size: 12px;
    font-weight: 700;
}
.apk-ba-slider__handle-grip i { font-size: 11px; }
.apk-ba-slider.is-dragging .apk-ba-slider__handle-grip { cursor: grabbing; }

/* ==========================================================================
   PROJECT GALLERY
   ========================================================================== */

.apk-project-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--apk-space-3);
}
.apk-project-gallery__item {
    position: relative;
    display: block;
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: var(--apk-radius-md);
    background: var(--apk-gray-100);
    cursor: pointer;
}
.apk-project-gallery__item--hero {
    grid-column: span 2;
    grid-row: span 2;
    aspect-ratio: 4/3.3;
}
.apk-project-gallery__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--apk-duration-slow) var(--apk-ease);
}
.apk-project-gallery__item:hover img { transform: scale(1.08); }
.apk-project-gallery__zoom {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.4);
    color: var(--apk-white);
    display: grid;
    place-items: center;
    font-size: 22px;
    opacity: 0;
    transition: opacity var(--apk-duration-fast);
}
.apk-project-gallery__item:hover .apk-project-gallery__zoom { opacity: 1; }

@media (max-width: 767px) {
    .apk-project-gallery { grid-template-columns: repeat(2, 1fr); }
    .apk-project-gallery__item--hero {
        grid-column: span 2;
        grid-row: auto;
        aspect-ratio: 16/9;
    }
}

/* ==========================================================================
   PROJECT VIDEO EMBED
   ========================================================================== */

.apk-project-video {
    position: relative;
    aspect-ratio: 16/9;
    border-radius: var(--apk-radius-lg);
    overflow: hidden;
    box-shadow: var(--apk-shadow-lg);
    background: #000;
}
.apk-project-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ==========================================================================
   PROJECT METADATA SIDEBAR
   ========================================================================== */

.apk-project-meta {
    background: var(--apk-white);
    border-radius: var(--apk-radius-lg);
    padding: var(--apk-space-5);
    box-shadow: var(--apk-shadow-sm);
    border-top: 4px solid var(--apk-primary);
    margin-bottom: var(--apk-space-4);
}
.apk-project-meta__title {
    font-family: var(--apk-font-body);
    font-size: var(--apk-text-base);
    font-weight: 700;
    color: var(--apk-gray-900);
    letter-spacing: 0;
    margin-bottom: var(--apk-space-4);
    padding-bottom: var(--apk-space-3);
    border-bottom: 1px solid var(--apk-gray-200);
}
.apk-project-meta__list {
    display: flex;
    flex-direction: column;
    gap: var(--apk-space-3);
    margin: 0;
}
.apk-project-meta__list > div {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--apk-space-3);
    padding-bottom: var(--apk-space-3);
    border-bottom: 1px dashed var(--apk-gray-200);
}
.apk-project-meta__list > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}
.apk-project-meta__list dt {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    font-size: var(--apk-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--apk-gray-500);
    margin: 0;
}
.apk-project-meta__list dt i { color: var(--apk-primary); width: 14px; text-align: center; }
.apk-project-meta__list dd {
    text-align: right;
    font-size: var(--apk-text-sm);
    font-weight: 600;
    color: var(--apk-gray-900);
    margin: 0;
}
.apk-project-meta__list dd a {
    color: var(--apk-primary);
    text-decoration: none;
}
.apk-project-meta__list dd a:hover { text-decoration: underline; }

/* ==========================================================================
   PROJECT SHARE + NEXT
   ========================================================================== */

.apk-project-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--apk-space-4);
    flex-wrap: wrap;
    padding-top: var(--apk-space-5);
    border-top: 1px solid var(--apk-gray-200);
}
.apk-project-share {
    display: flex;
    align-items: center;
    gap: var(--apk-space-2);
    font-size: var(--apk-text-sm);
    color: var(--apk-gray-600);
}
.apk-project-share > span { margin-right: 4px; font-weight: 600; }
.apk-project-share a {
    width: 38px;
    height: 38px;
    background: var(--apk-gray-100);
    color: var(--apk-gray-700);
    border-radius: 50%;
    display: grid;
    place-items: center;
    transition: all var(--apk-duration-fast);
}
.apk-project-share a:hover {
    background: var(--apk-primary);
    color: var(--apk-white);
    transform: translateY(-2px);
}

/* ==========================================================================
   LIGHTBOX
   ========================================================================== */

.apk-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.95);
    z-index: var(--apk-z-modal);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--apk-duration-normal) var(--apk-ease);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--apk-space-5);
}
.apk-lightbox[hidden] { display: none; }
.apk-lightbox.is-visible {
    opacity: 1;
    visibility: visible;
}
.apk-lightbox .swiper {
    width: 100%;
    height: 100%;
    max-width: 1400px;
}
.apk-lightbox__slide {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: var(--apk-space-4);
}
.apk-lightbox__slide-inner {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.apk-lightbox__slide img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--apk-radius-sm);
    box-shadow: 0 30px 60px rgba(0,0,0,.5);
}

.apk-lightbox__close {
    position: absolute;
    top: var(--apk-space-4);
    right: var(--apk-space-4);
    width: 48px;
    height: 48px;
    border: 0;
    background: rgba(255,255,255,.1);
    color: var(--apk-white);
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    z-index: 2;
    transition: all var(--apk-duration-fast);
}
.apk-lightbox__close:hover {
    background: var(--apk-primary);
    transform: rotate(90deg);
}

.apk-lightbox__counter {
    position: absolute;
    top: var(--apk-space-4);
    left: var(--apk-space-4);
    background: rgba(255,255,255,.08);
    color: var(--apk-white);
    border: 0;
    padding: 8px 14px;
    border-radius: var(--apk-radius-pill);
    font-size: var(--apk-text-sm);
    font-weight: 600;
    z-index: 2;
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.apk-lightbox__nav {
    position: absolute;
    top: 50%;
    width: 56px;
    height: 56px;
    margin-top: -28px;
    background: rgba(255,255,255,.08);
    color: var(--apk-white);
    border-radius: 50%;
    display: grid !important;
    place-items: center;
    cursor: pointer;
    transition: all var(--apk-duration-fast);
    z-index: 2;
}
.apk-lightbox__nav::after {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 18px;
}
.apk-lightbox__nav--prev { left: var(--apk-space-4); }
.apk-lightbox__nav--prev::after { content: "\f053"; }
.apk-lightbox__nav--next { right: var(--apk-space-4); }
.apk-lightbox__nav--next::after { content: "\f054"; }
.apk-lightbox__nav:hover {
    background: var(--apk-primary);
    transform: scale(1.08);
}
.apk-lightbox__nav.swiper-button-disabled {
    opacity: 0.35;
    pointer-events: none;
}

.apk-lightbox__caption {
    position: absolute;
    bottom: var(--apk-space-5);
    left: 50%;
    transform: translateX(-50%);
    max-width: 80%;
    background: rgba(0,0,0,.6);
    color: var(--apk-white);
    padding: 10px 20px;
    border-radius: var(--apk-radius-pill);
    font-size: var(--apk-text-sm);
    text-align: center;
    backdrop-filter: blur(8px);
}

@media (max-width: 639px) {
    .apk-lightbox__nav { width: 44px; height: 44px; margin-top: -22px; }
    .apk-lightbox__nav::after { font-size: 15px; }
    .apk-lightbox__close { width: 40px; height: 40px; font-size: 15px; }
}
