.tag-hash-slideshow {
    /* Prevent flashy/jumpy behavior in Firefox. */
    overflow-anchor: none;
    scrollbar-width: none;

    &::-webkit-scrollbar {
        scrollbar-width: none;
    }

    /* Hide subscribe controls on slideshows */
    [id=ghost-portal-root] {
        display: none;
    }
}

.slideshow-slide-title {
    > h2 {
        margin-block: 0;
    }
}

.slideshow {
  display: grid;
  grid-template-columns: 100vw;
  grid-template-rows: 46vh auto;
  overflow: hidden;
  width: 99vw;

  &.fixed {
    position: fixed;
  }
}


.slideshow-slide-caption {
    padding-block: 1rem;
    line-height: 1.5;

    p {
        margin: 0
    }
}

@media screen and (width >= 990px) {
	.slideshow {
	    background: var(--accent-tertiary);
        gap: 2px;
        grid-template-columns: calc(100cqw - 23rem) 23rem;
        grid-template-rows: auto auto;
        height: calc(99vh - var(--menu-height));
        width: auto;
        max-height: 68rem;
	}

    .slideshow-slide-caption {
        max-height: 12rem;
        overflow: hidden auto;
        padding-block-end: 2rem;
    }

}

/* Obsolete. Remove eventually */
.slideshow-track::-webkit-scrollbar {
    display: none;
}

.slideshow-track {
    background: var(--background);
    display: flex;
    gap: 0;
    overflow-x: scroll;
    padding-block: 1rem;
    scroll-snap-stop: always;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;

    &:focus {
        outline: none;
    }
}

.slide-img {
  flex: 0 0 100%;
  scroll-snap-align: center;

  img {
    display: block;
    height: 100%;
    margin: auto;
    max-height: 75rem;
    max-width: 100%;
    width: auto;

  }
}

@media screen and (min-width: 990px) {
    .slide-img img {
        object-fit: scale-down;
        object-position: center 0;
    }
}

.slideshow-sidebar {
    background: var(--background);
    display: grid;
    grid-template-rows: min-content min-content auto min-content;
    padding: 1rem;
    position: relative;
}

.slideshow-sidebar-ad {
    display: none;
}

@media screen and (width >= 990px) {
    .slideshow-sidebar-ad {
        margin-block: 0.5rem;
        text-align: center !important;
        min-height: 12.5rem;

        &::before {
            content: 'advertisement';
            color: #999;
            font-family: Arial, sans-serif;
            font-size: 10px;
            text-align: center;
            text-transform: uppercase;
        }
    }
}

.slideshow-sidebar-meta-controls {
    align-self: end;
    align-items: center;
    border-block-start: 2px solid var(--accent-tertiary);
    display: grid;
    gap: 0;
    grid-template: "xofy controls" "op op";
    justify-content: space-between;
    line-height: 1;
    margin-block: 1rem 0;
    padding-block: 1rem 0;

    .slideshow-original-post {
        grid-area: op;
        margin-block: 1rem 0;
    }
}

@media screen and (width >= 990px) {
    .slideshow-sidebar-meta-controls {
        background: rgba(255,255,255,0.8);
        backdrop-filter: blur(4px);
        border-bottom: 0;
        bottom: 0;
        display: grid;
        margin-block: 1rem;
        order: unset;
        padding: 1rem;
        position: absolute;
        width: 100%;
        grid-template: "xofy" "controls" "op";
        grid-template-columns: 1fr;

        .slideshow-original-post {
            margin-block: 2rem 0;
        }
    }
}

.slideshow-controls {
    display: grid;
    grid-template-columns: 6rem min-content min-content;

    [id=previous], [id=next] {
        border: 2px solid #555;
        padding: 0.25rem;
    }

    > span {
        display: inherit;
        grid-template-columns: 3rem 3rem;
        gap: 0;
    }

    [id=next] {
        border-left: 0;
    }

    &:disabled, [disabled] {
        background: var(--accent-tertiary);
        filter: opacity(0.5);
    }
}

@media screen and (width < 990px) {
    .slideshow-controls {
        display: inline-grid;
        justify-content: center;
    }
}

@media screen and (width >= 990px) {
    .slideshow-controls {
        gap: 1.5rem;
    }
}


[id=slideshow-grid-view] {
    border: 0;
    box-shadow: 0.5rem 0.5rem 0.75rem 0 rgba(0,0,0,0.25);
    height: 90vh;
    padding: 1rem;
    width: 90vw;

    &::backdrop {
        background: rgba(0,0,0,.5);
    }

    header {
        display: grid;
        justify-content: end;
    }
}

.slideshow-popout {
    display: none;
}

@media screen and (width >= 990px) {
    .slideshow-popout {
        display: inline-block;
    }
}

.slideshow-popout,
.slideshow-controls {
    a, button {
        width: 3rem;
        height: 3rem;
        padding: 0;
        border: 0;
        background: transparent;
    }

    svg {
        display: block;
        pointer-events: none;
        inline-size: 100%;
        block-size: auto;

        path {
            fill: #555;
        }
    }
}

[popovertarget=slideshow-grid-view],
[commandfor=slideshow-grid-view] {
    display: none;
    width: 3rem;
    height: 3rem;
    padding: 0;
    border: 0;
    background: transparent;
}

@media screen and (width >= 990px) {
    [popovertarget=slideshow-grid-view],
    [commandfor=slideshow-grid-view] {
        display: inline-block;
    }
}

.slideshow_ishidden {
    visibility: hidden;
}


.slideshow-grid-view-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    gap: 1.25rem;
    margin: 2rem 0rem;
}

.slideshow-tile {
    > a {
        color: #fff;
        display: grid;
        font: normal 1rem / 1 var(--font-accent);
        grid-template-areas: overlay;
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        justify-items: stretch;
        align-items: stretch;
        text-decoration: none;

        .slideshow-tile-title {
            visibility: hidden;
        }

        &:hover {
            .slideshow-tile-title {
                align-items: center;
                background: rgba(0,0,0,0.5);
                display: flex;
                justify-content: center;
                visibility: visible;

            }
        }
    }

    img, .slideshow-tile-title {
        grid-area: overlay;
    }
}

.slideshow-x-of-y {
    grid-area: xofy;
    gap: 0.5ch;
    align-items: center;
    display: inline-block;
    font-family: 'Helvetica','Arial', system-ui, sans-serif;
    font-size: 1.5rem;
    justify-content: center;
    margin: 0;
}


@media screen and (width >= 990px) {
    .slideshow-x-of-y {
        display: flex;
        justify-content: start;
        margin: 1rem 0;
    }
}

@media screen and (width >= 990px) {
    .slideshow-slide-title {
        order: 1;
    }
    .slideshow-slide-caption {
        order: 2;
    }

    .slideshow-sidebar-meta-controls {
        order: 3;
    }

    .slideshow-sidebar-ad {
        order: 4;
    }
}

.tag-hash-slideshow {

    .kg-bookmark-content {
        padding: 0;

        &::before {
            content: 'Return to post';
            font: bold 1rem / 2 var(--font-accent);
            text-transform: uppercase;
        }
    }

    .kg-bookmark-title {
        color: var(--accent-primary);
        font-family: var(--font-accent);
        font-size: 1.25rem;
    }

    .kg-bookmark-card {
        margin-block: 0;

        a.kg-bookmark-container {
            border: 0;
            border-radius: 0;
            display: grid;
            overflow: visible;
            grid-template-areas: "text img";
            grid-template-columns: 3fr 1fr;
            padding: 1rem;
            background: var(--accent-quaternary);
        }
    }

    :is(.kg-bookmark-metadata, .kg-bookmark-description)[hidden] {
        display: none !important;
    }

    .kg-bookmark-thumbnail {
        margin-left: 0.5rem;

        img {
            border-radius: 0;
            block-size: 100%;
            width: auto;
        }
    }
}

@media screen and (width >= 990px) {
    .tag-hash-slideshow {
        .kg-bookmark-card {
            margin-block: 0;
        }
    }
}
