/*
 * Rivera — Object page (all six catalogues)
 *
 * Blocks:
 *   .object-page    — the page ground
 *   .object         — the page's one section: catalogue link, facts, title,
 *                     description, gallery
 *   .object-facts   — the ID / plot / price panel with maroon badges
 *   .object-gallery — the big frame and the thumbnails under it
 *   .lightbox       — the full-size photo viewer over a dimmed page
 *
 * Geometry follows the design as fractions of the container: the photo runs
 * the full width, the facts sit in columns at 0 / 20% / 67%, six thumbnails a
 * row. Type and vertical rhythm are the design at about 75% — the same step
 * down the header took — so this page reads at one scale with it.
 */

/* ── Object ─────────────────────────────────────────────────────────────── */
/* Mixed with .page-title; this adds only what a link needs. */
.object__catalog {
    display:         inline-block;
    text-decoration: none;
    transition:      color var(--transition);
}

.object__catalog:hover,
.object__catalog:focus-visible {
    color: var(--color-secondary);
}

.object__facts {
    margin: 44px 0 0;
}

.object__title {
    margin:      64px 0 0;
    color:       var(--color-orange);
    font-size:   32px;
    font-weight: 400;
    line-height: 1.25;
}

.object__content {
    max-width:   none;
    margin-top:  32px;
    font-size:   var(--fs-body);
    line-height: 1.45;
}

/* Editor content arrives as bare paragraphs with no classes of their own.
 * Paragraphs are separated by a gap; the last one carries none, so the block
 * ends flush with its own box and the gallery's margin stays the only space. */
.object__content p {
    margin: 0 0 14px;
}

.object__content p:last-child {
    margin-bottom: 0;
}

.object__gallery {
    margin-top: 48px;
}


/* ── Facts panel ────────────────────────────────────────────────────────── */
/* Three columns at the design's own positions: plot from 20%, price from 67%.
 * The price is pinned to the third, so a catalogue without plot sizes
 * (apartments) does not pull it into the middle. */
.object-facts {
    display:               grid;
    grid-template-columns: 20% 47% 1fr;
    align-items:           center;
}

.object-facts__item {
    display:     flex;
    align-items: center;
    gap:         20px;
}

.object-facts__item--price {
    grid-column: 3;
}

.object-facts__label {
    display:          flex;
    align-items:      center;
    justify-content:  center;
    flex:             0 0 auto;
    width:            48px;
    height:           40px;
    border-radius:    2px;
    background-color: var(--color-maroon);
    font-size:        24px;
    line-height:      1;
}

.object-facts__value {
    margin:      0;
    font-size:   20px;
    line-height: 1.2;
}

.object-facts__value--code {
    font-size: 26px;
}

.object-facts__value--price {
    color:     var(--color-orange);
    font-size: var(--fs-price-single);
}

/* ── Gallery ────────────────────────────────────────────────────────────── */
/* The frame holds a photo whole: contain rather than cover, because cropping
 * the edge off a room or a plot hides exactly what a buyer is looking at.
 *
 * The stage keeps a 4:3 box from photo to photo, so the thumbnails under it
 * never jump. The thin border belongs to the photo itself, not to the box: a
 * portrait or a narrow shot is outlined at its own width instead of floating
 * in a wide empty frame. */
.object-gallery__viewer {
    position: relative;
}

.object-gallery__stage {
    position:         relative;
    display:          flex;
    align-items:      center;
    justify-content:  center;
    overflow:         hidden;
    aspect-ratio:     4 / 3;
    width:            100%;
    background-color: var(--color-navy-deep);
}

.object-gallery__photo {
    cursor: zoom-in;
}

.object-gallery__photo,
.object-gallery__video {
    position: relative;
    display:  flex;
    align-items:     center;
    justify-content: center;
    width:    100%;
    height:   100%;
}

.object-gallery__media {
    display:    block;
    width:      auto;
    height:     auto;
    min-width:  0;
    min-height: 0;
    max-width:  100%;
    max-height: 100%;
    border:     1px solid var(--color-sky);
}

/* YouTube's preview is 4:3 with black bands; cover fills the frame instead. */
.object-gallery__media--cover {
    width:      100%;
    height:     100%;
    object-fit: cover;
}

/* ── Gallery arrows ─────────────────────────────────────────────────────── */
.object-gallery__arrow {
    position:         absolute;
    top:              50%;
    width:            52px;
    height:           52px;
    /* Over the navy bands beside a narrow photo a plain dark disc would
     * vanish; the outline keeps the arrow findable on either ground. */
    border:           1px solid var(--color-sky);
    background-color: rgba(0, 19, 49, 0.7);
    transform:        translateY(-50%);
}

.object-gallery__arrow[hidden] {
    display: none;
}

.object-gallery__arrow:hover,
.object-gallery__arrow:focus-visible {
    background-color: var(--color-maroon);
    color:            var(--color-orange);
}

.object-gallery__arrow--prev {
    left: 16px;
}

.object-gallery__arrow--next {
    right: 16px;
}

.object-gallery__arrow-icon {
    display: block;
}

.object-gallery__frame {
    position: absolute;
    inset:    0;
    width:    100%;
    height:   100%;
    border:   1px solid var(--color-sky);
}

/* Mixed with .play-badge; only the size is the gallery's own. */
.object-gallery__play {
    width:         88px;
    height:        62px;
    border-radius: 16px;
}

.object-gallery__play::after {
    border-width: 13px 0 13px 22px;
}

.object-gallery__video:hover .object-gallery__play,
.object-gallery__video:focus-visible .object-gallery__play {
    background-color: #cc0000;
}

.object-gallery__thumbs {
    display:               grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap:                   34px 71px;
    margin:                40px 0 0;
    padding:               0;
    list-style:            none;
}

.object-gallery__thumb-item {
    display: flex;
}

.object-gallery__thumb {
    position:     relative;
    display:      block;
    width:        100%;
    overflow:     hidden;
    aspect-ratio: 1 / 1;
    border:       1px solid var(--color-sky);
    transition:   border-color var(--transition), opacity var(--transition);
}

.object-gallery__thumb:hover .object-gallery__thumb-img,
.object-gallery__thumb:focus-visible .object-gallery__thumb-img {
    transform: scale(1.06);
}

/* The one on show: an orange frame drawn inside the border, so it does not
 * shift the grid by a pixel. */
.object-gallery__thumb--active {
    border-color: var(--color-orange);
    box-shadow:   inset 0 0 0 2px var(--color-orange);
}

/* A small play mark on the video's thumbnail. */
.object-gallery__thumb--video::after {
    content:          '';
    position:         absolute;
    top:              50%;
    left:             50%;
    width:            36px;
    height:           26px;
    border-radius:    7px;
    background-color: #ff0000;
    transform:        translate(-50%, -50%);
}

.object-gallery__thumb:focus-visible,
.object-gallery__photo:focus-visible,
.object-gallery__video:focus-visible,
.object__catalog:focus-visible {
    outline:        2px solid var(--color-orange);
    outline-offset: 3px;
}

/* ── Lightbox ───────────────────────────────────────────────────────────── */
/* A native <dialog> opened with showModal(): it sits in the top layer, so no
 * z-index is needed, and ::backdrop is the dimmed page behind it. The dialog
 * itself spans the viewport and is transparent; the photo is centred in it
 * with room left for the arrows on either side. */
.lightbox {
    width:            100vw;
    max-width:        none;
    height:           100dvh;
    max-height:       none;
    margin:           0;
    padding:          0;
    border:           0;
    background-color: transparent;
    color:            var(--color-secondary);
    opacity:          0;
    transition:       opacity var(--transition-slow);
}

.lightbox::backdrop {
    background-color: rgba(0, 10, 28, 0.88);
}

.lightbox--open {
    opacity: 1;
}

.lightbox__figure {
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    gap:             16px;
    height:          100%;
    margin:          0;
    padding:         64px 96px 24px;
}

.lightbox__img {
    display:    block;
    width:      auto;
    max-width:  100%;
    height:     auto;
    max-height: calc(100dvh - 128px);
    object-fit: contain;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.lightbox__counter {
    color:          var(--color-sky);
    font-size:      16px;
    line-height:    1.5;
    letter-spacing: 1px;
}

.lightbox__btn {
    position:         absolute;
    width:            56px;
    height:           56px;
    background-color: rgba(0, 19, 49, 0.6);
}

.lightbox__btn:hover,
.lightbox__btn:focus-visible {
    background-color: var(--color-maroon);
    color:            var(--color-orange);
}

.lightbox__btn--close {
    top:   16px;
    right: 24px;
}

.lightbox__btn--prev,
.lightbox__btn--next {
    top:       50%;
    transform: translateY(-50%);
}

.lightbox__btn--prev {
    left: 24px;
}

.lightbox__btn--next {
    right: 24px;
}

.lightbox__icon {
    display: block;
}

@media (prefers-reduced-motion: reduce) {
    .lightbox {
        transition: none;
    }
}

/* ── Desktop steps ──────────────────────────────────────────────────────── */
/* The design's 71px between thumbnails is measured on a full 1340px column.
 * Kept as it is on a narrower desktop, the gaps ate the thumbnails down to
 * about 100px at 1200 — so the gaps shrink with the column and the photos
 * keep their size. */
@media (max-width: 1439px) {
    .object-gallery__thumbs {
        gap: 30px 52px;
    }
}

@media (max-width: 1279px) {
    .object__title {
        margin-top: 52px;
    }

    .object-gallery__thumbs {
        gap: 24px 36px;
    }
}

/* ── Tablet ─────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {


    .object__facts {
        margin-top: 32px;
    }

    .object__title {
        margin-top: 44px;
        font-size:  28px;
    }

    .object__gallery {
        margin-top: 36px;
    }

    .object-facts__label {
        width:     42px;
        height:    36px;
        font-size: 21px;
    }

    .object-facts__value--code {
        font-size: 22px;
    }

    .object-facts__value--price {
        font-size: 28px;
    }

    .object-gallery__thumbs {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap:                   18px 28px;
        margin-top:            24px;
    }
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {

    .object-gallery__arrow {
        width:  40px;
        height: 40px;
    }

    .object-gallery__arrow--prev {
        left: 8px;
    }

    .object-gallery__arrow--next {
        right: 8px;
    }

    .object-gallery__arrow-icon {
        width:  24px;
        height: 24px;
    }


    .object__facts {
        margin-top: 22px;
    }

    .object__catalog {
        font-size: 20px;
    }

    .object__title {
        margin-top: 28px;
        font-size:  22px;
    }

    .object__content {
        margin-top: 16px;
        font-size:  16px;
    }

    .object__gallery {
        margin-top: 28px;
    }

    /* ID and plot share the first row; the price takes its own below, where
     * it can stay large without squeezing either of them. */
    .object-facts {
        display:   flex;
        flex-wrap: wrap;
        gap:       14px 24px;
    }

    .object-facts__item {
        gap: 12px;
    }

    .object-facts__item--price {
        flex-basis: 100%;
    }

    .object-facts__label {
        width:     36px;
        height:    32px;
        font-size: 18px;
    }

    .object-facts__value {
        font-size: 16px;
    }

    .object-facts__value--code {
        font-size: 19px;
    }

    .object-facts__value--price {
        font-size: 24px;
    }

    .object-gallery__play {
        width:  64px;
        height: 46px;
    }

    /* Six a row on a large phone: at four, twenty photos ran to a screen and
     * a half of squares below the frame. The lightbox covers the browsing, so
     * the grid only has to show what there is. */
    .object-gallery__thumbs {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap:                   8px;
        margin-top:            12px;
    }

    .object-gallery__thumb--active {
        box-shadow: inset 0 0 0 1px var(--color-orange);
    }

    /* On a phone the photo takes the full width; the arrows sit over it at
     * the bottom corners, where a thumb reaches them, and swipe does the rest. */
    .lightbox__figure {
        padding: 64px 0 88px;
    }

    .lightbox__img {
        max-height: calc(100dvh - 152px);
    }

    .lightbox__btn {
        width:  48px;
        height: 48px;
    }

    .lightbox__btn--close {
        top:   8px;
        right: 8px;
    }

    .lightbox__btn--prev,
    .lightbox__btn--next {
        top:       auto;
        bottom:    20px;
        transform: none;
    }

    .lightbox__btn--prev {
        left: 16px;
    }

    .lightbox__btn--next {
        right: 16px;
    }
}

/* ── Small phone ────────────────────────────────────────────────────────── */
/* Below 480px six a row would drop a thumbnail under a 48px touch target;
 * four keep each one about 75px wide even on a 360px screen. */
@media (max-width: 479px) {
    .object-gallery__thumbs {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
