/**
 * mod_work - photo carousel.
 *
 * A scroll-snapping track: two photos across on the narrowest screens, three
 * from small, four from medium. Swiping and trackpad scrolling are native; the
 * dots underneath are added by script and page a screenful at a time.
 */

.mod-work__viewport {
    position: relative;
}

.mod-work__track {
    display: grid;
    grid-auto-flow: column;
    /* each page shows two, so two columns plus the one gap between them */
    grid-auto-columns: calc((100% - 1rem) / 2);
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    /* the dots are the affordance here, as they were in the old build */
    scrollbar-width: none;
}

.mod-work__track::-webkit-scrollbar {
    display: none;
}

.mod-work__track:focus-visible {
    outline: 2px solid var(--trillium-dark, #312f38);
    outline-offset: 4px;
}

.mod-work__item {
    scroll-snap-align: start;
}

/* mouse drag is script driven; the cursor only offers it when there is room */
.mod-work--scrollable .mod-work__track {
    cursor: grab;
}

.mod-work--dragging .mod-work__track {
    cursor: grabbing;
    user-select: none;
}

.mod-work__image {
    -webkit-user-drag: none;
}

.mod-work__card {
    position: relative;
    margin: 0;
    overflow: hidden;
}

.mod-work__image {
    display: block;
    width: 100%;
    height: auto;
}

.mod-work__title {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: .3rem;
    font-family: "Raleway", sans-serif;
    font-size: 1.3rem;
    line-height: 1.3;
    text-align: center;
    color: #fff;
    background-color: rgb(0 0 0 / 70%);
}

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

.mod-work__arrow {
    position: absolute;
    top: 50%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #fff;
    background-color: rgb(0 0 0 / 70%);
    border: 0;
    cursor: pointer;
    transform: translateY(-50%);
    transition: background-color .2s, opacity .2s;
}

.mod-work__arrow--prev {
    left: 0;
}

.mod-work__arrow--next {
    right: 0;
}

.mod-work__arrow:hover:not(:disabled) {
    background-color: var(--trillium-accent, #b2957a);
    color: var(--trillium-dark, #312f38);
}

.mod-work__arrow:disabled {
    opacity: .3;
    cursor: default;
}

/* nothing to page through, so no arrows */
.mod-work:not(.mod-work--scrollable) .mod-work__arrow {
    display: none;
}

/* ------------------------------------------------------------------ dots */

.mod-work__nav {
    display: flex;
    justify-content: center;
    gap: .5rem;
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}

.mod-work__dot {
    display: block;
    box-sizing: border-box;
    width: 20px;
    height: 20px;
    padding: 0;
    background-color: transparent;
    border: 1px solid rgb(0 0 0 / 50%);
    cursor: pointer;
    transition: background-color .2s;
}

.mod-work__dot:hover,
.mod-work__dot[aria-current="true"] {
    background-color: #fff;
}

/* ---------------------------------------------------------- breakpoints */

@media (max-width: 639px) {
    /* small screens swipe instead, as the old build did */
    .mod-work__nav {
        display: none;
    }
}

@media (min-width: 640px) {
    .mod-work__track {
        grid-auto-columns: calc((100% - 2rem) / 3);
    }
}

@media (min-width: 960px) {
    .mod-work__track {
        grid-auto-columns: calc((100% - 3rem) / 4);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mod-work__track {
        scroll-behavior: auto;
    }
}
