/*
 * RAZOR phone patterns: swipe row, canvas panel, canvas menu header,
 * current page link, popup sheet.
 *
 * Loaded on every front-end page before style.css and the generated
 * css/razor-generated.css, so a site or generated rule wins a tie.
 * These rules are NOT in @layer utilities: a layered rule loses to every
 * unlayered Divi rule, and Divi's own row and column rules are unlayered.
 *
 * Nothing here applies in the Visual Builder (body.et-fb). There the rows stay
 * stacked and the canvas stays in the flow, so a client can still edit them.
 */

/* ---------------------------------------------------------------------------
 * Swipe row: class rz-swipe-row on a Divi row or group, rz-swipe-item on each
 * child (column or module). At 767px and less it becomes one horizontal row
 * that scrolls and snaps; each item is 80% wide so the next one peeks in.
 * The gap is the row's own gap. js/razor-swipe.js adds the dots.
 * Desktop and tablet are unchanged.
 * ------------------------------------------------------------------------ */
.rz-swipe-dots {
	display: none;
}

@media only screen and (max-width: 767px) {
	/*
	 * The row takes the full width of its parent. The generated CSS gives rows
	 * per-node widths with !important and :is(#page-container *) weight, so
	 * this rule carries the same: an id in :is() plus three classes and body.
	 * The second selector covers a page without #page-container.
	 */
	body:not(.et-fb) .rz-swipe-row.rz-swipe-row.rz-swipe-row:is(#page-container *),
	body:not(.et-fb) .rz-swipe-row.rz-swipe-row.rz-swipe-row {
		box-sizing: border-box;
		width: 100% !important;
		max-width: 100% !important;
	}

	body:not(.et-fb) .rz-swipe-row.rz-swipe-row {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-items: stretch;
		overflow-x: auto;
		overflow-y: hidden;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-behavior: smooth;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	body:not(.et-fb) .rz-swipe-row.rz-swipe-row::-webkit-scrollbar {
		display: none;
	}

	body:not(.et-fb) .rz-swipe-row.rz-swipe-row > .rz-swipe-item {
		flex: 0 0 var(--rz-swipe-item, 80%);
		width: var(--rz-swipe-item, 80%);
		min-width: 0;
		max-width: none;
		margin-right: 0;
		margin-left: 0;
		scroll-snap-align: start;
		scroll-snap-stop: always;
	}

	/*
	 * The dots read custom properties that the divi-from-design generator sets
	 * on the section from the phone frame's pager (bar size, colours, gap,
	 * alignment). Each fallback is the default look: centred 8px round dots.
	 */
	body:not(.et-fb) .rz-swipe-dots {
		display: flex;
		/* Full width of the row's parent, also in a centring flex column. */
		align-self: stretch;
		justify-content: var(--rz-dots-justify, center);
		flex-wrap: wrap;
		gap: var(--rz-dots-gap, 8px);
		margin: var(--rz-dots-mt, 16px) var(--rz-dots-mx, auto) 0;
		padding: 0;
	}

	.rz-swipe-dot {
		box-sizing: content-box;
		width: var(--rz-dot-w, 8px);
		height: var(--rz-dot-h, 8px);
		margin: 0;
		/* The padding makes a 24px touch target around the visible dot. */
		padding: var(--rz-dot-pad, 8px);
		border: 0;
		background: none;
		color: var(--rz-dot-color, inherit);
		opacity: var(--rz-dot-opacity, 0.3);
		cursor: pointer;
		transition: opacity 0.2s ease, width 0.2s ease;
	}

	/* The visible dot fills the content box; the padding stays a clear touch area. */
	.rz-swipe-dot::before {
		content: "";
		display: block;
		width: 100%;
		height: 100%;
		border-radius: var(--rz-dot-radius, 50%);
		background: currentColor;
	}

	.rz-swipe-dot[aria-current="true"] {
		width: var(--rz-dot-active-w, var(--rz-dot-w, 8px));
		color: var(--rz-dot-active-color, var(--rz-dot-color, inherit));
		opacity: var(--rz-dot-active-opacity, 1);
	}

	.rz-swipe-dot:focus-visible {
		outline: 2px solid currentColor;
		outline-offset: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	body:not(.et-fb) .rz-swipe-row.rz-swipe-row {
		scroll-behavior: auto;
	}

	.rz-swipe-dot {
		transition: none;
	}
}

/* ---------------------------------------------------------------------------
 * Canvas panel: class rz-canvas-panel on the section of a Divi canvas that is
 * used as a mobile menu. It covers the whole viewport and scrolls on its own.
 * z-index is above the WordPress admin bar (99999), Divi's sticky header and
 * page canvases. Divi still shows and hides the section (inline display), so
 * this file never sets display on it.
 * js/razor-canvas.js adds body.rz-canvas-open while a panel is open.
 * ------------------------------------------------------------------------ */
body:not(.et-fb) .rz-canvas-panel.rz-canvas-panel {
	position: fixed;
	inset: 0;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	height: 100dvh;
	max-height: 100dvh;
	margin: 0;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	z-index: 100001;
}

html:has(> body.rz-canvas-open),
body.rz-canvas-open {
	overflow: hidden;
}

/* A popup sheet locks the page scroll only where it is a sheet (767px and less). */
@media only screen and (max-width: 767px) {
	html:has(> body.rz-sheet-open),
	body.rz-sheet-open {
		overflow: hidden;
	}
}

/* ---------------------------------------------------------------------------
 * Canvas menu header: class rz-has-canvas-menu on the header section that has
 * a canvas opener. Divi's menu module shows its own mobile toggle at 980px and
 * less; with a canvas menu that is a second hamburger, so it is hidden there.
 * The opener must then show on tablet and phone. Above 980px this file changes
 * nothing. Where the header menu stays collapsed above 980px (its collapse
 * width), the generated CSS (divi-from-design generator.py) hides Divi's
 * toggle and shows the opener there; the panel above has no width limit.
 * ------------------------------------------------------------------------ */
@media only screen and (max-width: 980px) {
	.rz-has-canvas-menu .et_mobile_nav_menu,
	.rz-has-canvas-menu .mobile_nav {
		display: none !important;
	}
}

/* ---------------------------------------------------------------------------
 * Current page link: js/razor-canvas.js gives the canvas menu link
 * (class rz-menu-link) whose path is the page path aria-current="page" and
 * the class rz-menu-current. It takes the accent colour: the custom property
 * --rz-menu-accent, set on the panel by the class rz-accent-<token> (the
 * script maps it to var(--gcid-razor-<token>)) or by site CSS. Without an
 * accent the link keeps its colour. The menu link has an inline
 * color:inherit, so the rule needs !important.
 * ------------------------------------------------------------------------ */
body:not(.et-fb) .rz-menu-current a[aria-current="page"],
body:not(.et-fb) a.rz-menu-current[aria-current="page"] {
	color: var(--rz-menu-accent, inherit) !important;
}

/* ---------------------------------------------------------------------------
 * Popup sheet: class rz-canvas-sheet on the first section of a page canvas
 * used as a popup. At 767px and less it is a bottom sheet: fixed to the
 * bottom, full width, rounded top corners, never closer to the viewport top
 * than --rz-sheet-top (the phone frame's gap; default 15dvh), its own scroll,
 * a grey backdrop (a spread shadow, so no stacking context can hide it), a
 * slide-up on open and a slide-down on close (class rz-sheet-closing). The
 * desktop card inside it (a row with a fill, radius and shadow) is flattened
 * into the sheet. Above 767px the popup is exactly as Divi builds it.
 *
 * Divi still shows and hides the section (inline display); this file never
 * sets display on it. Divi's canvas rules (position:fixed; inset 0) come
 * later in the page, so the position rules carry !important.
 * js/razor-canvas.js gives the sheet role=dialog, focus, a Tab trap, Escape,
 * a click on the backdrop closes it, and the class rz-canvas-close on its
 * close control. The close control's row stays at the top while the sheet
 * scrolls, with the control at the right.
 * Background: --rz-sheet-bg (default white). Corner radius: --rz-sheet-radius
 * (default 20px). Close control background: --rz-sheet-close-bg (light grey).
 * genflow.py writes the phone frame's sizes on the section: --rz-sheet-top,
 * --rz-sheet-pad-x, --rz-sheet-pad-top and --rz-sheet-pad-bottom (the sheet's
 * inner padding; default 16px, 24px and 24px), --rz-sheet-close (the close
 * control's size; default 44px), --rz-sheet-close-icon (its icon's font size;
 * default 18px) and --rz-sheet-close-line (the line width the glyph lacks
 * against the frame's X; default none), --rz-sheet-gap (the one gap of the sheet's stack: the close row, the
 * card's columns and their modules; default 24px), and the photo box:
 * --rz-sheet-media-ratio (width/height; default the image's own) and
 * --rz-sheet-media-radius (default 12px).
 * ------------------------------------------------------------------------ */
@keyframes rz-sheet-up {
	from {
		transform: translateY(100%);
	}

	to {
		transform: translateY(0);
	}
}

@keyframes rz-sheet-down {
	from {
		transform: translateY(0);
	}

	to {
		transform: translateY(100%);
	}
}

@media only screen and (max-width: 767px) {
	body:not(.et-fb) .rz-canvas-sheet.rz-canvas-sheet {
		position: fixed !important;
		top: auto !important;
		right: 0 !important;
		bottom: 0 !important;
		left: 0 !important;
		box-sizing: border-box;
		width: 100% !important;
		max-width: 100% !important;
		height: auto !important;
		max-height: calc(100vh - var(--rz-sheet-top, 15vh));
		max-height: calc(100dvh - var(--rz-sheet-top, 15dvh));
		margin: 0 !important;
		padding: var(--rz-sheet-pad-top, 24px) var(--rz-sheet-pad-x, 16px) var(--rz-sheet-pad-bottom, 24px) !important;
		overflow-x: hidden;
		overflow-y: auto;
		overscroll-behavior: contain;
		-webkit-overflow-scrolling: touch;
		border-radius: var(--rz-sheet-radius, 20px) var(--rz-sheet-radius, 20px) 0 0;
		background-color: var(--rz-sheet-bg, #fff) !important;
		-webkit-backdrop-filter: none !important;
		backdrop-filter: none !important;
		box-shadow: 0 0 0 100vmax rgba(17, 24, 39, 0.55);
		z-index: 100001;
		animation: rz-sheet-up 0.3s ease-out;
	}

	body:not(.et-fb) .rz-canvas-sheet.rz-canvas-sheet.rz-sheet-closing {
		animation: rz-sheet-down 0.25s ease-in forwards;
	}

	body:not(.et-fb) .rz-canvas-sheet.rz-canvas-sheet > .et_pb_row:has(.rz-canvas-close) {
		position: sticky;
		top: 0;
		/* Above modules with their own z-index (images, groups) in the sheet. */
		z-index: 100;
		justify-content: flex-end;
		margin: 0 0 var(--rz-sheet-gap, 24px) !important;
		padding: 0 !important;
	}

	/* The desktop card (a row with a fill, radius and shadow) becomes the sheet itself. */
	body:not(.et-fb) .rz-canvas-sheet.rz-canvas-sheet > .et_pb_row:not(:has(.rz-canvas-close)) {
		box-sizing: border-box;
		width: 100% !important;
		max-width: 100% !important;
		margin: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		border-radius: 0 !important;
		background-color: transparent !important;
		box-shadow: none !important;
		row-gap: var(--rz-sheet-gap, 24px) !important;
	}

	/* One stack: the card's columns and their modules at the frame's gap. */
	body:not(.et-fb) .rz-canvas-sheet.rz-canvas-sheet > .et_pb_row:not(:has(.rz-canvas-close)) > .et_pb_column {
		row-gap: var(--rz-sheet-gap, 24px) !important;
	}

	body:not(.et-fb) .rz-canvas-sheet.rz-canvas-sheet .et_pb_image img {
		height: auto !important;
		aspect-ratio: var(--rz-sheet-media-ratio, auto) !important;
		object-fit: cover;
		border-radius: var(--rz-sheet-media-radius, 12px) !important;
	}

	body:not(.et-fb) .rz-canvas-sheet .rz-canvas-close.rz-canvas-close {
		box-sizing: border-box;
		width: var(--rz-sheet-close, 44px) !important;
		height: var(--rz-sheet-close, 44px) !important;
		margin-right: 0;
		margin-left: auto;
		background-color: var(--rz-sheet-close-bg, #eef0f3);
	}

	body:not(.et-fb) .rz-canvas-sheet .rz-canvas-close.rz-canvas-close .et-pb-icon {
		font-size: var(--rz-sheet-close-icon, 18px) !important;
	}

	/* Divi draws the glyph as a mask: a sideways copy adds the line width it
	 * lacks. With no --rz-sheet-close-line the filter is invalid, so none. */
	body:not(.et-fb) .rz-canvas-sheet .rz-canvas-close.rz-canvas-close .et_pb_icon_wrap {
		filter: drop-shadow(var(--rz-sheet-close-line) 0 0);
	}
}

@media (prefers-reduced-motion: reduce) {
	body:not(.et-fb) .rz-canvas-sheet.rz-canvas-sheet,
	body:not(.et-fb) .rz-canvas-sheet.rz-canvas-sheet.rz-sheet-closing {
		animation: none;
	}
}
