/* Shop Grid — "Shop Triggers" WooCommerce product grid (design.md §shop-grid).
   Restyles the default [products] loop output (.woocommerce .products) into the
   dark tile grid. WC block/loop classes are the only non-tt- classes we style
   (system.md §6, §12). Featured first tile + carousel are follow-ups. */

/* Intro, pills and grid are siblings rather than a nested head block, so the
   mobile layout can reorder them with `order` — the design puts the category
   pills BELOW the product carousel there (nodes 4:434 → 4:451). */
.tt-shop-grid {
	display: grid;
	grid-template-columns: 1fr auto;
	align-items: end;
	column-gap: 24px;
	row-gap: 40px;
	padding-block: 90px 100px;
	padding-inline: 76px;
	background-color: var(--wp--preset--color--ink, #141412);
}

/* ---- Head: eyebrow + title + pills --------------------------------------- */
.tt-shop-grid__intro {
	grid-column: 1;
}

.tt-shop-grid__grid {
	grid-column: 1 / -1;
}

/* The title sits tight under the eyebrow — in Figma its text box starts 6px
   BEFORE the eyebrow's box ends (desktop 21:63/21:59, mobile 4:385/4:384), the
   two line boxes overlapping in their leading. Same on both breakpoints. */
.tt-shop-grid__eyebrow {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	font-family: var(--wp--preset--font-family--barlow-condensed, "Barlow Condensed", sans-serif);
	font-size: 16px;
	line-height: 1.45;
	letter-spacing: 2.4px;
	text-transform: uppercase;
	color: var(--wp--preset--color--red-bright, #ff4349);
}

.tt-shop-grid__eyebrow::before {
	content: "";
	flex: none;
	width: 40px;
	height: 1px;
	background: var(--wp--preset--color--red, #cf2026);
}

.tt-shop-grid__title {
	margin: 0;
	font-family: var(--wp--preset--font-family--oswald, "Oswald", sans-serif) !important;
	font-weight: 600 !important;
	font-size: 72px;
	line-height: 1.05;
	text-transform: uppercase;
	color: #fff !important;
}

.tt-shop-grid__pills {
	grid-column: 2;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.tt-shop-grid__pill {
	padding: 8px 14px;
}

/* ---- Product grid (restyled [products] output) --------------------------- */
.tt-shop-grid .woocommerce {
	margin: 0;
}

.tt-shop-grid ul.products {
	display: grid !important;
	grid-template-columns: repeat(5, 1fr);
	grid-auto-rows: 388px;    /* 315×388 card: 325 image plate + ~80 text band */
	gap: 1px;                 /* 1px black lines between the white cards */
	margin: 0;
	padding: 0;
	list-style: none;
	background: #000;         /* shows through the 1px gaps */
}

.tt-shop-grid ul.products::before,
.tt-shop-grid ul.products::after {
	content: none;
}

/* The explicit height is load-bearing, not decoration: the row track already
   sizes this tile, but a stretched grid item's height is not a *specified*
   height, so `height: 100%` on the <a> inside would resolve to auto and the card
   would grow to its content instead of clipping/fitting. Keep in sync with
   grid-auto-rows above (featured = 2 rows + the 1px gap). */
.tt-shop-grid ul.products li.product {
	position: relative;
	height: 388px;
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
	overflow: hidden;
	background: #fff;
}

/* Featured first tile spans 2×2 */
.tt-shop-grid ul.products li.product:first-child {
	grid-column: span 2;
	grid-row: span 2;
	height: 777px;            /* 2 × 388 + the 1px gap */
}

/* Card layout. The image plate is a FIXED height taken straight from Figma
   (325 small / 650 featured) and the text band is pinned to the bottom of the
   tile, overlapping the plate by whatever it needs — 17px under a one-line
   title, 29px under a two-line one. That overlap is how the design works, and
   it is why the plate does not shrink as titles get longer: sizing the plate as
   "card height minus band" instead renders the product ~12% small.

   The plate is therefore taken out of flow (absolute, top-aligned) so the band
   can sit over it, and `justify-content: flex-end` drops the band to the
   bottom. Both plate and band are then positioned boxes, so they paint in DOM
   order and the band lands on top of the plate. */
.tt-shop-grid ul.products li.product > a {
	position: relative;
	display: flex !important;   /* !important: WC's own `li.product a {display:block}`
	                               is equal specificity and loads after this file */
	flex-direction: column;
	justify-content: flex-end;
	height: 100%;
	text-decoration: none !important;
}

/* Image plate — fixed 325px, top-aligned, product contained on white and run
   edge-to-edge (no padding: Figma contains the 700×770 source to the full plate
   height, giving 295.4 × 325). !important beats WC's equal-specificity
   `height: auto` img rule. */
.tt-shop-grid ul.products li.product img {
	position: absolute;
	top: 0;
	left: 0;
	height: 325px !important;
	width: 100% !important;
	margin: 0;
	padding: 0;
	object-fit: contain;
	background: #fff;
}

.tt-shop-grid ul.products li.product:first-child img {
	height: 650px !important;
}

/* Text band — pinned to the bottom, painted over the plate it overlaps.
   position: relative on all three is load-bearing: the plate is absolutely
   positioned, so without it the plate would paint on top of the band. */
.tt-shop-grid ul.products li.product .tt-tile__stage,
.tt-shop-grid ul.products li.product .woocommerce-loop-product__title,
.tt-shop-grid ul.products li.product .price {
	position: relative;
}

.tt-shop-grid ul.products li.product .tt-tile__stage {
	display: inline-block;
	align-self: flex-start;
	margin: 0 10px;
	padding: 5px 6px;
	background: #878787;
	font-family: var(--wp--preset--font-family--oswald, "Oswald", sans-serif);
	font-weight: 700;
	font-size: 12px;
	letter-spacing: 0.6px;
	line-height: 12px;
	text-transform: uppercase;
	color: #fff;
}

.tt-shop-grid ul.products li.product .woocommerce-loop-product__title {
	margin: 7px 10px 0;
	padding: 0;
	font-family: var(--wp--preset--font-family--barlow, "Barlow", sans-serif) !important;
	font-weight: 700 !important;
	font-size: 16px;
	line-height: 1.3;
	text-transform: none;
	color: var(--wp--preset--color--ink, #141412) !important;
}

.tt-shop-grid ul.products li.product .price {
	display: block;
	margin: 2px 10px 8px;
	font-family: var(--wp--preset--font-family--barlow, "Barlow", sans-serif) !important;
	font-size: 14px;
	color: var(--wp--preset--color--ink, #141412) !important;
}

.tt-shop-grid ul.products li.product .price del {
	color: var(--wp--preset--color--grey, #73736f);
	text-decoration: line-through;
	opacity: 1;
	margin-right: 6px;
}

.tt-shop-grid ul.products li.product .price ins {
	color: var(--wp--preset--color--red, #cf2026);
	text-decoration: none;
	font-weight: 700;
}

/* Featured tile — same anatomy, larger tag/type and a 23px inset.
   777px card (2 rows) = ~646px image plate + ~131px band. */
.tt-shop-grid ul.products li.product:first-child .tt-tile__stage {
	margin: 0 23px;
	padding: 7px 9px;
	font-size: 14px;
	letter-spacing: 0.7px;
	line-height: 14px;
}

.tt-shop-grid ul.products li.product:first-child .woocommerce-loop-product__title {
	margin: 10px 23px 0;
	font-size: 22px;
}

.tt-shop-grid ul.products li.product:first-child .price {
	margin: 4px 23px 12px;
	font-size: 16px;
}

/* Badge sashes — a corner ribbon across the tile's top-left, rotated -30° (not
   -45°), per Figma nodes 2111:156 / :161 / :164. It reads as overlapping the
   product because the photo runs close to the corner, NOT because the band
   sits low on the tile: its top edge lands on the tile's top edge and its left
   end on the tile's left edge.

   Both ends of the band are cut square rather than perpendicular — left end
   vertical, right end horizontal — so it is not a plain rotated rectangle.
   clip-path reproduces that exactly: it resolves in the element's own
   unrotated box, and the rotation applies to the already-clipped shape.
   Polygon points are the Figma path verbatim.

   Positioning gotcha: for these rotated nodes Figma reports x/y as the
   PRE-ROTATION local origin, not the rotated bounding box. So left/top place
   the unrotated box and `transform-origin: 0 0` rotates about that same
   corner. Reading x/y as a bbox instead drops the ribbon ~100px down the tile.
   Coordinates are tile-relative — the sash box's containing block is
   li.product, the nearest positioned ancestor. */
.tt-tile__sashes {
	position: absolute;
	inset: 0;
	z-index: 2;
	overflow: hidden;
	pointer-events: none;
}

.tt-sash {
	position: absolute;
	left: -16px;
	top: 70.55px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 198.03px;
	height: 34.15px;
	padding-right: 30.6px;    /* centres the label in the *visible* trapezoid */
	transform: rotate(-30deg);
	transform-origin: 0 0;
	clip-path: polygon(19.63px 0.15px, 139.14px 0, 198.03px 34px, 0 34.15px);
	font-family: var(--wp--preset--font-family--barlow, "Barlow", sans-serif);
	font-weight: 700;
	font-size: 20px;
	line-height: 1;
	text-align: center;
	text-transform: uppercase;
	color: #fff;
}

.tt-sash--sale {
	background: var(--wp--preset--color--red, #cf2026);
}

.tt-sash--new {
	background: #596b95;      /* new-arrival slate blue (design.md) */
}

.tt-sash--factory {
	background: #686857;      /* factory-find olive (design.md) */
}

/* Bigger sash on the featured tile — same shape scaled up (node 2111:156) */
.tt-shop-grid ul.products li.product:first-child .tt-sash {
	left: -28px;
	top: 117px;
	width: 334.02px;
	height: 57.6px;
	padding-right: 57.7px;
	clip-path: polygon(33.11px 0.25px, 234.69px 0, 334.02px 57.35px, 0 57.6px);
	font-size: 30px;
}

/* Hide the default WC sale flash, add-to-cart, and star ratings in the grid */
.tt-shop-grid .onsale,
.tt-shop-grid .star-rating,
.tt-shop-grid ul.products li.product > a.button,
.tt-shop-grid ul.products li.product .add_to_cart_button,
.tt-shop-grid ul.products li.product .added_to_cart {
	display: none !important;
}

/* ---- Mobile (≤767px) ----------------------------------------------------- */
@media (max-width: 767px) {
	/* Single column, and the pills drop BELOW the carousel (design 4:451 sits at
	   y=611, under the 4:434 card track at y=114). */
	.tt-shop-grid {
		display: flex;
		flex-direction: column;
		align-items: stretch;   /* reset the desktop grid's `align-items: end` */
		gap: 24px;
		padding-inline: 20px;
		padding-block: 60px;
	}

	.tt-shop-grid__intro { order: 1; }
	.tt-shop-grid__grid  { order: 2; }
	.tt-shop-grid__pills { order: 3; }

	/* Four equal tiles in a 2 × 2 grid — the design's cells are 186 × 35 with a
	   13px column gap and 8px row gap across a 385px row, i.e. half-width each,
	   with the label centred (the narrower frames in the Figma metadata are the
	   text bounds, not the tiles). Column-major flow so the pairs match the
	   design: Bolt Action / Pistol on the top row, Gas-Operated / PCC below. */
	.tt-shop-grid__pills {
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-template-rows: repeat(2, auto);
		grid-auto-flow: column;
		gap: 8px 13px;
	}

	.tt-shop-grid__pill {
		text-align: center;
	}

	.tt-shop-grid__title {
		font-size: 46px;
	}

	/* Products become a horizontal snap-scrolling carousel (design `Group 54`:
	   a 1095px track of 356px cards inside the 440 viewport, so one card shows
	   with the next peeking). The row bleeds to the screen edges and re-pads
	   inside, so the first card still lines up with the copy while the peek runs
	   off-screen. Card width tracks the viewport but never exceeds the design's
	   356px, which keeps a peek on narrower handsets too. */
	.tt-shop-grid__grid {
		margin-inline: -20px;
	}

	.tt-shop-grid ul.products {
		display: flex !important;
		flex-wrap: nowrap;
		gap: 4px;
		/* !important: WC's own `ul.products { padding: 0 }` is equal specificity
		   and loads after this file — without it the first card sits flush to
		   the screen edge instead of lining up with the copy. */
		padding-inline: 20px !important;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		/* Without this, snapping aligns the card to the scrollport edge and
		   scrolls straight past the padding above, pinning card 1 to x=0. */
		scroll-padding-inline: 20px;
		scrollbar-width: none;
		-ms-overflow-style: none;
		background: none;    /* no 1px black gap lines in carousel mode */
	}

	.tt-shop-grid ul.products::-webkit-scrollbar {
		display: none;
	}

	.tt-shop-grid ul.products li.product,
	.tt-shop-grid ul.products li.product:first-child {
		flex: 0 0 81vw;
		max-width: 356px;
		width: auto;
		height: auto;         /* cards size to content here */
		scroll-snap-align: start;
	}

	/* Card = 356 × ~457: plate 356×368 + ~89 band, overlapping 18px (node 4:390).
	   Cards are auto-height here, so the plate has to stay in flow — an absolute
	   plate would contribute no height and the card would collapse to the band.
	   Ratio-driven rather than fixed, with the band pulled up onto it. */
	.tt-shop-grid ul.products li.product img,
	.tt-shop-grid ul.products li.product:first-child img {
		position: static;
		height: auto !important;
		aspect-ratio: 356 / 368;
		padding: 0;
	}

	.tt-shop-grid ul.products li.product .tt-tile__stage,
	.tt-shop-grid ul.products li.product:first-child .tt-tile__stage {
		margin: -18px 11px 0;
		padding: 6px 4px;
		font-size: 12px;
		letter-spacing: 0.6px;
		line-height: 13px;
	}

	.tt-shop-grid ul.products li.product .woocommerce-loop-product__title,
	.tt-shop-grid ul.products li.product:first-child .woocommerce-loop-product__title {
		margin: 8px 11px 0;
		font-size: 18px;
	}

	.tt-shop-grid ul.products li.product .price,
	.tt-shop-grid ul.products li.product:first-child .price {
		margin: 3px 11px 12px;
		font-size: 16px;
	}

	/* Sash is a size up on mobile and every card uses it (node 4:431) */
	.tt-shop-grid ul.products li.product .tt-sash,
	.tt-shop-grid ul.products li.product:first-child .tt-sash {
		left: -19.58px;
		top: 80.59px;
		width: 229.16px;
		height: 39.25px;
		padding-right: 6.7px;
		clip-path: polygon(22.5px 0.19px, 161.17px 0, 229.16px 39.25px, 0 39.16px);
		font-size: 20px;
	}
}
