/* ==========================================================================
   INSTAGRAM SECTION  —  [sy_instagram]
   Markup: inc/shortcodes.php. Content: Customize > SY Sections > Instagram.

   A cream panel carrying the labelling, with the grid of posts running from it
   to the right edge of the screen. Column count comes through as --sy-ig-cols.

   Font sizes are px, not rem: this site's root font size is 10px rather than
   16px, so rem values render at 62.5% of their intended size.
   ========================================================================== */

.sy-instagram {
    --sy-ig-ink: #2c2520;
    --sy-ig-muted: #8a7f70;
    --sy-ig-cream: #f2efe9;
    --sy-ig-serif: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
    --sy-ig-sans: 'Raleway', Helvetica, Arial, sans-serif;

    display: grid;
    /* The panel takes a third, the photographs take the rest. */
    grid-template-columns: 1fr 2fr;
    align-items: stretch;

    /* Full-bleed: the whole point of moving the labelling into a panel is that
       the images can reach the edge of the screen. The theme sets
       body { overflow: hidden }, so 100vw cannot introduce a scrollbar. */
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    background: #ffffff;
}

/* --- Panel ----------------------------------------------------------------- */
.sy-instagram-aside {
    background: var(--sy-ig-cream);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: clamp(12px, 1.4vw, 20px);
    padding: clamp(40px, 5vw, 80px) clamp(24px, 4.5vw, 80px);
}

.sy-instagram-eyebrow {
    font-family: var(--sy-ig-sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 4.5px;
    text-transform: uppercase;
    color: var(--sy-ig-muted);
}

.sy-instagram-heading {
    margin: 0;
    font-family: var(--sy-ig-serif);
    font-size: clamp(34px, 3.6vw, 62px);
    font-weight: 300;
    line-height: 1.05;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--sy-ig-ink);
}

/* Rules either side of the label, matching the CTA treatment used elsewhere. */
.sy-instagram-btn {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    margin-top: clamp(4px, 0.8vw, 10px);
    font-family: var(--sy-ig-sans);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--sy-ig-ink);
    text-decoration: none;
    transition: color 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.sy-instagram-btn::before,
.sy-instagram-btn::after {
    content: "";
    width: 22px;
    height: 1px;
    background: currentColor;
    opacity: 0.6;
    transition: width 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.sy-instagram-btn:hover,
.sy-instagram-btn:focus-visible {
    color: var(--sy-ig-muted);
}

.sy-instagram-btn:hover::before,
.sy-instagram-btn:hover::after {
    width: 30px;
}

/* --- Grid ------------------------------------------------------------------ */
.sy-instagram-grid {
    display: grid;
    grid-template-columns: repeat(var(--sy-ig-cols, 4), 1fr);
    gap: 4px;
    padding-left: 4px;
}

/* --- Tile ------------------------------------------------------------------ */
.sy-instagram-tile {
    display: block;
    position: relative;
    overflow: hidden;
    background: #efece7;
    text-decoration: none;

    /* Scroll reveal — sections.js adds .sy-instagram-tile--visible */
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.9s cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
    transition-delay: calc((var(--sy-i, 1) - 1) * 0.06s);
}

.sy-instagram-tile--visible {
    opacity: 1;
    transform: translateY(0);
}

.sy-instagram-tile img {
    width: 100%;
    display: block;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    transition: transform 1.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.sy-instagram-tile:hover img,
.sy-instagram-tile:focus-visible img {
    transform: scale(1.06);
}

/* --- Hover scrim + inset hairline ------------------------------------------ */
.sy-instagram-hover {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(38, 33, 28, 0.28);
    opacity: 0;
    transition: opacity 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.sy-instagram-hover::before {
    content: "";
    position: absolute;
    inset: clamp(8px, 0.9vw, 14px);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.sy-instagram-tile:hover .sy-instagram-hover,
.sy-instagram-tile:focus-visible .sy-instagram-hover {
    opacity: 1;
}

/* --- Reel / carousel marker ------------------------------------------------
   Drawn in CSS rather than shipped as an icon file, and a sibling of the hover
   layer rather than a child: opacity on that layer would clamp the badge and
   hide it at rest. */
.sy-instagram-badge {
    position: absolute;
    top: clamp(9px, 1vw, 14px);
    right: clamp(9px, 1vw, 14px);
    width: 15px;
    height: 15px;
    /* Sits over the photo itself, so it needs its own contrast. */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
    pointer-events: none;
    z-index: 2;
}

.sy-instagram-badge--video::before {
    content: "";
    position: absolute;
    top: 1px;
    right: 0;
    border-style: solid;
    border-width: 6px 0 6px 10px;
    border-color: transparent transparent transparent #ffffff;
}

.sy-instagram-badge--carousel_album::before,
.sy-instagram-badge--carousel_album::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    border: 1.5px solid #ffffff;
}

.sy-instagram-badge--carousel_album::before {
    top: 0;
    right: 3px;
}

.sy-instagram-badge--carousel_album::after {
    top: 3px;
    right: 0;
    background: rgba(38, 33, 28, 0.35);
}

@media (prefers-reduced-motion: reduce) {
    .sy-instagram-tile {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .sy-instagram-tile img {
        transition: none;
    }
}

/* ==========================================================================
   RESPONSIVE

   Below 1024px the panel sits above the grid rather than beside it: a third of
   a tablet screen is not enough width for a serif heading, and squeezing it
   there costs the photographs more than it saves.
   ========================================================================== */

@media (max-width: 1024px) {
    .sy-instagram {
        grid-template-columns: 1fr;
    }

    .sy-instagram-aside {
        align-items: center;
        text-align: center;
        padding: clamp(36px, 6vw, 56px) 24px clamp(28px, 4vw, 40px);
    }

    .sy-instagram-grid {
        grid-template-columns: repeat(4, 1fr);
        padding-left: 0;
    }
}

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

    .sy-instagram-heading {
        font-size: 34px;
    }

    .sy-instagram-eyebrow {
        font-size: 10px;
        letter-spacing: 3.5px;
    }

    /* No hover on touch — show the frame at rest so tiles read as tappable. */
    .sy-instagram-hover {
        opacity: 1;
        background: transparent;
    }

    .sy-instagram-hover::before {
        opacity: 0.4;
    }
}
