/* Godam Feed — Instagram-style scrollable feed */

.godam-feed {
	/*
	 * Feed cards are intentionally dark regardless of system theme — Hotstar/Reels look.
	 * Only the accent (heart, lock CTA) follows the theme palette so the brand
	 * color stays consistent if the site owner changes Primary in Site Editor.
	 *
	 * `.godam-feed` is the block instance; `.godam-feed__inner` is the layout
	 * container. Keeping them separate means the parent (Ollie's entry-content)
	 * can drop its padding without leaving cards flush to the screen edge — the
	 * inner container owns the gutter and the parent can't cancel it.
	 */
	--gf-bg: #0f0f12;
	--gf-text: #f3f4f6;
	--gf-muted: #9ca3af;
	--gf-border: rgba(255, 255, 255, 0.08);
	--gf-accent: var(--wp--preset--color--primary, #ed4956);
	--gf-radius: 12px;
	--gf-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);

	color: var(--gf-text);
	font-family: inherit;
	/* Mobile Safari/Chrome paint a translucent gray box on tap; suppressing it
	   saves a paint pass per tap. Doesn't affect focus rings. */
	-webkit-tap-highlight-color: transparent;
}

/* The layout container: Instagram-web's column — capped at 470px on large
   screens and centered. On large screens there's no inner gutter (the column
   is the media width); on phones a hairline 4px gutter is added in the mobile
   override below so media sits nearly edge-to-edge. */
.godam-feed__inner {
	max-width: 470px;
	margin-inline: auto;
	padding-inline: 0;
}

/* Beats WP's constrained-layout default on the block wrapper. */
.godam-feed.wp-block-godam-feed,
.godam-feed.wp-block-godam-feed.alignwide,
.godam-feed.wp-block-godam-feed.alignfull {
	max-width: none;
}

.godam-feed__list {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* --- Outer chrome around the feed -----------------------------------------
   Ollie's page.html wraps the feed in <main> with `xx-large` vertical padding
   and an `entry-content has-global-padding` with horizontal padding. For an
   IG-style feed that's far too generous — cards are already self-contained.
   Scope the override via `:has(.godam-feed)` so we only affect pages that
   actually host the feed block. */
main:has(.godam-feed) {
	padding-top: var(--wp--preset--spacing--small, 1rem) !important;
	padding-bottom: var(--wp--preset--spacing--small, 1rem) !important;
}
/* `.has-global-padding` (on <main> and the post-content wrapper) injects the
   root horizontal padding — redundant here since the feed owns its own gutter
   and 470px centering. Strip it on any global-padding ancestor of the feed.
   `:has(.godam-feed)` keeps this scoped to the feed page; the descendant
   selector raises specificity above the theme's `.has-global-padding`, and the
   `!important` matches the vertical override above so theme source-order can't
   reassert it. */
.has-global-padding:has(.godam-feed) {
	padding-inline: 0 !important;
}
.wp-block-post-content:has(> .godam-feed) {
	padding-block: 0;
}

@media (max-width: 600px) {
	/* Drop the entry-content's horizontal padding so it doesn't compound with
	   the feed's own gutter, then add just a hairline 4px gutter on the inner
	   so media reads as nearly edge-to-edge (Instagram-on-mobile) without being
	   flush against the screen. */
	.wp-block-post-content:has(> .godam-feed) {
		padding-inline: 0;
	}
	.godam-feed__inner {
		padding-inline: 4px;
	}
	.godam-feed__list {
		gap: 12px;
	}
	/* Mobile paint budget is tight. `box-shadow` and `border` each force the
	   GPU to do extra rasterization work for every visible card on every scroll
	   frame; the gap between cards reads as separation on its own. Keep the
	   border-radius (cheap once a card has its own paint container). */
	.godam-feed-card {
		box-shadow: none;
		border: 0;
	}
}

.godam-feed__status {
	text-align: center;
	color: var(--gf-muted);
	font-size: 0.9rem;
	padding: 24px 0;
	margin: 0;
}

.godam-feed__empty {
	text-align: center;
	color: var(--gf-muted);
	font-size: 1rem;
	padding: 64px 24px;
	margin: 0;
}

.godam-feed__sentinel {
	height: 1px;
}

/* Card */
.godam-feed-card {
	background: var(--gf-bg);
	border: 1px solid var(--gf-border);
	border-radius: var(--gf-radius);
	box-shadow: var(--gf-shadow);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	/* Skip rendering work for off-screen cards entirely. `contain-intrinsic-size`
	   reserves a sensible height so the scrollbar isn't jumpy before the card
	   has been measured once — the `auto` keyword tells the browser to cache
	   the real measured size after first reveal. */
	content-visibility: auto;
	contain-intrinsic-size: auto 720px;
	/* Isolate layout + paint so changes inside one card can't invalidate the
	   render tree of its siblings. */
	contain: layout paint style;
}

.godam-feed-card__header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
}

.godam-feed-card__avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	background: #1f2937;
}

.godam-feed-card__who {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.godam-feed-card__name {
	font-weight: 600;
	font-size: 0.92rem;
	line-height: 1.2;
}

.godam-feed-card__location {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	color: var(--gf-muted);
	font-size: 0.78rem;
	line-height: 1.2;
	margin-top: 2px;
}

.godam-feed-card__location svg {
	width: 12px;
	height: 12px;
}

/* Media — Instagram-style clamped-aspect feed.
   Each post commits to its OWN display ratio (width ÷ height), clamped
   server-side to Instagram's 4:5 … 1.91:1 range and passed in as `--gf-ratio`.
   `object-fit: cover` fills the box and crops anything outside that range.
   The box is reserved from the ratio before any pixels arrive → zero CLS.
   Galleries reuse the post's single ratio for every slide, so the frame
   doesn't jump on swipe. */
/* The padding-bottom hack (height:0 + padding-bottom) reserves the box from
   `--gf-ratio` rather than `aspect-ratio`, because the Ollie theme's layout
   containment collapses aspect-ratio's intrinsic sizing on some cards. The
   padding hack is bulletproof and containment-independent.
   padding-bottom% = 100 / ratio  (0.8 → 125%, 1.0 → 100%, 1.91 → ~52%). */
.godam-feed-card__media {
	position: relative;
	background: var(--gf-bg);
	width: 100%;
	height: 0;
	padding-bottom: calc( 100% / var( --gf-ratio, 0.8 ) );
	overflow: hidden;
}

/* Direct child of the media wrapper fills the 4:5 box. For single
   image / single video / gallery the child is the obvious one. For
   single video via [godam_video] shortcode the child is an unclassed
   `<div style="--rtgodam-...">` wrapper — we target it via its inline
   CSS variable rather than `> div` (the latter would also catch
   sibling utility divs like `.godam-feed-card__dots` and cover them
   over the gallery). */
.godam-feed-card__media > img,
.godam-feed-card__media > video,
.godam-feed-card__media > [style*="--rtgodam"],
.godam-feed-card__media > .godam-feed-card__gallery {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

/* The godam player nests video.js inside several wrappers. Make them
   all fill the 4:5 box so object-fit on the inner <video> can do the
   cover crop. `!important` because video.js sets explicit pixel widths
   we'd otherwise lose to specificity. */
.godam-feed-card__media figure,
.godam-feed-card__media .godam-video-wrapper,
.godam-feed-card__media .easydam-video-container,
.godam-feed-card__media .easydam-player {
	width: 100% !important;
	height: 100% !important;
	margin: 0;
}

.godam-feed-card__media img,
.godam-feed-card__media video {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Custom video controls (own overlay, works identically on mobile + desktop).
   video.js' own chrome was unreliable on mobile — its volume panel renders
   off-screen on narrow viewports and its tap-to-pause is flaky on touch — so
   we hide ALL of it and provide our own overlay (mute toggle + tap-to-play /
   pause + a centered play indicator). The godam player still drives
   autoplay-on-scroll; a manual pause sticks (it only re-plays on re-entry).
   See view.js `setupVideoControls`. */
.godam-feed-card__media .vjs-control-bar,
.godam-feed-card__media .vjs-big-play-button {
	display: none !important;
}

/* `.gf-video` is added by JS to each video's `.godam-video-wrapper`. */
.gf-video {
	position: relative;
}
/* Full-surface tap target → play/pause. Sits above the media, below the
   buttons. A swipe (in a gallery) won't fire its click, so carousel swiping
   still works. */
.gf-video__tap {
	position: absolute;
	inset: 0;
	z-index: 2;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
/* Centered play glyph — shown only while paused. */
.gf-video__play {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 3;
	pointer-events: none;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.5);
	color: #fff;
	display: none;
	align-items: center;
	justify-content: center;
}
.gf-video--paused .gf-video__play {
	display: flex;
}
/* Always-visible mute/unmute toggle, bottom-right (Instagram-style: small,
   subtle, glassy), on every device. */
.gf-video__mute {
	position: absolute;
	right: 10px;
	bottom: 10px;
	z-index: 4;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.45);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	-webkit-tap-highlight-color: transparent;
}
.gf-video__mute svg {
	width: 15px;
	height: 15px;
	display: block;
}
/* Icon swap is CSS-driven off the `gf-video--muted` state class, so toggling
   the global mute updates every button at once with no per-icon JS. */
.gf-video__mute .gf-video__icon-unmuted {
	display: none;
}
.gf-video:not(.gf-video--muted) .gf-video__mute .gf-video__icon-muted {
	display: none;
}
.gf-video:not(.gf-video--muted) .gf-video__mute .gf-video__icon-unmuted {
	display: block;
}

.godam-feed-card__gallery {
	display: flex;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	/* Legacy iOS Safari momentum scrolling. Modern Safari ignores this. */
	-webkit-overflow-scrolling: touch;
	/* Reserve focus visibility for keyboard users — but don't leak the
	   default outline onto the box. */
	outline: none;
	scroll-behavior: smooth;
}
.godam-feed-card__gallery:focus-visible {
	box-shadow: inset 0 0 0 2px var(--gf-accent);
}

.godam-feed-card__gallery::-webkit-scrollbar {
	display: none;
}

/* Slides may be raw <img> tags or the wrapper <div> the godam_video
   shortcode emits. Every slide fills the 4:5 box; `object-fit: cover` on
   the inner <img>/<video> handles the crop. */
.godam-feed-card__gallery > * {
	flex: 0 0 100%;
	width: 100%;
	height: 100%;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	display: block;
	overflow: hidden;
	-webkit-user-drag: none;
	user-select: none;
}
/* The godam player wrapper carries its own 16:9 sizing — video.js sets
   explicit pixel widths on the inner <figure> that our `width: 100%`
   can't fight via specificity. Solution: take the figure out of flow
   (absolute), pin it to the slide box, and let object-fit on the video
   element do the cover crop. */
.godam-feed-card__gallery > div {
	position: relative;
}
.godam-feed-card__gallery > div > figure {
	position: absolute;
	inset: 0;
	margin: 0;
	width: 100% !important;
	height: 100% !important;
}
.godam-feed-card__gallery > div .godam-video-wrapper,
.godam-feed-card__gallery > div .easydam-video-container,
.godam-feed-card__gallery > div .easydam-player {
	width: 100% !important;
	height: 100% !important;
}

.godam-feed-card__dots {
	/* Anchored to the bottom of the 4:5 box (the media uses the
	   padding-bottom hack so in-flow children sit at the top of a
	   0-height content area — that's why we position the dots absolutely). */
	position: absolute;
	left: 0;
	right: 0;
	bottom: 8px;
	display: flex;
	justify-content: center;
	gap: 6px;
	z-index: 2;
}

.godam-feed-card__dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.25);
	cursor: pointer;
	transition: background 150ms ease, transform 150ms ease;
}
.godam-feed-card__dots span:hover,
.godam-feed-card__dots span:focus-visible {
	background: rgba(255, 255, 255, 0.55);
	outline: none;
}
.godam-feed-card__dots span.is-active {
	background: var(--gf-accent);
	transform: scale(1.15);
}

/* Prev/next chevrons for mouse users on desktop. Hidden on touch-only
   devices (no hover capability) — touch users have native swipe. */
.godam-feed-card__gallery-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 32px;
	height: 32px;
	border-radius: 999px;
	border: 0;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 2;
	opacity: 0;
	transition: opacity 150ms ease, background 150ms ease;
}
.godam-feed-card__gallery-nav--prev { left: 8px; }
.godam-feed-card__gallery-nav--next { right: 8px; }
.godam-feed-card__gallery-nav[hidden] { display: none; }
.godam-feed-card__gallery-nav:hover { background: rgba(0, 0, 0, 0.65); }

/* Reveal nav on pointer hover over the media area. Touch devices don't
   match `:hover`, so the nav stays hidden there — they swipe instead. */
.godam-feed-card__media--gallery:hover .godam-feed-card__gallery-nav,
.godam-feed-card__gallery-nav:focus-visible {
	opacity: 1;
}
@media (hover: none) {
	.godam-feed-card__gallery-nav { display: none; }
}

/* Actions */
.godam-feed-card__actions {
	display: flex;
	gap: 4px;
	padding: 8px 8px 0;
}

.godam-feed-card__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 0;
	padding: 8px;
	border-radius: 999px;
	cursor: pointer;
	color: var(--gf-text);
	transition: transform 120ms ease, color 120ms ease;
}

.godam-feed-card__btn:hover {
	color: var(--gf-muted);
}

.godam-feed-card__btn:active {
	transform: scale(0.92);
}

/* Heart fill is driven by `aria-pressed` (or `.is-active` for the
   animation hook). SSR cards ship with `fill="currentColor"` on the SVG; this
   override hides the fill until the button is pressed, so the same DOM works
   whether it came from PHP or `makeCard()`. */
.godam-feed-card__btn--like svg {
	fill: none;
	transition: fill 120ms ease;
}
.godam-feed-card__btn--like[aria-pressed="true"] svg,
.godam-feed-card__btn--like.is-active svg {
	fill: currentColor;
}

.godam-feed-card__btn--like.is-active {
	color: var(--gf-accent);
	animation: gf-pop 280ms ease;
}

@keyframes gf-pop {
	0% {
		transform: scale(1);
	}

	40% {
		transform: scale(1.25);
	}

	100% {
		transform: scale(1);
	}
}

/* Likes / caption / time */
.godam-feed-card__likes {
	margin: 6px 14px 0;
	font-weight: 600;
	font-size: 0.92rem;
}

.godam-feed-card__caption {
	margin: 4px 14px 0;
	font-size: 0.92rem;
	line-height: 1.4;
}

.godam-feed-card__caption strong {
	margin-right: 6px;
}

.godam-feed-card__time {
	margin: 6px 14px 14px;
	font-size: 0.72rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--gf-muted);
}

/* Per-post lock (gated content). Same per-post ratio box as the unlocked
   variant so a locked card reserves the same shape it would when unlocked. */
.godam-feed-card__media--locked {
	position: relative;
	width: 100%;
	height: 0;
	padding-bottom: calc( 100% / var( --gf-ratio, 0.8 ) );
	overflow: hidden;
	background: linear-gradient(135deg, #1f2937, #0f172a);
}

.godam-feed-card__locked-preview {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	filter: blur(28px) saturate(1.1);
	transform: scale(1.1);
}

.godam-feed-card__locked-preview--empty {
	background: linear-gradient(135deg, #4338ca, #ec4899);
}

.godam-feed-card__lock {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 24px;
	color: #fff;
	text-align: center;
	background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.55) 100%);
}

.godam-feed-card__lock-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
	margin-bottom: 4px;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.godam-feed-card__lock-kind {
	display: inline-block;
	font-size: 0.7rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.8);
	background: rgba(255, 255, 255, 0.12);
	padding: 4px 10px;
	border-radius: 999px;
	font-weight: 600;
}

.godam-feed-card__lock-headline {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 600;
	line-height: 1.3;
	max-width: 22ch;
}

.godam-feed-card__lock-cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: 8px;
	padding: 11px 18px;
	border: 0;
	border-radius: 999px;
	background: var(--gf-accent);
	color: #fff;
	font-weight: 600;
	font-size: 0.95rem;
	text-decoration: none;
	cursor: pointer;
	transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.godam-feed-card__lock-cta:hover {
	background: #d8434f;
	color: #fff;
}

.godam-feed-card__lock-cta:active {
	transform: scale(0.98);
}

.godam-feed-card__lock-cta:disabled {
	opacity: 0.65;
	cursor: progress;
}

.godam-feed-card__lock-status {
	margin: 8px 0 0;
	min-height: 1.2em;
	font-size: 0.82rem;
	color: #fca5a5;
	text-align: center;
}

/* Editor placeholder */
.godam-feed-editor__placeholder {
	border: 1px dashed rgba(0, 0, 0, 0.2);
	border-radius: 12px;
	padding: 32px;
	text-align: center;
	background: rgba(0, 0, 0, 0.02);
}

.godam-feed-editor__placeholder strong {
	display: block;
	font-size: 1.1rem;
	margin-bottom: 6px;
}

.godam-feed-editor__placeholder p {
	margin: 0;
	color: #555;
}

/* Confirm-before-spend modal (native <dialog>) — opened before an unlock so a
   single accidental tap can't drain coins. Light surface over a dimmed
   backdrop; matches the WC paywall buttons. */
.godam-feed-confirm {
	border: 0;
	padding: 0;
	border-radius: 16px;
	width: calc(100% - 2rem);
	max-width: 360px;
	background: #fff;
	color: #111;
	box-shadow: 0 25px 60px rgba(0, 0, 0, 0.22);
}
.godam-feed-confirm::backdrop {
	background: rgba(0, 0, 0, 0.55);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}
.godam-feed-confirm__title {
	margin: 0;
	padding: 1.25rem 1.25rem 0.4rem;
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1.25;
}
.godam-feed-confirm__body {
	margin: 0;
	padding: 0 1.25rem 1.2rem;
	color: #4b5563;
	line-height: 1.5;
	font-size: 0.95rem;
}
.godam-feed-confirm__actions {
	display: flex;
	gap: 0.5rem;
	padding: 0 1.25rem 1.25rem;
	justify-content: flex-end;
}
.godam-feed-confirm__btn {
	appearance: none;
	border: 0;
	padding: 0.55rem 1.15rem;
	border-radius: 999px;
	font: inherit;
	font-weight: 600;
	font-size: 0.9rem;
	cursor: pointer;
	transition: background 120ms ease, opacity 120ms ease, transform 120ms ease;
}
.godam-feed-confirm__btn:active {
	transform: translateY(1px);
}
.godam-feed-confirm__btn--ghost {
	background: transparent;
	color: #111;
}
.godam-feed-confirm__btn--ghost:hover {
	background: rgba(0, 0, 0, 0.06);
}
.godam-feed-confirm__btn--primary {
	background: #111;
	color: #fff;
}
.godam-feed-confirm__btn--primary:hover {
	opacity: 0.92;
}

/* Dark mode is the theme's responsibility — set palette tokens in theme.json or Site Editor → Styles. */