/* ==========================================================================
   fwmg-modules.css - the WIDGET tier.

   A widget is placed on pages the gallery does not own: an article, a sidebar,
   a home page built by somebody else's theme. So everything is scoped under
   `.fwmg-module`, nothing sets a colour it did not have to, and sizes come from
   the host's own font size - a widget should look like it belongs to the page
   it is on, not like a window cut into another site.

   The layout knobs are custom properties the templates set per instance, so an
   instance is configured by its parameters rather than by a stylesheet override.
   ========================================================================== */

.fwmg-module {
    --fwmg-mod-gap: .75rem;
    --fwmg-mod-radius: 6px;
    margin: 0 0 1.25rem;
}

.fwmg-module a {
    text-decoration: none;
    color: inherit;
}

/* ── tiles: the shape latest/carousel share ─────────────────────────────── */

.fwmg-mod-tile-image,
.fwmg-mod-carousel-image {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: var(--fwmg-mod-radius);
    background: rgba(127, 127, 127, .12);
    aspect-ratio: 4 / 3;
}

.fwmg-mod-tile-image img,
.fwmg-mod-carousel-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}

.fwmg-mod-tile:hover .fwmg-mod-tile-image img,
.fwmg-mod-carousel-slide:hover .fwmg-mod-carousel-image img {
    transform: scale(1.04);
}

.fwmg-mod-tile-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    opacity: .45;
}

.fwmg-mod-tile-badge {
    position: absolute;
    top: .4rem;
    left: .4rem;
    padding: .1rem .4rem;
    border-radius: 3px;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: .7em;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.fwmg-mod-tile-info {
    padding: .4rem .1rem 0;
}

.fwmg-mod-tile-name {
    font-weight: 600;
    line-height: 1.3;
}

.fwmg-mod-tile-description {
    margin-top: .2rem;
    font-size: .85em;
    opacity: .75;
}

.fwmg-mod-tile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .25rem;
    font-size: .78em;
    opacity: .65;
}

.fwmg-mod-tile--featured .fwmg-mod-tile-image {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

/* ── latest ─────────────────────────────────────────────────────────────── */

.fwmg-mod-latest {
    display: grid;
    gap: var(--fwmg-mod-gap);
}

.fwmg-mod-latest--vertical {
    grid-template-columns: 1fr;
}

.fwmg-mod-latest--horizontal {
    grid-template-columns: repeat(var(--fwmg-mod-cols, 4), minmax(0, 1fr));
}

/* The slider layout is a real scroller, so it needs no script to be usable. */
.fwmg-mod-latest--trendy {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: .35rem;
}

.fwmg-mod-latest--trendy .fwmg-mod-tile {
    flex: 0 0 calc((100% - (var(--fwmg-mod-cols, 4) - 1) * var(--fwmg-mod-gap)) / var(--fwmg-mod-cols, 4));
    scroll-snap-align: start;
}

@media (max-width: 720px) {
    .fwmg-mod-latest--horizontal {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ── carousel ───────────────────────────────────────────────────────────── */

.fwmg-mod-carousel {
    position: relative;
}

.fwmg-mod-carousel-track {
    display: flex;
    gap: var(--fwmg-mod-gap);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding-bottom: .35rem;
}

.fwmg-mod-carousel-slide {
    flex: 0 0 calc((100% - (var(--fwmg-mod-visible, 5) - 1) * var(--fwmg-mod-gap)) / var(--fwmg-mod-visible, 5));
    scroll-snap-align: start;
}

.fwmg-mod-carousel-prev,
.fwmg-mod-carousel-next {
    position: absolute;
    top: calc(50% - 1.25rem);
    z-index: 2;
    width: 2rem;
    height: 2.5rem;
    border: 0;
    border-radius: var(--fwmg-mod-radius);
    background: rgba(0, 0, 0, .5);
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity .2s ease;
}

.fwmg-mod-carousel:hover .fwmg-mod-carousel-prev,
.fwmg-mod-carousel:hover .fwmg-mod-carousel-next,
.fwmg-mod-carousel-prev:focus-visible,
.fwmg-mod-carousel-next:focus-visible {
    opacity: 1;
}

.fwmg-mod-carousel-prev { left: 0; }
.fwmg-mod-carousel-next { right: 0; }

@media (max-width: 720px) {
    .fwmg-mod-carousel-slide {
        flex-basis: 70%;
    }
}

/* ── search ─────────────────────────────────────────────────────────────── */

.fwmg-mod-search-row {
    display: flex;
    gap: .4rem;
}

.fwmg-mod-search-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: .45rem .6rem;
    border: 1px solid rgba(127, 127, 127, .45);
    border-radius: var(--fwmg-mod-radius);
    background: transparent;
    color: inherit;
    font: inherit;
}

.fwmg-mod-search-submit {
    padding: .45rem .9rem;
    border: 1px solid rgba(127, 127, 127, .45);
    border-radius: var(--fwmg-mod-radius);
    background: rgba(127, 127, 127, .12);
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.fwmg-mod-search-types {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: .5rem;
    font-size: .85em;
}

.fwmg-mod-search-type {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    cursor: pointer;
}

.fwmg-mod-search-count {
    opacity: .6;
}

/* ── map ────────────────────────────────────────────────────────────────── */

.fwmg-mod-map {
    width: 100%;
    border-radius: var(--fwmg-mod-radius);
}

.fwmg-mod-map-pin {
    display: block;
    max-width: 160px;
}

.fwmg-mod-map-pin img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 3px;
}

.fwmg-mod-map-pin span {
    display: block;
    margin-top: .2rem;
    font-weight: 600;
}

/* ── tags ───────────────────────────────────────────────────────────────── */

.fwmg-mod-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .6rem;
    align-items: baseline;
}

.fwmg-mod-tags--list {
    flex-direction: column;
    gap: .3rem;
}

.fwmg-mod-tags--inline {
    flex-wrap: nowrap;
    overflow-x: auto;
}

.fwmg-mod-tag {
    line-height: 1.2;
    opacity: .9;
}

.fwmg-mod-tag:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Four steps, not a computed size: a design restyles the cloud by redefining these. */
.fwmg-mod-tag--w1 { font-size: .85em; opacity: .65; }
.fwmg-mod-tag--w2 { font-size: 1em; }
.fwmg-mod-tag--w3 { font-size: 1.25em; font-weight: 600; }
.fwmg-mod-tag--w4 { font-size: 1.55em; font-weight: 700; }

/* ── layout anywhere ────────────────────────────────────────────────────── */

.fwmg-mod-layout--float-left {
    float: left;
    margin: 0 1rem 1rem 0;
}

.fwmg-mod-layout--float-right {
    float: right;
    margin: 0 0 1rem 1rem;
}

@media (max-width: 720px) {
    .fwmg-mod-layout--float-left,
    .fwmg-mod-layout--float-right {
        float: none;
        width: auto !important;
        margin: 0 0 1rem;
    }
}
