/* Tutorials feature — landing section + gallery page card grid (16:9 YouTube videos) */

.tutorials-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 26px;
}

.tutorials-grid.tutorials-grid-gallery {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Narrower "Guides" column when the News sidebar sits beside it (see index.html) —
   3 columns doesn't have room here, and 2 columns keeps 4 cards a clean 2x2 grid. */
.tutorials-grid.tutorials-grid-sidebar {
    grid-template-columns: repeat(2, 1fr);
}

/* Bootstrap's col-md-8/col-md-4 stack full-width below 992px; add breathing
   room between them since Bootstrap 3 doesn't add vertical gutters itself. */
@media (max-width: 991px) {
    .guides-news-row [id="tutorials"] {
        margin-bottom: 60px;
    }
}

@media (max-width: 1024px) {
    .tutorials-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .tutorials-grid { grid-template-columns: 1fr; }
}

.tutorials-card {
    position: relative;
    display: block;
    min-width: 0;
    border-radius: 14px;
    overflow: hidden;
    background: #111;
    aspect-ratio: 16 / 9;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.tutorials-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

/* Wraps the thumbnail + badge + play icon. On desktop it just fills the card
   (see below) so absolute-positioned children land exactly where they always
   did; the mobile override further down gives it its own fixed-ratio box so
   the card can grow taller and put details below it instead of on top. */
.tutorials-card-media {
    position: absolute;
    inset: 0;
}

/* Scoped under .tutorials-card so it outweighs style.css's global
   `img:not([draggable]) { height: auto }` reset (specificity 0,1,1) —
   without this the <img> thumb collapses to its natural height and fills
   only the top of the card. */
.tutorials-card .tutorials-card-thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #1a1a1a;
}

.tutorials-card-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.tutorials-card-play svg { width: 22px; height: 22px; fill: #111; margin-left: 2px; }

.tutorials-card-info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 34px 14px 12px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.78) 100%);
    color: #fff;
}

.tutorials-card-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.tutorials-card-author { font-size: 12px; opacity: 0.8; margin: 0; }

.tutorials-platform-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
}

.tutorials-empty { text-align: center; color: #888; padding: 40px 0; grid-column: 1 / -1; }

.tutorials-explore-more { text-align: center; margin-top: 40px; }

/* Magnific popup iframe wrapper for 16:9 tutorial video */
.tutorials-popup-iframe {
    max-width: 900px;
    width: 92%;
    margin: 40px auto;
}

.tutorials-popup-iframe .mfp-iframe-scaler {
    padding-top: 56.25%; /* 16:9 */
}

/* Details sit below the thumbnail instead of overlaid on it — the fixed 16:9
   ratio moves from the whole card onto just the media box, freeing the card
   to grow as tall as its content needs. Must come after the base .tutorials-card*
   rules above so it wins the cascade (same selectors, so source order decides
   — an earlier same-selector media query would otherwise lose to these). */
@media (max-width: 640px) {
    .tutorials-card {
        aspect-ratio: auto;
        display: flex;
        flex-direction: column;
    }

    .tutorials-card-media {
        position: relative;
        inset: auto;
        aspect-ratio: 16 / 9;
        flex: none;
    }

    .tutorials-card-info {
        position: static;
        background: none;
        padding: 12px 14px 14px;
    }
}

/* ---------------------------------------------
   Share + highlight (see netlify/functions/guide.js)
   --------------------------------------------- */

/* The card is now wrapped so the share button can sit outside the <a> — a
   button nested inside a link is invalid markup and swallows the popup
   trigger on touch devices. The wrapper is the grid item; it must not
   introduce any sizing of its own. */
.tutorials-card-wrap {
    position: relative;
    min-width: 0;
}

.tutorials-share-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    border: 0;
    border-radius: 999px;
    background: rgba(17, 17, 17, 0.72);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    /* Hidden until hover on pointer devices (see below); always shown on touch. */
    opacity: 1;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.tutorials-share-btn svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
}

.tutorials-share-btn:hover,
.tutorials-share-btn:focus-visible {
    background: #111;
}

.tutorials-share-btn.is-copied {
    background: #1c6b34;
}

/* On a mouse, keep the card art clean until the visitor is actually on it.
   Touch devices have no hover, so the button stays visible there. */
@media (hover: hover) and (pointer: fine) {
    .tutorials-share-btn { opacity: 0; }
    .tutorials-card-wrap:hover .tutorials-share-btn,
    .tutorials-share-btn:focus-visible { opacity: 1; }
}

/* Marks the one guide a visitor followed a shared /g/:id link to find.
   Matches the Info treatment in shorts.css so both sections feel the same. */
.tutorials-card-highlight .tutorials-card {
    animation: tutorialsCardHighlightPulse 1.6s ease-in-out 3;
}

@keyframes tutorialsCardHighlightPulse {
    0%, 100% { box-shadow: 0 0 0 3px #fff, 0 0 0 7px rgba(255, 140, 0, 0.9), 0 18px 40px rgba(0, 0, 0, 0.22); }
    50% { box-shadow: 0 0 0 3px #fff, 0 0 0 12px rgba(255, 140, 0, 0.3), 0 18px 40px rgba(0, 0, 0, 0.22); }
}

@media (prefers-reduced-motion: reduce) {
    .tutorials-card-highlight .tutorials-card {
        animation: none;
        box-shadow: 0 0 0 3px #fff, 0 0 0 7px rgba(255, 140, 0, 0.9), 0 18px 40px rgba(0, 0, 0, 0.22);
    }
}
