/*
Theme Name: Meme Shop
Description: Black studio theme for the meme shop. Every product alone under one spotlight.
Version: 0.1.0
Requires at least: 6.6
Requires PHP: 8.0
Text Domain: memeshop
*/

:root {
	--bg: var(--wp--preset--color--base);
	--surface: var(--wp--preset--color--surface);
	--ink: var(--wp--preset--color--ink);
	--muted: var(--wp--preset--color--muted);
	--accent: var(--wp--preset--color--accent);
	--accent-ink: var(--wp--preset--color--accent-ink);
	--display: var(--wp--preset--font-family--display);
	--m: clamp(16px, 2.2vw, 32px);
	--step-small: var(--wp--preset--font-size--small);
	--step-body: var(--wp--preset--font-size--body);
	--step-lead: var(--wp--preset--font-size--lead);
	--step-head: var(--wp--preset--font-size--head);
	--ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

html { background: var(--bg); }
body { margin: 0; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }
.wp-site-blocks > * + * { margin-block-start: 0; }

.ms-button {
	display: inline-block;
	font-size: var(--step-body);
	background: var(--accent);
	color: var(--accent-ink);
	font-weight: 500;
	text-decoration: none;
	padding: 0.9rem 1.5rem;
	transition: background-color 0.2s, color 0.2s, transform 0.15s var(--ease-out);
}
.ms-button:hover { background: var(--ink); color: var(--bg); }
.ms-button:active { transform: scale(0.97); }

/* ---------- Header ---------- */
.ms-header {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 1rem;
	padding: 18px var(--m);
	font-size: var(--step-small);
	background: var(--surface);
	position: relative;
	z-index: 5;
}
.ms-header--home { position: absolute; top: 12px; left: 12px; right: 12px; background: transparent; }
.ms-header a { color: var(--ink); text-decoration: none; }
.ms-header a:hover { color: var(--accent); }
.ms-wordmark { font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: -0.01em; }
.ms-nav { display: flex; gap: 2rem; }
.ms-cart { justify-self: end; }

/* ---------- Hero: the bear on the seam ---------- */
.ms-hero {
	position: relative;
	min-height: max(100svh, 640px);
	overflow: hidden;
	background: var(--bg);
}
.ms-hero__panel { position: absolute; top: 12px; left: 12px; right: 12px; height: 44%; background: var(--surface); }
.ms-hero__object { position: absolute; inset: 0; overflow: hidden; }
/* The photo is scaled past the screen so the bear fills its height; 0.745 = the bear's centre across the photo, 1.791 = its ratio. */
.ms-hero__object img {
	position: absolute;
	height: 130svh; width: auto; max-width: none;
	top: -17svh;
	left: calc(64vw - 0.745 * 1.791 * 130svh);
	mix-blend-mode: lighten; /* the studio black melts into the panel above the seam and the page below it */
}
.ms-hero__text { position: absolute; left: var(--m); top: 44%; width: min(40rem, 44vw); z-index: 2; }
.ms-hero__title { font-size: var(--step-head); line-height: 1; margin: -1em 0 1.5rem; }
.ms-hero__title span { display: block; color: var(--muted); white-space: nowrap; }
.ms-hero__lede { max-width: 34ch; margin: 0 0 1.75rem; }

/* ---------- Five loud ones: object on a disc ---------- */
.ms-disc {
	position: relative;
	min-height: 100svh;
	display: grid;
	grid-template-columns: repeat(12, 1fr);
	padding: 120px var(--m);
	box-sizing: border-box;
}
.ms-disc { --d: min(64vh, 40vw); }
.ms-disc__stage { grid-column: 5 / 11; grid-row: 1; position: relative; display: grid; place-items: center; min-height: calc(var(--d) * 1.3); }
.ms-disc__circle { width: var(--d); aspect-ratio: 1; border-radius: 50%; transition: background-color 0.3s; }
.ms-disc__object {
	position: absolute;
	height: calc(var(--d) * 1.2); /* taller than the disc, so the object breaks its outline at the top */
	width: auto;
	bottom: calc(50% - var(--d) / 2);
	left: 50%;
	transform: translateX(-50%);
	opacity: 0;
	transition: opacity 0.3s;
	pointer-events: none;
}
.ms-disc__object.is-active { opacity: 1; }
.ms-disc__facts { grid-column: 11 / 13; grid-row: 1; align-self: end; padding-bottom: calc((var(--d) * 1.3 - var(--d)) / 2); }
.ms-disc__fact { display: none; }
.ms-disc__fact.is-active { display: block; }
.ms-disc__fact p { margin: 0 0 0.5rem; }
.ms-disc__price { font-size: var(--step-lead); white-space: nowrap; }
.ms-disc__fact a { color: var(--accent); }
.ms-disc__names {
	grid-column: 1 / 5; grid-row: 1;
	align-self: end;
	list-style: none; margin: 0; padding: 0;
	font-size: var(--step-head);
	line-height: 1.1;
	z-index: 2;
}
.ms-disc__heading { color: var(--muted); }
.ms-disc__names button {
	all: unset;
	cursor: pointer;
	color: var(--muted);
	font: inherit;
	transition: color 0.2s;
}
.ms-disc__names button:hover,
.ms-disc__names button[aria-pressed="true"] { color: var(--ink); }
.ms-disc__names button[aria-pressed="true"]::after { content: ""; display: inline-block; width: 0.5em; height: 0.5em; margin-left: 0.3em; background: var(--accent); border-radius: 50%; vertical-align: 0.1em; }
.ms-disc__names button:focus-visible { outline: 2px solid var(--accent); }

/* ---------- Best sellers: sticky photograph, active list ---------- */
.ms-list {
	display: grid;
	grid-template-columns: repeat(12, 1fr);
	column-gap: 1.5rem;
	padding: 160px var(--m);
	background: var(--surface);
}
.ms-list__photo { grid-column: 1 / 6; position: sticky; top: 12vh; align-self: start; aspect-ratio: 4 / 5; width: 34vw; }
.ms-list__photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.3s; }
.ms-list__photo img.is-active { opacity: 1; }
.ms-list__rows { grid-column: 7 / 12; }
.ms-list__title { margin: 0 0 3rem; }
.ms-list__items { list-style: none; margin: 0; padding: 0; }
.ms-row__head {
	display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
	min-height: 58px; align-content: center;
	padding: 0.85rem 0;
	color: var(--muted);
	text-decoration: none;
	font-size: var(--step-lead);
	transition: color 0.2s;
}
.ms-row__price { font-size: var(--step-small); color: var(--muted); white-space: nowrap; }
.ms-row.is-active .ms-row__head, .ms-row__head:hover { color: var(--ink); }
.ms-row__more { max-width: 34ch; padding-bottom: 1.25rem; }
.ms-row__more p { margin: 0 0 0.5rem; }
.ms-row__more a { color: var(--accent); }
.js .ms-row__more { display: none; }
.js .ms-row.is-active .ms-row__more { display: block; }

/* ---------- Shot in the dark: small frames, wide space ---------- */
.ms-strip { position: relative; min-height: 100svh; display: grid; align-content: center; }
.ms-strip__title {
	position: relative; z-index: 2;
	margin: 0 0 -12px var(--m);
	font-size: var(--step-lead);
}
.ms-strip__title span { color: var(--muted); }
.ms-strip__row {
	display: flex; gap: 5vw;
	overflow-x: auto; scrollbar-width: none;
	padding: 0 var(--m) 0 calc(var(--m) + 12px);
	scroll-snap-type: x mandatory;
}
.ms-strip__row::-webkit-scrollbar { display: none; }
.ms-strip__frame { flex: 0 0 11vw; height: 24svh; scroll-snap-align: start; }
.ms-strip__frame img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s var(--ease-out); }
.ms-strip__frame:hover img, .ms-strip__frame:focus-visible img { transform: scale(1.1); }

/* ---------- The bear returns ---------- */
.ms-return {
	position: relative;
	min-height: 90svh;
	display: grid;
	grid-template-columns: repeat(12, 1fr);
	column-gap: 1.5rem;
	overflow: hidden;
	background: var(--surface);
	padding: 0 var(--m);
}
.ms-return__photo { grid-column: 1 / 9; position: relative; overflow: hidden; }
.ms-return__photo img {
	position: absolute; left: -12%; bottom: -18%;
	width: 130%; max-width: none; height: auto;
	mix-blend-mode: lighten;
}
.ms-return__text { grid-column: 9 / 13; align-self: center; padding: 4rem 0; }
.ms-return__text h2 { margin: 0 0 1rem; }
.ms-return__text p { margin: 0 0 1rem; }
.ms-return__price { font-size: var(--step-lead); }

/* ---------- Footer: the name across the last photograph ---------- */
.ms-footer {
	position: relative;
	min-height: 100svh;
	overflow: hidden;
	display: grid;
	grid-template-rows: auto 1fr auto auto;
	padding: 32px var(--m) 24px;
	box-sizing: border-box;
	color: var(--ink);
}
.ms-footer__photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; filter: brightness(0.62); }
.ms-footer > :not(.ms-footer__photo) { position: relative; }
.ms-footer__links { display: flex; gap: 2rem; }
.ms-footer__links a { color: var(--ink); text-decoration: none; }
.ms-footer__links a:hover { color: var(--accent); }
.ms-footer__note { grid-row: 1; justify-self: end; max-width: 24rem; margin: 0; text-align: right; }
.ms-footer__name {
	grid-row: 3;
	margin: 0;
	font-family: var(--display); font-weight: 800; text-transform: uppercase;
	font-size: 11.2vw; line-height: 0.85; letter-spacing: -0.02em;
	white-space: nowrap;
	width: max-content;
}
.ms-footer__legal { grid-row: 4; margin: 0.75rem 0 0; font-size: var(--step-small); color: var(--muted); }

/* ---------- Plain pages and WooCommerce ---------- */
.ms-page { padding-block: 64px 160px; }
.wp-block-woocommerce-product-collection .wc-block-components-product-image img,
.wc-block-grid__product-image img { background: var(--bg); }
.wc-block-components-product-name, .wp-block-post-title a { text-decoration: none; }
.wc-block-components-product-price, .wp-block-woocommerce-product-price { color: var(--muted); }
.wp-block-button__link, .wc-block-components-button:not(.is-link), .single_add_to_cart_button {
	border-radius: 0 !important;
	background: var(--accent) !important;
	color: var(--accent-ink) !important;
}
.wp-block-button__link:hover, .wc-block-components-button:not(.is-link):hover, .single_add_to_cart_button:hover {
	background: var(--ink) !important; color: var(--bg) !important;
}
select, input[type="text"], input[type="email"], input[type="tel"], input[type="number"], textarea {
	background: var(--surface); color: var(--ink); border: 1px solid #3a3a3a; border-radius: 0; padding: 0.6rem 0.75rem; font: inherit;
}
.woocommerce-breadcrumb, .wp-block-woocommerce-breadcrumbs { color: var(--muted); font-size: var(--step-small); }
select { height: auto; line-height: 1.4; min-width: 12rem; }
.woocommerce-Tabs-panel h2, .wc-tabs-wrapper h2, .related.products > h2, .woocommerce-Reviews-title { font-size: var(--step-lead); }

/* ---------- Motion ---------- */
@keyframes ms-shutter { from { clip-path: inset(0 0 0 100%); transform: scale(1.12); } to { clip-path: inset(0 0 0 0); transform: scale(1); } }
.ms-hero__object img { animation: ms-shutter 1.1s var(--ease-out) both; }
.js [data-reveal] > * { opacity: 0; transform: translateY(24px); transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out); }
.js [data-reveal].is-in > * { opacity: 1; transform: none; }
.js [data-reveal].is-in > *:nth-child(2) { transition-delay: 0.08s; }
.js [data-reveal].is-in > *:nth-child(3) { transition-delay: 0.16s; }
.js [data-reveal].is-in > *:nth-child(4) { transition-delay: 0.24s; }
.ms-return__photo img { transition: transform 1.2s var(--ease-out); }
.ms-return.is-in .ms-return__photo img { transform: translateY(-3%); }

@media (prefers-reduced-motion: reduce) {
	.ms-hero__object img { animation: none; }
	.js [data-reveal] > * { opacity: 1; transform: none; transition: none; }
	.ms-disc__object, .ms-list__photo img, .ms-strip__frame img, .ms-return__photo img { transition: none; }
}

/* ---------- Phone ---------- */
@media (max-width: 899px) {
	.ms-nav { display: none; }
	.ms-header { grid-template-columns: 1fr auto; }
	.ms-hero { min-height: 100svh; }
	.ms-hero__panel { height: 46%; }
	.ms-hero__object { inset: 9% 0 auto; height: 52%; }
	.ms-hero__object img { position: static; width: 100%; height: 100%; object-fit: cover; object-position: 50% 55%; }
	.ms-hero__text { top: auto; bottom: 28px; left: 20px; right: 20px; width: auto; }
	.ms-hero__title { margin: 0 0 0.75rem; font-size: min(var(--step-head), 7.4vw); white-space: nowrap; }
	.ms-hero__lede { margin-bottom: 1.25rem; }

	.ms-disc { --d: 86vw; display: block; padding: 96px 0; min-height: 0; }
	.ms-disc__stage { min-height: 0; padding-top: calc(var(--d) * 0.25); }
	.ms-disc__object { bottom: 0; }
	.ms-disc__facts { padding: 1.5rem 20px 0; }
	.ms-disc__names { display: flex; gap: 24px; overflow-x: auto; padding: 1.5rem 20px 0; font-size: var(--step-lead); white-space: nowrap; scrollbar-width: none; }
	.ms-disc__heading { display: none; }

	.ms-list { display: block; padding: 0 0 96px; }
	.ms-list__photo { position: sticky; top: 0; width: 100%; aspect-ratio: auto; height: 38svh; z-index: 2; background: var(--surface); }
	.ms-list__photo img { object-fit: contain; }
	.ms-list__rows { padding: 2rem 20px 0; }
	.ms-list__title { margin-bottom: 1.5rem; }
	.ms-row__head { min-height: 56px; }

	.ms-strip { min-height: 80svh; }
	.ms-strip__title { margin: 0 0 20px 20px; }
	.ms-strip__row { gap: 5vw; padding: 0 20px; }
	.ms-strip__frame { flex-basis: 34vw; height: auto; aspect-ratio: 2 / 3; }

	.ms-return { display: flex; flex-direction: column-reverse; padding: 0; min-height: 0; }
	.ms-return__text { padding: 64px 20px 0; }
	.ms-return__text .ms-button { display: block; text-align: center; }
	.ms-return__photo { height: 55svh; }
	.ms-return__photo img { width: 130vw; left: -10vw; bottom: -20%; }

	.ms-footer { min-height: 88svh; padding: 24px 20px 20px; grid-template-rows: auto auto 1fr auto auto; }
	.ms-footer__links { flex-direction: column; gap: 0.5rem; }
	.ms-footer__note { grid-row: 2; justify-self: start; text-align: left; margin-top: 1.5rem; }
	.ms-footer__name { grid-row: 4; }
	.ms-footer__legal { grid-row: 5; }
}
