/* Front end only: sticky header, overlays, photo arrows. Not loaded in the Site Editor. */

html { scroll-padding-top: calc(var(--ej-header) + 24px); }

/* Keep the page still behind an open overlay. */
html:has(dialog[open]) { overflow: hidden; }

.wp-site-blocks > header {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 10;
}

/* The WordPress admin bar scrolls away on small phones. */
@media (max-width: 600px) {
	.wp-site-blocks > header { top: 0; }
}

/* main.js moves the menu into a dialog; until then it stays hidden. */
.ej-menu { display: none; }
.ej-menu-dialog .ej-menu { display: flex; }

/* ---------- Wordmark to EJ mark ---------- */

@media (min-width: 1024px) {
	.ej-logo__wordmark,
	.ej-logo__mark { transition: opacity 0.35s ease, transform 0.35s ease; }

	/* Two classes, so WooCommerce's image styles can't change its height. */
	.ej-logo .ej-logo__mark {
		position: absolute;
		top: 50%;
		left: 50%;
		display: block;
		width: auto;
		height: 38px;
		opacity: 0;
		transform: translate(-50%, -50%) scale(1.3);
	}

	.is-scrolled .ej-logo__wordmark { opacity: 0; transform: scale(0.4); }
	.is-scrolled .ej-logo__mark { opacity: 1; transform: translate(-50%, -50%); }
}

/* ---------- Opening photo, with the header over it ---------- */

/* On tall phones, stop before the sides of the bag are cut off. */
.ej-hero { height: 100svh; min-height: 480px; max-height: 180vw; }
.ej-hero img { aspect-ratio: auto; }

/* Darkens the top of the photo, so the white logo is easy to read. */
.ej-hero::before {
	content: "";
	position: absolute;
	inset: 0 0 auto;
	z-index: 1;
	height: calc(var(--ej-header) * 2.5);
	background: linear-gradient(to bottom, rgb(17 19 18 / 0.72), rgb(17 19 18 / 0.45) 40%, transparent);
	pointer-events: none;
}

.ej-header,
.ej-logo img { transition: background-color 0.35s ease, color 0.35s ease, filter 0.35s ease, opacity 0.35s ease, transform 0.35s ease; }

/* main.js changes the header back after the photo. Without JavaScript, it stays white and above the photo. */
@media (scripting: enabled) {
	.ej-main:has(.ej-hero) { margin-top: calc(var(--ej-header) * -1); }
	:root:not(.is-past-hero) .wp-site-blocks:has(.ej-hero) .ej-header { background: transparent; color: var(--ej-white); }
	:root:not(.is-past-hero) .wp-site-blocks:has(.ej-hero) .ej-logo img { filter: brightness(0) invert(1); }
}

/* ---------- 2027 scenes ---------- */

.ej-scene__canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 0.4s ease; }
.ej-scene__canvas.is-ready { opacity: 1; }

/* Start on plain paper, so the finished picture doesn't show before the drawing. scenes.js shows it if the scene can't play. */
@media (scripting: enabled) {
	.ej-scene:not(.is-still) .ej-scene__still { visibility: hidden; }
}

/* The line fades in as she raises her eyebrow. It stays visible to screen readers the whole time. */
.ej-scene__line { transition: opacity 0.8s ease; }
@media (scripting: enabled) {
	.ej-scene:not(.is-said, .is-still) .ej-scene__line { opacity: 0; }
}

.ej-scene__toggle {
	position: absolute;
	right: 8px;
	bottom: 8px;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgb(255 255 255 / 0.82);
	color: var(--ej-ink);
	cursor: pointer;
}
.ej-scene__toggle[hidden] { display: none; }
.ej-scene__toggle:not(.is-paused) .ej-scene__play,
.ej-scene__toggle.is-paused .ej-scene__pause { display: none; }

/* ---------- Dialogs ---------- */

.ej-menu-dialog {
	width: 100%;
	max-width: none;
	height: 100dvh;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--ej-petrol);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.ej-search {
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 24px var(--ej-gutter);
	border: 0;
	background: var(--ej-white);
	color: var(--ej-ink);
}
.ej-search::backdrop { background: rgb(17 19 18 / 0.32); }

.ej-search__form {
	display: flex;
	align-items: center;
	max-width: 720px;
	margin-inline: auto;
	border-bottom: 1px solid var(--ej-ink);
}
.ej-search__form input[type="search"] {
	flex: 1;
	min-width: 0;
	min-height: 48px;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-size: 1rem;
}
.ej-search__form input::-webkit-search-cancel-button { display: none; }

.ej-menu-dialog,
.ej-search { transition: opacity 0.25s ease, display 0.25s allow-discrete, overlay 0.25s allow-discrete; opacity: 0; }
.ej-menu-dialog[open],
.ej-search[open] { opacity: 1; }
@starting-style {
	.ej-menu-dialog[open],
	.ej-search[open] { opacity: 0; }
}

@media (min-width: 1024px) {
	.ej-menu__links { visibility: hidden; }
	.ej-menu__group.is-active .ej-menu__links { visibility: visible; }
}

/* ---------- Photo arrows, dots and row arrows ---------- */

.ej-frame__arrow {
	position: absolute;
	top: 50%;
	z-index: 1;
	display: none;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--ej-ink);
	transform: translateY(-50%);
	cursor: pointer;
}
.ej-frame__arrow[hidden] { display: none; }
/* Pale backing keeps arrows visible on dark lifestyle photos. */
.ej-frame__arrow .ej-icon { box-sizing: border-box; width: 32px; height: 32px; padding: 5px; background: rgb(255 255 255 / 0.82); }
.ej-frame__arrow--prev { left: 0; }
.ej-frame__arrow--next { right: 0; }

.ej-frame__dots {
	position: absolute;
	inset: auto 0 10px;
	display: flex;
	justify-content: center;
	gap: 6px;
	pointer-events: none;
}
.ej-frame__dots span { width: 6px; height: 6px; border-radius: 50%; background: rgb(255 255 255 / 0.75); box-shadow: 0 0 0 1px rgb(17 19 18 / 0.3); }
.ej-frame__dots .is-current { background: var(--ej-ink); }

/* With a mouse: arrows replace swiping and dots. */
@media (hover: hover) and (pointer: fine) {
	.ej-frame .ej-gallery { overflow-x: hidden; }
	.ej-frame__dots { display: none; }
	.ej-frame__arrow:not([hidden]) { display: inline-flex; opacity: 0; transition: opacity 0.2s ease; }
	.ej-frame:hover .ej-frame__arrow,
	.ej-frame:focus-within .ej-frame__arrow { opacity: 1; }
}

/* On product pages, the photos stay in view while the text scrolls. */
@media (min-width: 1024px) {
	.ej-product__gallery { position: sticky; top: calc(var(--ej-header) + var(--wp-admin--admin-bar--height, 0px) + 8px); }
	/* On the shop page, products scroll past the large photo. */
	.ej-shop .ej-shop__image { position: sticky; top: calc(var(--ej-header) + var(--wp-admin--admin-bar--height, 0px)); }
}

/* Product page arrows sit in the bottom corners, clear of the clothes. */
.ej-product__gallery .ej-frame__arrow { top: auto; bottom: 8px; transform: none; }
@media (hover: hover) and (pointer: fine) {
	.ej-product__gallery .ej-frame__arrow { opacity: 1; }
}
/* With a mouse or keyboard, sizes appear on the photo, so there's no + button. */
@media (hover: hover) and (pointer: fine) {
	.ej-quick__toggle { display: none; }
	.ej-quick__panel { right: 8px; bottom: 8px; left: 8px; display: block; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
	.ej-card__media:hover .ej-quick__panel,
	.ej-quick:focus-within .ej-quick__panel { opacity: 1; pointer-events: auto; }
	.ej-quick__sizes span { flex-basis: auto; padding: 0 8px; }
}

/* Floating buy bar */
.ej-bar {
	position: fixed;
	z-index: 9;
	right: 0;
	bottom: 0;
	left: 0;
	padding-bottom: max(10px, env(safe-area-inset-bottom));
	visibility: hidden;
	opacity: 0;
	transform: translateY(16px);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}
.ej-bar.is-visible { visibility: visible; opacity: 1; transform: none; }
@media (min-width: 768px) {
	.ej-bar { right: 24px; bottom: 20px; left: 24px; max-width: 860px; margin-inline: auto; padding-bottom: 10px; }
}
/* Room to scroll the footer and focused links clear of the bar. */
body:has(.ej-bar) .ej-footer { padding-bottom: 180px; }
html:has(.ej-bar) { scroll-padding-bottom: 160px; }

.ej-row-arrows { display: flex; grid-column: 2; grid-row: 1 / span 3; align-self: end; margin-right: -10px; }
.ej-row-arrows[hidden] { display: none; }
.ej-row-arrows button:disabled { opacity: 0.3; cursor: default; }

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after,
	::backdrop { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* The photo opens the product too. Left out of the editor so it can be selected there. */
.ej-story__caption a::after { content: ""; position: absolute; inset: 0; }
