/*
 * MEDIA BLOCKS - YouTube and Instagram embeds.
 *
 * Merged from the former instagram.css and youtube.css: both blocks solve
 * the same problem (framing a third-party embed so it reads as part of the
 * page), so they share the frame treatment here.
 *
 * Aspect ratios are declared on the wrapper, not the iframe, so the space
 * is reserved before the embed loads and nothing shifts on load.
 */

/* ---- YouTube --------------------------------------------------------- */

.youtube-grid {
    display: grid;
    gap: var(--space-lg);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
}

/* A lone video reads as a feature, not as a stranded grid cell. */
.youtube-grid--1 {
    grid-template-columns: 1fr;
    max-width: 50rem;
    margin-inline: auto;
}

.youtube-item {
    width: 100%;
}

.youtube-item__frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #0f172a;
    box-shadow: var(--shadow-ambient);
    transition: box-shadow var(--transition), transform var(--transition);
}

.youtube-item:hover .youtube-item__frame {
    box-shadow: var(--shadow-lifted);
    transform: translateY(var(--lift));
}

.youtube-item__frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.youtube-item__title {
    margin-top: var(--space-md);
    text-align: center;
    font-family: var(--font-heading);
    font-size: var(--fs-body);
    font-weight: 600;
    line-height: var(--lh-snug);
    color: var(--text-primary);
}

/* ---- Instagram ------------------------------------------------------- */

.instagram-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-lg);
}

.instagram-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 22.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    box-shadow: var(--shadow-ambient);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}

.instagram-item:hover {
    box-shadow: var(--shadow-lifted);
    transform: translateY(var(--lift));
}

/*
 * Instagram's embed.js rewrites the blockquote and re-applies its own
 * inline sizing on every instgrm.Embeds.process() call. An author
 * stylesheet marked !important still outranks a plain inline style, so
 * these clamps survive whatever the third-party script does afterwards.
 */
.instagram-media {
    width: 100% !important;
    max-width: 22.5rem !important;
    min-width: 17.5rem !important;
    margin: 0 auto !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.instagram-item__caption {
    padding: var(--space-md) var(--space-md) var(--space-lg);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    line-height: var(--lh-normal);
    text-align: center;
}
