/**
 * Gallery front-end styles.
 *
 * Scoped to .swg-container so nothing here can leak into the rest of the site.
 * The palette and a few measurements are custom properties, so a theme can
 * retune the gallery without overriding rules.
 *
 * @package SW_Gallery
 */

.swg-container {
    --swg-gap: 1rem;
    --swg-radius: 4px;
    --swg-surface: #111;
    --swg-surface-text: #fff;
    --swg-muted: #5b6472;
    --swg-border: rgba(0, 0, 0, 0.12);
    --swg-control-bg: rgba(0, 0, 0, 0.55);
    --swg-control-bg-hover: rgba(0, 0, 0, 0.8);
    --swg-control-text: #fff;
    --swg-focus: #1e6fd9;

    box-sizing: border-box;
    margin-inline: auto;
    max-width: 100%;
    padding-block: 1.5rem 3rem;
}

.swg-container *,
.swg-container *::before,
.swg-container *::after {
    box-sizing: inherit;
}

/* ---------------------------------------------------------------- Header -- */

.swg-header {
    margin-bottom: 1.5rem;
}

.swg-title {
    margin: 0 0 0.35rem;
    overflow-wrap: break-word;
}

.swg-meta {
    margin: 0 0 1rem;
    color: var(--swg-muted);
    font-size: 0.9em;
}

.swg-intro {
    margin-bottom: 1.5rem;
}

.swg-intro > *:first-child {
    margin-top: 0;
}

.swg-empty {
    padding: 2rem;
    border: 1px dashed var(--swg-border);
    border-radius: var(--swg-radius);
    color: var(--swg-muted);
    text-align: center;
}

/* ------------------------------------------------------------- Slideshow -- */

.swg-slideshow {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: var(--swg-surface);
    border-radius: var(--swg-radius);
    overflow: hidden;
}

.swg-slide__figure {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    /* Fills the slide. Without this the ratio below derives the width from the
       height instead — and once max-height caps that height, the figure stops
       spanning the slideshow and the image sits left of centre. */
    width: 100%;
    /* Keeps the slideshow from jumping as slides of different heights load. */
    aspect-ratio: 3 / 2;
    max-height: 75vh;
}

.swg-slide__img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.swg-slide__caption {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    padding: 2.5rem 1rem 0.85rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0));
    color: var(--swg-surface-text);
    font-size: 0.95em;
    line-height: 1.4;
    text-align: start;
}

.swg-slide__title {
    display: block;
    font-weight: 600;
}

.swg-slide__text {
    display: block;
    margin-top: 0.15rem;
    opacity: 0.9;
}

/* ---------------------------------------------------------------- Controls -- */

.swg-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    transform: translateY(-50%);
    border: 0;
    border-radius: 50%;
    background: var(--swg-control-bg);
    color: var(--swg-control-text);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
}

.swg-nav:hover {
    background: var(--swg-control-bg-hover);
}

.swg-nav--prev {
    inset-inline-start: 0.75rem;
}

.swg-nav--next {
    inset-inline-end: 0.75rem;
}

.swg-status {
    position: absolute;
    inset-inline-end: 0.75rem;
    bottom: 0.5rem;
    z-index: 2;
}

.swg-status__position {
    margin: 0;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--swg-control-bg);
    color: var(--swg-control-text);
    font-size: 0.8rem;
}

.swg-status__position:empty {
    display: none;
}

/* --------------------------------------------------------------- Sharing -- */

.swg-share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-block: 1rem;
}

.swg-share__label {
    color: var(--swg-muted);
    font-size: 0.85em;
    font-weight: 600;
}

.swg-share__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Height and the hover colours are pinned on purpose. The copy button is a
   <button> and the networks are <a> elements, and a theme's element-level
   `button { height: 50px }` / `button:hover { background: ... }` would reach
   the one without touching the others — which is how a single button ends up
   twice the height of the row it sits in. */
.swg-share__btn {
    display: inline-block;
    height: auto;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--swg-border);
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
}

.swg-share__btn:hover,
.swg-share__btn:focus {
    background: transparent;
    color: inherit;
    border-color: currentColor;
}

/* Focus ring, kept visible on both the dark slideshow and a light page. */
.swg-container :focus-visible {
    outline: 2px solid var(--swg-focus);
    outline-offset: 2px;
}

/* --------------------------------------------------------------- Archive -- */

.swg-archive__header {
    margin-bottom: 1.5rem;
}

.swg-archive__title {
    margin-top: 30px;
}

/* ------------------------------------------------------------ Small screens -- */

@media (max-width: 600px) {
    .swg-container {
        --swg-gap: 0.85rem;
    }

    .swg-slide__figure {
        aspect-ratio: 4 / 3;
        max-height: 60vh;
    }

    .swg-nav {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1.4rem;
    }

    .swg-share {
        gap: 0.4rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .swg-container *,
    .swg-container *::before,
    .swg-container *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }

    .swg-card__link:hover .swg-card__img,
    .swg-card__link:focus .swg-card__img {
        transform: none;
    }
}
