/* Home screen redesign (opt-in via Pin\Widget\Grid cardStyle="home_v2") — Home page only.
   Colors/fonts reuse the site's existing tokens (see agent/modules/in-progress/home-screen/new.md):
   brand red #e74c3c / hover #ec7063 / accent #df4a37, neutral bg #d7dcde, neutral text #667686,
   hover bg #f1f3f4, heading text #2d3e4f (same as .pin-title), font Lato. */

/* Root page background. This stylesheet is only enqueued when cardStyle="home_v2" (Home page only —
   see grid.phtml), so a plain `body` rule here is already correctly scoped, no extra class needed.
   Overrides the site-wide body { background-color:#ededed; background-image:url(bg.png); } texture
   with a flat, near-white tone. */
body {
	background-color: #f9f9f8;
	background-image: none;
}

/* Page shell: left rail | main content | right rail. Full viewport width — just side padding,
   no centered max-width container — with the two sticky rails alongside the main column when
   banners exist for module="home" (see Banner::getActiveBannersForModule()); with none active,
   .home-v2-layout simply contains one child and looks identical to the unwrapped page. */
.home-v2-layout {
	display: flex;
	align-items: flex-start;
	gap: 24px;
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0 24px;
	box-sizing: border-box;
}
.home-v2-main {
	flex: 1 1 auto;
	min-width: 0;
}
.home-v2-rail {
	width: 260px;
	flex-shrink: 0;
	position: sticky;
	top: 76px;
	display: flex;
	flex-direction: column;
	gap: 20px;
}
/* No card box — just a gray "Sponsored" label header, then the ad content itself with no
   background/padding around it. Both cards in a rail get a fixed, identical media height
   (object-fit:cover) so a tall image banner and an ad-network HTML embed of unrelated native
   size always end up the same height and line up cleanly, whatever the source creative is. */
.home-v2-rail-ad {
	background: none;
	border-radius: 0;
	box-shadow: none;
}
.home-v2-rail-sponsored {
	display: block;
	font-size: 11px;
	color: #97a3ad;
	padding: 0 0 6px;
	text-transform: capitalize;
	letter-spacing: .2px;
}
.home-v2-rail-ad-media {
	display: block;
	position: relative;
	width: 100%;
	height: 360px;
	overflow: hidden;
}
/* Ad-network HTML embeds (type="html") can wrap the real creative in extra markup — e.g. a small
   "Ads by Btab" text link sitting *before* the actual image link in the source HTML. Forcing every
   wrapper to 100% height (previous approach) stretched that text link to fill the whole box and
   pushed the real image out of view under overflow:hidden. Absolutely positioning the <img> itself
   sidesteps that entirely — it always fills the box regardless of sibling/wrapper markup. */
.home-v2-rail-ad-media img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100% !important;
	height: 100% !important;
	/* contain, not cover — this is ad creative (branding/text near the edges matters), never crop it.
	   No background fill either — just the image, page background shows through any letterboxing. */
	object-fit: contain;
}
@media (max-width: 1400px) {
	.home-v2-rail { display: none; }
}

.home-hero {
	max-width: 100%;
	margin: 0;
	padding: 32px 0 6px;
}
.home-hero-title {
	font-size: 30px;
	line-height: 36px;
	font-weight: 900;
	letter-spacing: -0.4px;
	margin: 0 0 7px;
	/* Warm brand-red → amber gradient instead of flat dark navy text. `color` is the
	   fallback for browsers without background-clip:text support. */
	color: #e74c3c;
	background: linear-gradient(100deg, #e74c3c 0%, #ff8a5c 55%, #ec7063 100%);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
}
.home-hero-subtitle {
	font-size: 15px;
	line-height: 22px;
	color: #7c8994;
	margin: 0;
}

.home-toolbar {
	max-width: 100%;
	margin: 22px 0 4px;
	padding: 0 0 20px;
	border-bottom: 1px solid #ecebe8;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
}
.home-tabs {
	display: flex;
	gap: 10px;
}
.home-tab {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 22px;
	border-radius: 12px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .1px;
	text-decoration: none;
	background-color: #fff;
	border: 1px solid #e9e7e3;
	color: #6b7680;
	box-shadow: 0 1px 2px rgba(45,62,79,.04);
	transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s, transform .15s;
}
.home-tab svg {
	width: 15px;
	height: 15px;
	flex-shrink: 0;
}
.home-tab:hover {
	background-color: #fafafa;
	border-color: #ddd9d3;
	transform: translateY(-1px);
	box-shadow: 0 3px 8px rgba(45,62,79,.07);
}
.home-tab.is-active {
	background-color: #e74c3c;
	border-color: #e74c3c;
	color: #fff;
	box-shadow: 0 4px 12px rgba(231,76,60,.28);
}
.home-tab.is-active:hover {
	background-color: #ec7063;
	border-color: #ec7063;
	box-shadow: 0 6px 16px rgba(231,76,60,.32);
}

.home-toolbar-right {
	display: flex;
	align-items: center;
	gap: 10px;
}
.home-sort {
	display: inline-block;
}
/* Single background-image chevron on the select itself — no separate pseudo-element sitting next
   to it (that approach could visually double up with the browser's own affordance in some
   engines). One clean, unambiguous dropdown control. */
.home-sort select {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	font-family: Lato, sans-serif;
	font-size: 13px;
	font-weight: 700;
	color: #6b7680;
	background-color: #fff;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667686' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	background-size: 14px;
	border: 1px solid #e9e7e3;
	border-radius: 12px;
	padding: 12px 38px 12px 20px;
	box-shadow: 0 1px 2px rgba(45,62,79,.04);
	cursor: pointer;
	transition: border-color .15s, box-shadow .15s;
}
.home-sort select:hover {
	border-color: #ddd9d3;
	box-shadow: 0 3px 8px rgba(45,62,79,.07);
}
.home-sort select:focus {
	outline: none;
	border-color: #df4a37;
	box-shadow: 0 0 0 3px rgba(223,74,55,.12);
}

/* The pin grid widget's own shared template wraps .boxcontainer in the legacy `.container.fluid`
   (main.css: width:auto; margin:0 20px) — used site-wide, so it can't be edited directly. That
   20px side margin was insetting the grid 20px from the hero/toolbar above it (which live outside
   that wrapper). Neutralized here, scoped to only inside .home-v2-main so no other page that
   reuses .container.fluid is affected. */
.home-v2-main .container.fluid {
	margin: 0;
	width: 100%;
}

/* Uniform card grid, replaces masonry for this variant only */
.boxcontainer.grid-v2 {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
	gap: 16px;
	max-width: 100%;
	margin: 0;
	padding: 16px 0 0;
	/* Default grid behavior stretches every item to the tallest item in its row. A tall banner ad
	   (e.g. a 236x522 banner next to ~380px pin cards) was forcing short cards to stretch into
	   big empty white boxes. align-items:start makes every card sit at its own natural height
	   instead — the classic plain-CSS-Grid masonry-lookalike fix. */
	align-items: start;
}
.boxcontainer.grid-v2 .box {
	position: relative;
	width: auto !important;
	/* Ad/banner cards carry their own fixed pixel width (unrelated markup, untouched by this
	   redesign) — without min-width:0 a grid item's content intrinsic size can inflate its
	   whole column (and therefore every row sharing that column), not just its own cell. */
	min-width: 0;
	background-color: #fff;
	border-radius: 4px;
	box-shadow: 0 4px 12px rgba(45,62,79,.10);
	overflow: hidden;
	transition: box-shadow .18s, transform .18s;
}
.boxcontainer.grid-v2 .box:hover {
	box-shadow: 0 8px 20px rgba(45,62,79,.16);
	transform: translateY(-2px);
}
.boxcontainer.grid-v2 .box.empty { display: none; }

/* Ad/reel cards spliced into the pin grid (Banner/Userads/Reel — unrelated markup, own inline
   width/height from their own DB row) previously kept their native ~236x522 proportions, ending
   up much taller than neighboring pin cards even with align-items:start above. Force them to the
   same overall proportions as a pin card (square thumb + ~118px info section, at a representative
   card width) via aspect-ratio, and crop their creative to fit via object-fit:cover — every card
   in the grid now reads as the same height, ads included. `!important` needed to beat each
   template's own inline `style="width:…;height:…"`. Grid mode only — list-view's own rule below
   still governs when .list-view is active (more specific selector wins there). */
.boxcontainer.grid-v2 .box[class*="box-banner-"],
.boxcontainer.grid-v2 .box[class*="box-userad-"],
.boxcontainer.grid-v2 .box.reel-feed-card {
	height: auto !important;
	aspect-ratio: 0.69;
	/* Ads get no card chrome — no white box background, no shadow — just the creative itself. */
	background-color: transparent;
	box-shadow: none;
}
.boxcontainer.grid-v2 .box[class*="box-banner-"] .banner,
.boxcontainer.grid-v2 .box[class*="box-userad-"] .banner {
	width: 100% !important;
	height: 100% !important;
}
.boxcontainer.grid-v2 .box[class*="box-banner-"] .banner img,
.boxcontainer.grid-v2 .box[class*="box-userad-"] .banner img,
.boxcontainer.grid-v2 .box.reel-feed-card img {
	width: 100% !important;
	height: 100% !important;
	/* contain, not cover — ad/reel creative shouldn't get cropped, unlike pin photos below.
	   No background fill either, per instruction — just the image. */
	object-fit: contain;
}

.card-v2-body { position: relative; }
.card-v2-bookmark {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	width: 32px;
	height: 32px;
	border-radius: 8px;
	background-color: rgba(255,255,255,.94);
	color: #6b7680;
	display: flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	box-shadow: 0 2px 6px rgba(31,47,61,.14);
	backdrop-filter: blur(2px);
	transition: color .15s, background-color .15s, transform .15s;
}
.card-v2-bookmark:hover {
	color: #e74c3c;
	background-color: #fff;
	transform: translateY(-1px);
}
.card-v2-thumb {
	display: block;
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	background-position: center;
	background-size: cover;
	overflow: hidden;
}
.card-v2-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .25s ease;
}
.boxcontainer.grid-v2 .box:hover .card-v2-thumb img {
	transform: scale(1.04);
}
/* Video-pin play badge — centered on the thumb itself (not the whole card, whose
   height varies with title/author length) so it stays correctly placed at any
   card width. Replaces the legacy .ribbon-video for cardStyle=home_v2 only. */
.card-v2-video-badge {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%,-50%);
	z-index: 2;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: rgba(17,17,17,.4);
	border: 1.5px solid rgba(255,255,255,.6);
	backdrop-filter: blur(2px);
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	transition: background-color .18s, transform .18s;
}
.card-v2-video-badge svg { width: 16px; height: 16px; margin-left: 2px; }
.boxcontainer.grid-v2 .box:hover .card-v2-video-badge {
	background: rgba(231,76,60,.88);
	transform: translate(-50%,-50%) scale(1.08);
}
.card-v2-info {
	padding: 12px 14px 14px;
}
.card-v2-title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 14px;
	line-height: 19px;
	font-weight: 700;
	letter-spacing: -.1px;
	color: #1f2f3d;
	text-decoration: none;
	margin-bottom: 9px;
	min-height: 38px;
	transition: color .15s;
}
.card-v2-title:hover { color: #e74c3c; }
.card-v2-author {
	display: flex;
	align-items: center;
	gap: 7px;
	text-decoration: none;
	color: #7c8994;
	font-size: 12px;
	font-weight: 600;
	margin-bottom: 10px;
}
.card-v2-author:hover { color: #6b7680; }
.card-v2-avatar {
	width: 20px;
	height: 20px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	box-shadow: 0 0 0 1px rgba(31,47,61,.08);
}
.card-v2-author span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.card-v2-price {
	display: inline-block;
	font-size: 12px;
	font-weight: 700;
	color: #e74c3c;
	margin-bottom: 8px;
}
.card-v2-actions {
	display: flex;
	align-items: center;
	gap: 16px;
	border-top: 1px solid #f1f0ec;
	padding-top: 10px;
	margin-top: 2px;
}
.card-v2-action {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 5px 7px;
	margin: -5px -7px;
	border-radius: 7px;
	color: #7c8994;
	text-decoration: none;
	font-size: 12px;
	font-weight: 700;
	transition: color .15s, background-color .15s;
}
.card-v2-action:hover,
.card-v2-action.is-active {
	color: #e74c3c;
	background-color: #fdeeec;
}
.card-v2-action svg { flex-shrink: 0; }
.card-v2-share {
	position: relative;
	margin-left: auto;
}
.card-v2-share-menu {
	position: absolute;
	right: 0;
	bottom: 26px;
	background-color: #fff;
	border-radius: 8px;
	box-shadow: 0 2px 10px rgba(0,0,0,.18);
	list-style: none;
	margin: 0;
	padding: 6px 0;
	min-width: 120px;
	z-index: 5;
}
.card-v2-share-menu li a {
	display: block;
	padding: 7px 14px;
	font-size: 12px;
	font-weight: 700;
	color: #667686;
	text-decoration: none;
}
.card-v2-share-menu li a:hover {
	background-color: #f1f3f4;
	color: #e74c3c;
}

/* List view (toggle-driven) */
.boxcontainer.grid-v2.list-view {
	display: block;
	max-width: 760px;
}
.boxcontainer.grid-v2.list-view .box {
	/* Banner/Userads/Reel cards spliced into this grid use their own markup (no .card-v2-body) —
	   only pin cards get the flex row layout below, so ad/reel slots keep their native sizing. */
	margin-bottom: 14px;
}
/* Ad/reel interstitials carry their own fixed pixel dimensions (built for the grid, not a full-width
   row) — without this they'd stretch the card's white background to match their fixed height. */
.boxcontainer.grid-v2.list-view .box[class*="box-banner-"],
.boxcontainer.grid-v2.list-view .box[class*="box-userad-"],
.boxcontainer.grid-v2.list-view .box.reel-feed-card {
	width: fit-content !important;
	max-width: 100%;
}
.boxcontainer.grid-v2.list-view .card-v2-body {
	display: flex;
	width: 100%;
}
.boxcontainer.grid-v2.list-view .card-v2-thumb {
	width: 160px;
	flex-shrink: 0;
	aspect-ratio: auto;
	height: 160px;
}
.boxcontainer.grid-v2.list-view .card-v2-info {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
}
.boxcontainer.grid-v2.list-view .card-v2-title {
	min-height: 0;
}

@media (max-width: 720px) {
	.home-toolbar { justify-content: flex-start; }
	.home-hero-title { font-size: 22px; line-height: 28px; }
	.boxcontainer.grid-v2 { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; padding: 10px 12px 0; }
}
