/*  THE PRODUCT PAGE'S PHOTO VIEWER (pdp-viewer.js): «تصاویر رسمی» and «تصاویر خریداران».
    Phone: the whole screen in white - the close button and the count, the tabs, the photos to swipe,
    the review under a buyer's photo, a row of tiles at the bottom.
    Desktop: a window over the page - the head with the title, the tabs and the count; the photo with
    its arrows on the right, a 340px column on the left with the review and the tiles.  */

.tc-pv {
    --pv-ink: #0C0C0C;
    --pv-text: #3F4064;
    --pv-muted: #81858B;
    --pv-line: #EDEDEF;
    --pv-soft: #F5F5F6;
    --pv-accent: #EF4056;
    --pv-star: #F9BC00;
    position: fixed;
    inset: 0;
    z-index: 100001;
    display: none;
    direction: rtl;
    font-family: inherit;
    color: var(--pv-text);
    -webkit-tap-highlight-color: transparent;
}

.tc-pv.is-open { display: block; }
.tc-pv *, .tc-pv *::before, .tc-pv *::after { box-sizing: border-box; }
.tc-pv button { font: inherit; color: inherit; cursor: pointer; }
.tc-pv [hidden] { display: none !important; }

.tc-pv__panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #FFF;
}

/* ---- head --------------------------------------------------------------- */
.tc-pv__head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "close titles count" "tabs tabs tabs";
    align-items: center;
    gap: 8px 12px;
    padding: 10px 12px 0;
    border-bottom: 1px solid var(--pv-line);
}

.tc-pv__close {
    grid-area: close;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--pv-soft);
    color: var(--pv-ink);
}

.tc-pv__titles { grid-area: titles; min-width: 0; }

.tc-pv .tc-pv__title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 24px;
    color: var(--pv-ink);
}

.tc-pv__sub {
    margin: 0;
    overflow: hidden;
    font-size: 12px;
    line-height: 20px;
    color: var(--pv-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tc-pv__count {
    grid-area: count;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--pv-soft);
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    color: var(--pv-text);
    white-space: nowrap;
}

/* the tabs: two words with a red bar under the open one */
.tc-pv__tabs {
    grid-area: tabs;
    display: flex;
    gap: 20px;
    margin-top: 2px;
}

.tc-pv .tc-pv__tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 2px 12px;
    border: 0;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--pv-muted);
}

.tc-pv .tc-pv__tab.is-on {
    font-weight: 700;
    color: var(--pv-ink);
}

.tc-pv__tab.is-on::after {
    content: "";
    position: absolute;
    right: 0;
    left: 0;
    bottom: -1px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--pv-accent);
}

.tc-pv__tab-n {
    min-width: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--pv-soft);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    color: var(--pv-text);
}

.tc-pv__tab.is-on .tc-pv__tab-n {
    background: var(--pv-ink);
    color: #FFF;
}

/* ---- body: the photos, the review, the tiles ------------------------------ */
.tc-pv__body {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.tc-pv__stage {
    position: relative;
    flex: 1;
    min-height: 0;
}

.tc-pv__track {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior: contain;
    scrollbar-width: none;
}

.tc-pv__track::-webkit-scrollbar { display: none; }

/* a zoomed photo holds the track still: the finger pans the photo instead */
.tc-pv.is-zoomed .tc-pv__track {
    overflow: hidden;
    touch-action: none;
}

.tc-pv__slide {
    display: flex;
    flex: 0 0 100%;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 12px;
    scroll-snap-align: center;
    scroll-snap-stop: always;
}

.tc-pv__zoom {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.tc-pv__img,
.tc-pv__video {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform .2s ease;
}

.tc-pv.is-zoomed .tc-pv__img { transition: none; }

/* a photo on its way: a square skeleton where it will be (the slide loses is-wait once it has loaded) */
.tc-pv__slide.is-wait .tc-pv__zoom {
    position: relative;
}

.tc-pv__slide.is-wait .tc-pv__zoom::before {
    content: "";
    height: min(100%, calc(100vw - 24px));
    max-width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--pv-soft) 0%, #FBFBFC 50%, var(--pv-soft) 100%);
    background-size: 200% 100%;
    animation: tc-pv-shimmer 1.2s linear infinite;
}

.tc-pv__slide.is-wait .tc-pv__img {
    position: absolute;
    opacity: 0;
}

@keyframes tc-pv-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* sized by pdp-viewer.js (fitVideo) to the video's own proportions; unseen until then, so the
   default wide player never shows and nothing jumps when it plays */
.tc-pv__video {
    background: #000;
    opacity: 0;
    transition: opacity .25s ease;
}

.tc-pv__video.is-ready {
    opacity: 1;
}

/* while the size is on its way: a quiet ring where the video will be */
.tc-pv__slide:has(> .tc-pv__video:not(.is-ready)) {
    position: relative;
}

.tc-pv__slide:has(> .tc-pv__video:not(.is-ready))::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 2px solid rgba(12, 12, 12, .12);
    border-top-color: rgba(12, 12, 12, .55);
    border-radius: 50%;
    animation: tc-pv-spin .8s linear infinite;
}

@keyframes tc-pv-spin {
    to {
        transform: rotate(360deg);
    }
}

/* the arrows: white rounds on the photo's sides (desktop) */
.tc-pv__nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    padding: 0;
    border: 1px solid var(--pv-line);
    border-radius: 50%;
    background: rgba(255, 255, 255, .94);
    color: var(--pv-ink);
    box-shadow: 0 4px 14px rgba(12, 12, 12, .08);
    transition: opacity .15s ease, background-color .15s ease;
}

.tc-pv__nav:hover { background: #FFF; }
.tc-pv__nav:disabled { opacity: 0; pointer-events: none; }
.tc-pv__nav--prev { right: 16px; }
.tc-pv__nav--next { left: 16px; }

.tc-pv__side {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ---- the review that came with a buyer's photo ---------------------------- */
.tc-pv__review {
    margin: 0 12px 10px;
    padding: 12px 14px;
    border: 1px solid var(--pv-line);
    border-radius: 14px;
    background: #FFF;
}

.tc-pv__who {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tc-pv__avatar {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #F0F0F1;
    font-size: 15px;
    font-weight: 700;
    color: var(--pv-text);
}

.tc-pv__who-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tc-pv__name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    line-height: 20px;
    color: var(--pv-ink);
    white-space: nowrap;
}

.tc-pv__buyer {
    padding: 0 8px;
    border-radius: 999px;
    background: #E8F6EE;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    color: #00875A;
}

.tc-pv__meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tc-pv__stars { display: inline-flex; gap: 1px; }
.tc-pv__star svg { display: block; fill: #E0E0E2; }
.tc-pv__star.is-on svg { fill: var(--pv-star); }

.tc-pv__date {
    font-size: 11px;
    line-height: 18px;
    color: var(--pv-muted);
}

.tc-pv__text {
    display: -webkit-box;
    margin: 10px 0 0;
    overflow: hidden;
    font-size: 13px;
    line-height: 24px;
    color: var(--pv-text);
    white-space: pre-line;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.tc-pv__review.is-open .tc-pv__text {
    display: block;
    max-height: 30vh;
    overflow-y: auto;
}

.tc-pv .tc-pv__more {
    margin: 4px 0 0;
    padding: 0;
    border: 0;
    background: none;
    font-size: 12px;
    font-weight: 700;
    color: #1672DD;
}

/* ---- the tiles ----------------------------------------------------------- */
.tc-pv__thumbs {
    display: flex;
    gap: 8px;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    overflow-x: auto;
    border-top: 1px solid var(--pv-line);
    scrollbar-width: none;
}

.tc-pv__thumbs::-webkit-scrollbar { display: none; }

.tc-pv .tc-pv__thumb {
    position: relative;
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
    padding: 3px;
    overflow: hidden;
    border: 1px solid var(--pv-line);
    border-radius: 10px;
    background: #FFF;
    transition: border-color .15s ease;
}

.tc-pv .tc-pv__thumb.is-on {
    border: 2px solid var(--pv-ink);
    padding: 2px;
}

.tc-pv__thumb img,
.tc-pv__thumb video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 7px;
    pointer-events: none;
}

.tc-pv__thumb video { background: #1F1F23; }

.tc-pv__play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    background: rgba(12, 12, 12, .22);
    border-radius: 7px;
}

/* ---- desktop: a window ------------------------------------------------------ */
@media (min-width: 960px) {
    .tc-pv {
        background: rgba(17, 17, 20, .5);
    }

    .tc-pv.is-open {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 32px;
    }

    .tc-pv__panel {
        width: min(1320px, 100%);
        height: min(880px, 100%);
        overflow: hidden;
        border-radius: 20px;
        box-shadow: 0 24px 64px rgba(17, 17, 20, .24);
        animation: tc-pv-in .18s ease-out;
    }

    .tc-pv__head {
        grid-template-columns: 1fr auto auto auto;
        grid-template-areas: "titles tabs count close";
        gap: 16px;
        padding: 16px 24px 0;
    }

    .tc-pv__titles { padding-bottom: 14px; }
    .tc-pv .tc-pv__title { font-size: 17px; line-height: 28px; }
    .tc-pv__sub { font-size: 13px; }
    .tc-pv__tabs { align-self: end; gap: 24px; margin: 0; }
    .tc-pv .tc-pv__tab { padding: 8px 2px 14px; font-size: 14px; }
    .tc-pv__count { margin-bottom: 14px; }
    .tc-pv__close { margin-bottom: 14px; }

    .tc-pv__body {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 340px;
    }

    .tc-pv__slide { padding: 24px 72px; }
    .tc-pv__nav { display: inline-flex; }

    .tc-pv__img { cursor: zoom-in; }
    .tc-pv.is-zoomed .tc-pv__img { cursor: zoom-out; }

    /* the column: the review on top, then every tile of the tab in three columns */
    .tc-pv__side {
        padding: 20px 20px 0;
        overflow-y: auto;
        border-right: 1px solid var(--pv-line);
    }

    .tc-pv__review {
        margin: 0 0 16px;
        padding: 16px;
        background: #FAFAFB;
    }

    /* the column scrolls: the whole text, no "بیشتر" */
    .tc-pv__text {
        display: block;
        -webkit-line-clamp: unset;
    }

    .tc-pv .tc-pv__more { display: none; }

    .tc-pv__thumbs {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        align-content: start;
        gap: 10px;
        padding: 0 0 20px;
        overflow: visible;
        border-top: 0;
    }

    .tc-pv .tc-pv__thumb {
        width: auto;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .tc-pv .tc-pv__thumb:hover { border-color: #C2C3C7; }
    .tc-pv .tc-pv__thumb.is-on { border-color: var(--pv-ink); }
}

@keyframes tc-pv-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: none; }
}

/* phone: the whole screen slides up */
@media (max-width: 959px) {
    .tc-pv.is-open .tc-pv__panel { animation: tc-pv-up .22s ease-out; }
}

@keyframes tc-pv-up {
    from { opacity: .6; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .tc-pv__panel { animation: none !important; }
    .tc-pv__img { transition: none; }
    .tc-pv__slide.is-wait .tc-pv__zoom::before { animation: none; }
}
