/**
 * Front-end feed styles for AMG Instagram Feed.
 *
 * 2.4.0: the legacy dark-scheme fallbacks named below are superseded by the AMG
 * skin at the END of this file (token block near the top). The structural rules
 * in between are unchanged from 2.3.1.
 *
 * All colours flow from CSS custom properties set inline on .sif-feed by the
 * renderer, with the site's dark scheme as fallbacks so a feed is always
 * themed even if the inline vars are stripped by a cache/optimizer:
 *   --sif-bg          background (#2b2b2b)
 *   --sif-accent      accents: hover, arrows, lightbox chrome (#959D7A)
 *   --sif-columns     column count for grid/masonry/carousel
 *   --sif-gap         gutter between items (8px)
 *   --sif-radius      card corner radius (4px)
 *   --sif-card-height fixed card height; unset ⇒ natural / square ratio
 *   --sif-maxwidth    container max-width; unset ⇒ full width (none)
 *   --sif-caption-color   caption text colour: a custom colour (inline, from
 *                         the renderer) or the JS auto-contrast pick (#dcdcdc)
 *   --sif-caption-shadow  caption text-shadow colour, complemented to the
 *                         caption colour by the JS (dark behind light text)
 *
 * Every var has a fallback here so a feed renders correctly even if the inline
 * vars are stripped by a cache/optimizer. Everything is scoped under
 * .sif-feed / .sif-lightbox so it cannot leak into the theme (Kadence) or
 * other plugins.
 */

/* -------------------------------------------------------------------------
 * AMG design tokens (2.4.0). Each reads the site's Kadence palette slot and
 * falls back to the style-tile value, so the feed follows palette changes and
 * still themes correctly where the Kadence variables are absent. Values are
 * copied from plan/style-tile.html (:root) — slot order matches BRAND.md 1.3.
 * Fonts: the plugin loads none. Text inherits the site's fonts; only the
 * plugin's own buttons (which do not inherit by default) name a stack.
 * ---------------------------------------------------------------------- */
.sif-feed,
.sif-feed-notice,
.sif-lightbox {
	--amg-green:     var(--global-palette1, #394030); /* Primary green */
	--amg-sage:      var(--global-palette2, #7B8166); /* Sage */
	--amg-black:     var(--global-palette3, #010101); /* Black */
	--amg-olive:     var(--global-palette4, #2D3127); /* Deep olive (body text) */
	--amg-dark-sage: var(--global-palette5, #5B614B); /* Dark sage (muted text) */
	--amg-pale-sage: var(--global-palette6, #B0B898); /* Pale sage */
	--amg-tan:       var(--global-palette7, #E5E1D4); /* Tan */
	--amg-cream:     var(--global-palette8, #F4F0EC); /* Cream */
	--amg-card:      var(--global-palette9, #FAF8F3); /* Card tint */
	--amg-hairline:  rgba(123,129,102,.35);
	--amg-font-display: "Barlow Condensed","Arial Narrow",Arial,sans-serif;
	--amg-font-body:    "Barlow",system-ui,-apple-system,"Segoe UI",Arial,sans-serif;
}

.sif-feed {
	--sif-bg: #2b2b2b;
	--sif-accent: #959d7a;
	--sif-columns: 3;
	--sif-gap: 8px;
	--sif-radius: 4px;

	position: relative;
	box-sizing: border-box;
	background: var(--sif-bg);
	padding: var(--sif-gap);
	border-radius: 6px;
	max-width: var(--sif-maxwidth, none);
	margin-left: auto;
	margin-right: auto;
}

.sif-feed *,
.sif-lightbox * {
	box-sizing: border-box;
}

/* -------------------------------------------------------------------------
 * Item cell (shared)
 * ---------------------------------------------------------------------- */
.sif-item {
	margin: 0;
	padding: 0;
	position: relative;
}

/* 2.5.0: tiles are <figure>s, and themes such as Kadence give figures a
   margin through a descendant selector (.single-content figure, 0,1,1) that
   out-ranks the (0,1,0) reset above. (0,2,0) wins, and sits BEFORE the layout
   rules (.sif-masonry .sif-item, .sif-vertical .sif-item …) which are the same
   specificity and later, so their own margins still apply. */
.sif-feed .sif-item {
	margin: 0;
}

.sif-item__btn {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: #1e1e1e;
	cursor: pointer;
	overflow: hidden;
	border-radius: var(--sif-radius, 4px);
	position: relative;
}

.sif-item__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s ease, opacity 0.3s ease;
}

.sif-item__overlay {
	position: absolute;
	inset: 0;
	background: var(--sif-accent);
	opacity: 0;
	mix-blend-mode: multiply;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.sif-item__btn:hover .sif-item__img,
.sif-item__btn:focus-visible .sif-item__img {
	transform: scale(1.05);
}

.sif-item__btn:hover .sif-item__overlay,
.sif-item__btn:focus-visible .sif-item__overlay {
	opacity: 0.28;
}

.sif-item__btn:focus-visible {
	outline: 3px solid var(--sif-accent);
	outline-offset: 2px;
}

/* Play badge for videos (pure CSS triangle, no icon font). */
.sif-item__play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 46px;
	height: 46px;
	transform: translate(-50%, -50%);
	background: rgba(0, 0, 0, 0.45);
	border-radius: 50%;
	pointer-events: none;
}

.sif-item__play::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 54%;
	transform: translate(-50%, -50%);
	border-style: solid;
	border-width: 9px 0 9px 15px;
	border-color: transparent transparent transparent #fff;
}

/* Hover-preview video: created by the JS on mouse-enter and laid over the
   thumbnail inside the button. Removed on mouse-leave. */
.sif-item__video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	z-index: 1;
	background: #1e1e1e;
	pointer-events: none;
}

/* While previewing, hide the static play badge — the moving video reads as
   "this is a video" on its own. */
.sif-item.is-previewing .sif-item__play {
	display: none;
}

/* Optional caption under a card (shown only when the feed enables captions).
   Clamped to two lines so it never dominates the tile; the full caption is
   still available in the lightbox. */
.sif-item__caption {
	margin: 6px 2px 0;
	/* Caption colour: a custom colour or the JS auto-contrast value arrives via
	   --sif-caption-color; the fixed light grey is the fallback when neither is
	   set (auto-contrast off, no custom colour) or the inline var is stripped. */
	color: var(--sif-caption-color, #dcdcdc);
	font-size: 12px;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	word-break: break-word;
}

/* Optional drop shadow for legibility over busy images (Change 5). The shadow
   colour is complemented to the caption colour in JS (light text → dark shadow,
   dark text → light shadow); the fallback suits the default light caption. */
.sif-feed--caption-shadow .sif-item__caption {
	/* Layered halo so caption text stays readable even when the feed background
	   is nearly transparent (low bg opacity) and the page/image behind it is an
	   unknown colour. Both layers use the JS-set --sif-caption-shadow colour
	   (complemented to the text), with a strong opaque fallback. */
	text-shadow:
		0 1px 3px var(--sif-caption-shadow, rgba(0, 0, 0, 0.9)),
		0 0 6px var(--sif-caption-shadow, rgba(0, 0, 0, 0.7));
}

/* -------------------------------------------------------------------------
 * Content extras (v2.2): reel badge, engagement meta, caption links
 * ---------------------------------------------------------------------- */

/* Visually-hidden text for screen readers (prefixed so it never collides with a
   theme's own screen-reader class). */
.sif-sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Reel badge: a small labelled pill in the top-right corner, distinct from the
   centered play triangle. Shown for posts whose permalink looks like a reel when
   the feed enables the badge (best-effort/cosmetic). */
.sif-item__reel {
	position: absolute;
	top: 8px;
	right: 8px;
	padding: 2px 7px;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.45;
	letter-spacing: 0.02em;
	color: #fff;
	background: rgba(0, 0, 0, 0.62);
	border-radius: 4px;
	pointer-events: none;
	z-index: 2;
}

/* Engagement meta (likes + comments) under a card. Each metric is emitted only
   when the feed enables engagement AND Meta returned it — a null metric renders
   nothing, so this row may hold one stat, both, or (never emitted) none. */
.sif-item__meta {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 6px 2px 0;
	font-size: 12px;
	line-height: 1.4;
	color: var(--sif-caption-color, #dcdcdc);
}

.sif-item__likes,
.sif-item__comments {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

/* Like/comment glyphs: inline-SVG masks tinted to the current text colour — no
   icon font, no external asset (the SVG is a self-contained data URI). The same
   glyph artwork serves the card meta and the lightbox meta (v2.3). */
.sif-item__meta-icon,
.sif-lightbox__meta-icon {
	display: inline-block;
	width: 14px;
	height: 14px;
	flex: 0 0 auto;
	background-color: currentColor;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-position: center;
	-webkit-mask-size: contain;
	mask-size: contain;
}

/* Lightbox meta runs a larger type size (14px vs 12px); scale its icon up. */
.sif-lightbox__meta-icon {
	width: 16px;
	height: 16px;
}

.sif-item__meta-icon--like,
.sif-lightbox__meta-icon--like {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-7.5-4.9-10-9.3C.6 9 1.6 5.5 4.7 4.6 6.8 4 9 4.9 10 6.6c.4.6.7.9 2 .9s1.6-.3 2-.9c1-1.7 3.2-2.6 5.3-2C22.4 5.5 23.4 9 22 11.7 19.5 16.1 12 21 12 21z'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-7.5-4.9-10-9.3C.6 9 1.6 5.5 4.7 4.6 6.8 4 9 4.9 10 6.6c.4.6.7.9 2 .9s1.6-.3 2-.9c1-1.7 3.2-2.6 5.3-2C22.4 5.5 23.4 9 22 11.7 19.5 16.1 12 21 12 21z'/%3E%3C/svg%3E");
}

.sif-item__meta-icon--comment,
.sif-lightbox__meta-icon--comment {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3v4l4-4h7a2 2 0 0 0 2-2V6z'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3v4l4-4h7a2 2 0 0 0 2-2V6z'/%3E%3C/svg%3E");
}

/* Linkified caption tokens (#tags / @mentions), on both the card and lightbox.
   Coloured with the feed accent; underline on hover/focus only. */
.sif-item__caption-link,
.sif-lightbox__caption-link {
	color: var(--sif-accent, #959d7a);
	text-decoration: none;
}

.sif-item__caption-link:hover,
.sif-item__caption-link:focus,
.sif-lightbox__caption-link:hover,
.sif-lightbox__caption-link:focus {
	text-decoration: underline;
}

/* Lightbox engagement meta (populated by JS from the item's data-* counts). */
.sif-lightbox__meta {
	display: flex;
	align-items: center;
	gap: 18px;
	margin: 10px 0 0;
	font-size: 14px;
	color: #f2f2f2;
}

/* Keep [hidden] authoritative even though the base rule sets display:flex. */
.sif-lightbox__meta[hidden] {
	display: none;
}

.sif-lightbox__likes,
.sif-lightbox__comments {
	display: inline-flex;
	align-items: center;
	gap: 5px;
}

/* -------------------------------------------------------------------------
 * Grid layout
 * ---------------------------------------------------------------------- */
.sif-grid {
	display: grid;
	grid-template-columns: repeat(var(--sif-columns), minmax(0, 1fr));
	gap: var(--sif-gap);
}

/* The media tile carries the square (or fixed-height) shape, so an optional
   caption can flow beneath it without distorting the image. When
   --sif-card-height is unset the aspect-ratio governs; when it is set, the
   explicit height wins and the width stays the grid track. */
.sif-grid .sif-item__btn {
	aspect-ratio: 1 / 1;
	height: var(--sif-card-height, auto);
}

/* -------------------------------------------------------------------------
 * Masonry layout — CSS columns, no JS, no external library.
 * ---------------------------------------------------------------------- */
.sif-masonry {
	column-count: var(--sif-columns);
	column-gap: var(--sif-gap);
}

.sif-masonry .sif-item {
	break-inside: avoid;
	margin-bottom: var(--sif-gap);
	display: inline-block; /* helps some engines avoid column breaks */
	width: 100%;
}

/* Masonry keeps each image's natural ratio by default; a fixed card height,
   when set, crops uniformly via object-fit: cover. */
.sif-masonry .sif-item__img {
	height: var(--sif-card-height, auto);
}

/* Masonry buttons must NOT inherit the base .sif-item__btn { height: 100% }.
   In a sparse (single-row flex) masonry, a stretched figure gets a definite
   height, and a 100%-height button would then consume the whole figure and push
   the caption out below the feed background (the clipping bug). A natural /
   card-height button keeps the image and its caption together inside the feed. */
.sif-masonry .sif-item__btn {
	height: var(--sif-card-height, auto);
}

/* -------------------------------------------------------------------------
 * Item body (v2.2): wraps the date + engagement meta + caption. A transparent
 * block under the media in grid/masonry/hero; the text column beside the
 * thumbnail in List view.
 * ---------------------------------------------------------------------- */
.sif-item__body {
	min-width: 0; /* let flex/grid children shrink and wrap instead of overflow */
}

/* Post date shown in List view (other layouts don't emit it). */
.sif-item__date {
	display: block;
	margin: 2px 2px 4px;
	font-size: 11px;
	letter-spacing: 0.02em;
	opacity: 0.75;
	color: var(--sif-caption-color, #dcdcdc);
}

/* -------------------------------------------------------------------------
 * Hero + Grid layout (v2.2) — the first post spans the full width above the
 * rest, which flow as the normal grid. Reuses the grid engine.
 * ---------------------------------------------------------------------- */
.sif-hero {
	display: grid;
	grid-template-columns: repeat(var(--sif-columns), minmax(0, 1fr));
	gap: var(--sif-gap);
}

.sif-hero .sif-item__btn {
	aspect-ratio: 1 / 1;
	height: var(--sif-card-height, auto);
}

/* The hero item spans every column and takes a wide, cinematic ratio.
   v2.3 options: a PARTIAL span (1..columns-1) arrives as --sif-hero-span +
   the sif-feed--hero-span modifier, letting normal cards fill the columns
   beside the hero; --sif-hero-height is a CAP on the hero media, and the
   ratio lock decides whether 16/9 survives it (sif-feed--hero-free = lock
   off → ratio released, the hero fills its given height freely). */
.sif-hero .sif-item--hero {
	grid-column: 1 / -1;
}

.sif-feed--hero-span .sif-hero .sif-item--hero {
	grid-column: span var(--sif-hero-span, 1);
}

.sif-hero .sif-item--hero .sif-item__btn {
	aspect-ratio: 16 / 9;
	height: var(--sif-card-height, auto);
	max-height: var(--sif-hero-height, none);
}

.sif-feed--hero-free .sif-hero .sif-item--hero .sif-item__btn {
	aspect-ratio: auto;
	height: var(--sif-hero-height, var(--sif-card-height, auto));
}

/* -------------------------------------------------------------------------
 * List layout (v2.2) — compact rows: thumbnail + text column (date, caption,
 * engagement meta). Reuses the item markup + lightbox contract.
 * v2.3: --sif-list-maxwidth (a layout option) caps and centers the LIST
 * ITSELF — distinct from --sif-maxwidth, which caps the whole feed wrapper.
 * Unset (option 0) falls back to none = today's full-width behavior.
 * ---------------------------------------------------------------------- */
.sif-list {
	display: flex;
	flex-direction: column;
	gap: var(--sif-gap);
	max-width: var(--sif-list-maxwidth, none);
	margin-left: auto;
	margin-right: auto;
}

.sif-list .sif-item {
	display: flex;
	align-items: flex-start;
	gap: 14px;
}

/* The media becomes a fixed-size thumbnail; the text column takes the rest. */
.sif-list .sif-item__btn {
	flex: 0 0 auto;
	width: 112px;
	aspect-ratio: 1 / 1;
	height: var(--sif-card-height, auto);
	border-radius: var(--sif-radius);
	overflow: hidden;
}

.sif-list .sif-item__body {
	flex: 1 1 auto;
	align-self: center;
}

/* In a row the caption can breathe to more lines than a grid tile. */
.sif-list .sif-item__caption {
	-webkit-line-clamp: 3;
	font-size: 13px;
}

.sif-list .sif-item__date {
	margin-top: 0;
}

/* -------------------------------------------------------------------------
 * Load-more (v2.2, client-side reveal) — overflow items are hidden ONLY once
 * the JS marks the feed collapsed (progressive enhancement: no JS ⇒ all shown).
 * ---------------------------------------------------------------------- */
.sif-feed.is-collapsed .sif-item--overflow {
	display: none;
}

.sif-loadmore {
	display: flex;
	justify-content: center;
	margin-top: calc(var(--sif-gap) + 4px);
}

.sif-loadmore__btn {
	padding: 8px 22px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	color: #fff;
	background: transparent;
	border: 2px solid var(--sif-accent, #959d7a);
	border-radius: 6px;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.sif-loadmore__btn:hover,
.sif-loadmore__btn:focus-visible {
	background: var(--sif-accent, #959d7a);
	color: var(--sif-bg, #2b2b2b);
}

.sif-loadmore__btn:focus-visible {
	outline: 3px solid var(--sif-accent, #959d7a);
	outline-offset: 2px;
}

/* [hidden] must always win: the button starts hidden (JS reveals it only when
   there is an overflow pool) and hides again when the pool is exhausted. In the
   carousel's in-track placement this is also what removes the cell from the
   flex flow — no ghost snap stop, no empty gap. */
.sif-loadmore__btn[hidden] {
	display: none;
}

/* In-track placement (carousel, v2.3): the button itself is the track's last
   snap cell, sized exactly like a card so it appears where the next photo
   would when scrolling. */
.sif-carousel .sif-loadmore__btn--intrack {
	flex: 0 0 auto;
	width: calc((100% - (var(--sif-columns) - 1) * var(--sif-gap)) / var(--sif-columns));
	aspect-ratio: 1 / 1;
	height: var(--sif-card-height, auto);
	scroll-snap-align: start;
	border-radius: var(--sif-radius);
	margin: 0;
}

/* -------------------------------------------------------------------------
 * Vertical scroll layout (redesigned in v2.3) — Instagram-native single
 * column that scrolls WITHIN the feed: a fixed-height overflow-y container
 * (a carousel turned 90°), NOT a paginated feed — load-more is ignored for
 * this layout. --sif-vert-maxheight comes from the renderer when the card
 * height makes it computable in PHP, or is measured by JS from the first
 * item when the card height is auto; with neither (no JS + auto height) the
 * column simply renders uncapped and scrolls with the page. The scrollbar is
 * themed by the shared rule below, next to the carousel's.
 * ---------------------------------------------------------------------- */
.sif-vertical {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--sif-gap);
	overflow-y: auto;
	max-height: var(--sif-vert-maxheight, none);
}

.sif-vertical .sif-item {
	width: 100%;
	max-width: var(--sif-vert-maxwidth, 470px); /* Instagram-like column width. */
}

.sif-vertical .sif-item__btn {
	aspect-ratio: 1 / 1;
	height: var(--sif-card-height, auto);
	border-radius: var(--sif-radius);
	overflow: hidden;
}

/* -------------------------------------------------------------------------
 * Carousel layout — scroll-snap track + prev/next buttons.
 * ---------------------------------------------------------------------- */
.sif-carousel {
	display: flex;
	gap: var(--sif-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	/* A little breathing room so the themed bar doesn't crowd the last row. */
	padding-bottom: 2px;
}

/* Themed scrollbar — SHARED by both scroll containers (v2.3): the carousel's
   horizontal track and the vertical layout's column. Accent thumb on the feed
   background (the feed's own custom props), not the default light-on-dark bar.
   Firefox first, then WebKit/Blink. */
.sif-carousel,
.sif-vertical {
	scrollbar-width: thin;
	scrollbar-color: var(--sif-accent, #959d7a) var(--sif-bg, #2b2b2b);
}

.sif-carousel::-webkit-scrollbar,
.sif-vertical::-webkit-scrollbar {
	height: 8px; /* horizontal bar (carousel) */
	width: 8px;  /* vertical bar (vertical layout) */
}

.sif-carousel::-webkit-scrollbar-track,
.sif-vertical::-webkit-scrollbar-track {
	background: var(--sif-bg, #2b2b2b);
	border-radius: 8px;
}

.sif-carousel::-webkit-scrollbar-thumb,
.sif-vertical::-webkit-scrollbar-thumb {
	background: var(--sif-accent, #959d7a);
	border-radius: 8px;
	/* Inset the thumb slightly from the track using a transparent border. */
	border: 2px solid var(--sif-bg, #2b2b2b);
}

.sif-carousel::-webkit-scrollbar-thumb:hover,
.sif-vertical::-webkit-scrollbar-thumb:hover {
	background: var(--sif-accent, #959d7a);
	border-width: 1px;
}

.sif-carousel .sif-item {
	flex: 0 0 auto;
	width: calc((100% - (var(--sif-columns) - 1) * var(--sif-gap)) / var(--sif-columns));
	scroll-snap-align: start;
}

.sif-carousel .sif-item__btn {
	aspect-ratio: 1 / 1;
	height: var(--sif-card-height, auto);
}

/* Outline-only nav buttons: no filled circle, larger glyph, a subtle grey
   border so they read over both light and dark content. A soft text-shadow
   keeps the glyph legible over bright image content without a filled backing. */
.sif-carousel__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 50px;
	height: 50px;
	/* The glyph paints low within its line box, so flex-centering the box alone
	   leaves the ink sitting below centre. A small em-scaled bottom padding
	   lifts the centring region to optically centre the glyph. */
	padding: 0 0 0.08em;
	/* Border uses the feed accent (opacity-aware: --sif-accent is composed as
	   RGBA from the accent colour + its opacity), so the accent-opacity control
	   reaches the buttons. When accent opacity is low the border fades, but the
	   layered glyph halo below keeps the arrow readable. */
	border: 2px solid var(--sif-accent, #959d7a);
	border-radius: 50%;
	background: transparent;
	color: #fff;
	font-size: 42px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.95;
	/* Layered dark halo so the white glyph stays legible over bright image
	   content, not just dark. */
	text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.6);
	transition: opacity 0.2s ease, border-color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.sif-carousel__nav:hover,
.sif-carousel__nav:focus-visible {
	opacity: 1;
	border-color: var(--sif-accent, #959d7a);
}

.sif-carousel__nav:focus-visible {
	outline: 2px solid var(--sif-accent, #959d7a);
	outline-offset: 2px;
}

.sif-carousel__nav--prev { left: 6px; }
.sif-carousel__nav--next { right: 6px; }

/* Hidden by JS when the track has no scrollable overflow (all posts fit). */
.sif-carousel__nav.is-hidden { display: none; }

/* At the start / end of the track (2.5.0): dimmed, still focusable, a click
   does nothing (aria-disabled, not the disabled attribute, so keyboard focus
   is never lost when the end is reached). */
.sif-carousel__nav.is-disabled,
.sif-carousel__nav.is-disabled:hover,
.sif-carousel__nav.is-disabled:focus-visible {
	opacity: 0.35;
	cursor: default;
}

/* -------------------------------------------------------------------------
 * Sparse feeds — center the items when there are fewer posts than would fill
 * one row (grid/masonry) or the visible carousel width. The renderer adds
 * .sif-feed--sparse only in that case, so these rules never touch a full,
 * multi-row layout. Each item keeps its normal column width:
 *   (100% - (columns - 1) * gap) / columns.
 * ---------------------------------------------------------------------- */

/* Grid: auto-fit collapses the empty trailing tracks, and justify-content
   centers the filled ones. The track max equals the normal column width, so
   the cards stay the same size as a full row. */
.sif-feed--sparse .sif-grid {
	grid-template-columns: repeat(
		auto-fit,
		minmax(0, calc((100% - (var(--sif-columns) - 1) * var(--sif-gap)) / var(--sif-columns)))
	);
	justify-content: center;
}

/* Masonry: a sparse feed is by definition a single row (at most one item per
   column), so switching the CSS-columns flow to a centered flex row is safe
   here — it can never collapse a multi-row masonry, which stays untouched
   because it never carries .sif-feed--sparse. */
.sif-feed--sparse .sif-masonry {
	column-count: initial;
	display: flex;
	justify-content: center;
	/* Top-align (don't stretch) so each figure keeps its natural height — image
	   plus caption — rather than being stretched to a definite row height that
	   would clip the caption. */
	align-items: flex-start;
	gap: var(--sif-gap);
}

.sif-feed--sparse .sif-masonry .sif-item {
	display: block;
	width: calc((100% - (var(--sif-columns) - 1) * var(--sif-gap)) / var(--sif-columns));
	margin-bottom: 0;
}

/* Carousel (2.5.0): centre the tiles only when they all fit. justify-content:
   center on a track that OVERFLOWS (a phone showing 2 or 2.5 tiles of 3–5 posts)
   pushes the overflow off the start edge, where scrolling cannot reach it. Two
   zero-width spacers with auto margins on their OUTER sides do the same job
   without that flaw: free space is split between them when there is some, and
   the margins are 0 when the tiles overflow. The inner margin cancels the flex
   gap each spacer would otherwise add. Pseudo-elements, so the markup and
   :first-child/:last-child tests are untouched, and they stay first and last
   whatever the track holds (hidden load-more tiles, the in-track button). */
.sif-carousel::before,
.sif-carousel::after {
	content: "";
	flex: 0 0 0;
}
.sif-carousel::before {
	margin-left: auto;
	margin-right: calc(-1 * var(--sif-gap, 12px));
}
.sif-carousel::after {
	margin-right: auto;
	margin-left: calc(-1 * var(--sif-gap, 12px));
}

/* -------------------------------------------------------------------------
 * Admin-only notice (empty / error states)
 * ---------------------------------------------------------------------- */
.sif-feed-notice {
	padding: 12px 14px;
	background: #fff3cd;
	border: 1px solid #ffe69c;
	border-radius: 4px;
	color: #664d03;
	font-size: 14px;
}

/* -------------------------------------------------------------------------
 * Lightbox
 * ---------------------------------------------------------------------- */
/* 2.5.0: the JS moves the open lightbox to <body> (a portal), so no theme
   stacking context can trap it. 100001 sits above Kadence's mobile drawer
   (100000) and the admin bar (99999). Nothing here may depend on a .sif-feed
   ancestor: while open it has none. */
.sif-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100001;
	overscroll-behavior: contain;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.92);
	padding: 4vh 4vw;
}

.sif-lightbox.is-open {
	display: flex;
}

/* The media area is capped so it never slides under the prev/next buttons: the
   `calc(100vw - 165px)` term reserves ~70px of clearance on each side for the
   nav controls, while 92vw remains the cap on very wide screens. */
.sif-lightbox__figure {
	margin: 0;
	max-width: min(92vw, calc(100vw - 165px));
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
}

.sif-lightbox__stage {
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: min(92vw, calc(100vw - 165px));
	max-height: 78vh;
}

.sif-lightbox__stage img,
.sif-lightbox__stage video {
	max-width: min(92vw, calc(100vw - 165px));
	max-height: 78vh;
	width: auto;
	height: auto;
	border-radius: 4px;
	display: block;
}

.sif-lightbox__caption {
	color: #eee;
	font-size: 14px;
	line-height: 1.5;
	max-width: 720px;
	text-align: center;
	max-height: 4.5em;
	overflow: auto;
	overscroll-behavior: contain;
	/* In <body> the lightbox no longer inherits the theme's content word-break
	   (Kadence .entry-content), so a long unbroken tag or URL wraps here. */
	overflow-wrap: anywhere;
	/* Keep an overflowing caption's scrollbar on-theme, not light-on-dark. */
	scrollbar-width: thin;
	scrollbar-color: var(--sif-accent, #959d7a) transparent;
}

.sif-lightbox__permalink {
	color: var(--sif-accent, #959d7a);
	font-size: 13px;
	text-decoration: none;
	font-weight: 600;
}

.sif-lightbox__permalink:hover {
	text-decoration: underline;
}

/* Lightbox controls (close + prev/next). All three share one rule so they are
   sized identically; the glyph is centered with flexbox (not line-height/font
   metrics), which keeps the ×, ‹ and › optically centered on every viewport.
   Offsets are fixed pixels so the buttons land in the same place regardless of
   viewport width. Outline-only: no filled circle, a subtle grey border and a
   larger glyph. They sit over the dark lightbox backdrop, so the white glyph
   stays legible without a fill. */
.sif-lightbox__close,
.sif-lightbox__nav {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	/* Optical centring is per-glyph (see the __close / __nav rules): the ×
	   already sits near-centre while the ‹ › chevrons paint low, so the
	   em-scaled bottom padding that lifts them is applied per class, not here. */
	padding: 0;
	margin: 0;
	/* Accent-coloured, opacity-aware border (see the carousel nav note). */
	border: 2px solid var(--sif-accent, #959d7a);
	border-radius: 50%;
	background: transparent;
	color: #fff;
	line-height: 1;
	cursor: pointer;
	/* Layered dark halo: the media can fill most of the viewport, so the glyph
	   must stay legible over bright media, not just the dark backdrop. */
	text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.6);
	transition: border-color 0.2s ease, background 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.sif-lightbox__close:hover,
.sif-lightbox__nav:hover,
.sif-lightbox__close:focus-visible,
.sif-lightbox__nav:focus-visible {
	border-color: var(--sif-accent, #959d7a);
	background: rgba(255, 255, 255, 0.08);
}

.sif-lightbox__close:focus-visible,
.sif-lightbox__nav:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* Glyph sizes: the close × and the chevrons have different metrics, so the
   chevrons are set a touch larger to read at the same visual weight while the
   button boxes stay identical. */
.sif-lightbox__close {
	top: 14px;
	right: 14px;
	font-size: 48px;
	/* The × already renders near-centre; only a hair of lift is needed, and
	   more (e.g. the chevrons' 0.08em) visibly pushes it too high. */
	padding-bottom: 0.02em;
}

.sif-lightbox__nav {
	top: 50%;
	transform: translateY(-50%);
	font-size: 56px;
	/* The ‹ › chevrons paint low; lift them to optical centre (em-scaled, so it
	   holds at the ≤480px size below). Matches the carousel nav chevrons. */
	padding-bottom: 0.08em;
}

.sif-lightbox__nav--prev { left: 14px; }
.sif-lightbox__nav--next { right: 14px; }

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
	.sif-item__img,
	.sif-item__overlay,
	.sif-carousel {
		transition: none;
		scroll-behavior: auto;
	}
}

/* Small screens: shrink the lightbox controls together (kept consistent) and
   tuck them closer to the edges so they don't crowd the media. */
@media (max-width: 480px) {
	.sif-lightbox__close,
	.sif-lightbox__nav {
		width: 50px;
		height: 50px;
	}
	.sif-lightbox__close { top: 8px; right: 8px; font-size: 40px; }
	.sif-lightbox__nav { font-size: 46px; }
	.sif-lightbox__nav--prev { left: 8px; }
	.sif-lightbox__nav--next { right: 8px; }
	/* List (v2.3): on phones a row STACKS — the thumbnail expands to the full
	   row width and the text column (date, caption, engagement meta) moves
	   below it, replacing the old 84px-thumbnail squeeze. Default behavior,
	   not an option. */
	.sif-list .sif-item {
		flex-direction: column;
		gap: 8px;
	}
	.sif-list .sif-item__btn { width: 100%; }
	.sif-list .sif-item__body { align-self: stretch; }
}

/* =========================================================================
 * AMG skin (2.4.0) — colour, radius and type only. Every structural / layout
 * rule above is untouched; this section is appended so it wins at equal
 * specificity. Variables the renderer emits inline (a non-default colour, gap
 * or radius a user chose) still override these defaults — see
 * SIF_Renderer::render(): stored legacy and AMG-default values are NOT emitted.
 * ========================================================================= */

/* Container: the Card tint panel (BRAND card: tint fill, 1px hairline, 16px). */
.sif-feed {
	--sif-bg: var(--amg-card);
	--sif-accent: var(--amg-green);
	--sif-gap: 12px;
	--sif-radius: 8px;
	background: var(--sif-bg);
	border: 1px solid var(--amg-hairline);
	border-radius: 16px;
	padding: 16px;
}

/* Media tile backing while the image loads. */
.sif-item__btn { background: var(--amg-tan); }

/* Captions, dates, engagement. The caption colour honours a custom colour or
   the JS auto-contrast pick (--sif-caption-color); Deep olive is the default. */
.sif-item__caption {
	color: var(--sif-caption-color, var(--amg-olive));
	font-size: 15px;
	line-height: 1.45;
}
.sif-item__date,
.sif-item__likes,
.sif-item__comments { color: var(--amg-dark-sage); font-weight: 500; opacity: 1; }
.sif-item__caption-link { color: var(--amg-green); font-weight: 600; text-decoration: underline; }
.sif-item__caption-link:hover,
.sif-item__caption-link:focus { color: var(--amg-black); }
.sif-list .sif-item__caption { font-size: 16px; }

/* Reel badge = the tile's "Striking" tag (Cream on Black, 6px radius). */
.sif-item__reel {
	background: var(--amg-black);
	color: var(--amg-cream);
	border-radius: 6px;
	padding: 4px 9px;
	font-family: var(--amg-font-display);
	font-weight: 700;
	font-size: 13px;
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

/* Load-more = the tile's secondary button on Cream. */
.sif-loadmore__btn {
	min-height: 48px;
	padding: 0 24px;
	font-family: var(--amg-font-display);
	font-weight: 700;
	font-size: clamp(18px, 17.586px + 0.1105vw, 19px);
	line-height: 1;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--amg-green);
	background: transparent;
	border: 2px solid var(--amg-green);
	border-radius: 8px;
}
.sif-loadmore__btn:hover { background: var(--amg-green); color: var(--amg-cream); }
.sif-loadmore__btn:active { background: var(--amg-black); border-color: var(--amg-black); color: var(--amg-cream); }
.sif-loadmore__btn:focus-visible { outline: 2px solid var(--amg-green); outline-offset: 3px; background: transparent; color: var(--amg-green); }
.sif-loadmore__btn:hover:focus-visible { background: var(--amg-green); color: var(--amg-cream); }
.sif-carousel .sif-loadmore__btn--intrack { border-radius: var(--sif-radius); }

/* Carousel arrows: Card-tint disc, Primary green ring + glyph (legible over any
   photo). The glyph buttons name the body stack so ‹ › × keep the metrics the
   centring offsets were tuned for. */
.sif-carousel__nav {
	font-family: var(--amg-font-body);
	background: rgba(250, 248, 243, 0.92);
	border: 2px solid var(--amg-green);
	color: var(--amg-green);
	text-shadow: none;
}
.sif-carousel__nav--prev { left: 22px; }
.sif-carousel__nav--next { right: 22px; }
.sif-carousel__nav:hover,
.sif-carousel__nav:focus-visible { background: var(--amg-green); border-color: var(--amg-green); color: var(--amg-cream); }
.sif-carousel__nav:focus-visible { outline: 2px solid var(--amg-cream); outline-offset: 2px; }

/* Themed scrollbars: Sage thumb on Tan. */
.sif-carousel,
.sif-vertical { scrollbar-color: var(--amg-sage) var(--amg-tan); }
.sif-carousel::-webkit-scrollbar-track,
.sif-vertical::-webkit-scrollbar-track { background: var(--amg-tan); }
.sif-carousel::-webkit-scrollbar-thumb,
.sif-vertical::-webkit-scrollbar-thumb { background: var(--amg-sage); border-color: var(--amg-tan); }

/* Empty / error notice (admins only) = the tile's Tan banner. */
.sif-feed-notice {
	background: var(--amg-tan);
	border: 0;
	border-radius: 12px;
	padding: 14px 18px;
	color: var(--amg-olive);
	font-weight: 500;
	font-size: 15px;
	line-height: 1.5;
}

/* Lightbox = the tile's "on Black" context. */
.sif-lightbox { background: rgba(1, 1, 1, 0.92); }
.sif-lightbox__caption { color: var(--amg-cream); font-size: 16px; line-height: 1.5; scrollbar-color: var(--amg-sage) transparent; }
.sif-lightbox__caption-link { color: var(--amg-pale-sage); font-weight: 600; text-decoration: underline; }
.sif-lightbox__caption-link:hover,
.sif-lightbox__caption-link:focus { color: var(--amg-cream); }
.sif-lightbox__meta,
.sif-lightbox__likes,
.sif-lightbox__comments { color: var(--amg-pale-sage); }
.sif-lightbox__close,
.sif-lightbox__nav {
	font-family: var(--amg-font-body);
	color: var(--amg-cream);
	border: 2px solid var(--amg-cream);
	background: transparent;
	text-shadow: none;
}
/* The base :hover/:focus-visible rules set border-color to the accent at higher
   specificity, so the Cream border is restated on every state. */
.sif-lightbox__close:hover,
.sif-lightbox__nav:hover { background: var(--amg-cream); border-color: var(--amg-cream); color: var(--amg-black); }
.sif-lightbox__close:focus-visible,
.sif-lightbox__nav:focus-visible { border-color: var(--amg-cream); outline: 2px solid var(--amg-cream); outline-offset: 3px; background: transparent; color: var(--amg-cream); }
.sif-lightbox__close:hover:focus-visible,
.sif-lightbox__nav:hover:focus-visible { border-color: var(--amg-cream); background: var(--amg-cream); color: var(--amg-black); }
/* The taller permalink button needs room: shorten the media stage a little and
   stop the caption/meta/button flex-shrinking (the base rules let the caption
   collapse to ~3px at 1440x900 once the button grew to 44px). */
.sif-lightbox__stage,
.sif-lightbox__stage img,
.sif-lightbox__stage video { max-height: 66vh; }
.sif-lightbox__meta,
.sif-lightbox__caption,
.sif-lightbox__permalink { flex: none; }
/* "View on Instagram" = the tile's primary button on Black (Sage fill, Black text). */
.sif-lightbox__permalink {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 0 22px;
	border-radius: 8px;
	background: var(--amg-sage);
	color: var(--amg-black);
	font-family: var(--amg-font-display);
	font-weight: 700;
	font-size: 18px;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	text-decoration: none;
}
.sif-lightbox__permalink:hover { background: var(--amg-pale-sage); color: var(--amg-black); text-decoration: none; }
.sif-lightbox__permalink:focus-visible { outline: 2px solid var(--amg-cream); outline-offset: 3px; }
/* 2.5.0: the stage's last resort when the image (or video) cannot load. */
.sif-lightbox__unavailable {
	margin: 0;
	padding: 24px 28px;
	border: 1px solid var(--amg-sage);
	border-radius: 8px;
	color: var(--amg-cream);
	font-size: 16px;
	line-height: 1.5;
	text-align: center;
}
/* A failed video shows its poster with the note beneath it (the stage holds
   one child otherwise, so the direction changes nothing else). */
.sif-lightbox__stage { flex-direction: column; }
.sif-lightbox__stage img + .sif-lightbox__unavailable { padding: 8px 14px; margin-top: 10px; }

/* -------------------------------------------------------------------------
 * Narrow viewports (below 600px): grid, masonry, hero and carousel show at most
 * 2 columns (--sif-columns-narrow is min(columns, 2), computed by the renderer),
 * and the carousel arrows are hidden so they never cover media or captions —
 * touch swipes, and the themed scrollbar shows position. A viewport query, not a
 * container query: the feed element contains the fixed-position lightbox, and a
 * query container would re-anchor it. Lists and the vertical column are
 * single-column already.
 * ---------------------------------------------------------------------- */
@media (max-width: 599px) {
	.sif-grid,
	.sif-hero { grid-template-columns: repeat(var(--sif-columns-narrow, 2), minmax(0, 1fr)); }
	.sif-masonry { column-count: var(--sif-columns-narrow, 2); }
	.sif-carousel .sif-item,
	.sif-carousel .sif-loadmore__btn--intrack {
		width: calc((100% - (var(--sif-columns-narrow, 2) - 1) * var(--sif-gap)) / var(--sif-columns-narrow, 2));
	}
	.sif-feed--hero-span .sif-hero .sif-item--hero { grid-column: 1 / -1; }
	.sif-carousel__nav { display: none; }

	/* Sparse feeds on a phone (2.5.0): the desktop sparse rules above are
	   sized from --sif-columns and out-rank the phone rules, so a sparse grid or
	   masonry kept desktop-width columns (1/6 of the width at 6 columns). Same
	   technique, sized from the narrow count. */
	.sif-feed--sparse .sif-grid {
		grid-template-columns: repeat(
			auto-fit,
			minmax(0, calc((100% - (var(--sif-columns-narrow, 2) - 1) * var(--sif-gap)) / var(--sif-columns-narrow, 2)))
		);
	}
	.sif-feed--sparse .sif-masonry {
		flex-wrap: wrap;
	}
	.sif-feed--sparse .sif-masonry .sif-item {
		width: calc((100% - (var(--sif-columns-narrow, 2) - 1) * var(--sif-gap)) / var(--sif-columns-narrow, 2));
	}
}
