/* Public «تور مجازی» + «نقشه ملک» viewers (property detail pages).
   Dark-surface stage so photos carry the page; matches the existing
   .property-gallery treatment and respects the site's dark-mode variables. */

.tour-block {
    --tour-surface: #10151f;
    --tour-arrow-bg: rgba(255, 255, 255, .9);
    --tour-arrow-fg: #10151f;
    margin-bottom: 1.5rem;
}

/* ------------------------------------------------------------------ poster */

.tour-poster {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: var(--tour-surface);
    min-height: 220px;
}

.tour-poster img {
    width: 100%;
    height: 320px;
    object-fit: cover;
    display: block;
    opacity: .55;
}

.tour-poster-body {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    padding: 1rem;
    gap: .65rem;
}

.tour-poster-body h3 {
    font-size: 1.15rem;
    margin: 0;
    text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
}

.tour-poster-body p {
    margin: 0;
    font-size: .85rem;
    opacity: .9;
    max-width: 34rem;
    text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
}

.tour-start-btn {
    min-height: 48px;
    padding-inline: 1.5rem;
    font-weight: 700;
}

/* ------------------------------------------------------------------- stage */

.tour-stage {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: var(--tour-surface);
}

.tour-stage.is-fullscreen {
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tour-frame {
    position: relative;
    width: 100%;
    height: 460px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
}

.tour-stage.is-fullscreen .tour-frame {
    height: 100vh;
}

.tour-frame canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
}

.tour-frame canvas.is-grabbing {
    cursor: grabbing;
}

.tour-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* Wide panorama: fill the height and let the visitor drag sideways. */
.tour-frame[data-kind="pano"] img {
    max-width: none;
    height: 100%;
    width: auto;
    object-fit: cover;
    cursor: grab;
}

/* ------------------------------------------------------------------ arrows */

.tour-arrow {
    position: absolute;
    z-index: 3;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--tour-arrow-bg);
    color: var(--tour-arrow-fg);
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
    cursor: pointer;
    transition: transform .15s, background-color .15s;
}

.tour-arrow:hover,
.tour-arrow:focus-visible {
    background: #fff;
    transform: scale(1.08);
    outline: none;
}

/* The forward/back arrows are pulled well in from the top and bottom edges.
   Flush against them they collided with the top bar (fullscreen + counter +
   floor buttons) and the caption row, and on a phone the top one ended up
   underneath the floor buttons entirely — invisible. */
.tour-arrow[data-tour-move="forward"] { top: 68px; left: 50%; margin-left: -24px; }
.tour-arrow[data-tour-move="back"] { bottom: 68px; left: 50%; margin-left: -24px; }
.tour-arrow[data-tour-move="left"] { left: 16px; top: 50%; margin-top: -24px; }
.tour-arrow[data-tour-move="right"] { right: 16px; top: 50%; margin-top: -24px; }

.tour-stairs {
    position: absolute;
    right: 12px;
    z-index: 3;
    min-height: 40px;
    border: none;
    border-radius: 20px;
    padding: 0 .85rem;
    background: var(--tour-arrow-bg);
    color: var(--tour-arrow-fg);
    font-size: .8rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
    cursor: pointer;
}

.tour-stairs[data-tour-stairs="up"] { top: 12px; }
.tour-stairs[data-tour-stairs="down"] { top: 60px; }

/* ------------------------------------------------------ look-around (360) */

/* Rotate-the-view buttons. Deliberately a different shape and position from
   the round move-arrows so "turn your head" never reads as "walk that way". */
.tour-look {
    position: absolute;
    bottom: 14px;
    z-index: 3;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: rgba(13, 110, 253, .92);
    color: #fff;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
    cursor: pointer;
}

.tour-look:hover,
.tour-look:focus-visible {
    background: #0d6efd;
    outline: none;
}

/* Bottom-left corner: the bottom-centre belongs to the «back» move arrow and
   the bottom-right to the room caption, so anchoring to the middle made the
   rotate buttons sit on top of the back arrow. */
.tour-look[data-tour-look="ccw"] { left: 12px; }
.tour-look[data-tour-look="cw"] { left: 60px; }

/* Bottom-left corner, sitting just above the rotate buttons. It used to be
   centred at the top, where it covered the «forward» arrow. */
.tour-look-badge {
    position: absolute;
    bottom: 64px;
    left: 12px;
    z-index: 4;
    max-width: calc(100% - 24px);
    background: rgba(13, 110, 253, .92);
    color: #fff;
    border-radius: 16px;
    padding: .25rem .7rem;
    font-size: .72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
    pointer-events: none;
}

.tour-look-badge i {
    margin-inline-end: .25rem;
}

.tour-frame.can-look canvas,
.tour-frame.can-look img {
    cursor: grab;
}

/* ------------------------------------------------------------------ chrome */

.tour-topbar {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 4;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    /* Reserve the right-hand column for the stairs buttons. Without this the
       floor buttons wrap and grow sideways into them on a narrow screen. */
    max-width: calc(100% - 130px);
}

.tour-levels {
    display: flex;
    gap: 4px;
}

.tour-levels .btn {
    --bs-btn-padding-y: .2rem;
    --bs-btn-padding-x: .55rem;
    font-size: .75rem;
}

.tour-caption {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 4;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    padding: .3rem .7rem;
    border-radius: 16px;
    font-size: .82rem;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tour-counter {
    background: rgba(0, 0, 0, .55);
    color: #fff;
    border-radius: 12px;
    padding: .15rem .5rem;
    font-size: .72rem;
    /* "2 / 5" is a ratio, not Persian prose — without isolating it the RTL page
       renders it reversed as "5 / 2". */
    direction: ltr;
    unicode-bidi: isolate;
}

.tour-hint {
    position: absolute;
    inset-inline: 0;
    bottom: 52px;
    z-index: 4;
    text-align: center;
    color: #fff;
    font-size: .78rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .8);
    transition: opacity .6s;
    pointer-events: none;
}

.tour-hint.is-faded {
    opacity: 0;
}

.tour-spinner {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* ------------------------------------------------------------- floor plans */

.plan-block .plan-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}

.plan-tile {
    display: block;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bs-body-bg, #fff);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: box-shadow .15s, transform .15s;
    padding: 0;
    width: 100%;
    text-align: start;
}

.plan-tile:hover,
.plan-tile:focus-visible {
    box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
    transform: translateY(-2px);
    outline: none;
}

.plan-tile .plan-tile-visual {
    height: 130px;
    background: #f1f3f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    color: #6c757d;
}

.plan-tile .plan-tile-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.plan-tile .plan-tile-meta {
    padding: .55rem .7rem;
    font-size: .82rem;
}

.plan-zoom-img {
    max-width: 100%;
    max-height: 76vh;
    display: block;
    margin: 0 auto;
    transform-origin: center center;
    cursor: zoom-in;
    touch-action: none;
}

.plan-zoom-img.is-zoomed {
    cursor: grab;
}

.plan-model-viewer {
    width: 100%;
    height: 70vh;
    min-height: 320px;
    background: #f8f9fa;
    --poster-color: transparent;
    /* Belt and braces with the touch-action attribute: the model owns its
       gestures, and any leftover scroll must not escape to the page behind. */
    touch-action: none;
    overscroll-behavior: contain;
}

/* Stop a drag that starts on the model (or a zoomed plan) from scrolling the
   article underneath once the gesture reaches the edge of the dialog. */
#plan-lightbox .modal-body {
    overscroll-behavior: contain;
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 767.98px) {
    .tour-frame { height: 360px; }
    .tour-poster img { height: 240px; }
    .tour-arrow { width: 44px; height: 44px; }
    .tour-caption { max-width: 46%; font-size: .74rem; }
    .plan-model-viewer { height: 52vh; }

    /* Tighter frame, so pull the vertical arrows in a little less but still
       clear of the top bar and the caption/rotate row. */
    .tour-arrow[data-tour-move="forward"] { top: 58px; margin-left: -22px; }
    .tour-arrow[data-tour-move="back"] { bottom: 58px; margin-left: -22px; }
    .tour-arrow[data-tour-move="left"] { left: 10px; margin-top: -22px; }
    .tour-arrow[data-tour-move="right"] { right: 10px; margin-top: -22px; }

    .tour-look { width: 38px; height: 38px; }
    .tour-look[data-tour-look="ccw"] { left: 10px; }
    .tour-look[data-tour-look="cw"] { left: 54px; }
    .tour-look-badge { bottom: 58px; left: 10px; font-size: .68rem; padding: .2rem .55rem; }

    /* The floor buttons wrap on narrow screens; keep them from growing down
       into the forward arrow. */
    .tour-levels .btn { --bs-btn-padding-x: .45rem; font-size: .7rem; }
    .tour-stairs { font-size: .7rem; padding: 0 .5rem; min-height: 34px; }
    .tour-stairs[data-tour-stairs="down"] { top: 52px; }
    .tour-topbar { max-width: calc(100% - 108px); }
}

@media (prefers-reduced-motion: reduce) {
    .tour-arrow,
    .plan-tile,
    .tour-hint {
        transition: none;
    }
}
