/* --- General Prose Styles --- */
.prose {
    width: 100%;
    color: var(--text-light);
    font-size: 1.1rem;
    line-height: 1.5;
    max-width: 79ch;
    text-align: justify;
}

/* Fix for top alignment */
.prose > *:first-child {
    margin-top: 0;
}

.prose > p > *:first-child {
    margin-top: 0;
}

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
    color: var(--text-main);
    font-family: var(--font-heading);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.prose p {
    margin-bottom: 1em;
}

.prose a {
    color: var(--accent);
    font-weight: 600;
}

.prose img, .prose video {
    max-width: 100%;
    max-height: 70svh;
    height: auto;
    display: block;
    margin: 1em 0;
    border-radius: 4px;
}

@property --angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

video.video-loading-bg {
    border: 4px solid #0000;
    border-radius: 12px;
    background:
            url('/homepage/static/img/loading-rainbow-slide.gif') center center / 144px 144px no-repeat padding-box,
            linear-gradient(#fff, #fff) padding-box,
            conic-gradient(
                    from var(--angle),
                    #ff0000,
                    #ff8000,
                    #ffff00,
                    #00ff00,
                    #0000ff,
                    #4b0082,
                    #ee82ee,
                    #ff0000
            ) border-box;
    animation: 4s rotate linear infinite;
}

@keyframes rotate {
    to {
        --angle: 360deg;
    }
}

.prose code {
    padding: 2px 5px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.prose pre code {
    padding: 0;
}

.prose pre {
    background: #1e1e1e;
    color: #dcdcdc;
    padding: 1em;
    border-radius: 5px;
    overflow-x: auto;
}

.prose pre {
    color: #dcdcdc;
    padding: 1em;
    position: relative;
    margin: 1.5em 0;
    overflow-x: auto;
}

.prose pre::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50vw);
    height: 80%;
    background: rgba(30, 30, 30, 0.03);
    z-index: -1;
}

.prose blockquote {
    margin: 1.5em 0;
    padding: 0.5em 1em;
    border-left: 4px solid var(--accent);
    background: rgba(0, 0, 0, 0.02);
    font-style: italic;
}

.prose blockquote p {
    margin: 0 0;
}

.prose ul, .prose ol {
    padding-left: 2em;
}

.prose figcaption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: -1.5em;
    margin-bottom: 2em;
}

.prose .spoiler {
    background: repeating-conic-gradient(#bcbcbc 0 25%, #eee 0 50%) 50% / 5px 5px;
    color: transparent;
    cursor: pointer;
    border-radius: 5px;
    transition: color 0.2s ease-in-out, background 0.2s ease-in-out;
}

.prose .spoiler:hover,
.prose .spoiler:focus {
    color: var(--text-light);
    background: transparent;
}

/* --- Content Utility Classes --- */
.prose .content-row-grid {
    display: grid;
    gap: 0.5em;
    margin: 1.5em 0;
}

.prose .content-row-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.prose .content-row-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.prose .content-row-grid img, .prose .content-row-grid video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
}

.prose .center {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* --- Image Carousel --- */
.prose .image-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 1em;
    margin: 1.5em 0;
    height: 456px;
    max-height: 60svh;
    scrollbar-width: thin;
    border-radius: 5px;
}

.prose .image-carousel > img, .prose .image-carousel > video {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    scroll-snap-align: center;
    margin: 0;
    border-radius: 5px;
}

.prose .carousel-wrapper {
    position: relative;
    margin: 1.5em 0;
}

.prose .carousel-wrapper .image-carousel {
    margin: 0;
}

.prose .image-carousel.carousel-initialized {
    scrollbar-width: none;
}

.prose .image-carousel.carousel-initialized::-webkit-scrollbar {
    display: none;
}

.prose .carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    padding-bottom: 4px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 10;
    opacity: 0.5;
    transition: opacity 0.2s, background 0.2s;
}

.prose .carousel-btn:hover {
    opacity: 1;
    background: var(--accent);
}

.prose .carousel-btn.prev {
    left: -46px;
}

.prose .carousel-btn.next {
    right: -46px;
}

@media (max-width: 950px) {
    .prose .carousel-btn.prev {
        left: 10px;
    }

    .prose .carousel-btn.next {
        right: 10px;
    }
}

@media (min-width: 950px) {
    .prose .expand-sm,
    .prose .expand-md,
    .prose .expand-full {
        position: relative;
        margin-left: 50%;
        transform: translateX(-50%);
    }

    .prose .expand-sm {
        width: calc(100vw - 40px);
        max-width: 90ch;
    }

    .prose .expand-md {
        width: calc(100vw - 40px);
        max-width: 1200px;
    }

    .prose .expand-full {
        width: 98svw;
        max-width: 98svw;
    }
}

.prose .shrink-sm {
    margin-left: 50%;
    transform: translateX(-50%);
    width: 50%;
    min-width: 35svw;
}

.prose .shrink-md {
    margin-left: 50%;
    transform: translateX(-50%);
    width: 30%;
    min-width: 35svw;
}

@media (max-width: 768px) {
    .prose .content-row-grid.cols-2,
    .prose .content-row-grid.cols-3 {
        grid-template-columns: 1fr;
    }

    .prose .image-carousel {
        height: 300px;
        max-height: 60svh;
    }
}

/* --- Masonry Gallery --- */
.prose .gallery-masonry {
    column-count: 3;
    column-gap: 0.5em;
    margin: 1.5em 0;
}

.prose .gallery-masonry img, .prose .gallery-masonry video {
    margin: 0 0 0.5em 0;
    width: 100%;
    height: auto;
    break-inside: avoid;
}

@media (min-width: 768px) {
    .prose .gallery-masonry.cols-2 {
        column-count: 2;
    }

    .prose .gallery-masonry.cols-4 {
        column-count: 4;
    }
}

@media (max-width: 768px) {
    .prose .gallery-masonry {
        column-count: 2;
    }
}

@media (max-width: 480px) {
    .prose .gallery-masonry {
        column-count: 1;
    }
}

/* --- Justified Grid Gallery --- */
.prose .gallery-justified {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin: 1.5em 0;
}

.prose .gallery-justified img, .prose .gallery-justified video {
    height: 250px;
    flex-grow: 1;
    object-fit: cover;
    margin: 0;
    width: auto;
}

.prose .gallery-justified.xl img, .prose .gallery-justified.xl video {
    height: 325px;
}

.prose .gallery-justified.lg img, .prose .gallery-justified.lg video {
    height: 275px;
}

.prose .gallery-justified.md img, .prose .gallery-justified.md video {
    height: 225px;
}

.prose .gallery-justified.sm img, .prose .gallery-justified.sm video {
    height: 150px;
}

.prose .gallery-justified.xs img, .prose .gallery-justified.xs video {
    height: 100px;
}

@media (max-width: 768px) {
    .prose .gallery-justified img, .prose .gallery-justified video {
        height: 150px;
    }
}

/* --- Floating Images --- */
.prose .float-right {
    float: right;
    margin-left: 2rem;
    margin-bottom: 1rem;
    margin-top: 0;
    max-width: 40%; /* Takes up roughly 1/3 to 1/2 of the width */
    height: auto;
    clear: right; /* Prevents stacking weirdness */
}

.prose .float-left {
    float: left;
    margin-right: 2rem;
    margin-bottom: 1rem;
    max-width: 40%;
    height: auto;
    clear: left;
}

@media (max-width: 768px) {
    .prose .float-right,
    .prose .float-left {
        float: none;
        display: block;
        margin: 1.5rem auto;
        max-width: 100%;
        width: 100%;
    }
}

.prose .inline {
    margin-top: 0;
    margin-bottom: 0;
    height: 1em;
    display: inline-block;
}

/* --- Details / Summary --- */
.prose details {
    margin: 1.5em 0;
    padding: 0 1em;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-card);
}

.prose summary {
    margin: 0 -1em;
    padding: 0.6em 1em;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.prose summary:hover {
    background: var(--bg-light);
}

.prose summary::-webkit-details-marker {
    display: none;
}

.prose summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 10px;
    font-size: 0.8em;
    transition: transform 0.2s ease;
    color: var(--accent);
}

.prose details[open] {
    padding-bottom: 1em;
}

.prose details[open] > summary {
    border-bottom: 1px solid var(--border-color);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 1em;
}

.prose details[open] > summary::before {
    transform: rotate(90deg);
}
