/**
 * Homepage secondary article grid + sticky banner.
 *
 * RTL layout (right to left):
 *   [sticky banner 320px — RIGHT] [gap 15px] [article grid 655px — LEFT]
 *   = 990px total (fits inside .hm-home-columns__main)
 *
 * Grid: 2 columns × 4 rows. Cell 7 (row 4, right col in RTL) = inline ad.
 *
 * Card styles are in article-card.css (hm-card-md).
 *
 * @package Hamechadesh
 */

/* ==========================================================================
   Outer column: banner (RIGHT, first child) + grid (LEFT, second child)
   ========================================================================== */

.hm-secondary-col {
	display: flex;
	gap: 15px;
	align-items: flex-start;
	width: 100%;
	margin-top: 15px;
}

/* ==========================================================================
   Sticky banner — 320px, RIGHT side
   ========================================================================== */

.hm-secondary-col__sticky {
	width: 320px;
	flex-shrink: 0;
	position: sticky;
	top: 100px; /* Adjust to match navbar height */
	overflow: hidden;
}

.hm-secondary-col__sticky .aso-zone {
	display: block;
	width: 100%;
	min-height: 600px;
}

/* ==========================================================================
   Article grid — 655px, LEFT side (2 × 320px columns + 15px gap)
   ========================================================================== */

.hm-secondary-col__grid {
	display: grid;
	grid-template-columns: repeat(2, 320px);
	gap: 15px;
	width: 655px;
	flex-shrink: 0;
}

/* ==========================================================================
   Ad card in grid — cell 7 (row 4, right column in RTL)
   ========================================================================== */

.hm-card-md--ad {
	height: 330px;
	background-color: transparent;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	/* border-radius inherited from .hm-card-md: 20px */
	padding-bottom: 0; /* override the card padding */
	gap: 0;
}

.hm-card-md--ad .aso-zone {
	display: block;
	width: 100%;
	height: 100%;
}

/* ==========================================================================
   Responsive — below 1350px: column layout, no sticky
   ========================================================================== */

@media (max-width: 1349px) {
	.hm-secondary-col {
		flex-direction: column;
	}

	.hm-secondary-col__sticky {
		position: static;
		width: 100%;
		display: flex;
		justify-content: center;
	}

	.hm-secondary-col__sticky .aso-zone {
		width: 320px;
		min-height: 600px;
	}

	.hm-secondary-col__grid {
		width: 100%;
		grid-template-columns: repeat(2, 1fr);
	}
}

/* Desktop scale-to-fit (see components.css): force the desktop side-by-side
   layout (sticky banner beside the 2x320 grid), overriding the <=1349 stacked
   layout above. The CSS zoom set by header.php then scales it down. */
html.hm-fit-desktop .hm-secondary-col {
	flex-direction: row;
}

html.hm-fit-desktop .hm-secondary-col__sticky {
	position: sticky;
	width: 320px;
	display: block;
}

html.hm-fit-desktop .hm-secondary-col__sticky .aso-zone {
	width: 100%;
}

html.hm-fit-desktop .hm-secondary-col__grid {
	width: 655px;
	grid-template-columns: repeat(2, 320px);
}

/* ==========================================================================
   Flashes slot (mobile-only) — hidden on desktop/tablet.
   JS moves the existing sidebar .hm-flashes into this slot on mobile.
   ========================================================================== */

.hm-secondary-col__flashes-slot {
	display: none;
}

/* Post 8 — visible only on mobile (completes the 4+4 layout) */
.hm-card-md--mobile-only {
	display: none;
}

/* Sponsored ad 2 — placed after flashes in DOM for mobile order,
   but on desktop: explicit grid placement to row 3, col 2 (LEFT in RTL) */
.hm-card-md--sponsored-ad-2 {
	grid-row: 3;
	grid-column: 2;
}

/* ==========================================================================
   Responsive — Mobile: horizontal card layout + inline flashes
   ========================================================================== */

@media (max-width: 767px) {
	.hm-secondary-col__grid {
		grid-template-columns: 1fr;
	}

	/* Show post 8 on mobile */
	.hm-card-md--mobile-only {
		display: flex;
	}

	/* ---- Hide ad card on mobile ---- */
	.hm-card-md--ad {
		display: none;
	}

	/* ---- First sponsored ad appears first on mobile ---- */
	.hm-card-md--sponsored-ad:not(.hm-card-md--sponsored-ad-2) {
		order: -1;
	}

	/* ---- Second sponsored ad: reset grid placement, natural DOM order (right after flashes) ---- */
	.hm-card-md--sponsored-ad-2 {
		grid-row: auto;
		grid-column: auto;
	}

	/* ---- Show flashes slot between posts 4 and 5 ---- */
	.hm-secondary-col__flashes-slot {
		display: block;
		grid-column: 1 / -1;
		overflow: hidden; /* contain carousel within grid bounds */
	}

	/* Ensure flashes respect slot width when moved here by JS */
	.hm-secondary-col__flashes-slot .hm-flashes {
		width: 100%;
		max-width: 100%;
	}

	/* ---- Mobile banner below grid ---- */
	.hm-secondary-col__mobile-banner {
		margin-top: 10px;
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.hm-secondary-col__mobile-banner .aso-zone {
		display: block;
		width: 320px;
		min-height: 100px;
	}
}
