/* =========================
   PORTFOLIO PAGE — accordion + thumbnail gallery
========================= */

:root {
    --accent: #5f5f5f;
    --accent-soft: rgba(var(--color-primary-rgb), .35);
}

.portfolio {
    padding: 140px 6% 60px;
    background:
        radial-gradient(circle at 18% 0%, rgba(var(--color-primary-rgb), 0.10), transparent 45%),
        rgb(20, 20, 20);
    min-height: 100vh;
}

.portfolio-header {
    text-align: center;
    margin-bottom: 48px;
}

.portfolio-header h1 {
    font-size: 32px;
    color: #fff;
    letter-spacing: .5px;
    position: relative;
    display: inline-block;
    margin-bottom: 0;
}

.portfolio-header h1::after {
    content: "";
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 46px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.portfolio-header .small-title {
    font-size: 14px;
    font-weight: 400;
    margin-top: 26px;
    color: rgba(255, 255, 255, .55);
}

/* ========================
   ACCORDION
======================== */
.accordion {
    display: flex;
    gap: 12px;
    height: 480px;
    width: 100%;
    direction: ltr;
}

.acc-panel {
    position: relative;
    flex: 0 0 62px;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: flex .5s cubic-bezier(.4, 0, .2, 1), box-shadow .35s ease, transform .35s ease;
    background: #1c1c1c;
}

.acc-panel.expanded {
    flex: 1 1 auto;
    box-shadow: 0 20px 50px rgba(var(--color-primary-rgb), 0.25), 0 0 1px rgba(255, 255, 255, 0.1);
    transform: scale(1.01);
}

/* Cover image — grayscale by default, color on hover/expanded */
.acc-panel > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
    pointer-events: none;
    transition: transform .55s ease, filter .4s ease, object-position .55s ease;
    filter: grayscale(100%) brightness(.75);
}

.acc-panel:not(.expanded):hover {
    flex: 0 0 85px;
    box-shadow: 0 8px 24px rgba(var(--color-primary-rgb), 0.15);
}

/* وقتی panel باز شد، position از data-focus-closed به data-focus-open می‌ره */
.acc-panel.expanded > img[data-focus-open] {
    object-position: var(--focus-open, center center);
}

.acc-panel:not(.expanded) > img[data-focus-closed] {
    object-position: var(--focus-closed, center center);
}

.acc-panel:hover > img,
.acc-panel.expanded > img {
    filter: grayscale(0%) brightness(1);
    transform: scale(1.04);
}

/* Vertical label when collapsed */
.acc-thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    color: rgba(255, 255, 255, .75);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity .25s ease;
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

.acc-panel.expanded .acc-thumb {
    opacity: 0;
}

/* Bottom overlay — shown when expanded */
.acc-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
    background: linear-gradient(0deg, rgba(0,0,0,.75) 0%, rgba(0,0,0,.15) 55%, transparent 100%);
    opacity: 0;
    transition: opacity .35s ease;
    pointer-events: none;
}

.acc-panel.expanded .acc-overlay {
    opacity: 1;
    pointer-events: all;
}

.acc-overlay-label {
    display: inline-block;
    background: rgba(255, 255, 255, .16);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, .28);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 20px;
    margin-bottom: 10px;
    align-self: flex-start;
    transform: translateY(6px);
    transition: transform .35s ease;
}

.acc-panel.expanded .acc-overlay-label {
    transform: translateY(0);
}

.acc-overlay-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    transform: translateY(8px);
    transition: transform .4s ease .05s;
}

.acc-panel.expanded .acc-overlay-row {
    transform: translateY(0);
}

.acc-count {
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
}

.acc-enter {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}

.acc-enter:hover {
    background: #05a070;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(var(--color-primary-rgb), 0.3);
}

.acc-enter:active {
    transform: translateY(0);
}

.acc-enter svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ========================
   THUMBNAIL MODAL (gallery grid)
======================== */
.thumb-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .95);
    display: none;
    flex-direction: column;
    z-index: 99998;
    opacity: 0;
    transform: scale(0.97);
    transition: opacity .3s ease, transform .3s ease;
}

.thumb-modal.active {
    opacity: 1;
    transform: scale(1);
}

.thumb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 30px 16px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.thumb-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.thumb-modal-title span.cat-pill {
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    padding: 3px 12px;
    border-radius: 20px;
}

.thumb-modal-count {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
}

.thumb-modal-close {
    font-size: 30px;
    color: rgba(255,255,255,.6);
    cursor: pointer;
    line-height: 1;
    background: none;
    border: none;
    color: rgba(255,255,255,.6);
    transition: color .2s;
    padding: 0;
}

.thumb-modal-close:hover { color: #fff; }

.thumb-grid {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 30px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    align-content: start;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-soft) rgba(255,255,255,.05);
}

.thumb-grid::-webkit-scrollbar { width: 6px; }
.thumb-grid::-webkit-scrollbar-track { background: transparent; }
.thumb-grid::-webkit-scrollbar-thumb { background: rgba(var(--color-primary-rgb), .5); border-radius: 6px; }

.thumb-item {
    position: relative;
    aspect-ratio: 3/2;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: linear-gradient(90deg, #2a2a2a 25%, #333333 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .35s ease, filter .35s ease;
    filter: grayscale(30%) brightness(.85);
    opacity: 0;
}

.thumb-item img.loaded {
    opacity: 1;
    animation: fadeInImage .4s ease forwards;
}

@keyframes fadeInImage {
    from { opacity: 0; }
    to { opacity: 1; }
}

.thumb-item:hover img {
    transform: scale(1.06);
    filter: grayscale(0%) brightness(1);
}

.thumb-item-num {
    position: absolute;
    bottom: 6px;
    left: 8px;
    font-size: 10px;
    color: rgba(255,255,255,.55);
    background: rgba(0,0,0,.45);
    padding: 2px 7px;
    border-radius: 10px;
    line-height: 1.6;
    pointer-events: none;
}

.thumb-item::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: border-color .2s;
}

.thumb-item:hover::after {
    border-color: var(--accent);
}

.thumb-item.loaded {
    animation: none;
    background: #1c1c1c;
}

/* ========================
   LIGHTBOX (slideshow)
======================== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .95);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
    z-index: 99999;
}

.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-img {
    max-width: 82%;
    max-height: 82vh;
    border-radius: 10px;
    transform: scale(.92);
    transition: transform .3s ease, opacity .25s ease;
    user-select: none;
    -webkit-user-drag: none;
    display: block;
    cursor: zoom-in;
}

.lightbox-img.zoom-active {
    cursor: zoom-out;
}

.lightbox.active .lightbox-img {
    transform: scale(1);
}

.lightbox-img.switching {
    opacity: 0;
    transform: scale(.94);
}

/* Top bar */
.lb-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: linear-gradient(180deg, rgba(0,0,0,.6) 0%, transparent 100%);
}

.lightbox-counter {
    color: var(--accent);
    font-size: 13px;
    direction: ltr;
    font-weight: 700;
    background: rgba(var(--color-primary-rgb), 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(var(--color-primary-rgb), 0.3);
}

.lightbox-cat-label {
    background: rgba(255, 255, 255, .12);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, .2);
    color: #fff;
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 20px;
}

.lb-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Back to grid button */
.lb-back-grid {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: rgba(255,255,255,.7);
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 20px;
    padding: 5px 14px;
    cursor: pointer;
    font-family: inherit;
    transition: background .2s, color .2s;
}

.lb-back-grid:hover {
    background: rgba(255,255,255,.2);
    color: #fff;
}

.lb-back-grid svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.close {
    font-size: 30px;
    color: rgba(255,255,255,.65);
    cursor: pointer;
    line-height: 1;
    transition: color .2s;
    background: none;
    border: none;
    padding: 0;
}

.close:hover { color: #fff; }

/* Nav arrows */
.nav span {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px;
    color: rgba(255, 255, 255, .6);
    cursor: pointer;
    padding: 10px;
    user-select: none;
    transition: color .2s;
}

.nav span:hover { color: #fff; }
.prev { left: 16px; }
.next { right: 16px; }

/* Bottom strip — thumbnail filmstrip */
.lb-strip {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    background: linear-gradient(0deg, rgba(0,0,0,.7) 0%, transparent 100%);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.lb-strip::-webkit-scrollbar { display: none; }

.lb-strip-thumb {
    flex-shrink: 0;
    width: 52px;
    height: 36px;
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color .2s, transform .2s;
    opacity: .55;
    transition: opacity .2s, border-color .2s, transform .2s;
}

.lb-strip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    transition: filter .2s ease;
}

.lb-strip-thumb.active img {
    filter: brightness(1.2);
}

.lb-strip-thumb.active {
    border-color: var(--accent);
    opacity: 1;
    transform: scale(1.08);
}

.lb-strip-thumb:hover {
    opacity: .85;
}

/* ========================
   BACK TO TOP
======================== */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .08);
    backdrop-filter: blur(8px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(15px) scale(.9);
    pointer-events: none;
    transition: opacity .3s, transform .3s, background .3s;
    z-index: 9998;
}

#backToTop.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

#backToTop:hover { background: rgba(255, 255, 255, .18); }

#backToTop svg {
    position: absolute;
    inset: 0;
    width: 52px;
    height: 52px;
    transform: rotate(-90deg);
}

#backToTop svg circle { fill: none; stroke-width: 3; }
#backToTop svg .ring-bg { stroke: rgba(255, 255, 255, .12); }
#backToTop svg .ring-progress {
    stroke: var(--accent);
    stroke-linecap: round;
    transition: stroke-dashoffset .15s linear;
}

#backToTop .arrow { position: relative; z-index: 1; }

/* دکمه‌ی موزیک پس‌زمینه از css/music-player.css میاد (مشترک بین همه‌ی صفحات) */

/* ========================
   SCROLLBAR
======================== */
body::-webkit-scrollbar { width: 8px; }
body::-webkit-scrollbar-track { background: #141414; }
body::-webkit-scrollbar-thumb { background: rgba(var(--color-primary-rgb), .6); border-radius: 10px; }
body::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ========================
   RESPONSIVE
======================== */
@media (max-width: 768px) {
    .accordion { height: 340px; gap: 8px; }
    .acc-panel { flex: 0 0 42px; border-radius: 10px; }
    .thumb-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .lb-strip-thumb { width: 42px; height: 28px; }
}

@media (max-width: 480px) {
    .portfolio { padding: 120px 4% 50px; }
    .accordion { height: 260px; gap: 6px; }
    .acc-panel { flex: 0 0 32px; border-radius: 8px; }
    .thumb-grid { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); gap: 7px; }
    #backToTop { bottom: 18px; right: 18px; width: 46px; height: 46px; }
    #backToTop svg { width: 46px; height: 46px; }
    .nav span { font-size: 30px; }
    .lb-strip { display: none; }
}
