/* Styles specific to the Context-Heavy Diagrams page. Shared styles live in ../../style.css. */

.chd-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Buttons are inline-block in the shared sheet; keep touch targets at least 44px tall */
.chd-cta .btn {
    min-height: 44px;
    text-align: center;
}

.chd-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));
    gap: 1.5rem;
}

/* Media: figures hold an image, clip, or SVG plus a visible caption */
.chd-figure {
    margin: 2rem 0;
}

.chd-figure img,
.chd-figure video,
.chd-figure svg {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.chd-figure figcaption {
    margin-top: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Carousel: without JavaScript the slides simply stack as figures.
   chd.js adds .chd-carousel--ready, which overlaps the slides and cross-fades between them. */
.chd-slide {
    margin: 2rem 0;
}

.chd-slide img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.chd-slide figcaption {
    margin-top: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.chd-carousel-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.chd-carousel-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 1;
}

.chd-carousel-controls button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border);
    border-radius: 4px;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.3s, color 0.3s;
}

.chd-carousel-controls button:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.chd-carousel-controls button[aria-selected="true"] {
    border-color: var(--accent);
    color: var(--text-primary);
}

.chd-carousel--ready {
    display: grid;
}

/* All slides share one grid cell so they overlap during the fade */
.chd-carousel--ready .chd-slide {
    grid-area: 1 / 1;
    margin: 1rem 0 0;
    opacity: 0;
    visibility: hidden;
    /* Hide after the fade-out so hidden slides leave the tab order and the accessibility tree */
    transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

.chd-carousel--ready .chd-slide.is-active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.35s ease, visibility 0s;
}

@media (prefers-reduced-motion: reduce) {
    .chd-carousel--ready .chd-slide,
    .chd-carousel--ready .chd-slide.is-active {
        transition: none;
    }
}

/* Slides differ in shape (a portrait terminal crop next to widescreen shots), so each takes its own height
   and the carousel resizes to the active slide (chd.js). */
.chd-carousel--ready {
    overflow: hidden;
    transition: height 0.35s ease;
}

.chd-carousel--ready .chd-slide {
    align-self: start;
}

/* A narrow screenshot stays at its natural size, centred, instead of being stretched to the full width */
.chd-slide--narrow img {
    max-width: 807px;
    margin: 0 auto;
}

@media (prefers-reduced-motion: reduce) {
    .chd-carousel--ready {
        transition: none;
    }
}

/* A screenshot narrower than the content width is capped at its natural width and centred, so it is not upscaled.
   Capping (not width: auto) keeps the reserved aspect ratio while the lazy image loads. */
.chd-slide--natural img {
    max-width: 1000px;
    margin: 0 auto;
}
