/* media.css - Media Library public styles: inline figures, galleries, lightbox */

/* ---- Inline article figures (inserted from the Media Library) ---- */
.ml-figure {
    margin: 2rem auto;
    max-width: 100%;
    text-align: center;
}
.ml-figure img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color, #243046);
    display: inline-block;
}
.ml-figure figcaption {
    font-size: 0.85rem;
    color: var(--text-secondary, #8a94a6);
    margin-top: 0.55rem;
    line-height: 1.45;
}
.ml-align-center { max-width: 680px; }
.ml-align-full   { max-width: 100%; }
.ml-align-wide   { max-width: 900px; }
.ml-align-left,
.ml-align-right  { max-width: 46%; margin-top: 0.4rem; margin-bottom: 1rem; }
.ml-align-left   { float: left;  margin-right: 1.4rem; text-align: left; }
.ml-align-right  { float: right; margin-left: 1.4rem;  text-align: left; }
@media (max-width: 640px) {
    .ml-align-left, .ml-align-right {
        float: none; max-width: 100%; margin-left: auto; margin-right: auto; text-align: center;
    }
}
/* Clear floats after the article body so floated figures never leak out */
.du-lesson-content::after { content: ""; display: table; clear: both; }

/* ---- Featured image ---- */
.ml-featured {
    margin: 0 0 2rem;
    border: 1px solid var(--border-color, #243046);
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-card, #111726);
}
.ml-featured img { display: block; width: 100%; height: auto; }
.ml-featured figcaption {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary, #8a94a6);
    border-top: 1px solid var(--border-color, #243046);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.ml-featured .ml-credit { font-style: italic; white-space: nowrap; }

/* ---- Galleries ---- */
.ml-gallery { margin: 2.5rem 0 1rem; }
.ml-gallery-item { margin: 0; }
.ml-gallery-item img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--border-color, #243046);
    display: block;
}
.ml-gallery-item figcaption {
    font-size: 0.8rem;
    color: var(--text-secondary, #8a94a6);
    margin-top: 0.4rem;
}
.ml-gallery a.ml-lightbox-link { display: block; cursor: zoom-in; }

/* Grid */
.ml-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
/* Masonry (CSS columns) */
.ml-gallery-masonry { columns: 3 220px; column-gap: 1rem; }
.ml-gallery-masonry .ml-gallery-item { break-inside: avoid; margin-bottom: 1rem; }
/* Carousel (scroll-snap) */
.ml-gallery-carousel {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 0.6rem;
    position: relative;
}
.ml-gallery-carousel .ml-gallery-item {
    flex: 0 0 min(86%, 640px);
    scroll-snap-align: center;
}
.ml-carousel-wrap { position: relative; }
.ml-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color, #243046);
    background: rgba(10, 14, 21, 0.85);
    color: var(--text-primary, #e6ecf5);
    font-size: 1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.ml-carousel-btn:hover { border-color: var(--accent-blue, #22d3ee); color: var(--accent-blue, #22d3ee); }
.ml-carousel-prev { left: -8px; }
.ml-carousel-next { right: -8px; }

/* ---- Lightbox ---- */
.ml-lb {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(3, 6, 11, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem 1rem;
}
.ml-lb img {
    max-width: 94vw;
    max-height: 86vh;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.ml-lb-caption {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-secondary, #b7c0d0);
    font-size: 0.85rem;
    max-width: 90vw;
    text-align: center;
}
.ml-lb-btn {
    position: absolute;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    width: 44px; height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.ml-lb-btn:hover { background: rgba(255, 255, 255, 0.18); }
.ml-lb-close { top: 16px; right: 16px; }
.ml-lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.ml-lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
@media (prefers-reduced-motion: no-preference) {
    .ml-lb { animation: mlLbIn 0.18s ease-out; }
    @keyframes mlLbIn { from { opacity: 0; } to { opacity: 1; } }
}
