/* ===========================================
   pagePartials/portfolioModal.css - Portfolio Modal
   =========================================== */

@media screen and (min-width: 768px) {
    .page-modal-portfolio {
        width: fit-content;
        /* Leaves room for a classic (Windows) scrollbar beside the 868px grid so
           the 3-column layout never collapses to 2 once the body scrolls. */
        max-width: 940px;
    }
}

@media screen and (min-width: 1100px) {
    .page-modal-portfolio {
        max-width: 1080px;
    }
}

/* Category Filter Tabs */
.portfolio-filter-tabs {
    display: flex;
    gap: 8px;
    /* 3px top/bottom keeps a focus ring inside the overflow clip; 3 + 17 keeps
       the 20px gap below the pills. */
    margin-bottom: 17px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 3px 0;
    /* The strip takes its width from the modal, not the other way round:
       otherwise a long tab row inflates the fit-content modal to its max width
       even with one or two cards. */
    contain: inline-size;
}
.portfolio-filter-tabs::-webkit-scrollbar {
    display: none;
}

.portfolio-filter-tab {
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 20px;
    border: 1px solid transparent;
    background: #f3f4f6;
    color: #4b5563;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: all 0.2s ease;
}
.portfolio-filter-tab:hover {
    color: #374151;
    background: #e5e7eb;
}
/* Inset ring: the strip clips its overflow (scrollbar hidden), so an outset ring would be cut. */
.portfolio-filter-tab:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}
.portfolio-filter-tab.active {
    color: #1f2937;
    color: color-mix(in srgb, var(--section-tag-color, var(--page-accent, #2563eb)) 35%, #1f2937);
    /* Resolved tint, not accent + white veil: a background-image is not animatable and
       flashes the raw accent on the way out. Full note in faqsModal.css. */
    background-color: #eef2fd;
    background-color: color-mix(in srgb, var(--section-tag-color, var(--page-accent, #2563eb)) 8%, #fff);
    border-color: rgba(37, 99, 235, 0.25);
    border-color: color-mix(in srgb, var(--section-tag-color, var(--page-accent, #2563eb)) 25%, transparent);
}

/* Grid */
.portfolio-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    max-width: 868px;
    justify-content: center;
}

.portfolio-card {
    width: 280px;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: portfolioCardFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (hover: hover) {
    .portfolio-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    }
}
.portfolio-card:focus-visible {
    outline: 2px solid var(--page-text-primary, #1f2937);
    outline-offset: 2px;
}

@keyframes portfolioCardFadeIn {
    0% {
        opacity: 0;
        transform: translateY(4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Card Image */
.portfolio-card-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 10;
}
.portfolio-card-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Card Info */
.portfolio-card-info {
    padding: 12px 14px;
}
.portfolio-card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
    color: var(--page-text-primary, #1f2937);
}
.portfolio-card-subtitle {
    font-size: 13px;
    color: #4b5563;
    margin: 2px 0 0;
    line-height: 1.4;
}
.portfolio-card-category {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #1f2937;
    color: color-mix(in srgb, var(--section-tag-color, var(--page-accent, #2563eb)) 35%, #1f2937);
    background-color: var(--section-tag-color, var(--page-accent, #2563eb));
    background-image: linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92));
    padding: 2px 8px;
    border-radius: 4px;
    /* One-line chip: a long category name ellipsises instead of wrapping into
       a two-line pill. */
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: top;
}

/* No cover image card */
.portfolio-card-no-cover {
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    min-height: 120px;
}
.portfolio-card-no-cover .portfolio-card-info {
    padding: 24px 20px;
}
.portfolio-card-no-cover .portfolio-card-title {
    font-size: 17px;
}

/* No cover detail view */
.portfolio-detail-no-cover .portfolio-detail-info {
    padding: 56px 32px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 200px;
}

/* Closed but not yet display:none (the 250ms fade): it must not keep hit-testing
   over the page and swallow the next click. Mirrors .page-modal-overlay:not(.open)
   in publicPage.css. */
.portfolio-detail-overlay:not(.open) {
    pointer-events: none;
}

/* Detail Overlay */
.portfolio-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    /* Track the dynamic viewport so iOS Safari's collapsing toolbar can't leave
       the overlay/inner taller than the visible area. */
    height: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.portfolio-detail-overlay.open {
    display: flex;
    opacity: 1;
}

.portfolio-detail-inner {
    position: relative;
    background: #fff;
    border-radius: 16px;
    max-height: 88vh;
    /* Landscape phones: never taller than the visible area minus the overlay padding. */
    max-height: min(88dvh, calc(100dvh - 48px));
    overflow-y: auto;
    width: 100%;
    animation: portfolio-detail-in 0.3s ease;
}
/* Fixed-width wrapper so the card is the same width for every project instead
   of being sized by its content. */
.portfolio-detail-content {
    width: 100%;
    max-width: 720px;
}

.portfolio-detail-close {
    /* Sticky inside the scrolling card (it is rendered as the card's first
       child) so it stays reachable while a tall cover/description scrolls.
       Block-level flex box: the auto left margin right-aligns it; the negative
       bottom margin takes its 12px + 36px out of the flow so the cover still
       starts at the top. */
    position: sticky;
    top: 12px;
    margin: 12px 12px -48px auto;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 2;
}
.portfolio-detail-close:hover {
    background: rgba(0, 0, 0, 0.65);
}
.portfolio-detail-no-cover .portfolio-detail-close {
    background: rgba(0, 0, 0, 0.06);
    color: #374151;
}
.portfolio-detail-no-cover .portfolio-detail-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

@keyframes portfolio-detail-in {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Detail Gallery */
.portfolio-detail-main-img {
    position: relative;
    background: #f3f4f6;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 10;
    /* The card is min(88dvh, 100dvh - 48px) tall; without this the cover alone is
       taller than that on a landscape phone. The img inside is object-fit: cover,
       so a shorter box just crops wider. No effect on portrait or desktop. */
    max-height: 50vh;
}
.portfolio-detail-main-img img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s ease;
}

.portfolio-detail-thumbs {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-top: 1px solid #f3f4f6;
}
.portfolio-detail-thumbs::-webkit-scrollbar {
    display: none;
}

.portfolio-detail-thumb {
    /* 72 x 45px: 60px made a 37px-tall tap target. */
    width: 72px;
    min-width: 72px;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s ease, border-color 0.2s ease;
    border: 2px solid transparent;
}
.portfolio-detail-thumb.active {
    opacity: 1;
    border-color: rgba(0, 0, 0, 0.3);
}

/* Split from .active above: the selected thumb must stay lit on every device,
   but a hovered one must not stay lit after a tap. */
@media (hover: hover) {
    .portfolio-detail-thumb:hover {
        opacity: 1;
        border-color: rgba(0, 0, 0, 0.3);
    }
}

/* Detail Info */
.portfolio-detail-info {
    padding: 24px 24px 32px;
    min-height: 80px;
}
.portfolio-detail-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.portfolio-detail-category {
    font-size: 12px;
    font-weight: 600;
    color: #1f2937;
    color: color-mix(in srgb, var(--section-tag-color, var(--page-accent, #2563eb)) 35%, #1f2937);
    background-color: var(--section-tag-color, var(--page-accent, #2563eb));
    background-image: linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92));
    padding: 3px 10px;
    border-radius: 6px;
}
.portfolio-detail-date {
    font-size: 13px;
    color: var(--page-text-secondary, #6b7280);
}
.portfolio-detail-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
    color: var(--page-text-primary, #1f2937);
}
.portfolio-detail-subtitle {
    font-size: 15px;
    color: var(--page-text-secondary, #6b7280);
    margin: 6px 0 0;
    line-height: 1.45;
}
.portfolio-detail-desc {
    font-size: 15px;
    line-height: 1.7;
    /* Primary, not secondary: descriptions are documents (headings, lists, up
       to 5,000 chars), the same content class the About surface renders in
       primary — and the colour the editor showed while writing. Block margins
       live in richTextBody.css (none, by design). */
    color: var(--page-text-primary, #1f2937);
    margin: 16px 0 0;
}
.portfolio-detail-desc h1 {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.35;
}
.portfolio-detail-desc h2 {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
}
/* Lists, alignment and the Quill counter scheme live in richTextBody.css, shared
   with the About text body under the .fd-rich-text class. */
.portfolio-detail-desc strong,
.portfolio-detail-desc b {
    font-weight: 700;
}
.portfolio-detail-desc em,
.portfolio-detail-desc i {
    font-style: italic;
}
.portfolio-detail-desc u {
    text-decoration: underline;
}

/* Responsive */
@media screen and (max-width: 600px) {
    .portfolio-card {
        width: 100%;
    }
    .portfolio-detail-overlay {
        padding: 0;
    }
    .portfolio-detail-inner {
        border-radius: 0;
        min-height: 100vh;
        min-height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        /* No entrance transform on mobile: avoids the iOS Safari compositing
           layer painting a stale/offset snapshot while images reflow in. */
        animation: none;
    }
    .portfolio-detail-main-img {
        border-radius: 0;
    }
    /* 44px target. The 4px border is transparent and clipped out of the disc, so
       the visible 36px circle and its position on screen are unchanged. */
    .portfolio-detail-close {
        top: calc(6px + env(safe-area-inset-top));
        margin: 6px 6px -50px auto;
        box-sizing: border-box;
        width: 44px;
        height: 44px;
        border: 4px solid transparent;
        background-clip: padding-box;
    }
    .portfolio-detail-info {
        padding-bottom: calc(32px + env(safe-area-inset-bottom));
    }
    .portfolio-detail-no-cover .portfolio-detail-info {
        padding-bottom: calc(48px + env(safe-area-inset-bottom));
    }
}

