/*
 * RaptClub home page (1.20.0 to 1.20.3): the hero, and the measures the page
 * below it shares. Loaded on the front page only, after showcase.css.
 *
 * The page opens on paper, a whole screen of it: RAPT / WHEN / WRAPPED in
 * ink, WHEN a 1px contour, one line of copy with links to the pieces in the
 * picture, and the picture on the right, 2:3, standing on WRAPPED's baseline,
 * the two in the middle of the screen's height (1.20.3). The page simply
 * scrolls on from it (1.20.4: the owner did not want the lacquer sliding over
 * a held hero, 1.20.2's reveal). One
 * highlight crosses the slogan on arrival; then its outer words trade places
 * and come back, over and over, until the pause button beside it is pressed
 * (the owner's choice, 1.20.1); paused, they stay where they are (1.20.2).
 *
 * The home page keeps the site's frame, so the header does not move between
 * pages (1.20.1); the frame is 1920px since 1.20.6. The type sizes stop
 * growing at a window of about 1800px, the column at 2000px.
 *
 * The picture is the Featured image of the page set as the home page, never
 * wider than the frame's five columns: staging's CDN serves every image at
 * most 1600 px wide, so the scale of the hero is carried by the type.
 */

main.rc-home {
	--rc-home-space: clamp(4.5rem, 11vw, 12rem);
	--rc-home-step: clamp(2.5rem, 6vw, 6.5rem);
	--rc-home-near: clamp(1.25rem, 2.4vw, 2.75rem);
	--rc-home-h2: clamp(2.25rem, 5.8vw, 6.5rem);
	--rc-home-lede: clamp(1.5rem, 2.9vw, 3.25rem);
	--rc-home-link: clamp(0.8rem, 0.62vw, 0.9rem);
}

/* ---------------------------------------------------------------------------
 * The hero
 * ------------------------------------------------------------------------ */

.rc-home-hero {
	overflow-x: clip;
	background: var(--rc-paper);
}

/* Phones and portrait screens: slogan, picture, copy, one under another.
   At least a screen tall (1.20.2); any height to spare opens above the
   picture, so the picture and copy stand on the fold. */
.rc-home-hero__grid {
	container-type: inline-size;
	display: flex;
	flex-direction: column;
	min-height: calc(100svh - var(--rc-header-actual, 4.8125rem) - var(--wp-admin--admin-bar--height, 0px));
	padding-block: clamp(1.5rem, 6vw, 2.5rem) clamp(2.5rem, 10vw, 3rem);
}

/* The space between the slogan and the picture: 1.5rem, or all the height
   there is to spare. */
.rc-home-hero__grid::before {
	flex: 1 0 1.5rem;
	order: 1;
	content: "";
}

.rc-slogan {
	--rc-slogan-w: 100cqi;
	position: relative;
	isolation: isolate;
	display: grid;
	grid-template-rows: repeat(3, 0.84em);
	width: max-content;
	margin: 0 0 0 -0.06em;
	padding: 0.1em 0.06em;
	background: var(--rc-paper);
	color: var(--rc-ink);
	font-family: var(--rc-font);
	/* As wide as the column allows, but never taller than the screen: a
	   phone turned sideways would otherwise show the slogan and a sliver. */
	font-size: min(calc(var(--rc-slogan-w) / 5.5), calc((100svh - var(--rc-header-actual, 4.8125rem) - 2rem) / 2.72));
	font-weight: 700;
	letter-spacing: 0;
	line-height: 0.84;
	text-transform: uppercase;
}

.rc-slogan__word {
	position: relative;
	grid-column: 1;
	justify-self: start;
	white-space: nowrap;
}

/* The ink of R and W hangs on the frame line, under the logo. */
.rc-slogan__word--rapt {
	grid-row: 1;
	z-index: 0;
	margin-left: -0.076em;
}

/* WHEN is drawn, not filled: the same 1px line of light that draws every
   edge further down the page. */
.rc-slogan__word--when {
	grid-row: 2;
	z-index: 1;
	margin-left: 1.44em;
	color: transparent;
	-webkit-text-fill-color: transparent;
	-webkit-text-stroke: clamp(1px, 0.0045em, 1.5px) var(--rc-ink);
}

.rc-slogan__word--wrapped {
	grid-row: 3;
	z-index: 2;
	margin-left: -0.02em;
}

/* The highlight. Its brightest point is the paper's own colour and it is
   blended with "lighten", so on the paper it is invisible and it only shows
   where it crosses the ink: light running across black latex. */
.rc-slogan__light {
	position: absolute;
	inset: 0;
	z-index: 3;
	overflow: hidden;
	mix-blend-mode: lighten;
	pointer-events: none;
}

.rc-slogan__bar {
	position: absolute;
	inset: 0;
	/* At rest it lies wholly outside the slogan: at -60% its tail still
	   greyed the R. */
	transform: translateX(-72%);
	background: linear-gradient(104deg, rgb(42 42 46 / 0) 40%, #2a2a2e 45%, #9d9da3 48.5%, #f5f5f7 50%, #9d9da3 51.5%, #2a2a2e 55%, rgb(42 42 46 / 0) 60%);
}

/* The pause button: a small ring beside the slogan, since the slogan now
   moves without end (WCAG 2.2.2 asks for a way to stop it). Two bars while
   it moves, a triangle once it is still. */
.rc-slogan-pause,
button.rc-slogan-pause {
	position: relative;
	display: grid !important;
	place-items: center;
	align-self: flex-end;
	width: 2.25rem !important;
	height: 2.25rem !important;
	margin: 0.75rem 0 0 !important;
	border: 1px solid var(--rc-line-strong) !important;
	/* The site's global reset squares every button's corners. */
	border-radius: 50% !important;
	color: var(--rc-ink) !important;
	cursor: pointer;
	transition: border-color 180ms var(--rc-ease);
}

.rc-slogan-pause:hover,
button.rc-slogan-pause:hover {
	border: 1px solid var(--rc-ink) !important;
	color: var(--rc-ink) !important;
}

.rc-slogan-pause:focus-visible,
button.rc-slogan-pause:focus-visible {
	outline: 2px solid var(--rc-ink) !important;
	outline-offset: 3px;
}

.rc-slogan-pause::before {
	width: 0.5rem;
	height: 0.625rem;
	border-inline: 2px solid currentColor;
	content: "";
}

.rc-slogan-pause[data-state="still"]::before {
	width: 0;
	height: 0;
	margin-left: 0.15rem;
	border-block: 0.3125rem solid transparent;
	border-inline: 0.5rem solid transparent;
	border-left-color: currentColor;
	border-right: 0;
}

.rc-home-hero__figure {
	position: relative;
	order: 1;
	flex-shrink: 0;
	aspect-ratio: 1;
	max-height: 56svh;
	margin: 0 calc(50% - 50vw);
	overflow: hidden;
	background: var(--rc-paper-soft);
}

.rc-home-hero__figure img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: var(--rc-hero-focus, 50% 0%);
}

/* The picture's colour, chosen in the page editor's Home hero panel: as
   shot, quieter, or black and white (1.20.1). */
.rc-home-hero__figure.is-tone-muted img {
	filter: saturate(0.35);
}

.rc-home-hero__figure.is-tone-mono img {
	filter: grayscale(1);
}

.rc-home-hero__copy {
	order: 2;
	padding-top: 1.25rem;
}

.rc-home-hero__line {
	max-width: 24em;
	margin: 0;
	color: var(--rc-ink);
	font-size: clamp(1.125rem, 1.2vw, 1.375rem);
	font-weight: 400;
	letter-spacing: 0;
	line-height: 1.25;
}

.rc-home-hero__links {
	display: flex;
	flex-wrap: wrap;
	column-gap: clamp(1.5rem, 3vw, 2.75rem);
	margin: clamp(0.75rem, 1.2vw, 1.5rem) 0 0;
}

/* Wide screens: twelve columns. The copy top left, the slogan along the
   bottom of columns 1 to 7, the picture in columns 8 to 12 at 2:3, its
   bottom edge on WRAPPED's baseline. The hero is a whole screen tall
   (1.20.2), and the picture and slogan sit in the middle of it, the same
   paper above and below them (1.20.3, the owner: 1.20.2 left all the space
   above, "上下gap要视觉均匀协调"). The gap is never less than --rc-hero-gap,
   so where the window's height caps the picture it still has paper above
   it as well as below. */
@media (min-width: 64rem) and (min-aspect-ratio: 5/4) {
	.rc-home-hero {
		display: grid;
		align-content: center;
		min-height: calc(100svh - var(--rc-header-actual, 4.8125rem) - var(--wp-admin--admin-bar--height, 0px));
	}

	.rc-home-hero__grid {
		--rc-hero-gap: clamp(2.5rem, 3.6vw, 4rem);
		--rc-hero-max: calc(100svh - var(--rc-header-actual, 4.8125rem) - var(--wp-admin--admin-bar--height, 0px) - 2 * var(--rc-hero-gap));
		display: grid;
		grid-template-columns: repeat(12, minmax(0, 1fr));
		grid-template-rows: auto minmax(0, 1fr) auto;
		column-gap: var(--rc-gutter);
		min-height: 0;
		padding-block: var(--rc-hero-gap);
	}

	.rc-home-hero__grid::before {
		display: none;
	}

	/* When the window's height caps the picture, it narrows towards the
	   frame's right edge (so it still lines up with the header's last
	   control), not towards column 8. */
	.rc-home-hero__figure {
		grid-column: 8 / -1;
		grid-row: 1 / -1;
		align-self: end;
		justify-self: end;
		width: min(100%, calc(var(--rc-hero-max) * 2 / 3));
		max-height: var(--rc-hero-max);
		margin: 0;
		aspect-ratio: 2 / 3;
	}

	/* The copy's first line sits level with the picture's top edge: the
	   picture sets the grid's height, so both start on its first line. */
	.rc-home-hero__copy {
		grid-column: 1 / span 4;
		grid-row: 1;
		align-self: start;
		padding-top: 0;
	}

	/* Level by the capitals, not by the line box. */
	.rc-home-hero__line {
		text-box: trim-start cap alphabetic;
	}

	/* Seven columns wide, and never so tall that the copy and the slogan
	   meet on a short window. The negative margin puts WRAPPED's baseline on
	   the picture's bottom edge: .09em from the baseline to the foot of the
	   line box at line-height .84, plus the .1em padding. */
	.rc-slogan {
		--rc-slogan-w: calc((100cqi - 11 * var(--rc-gutter)) / 12 * 7 + 6 * var(--rc-gutter));
		grid-column: 1 / span 7;
		grid-row: 3;
		align-self: end;
		margin-bottom: -0.19em;
		font-size: min(calc(var(--rc-slogan-w) / 5.5), calc((100svh - 23rem) / 2.72));
	}

	/* The pause ring: at the right of the slogan's columns, just above the
	   slogan, out of the words' path (WRAPPED runs to the column's end when
	   it is on the top line). */
	.rc-slogan-pause,
	button.rc-slogan-pause {
		grid-column: 7;
		grid-row: 2;
		align-self: end;
		justify-self: end;
		margin: 0 0 1.25rem !important;
	}

	.rc-home-hero--type .rc-slogan {
		--rc-slogan-w: 100cqi;
		grid-column: 1 / -1;
	}

	.rc-home-hero--type .rc-slogan-pause,
	.rc-home-hero--type button.rc-slogan-pause {
		grid-column: 12;
	}
}

/* The motion, only in the slogan's own face (the gate in functions.php sets
   rc-fonts-ready) and never under reduced motion. It paints at rest; the
   highlight crosses once (0.6s to 2s); then the outer words trade places
   across WHEN and come back, every six seconds: 2.1s at rest, 0.9s to cross,
   2.1s held, 0.9s back. */
@keyframes rc-slogan-rapt {
	0%,
	35% {
		transform: none;
	}

	50%,
	85% {
		transform: translateY(1.68em);
	}

	100% {
		transform: none;
	}
}

@keyframes rc-slogan-wrapped {
	0%,
	35% {
		transform: none;
	}

	50%,
	85% {
		transform: translateY(-1.68em);
	}

	100% {
		transform: none;
	}
}

@keyframes rc-slogan-pass {
	from {
		transform: translateX(-72%);
	}

	to {
		transform: translateX(72%);
	}
}

@media (prefers-reduced-motion: no-preference) {
	.rc-fonts-ready:not(.rc-fonts-late) .rc-slogan__word--rapt {
		animation: rc-slogan-rapt 6s var(--rc-tension) 400ms infinite;
		will-change: transform;
	}

	.rc-fonts-ready:not(.rc-fonts-late) .rc-slogan__word--wrapped {
		animation: rc-slogan-wrapped 6s var(--rc-tension) 400ms infinite;
		will-change: transform;
	}

	.rc-fonts-ready:not(.rc-fonts-late) .rc-slogan__bar {
		animation: rc-slogan-pass 1400ms var(--rc-tension) 600ms both;
	}

	/* Paused: everything stays where it is, RAPT or WRAPPED on top (1.20.2;
	   it used to go back to rest, so WRAPPED on top dropped back down).
	   raptclub.js lets a swap under way, or the highlight's one pass, finish
	   first, so nothing stops in mid-air. Played again, it carries on from
	   there. rc-slogan-still is the head script's: paused on an earlier
	   visit, it never starts. */
	.rc-slogan.is-still .rc-slogan__word,
	.rc-slogan.is-still .rc-slogan__bar,
	.rc-slogan-still .rc-slogan__word,
	.rc-slogan-still .rc-slogan__bar {
		animation-play-state: paused;
	}
}

@media (prefers-reduced-motion: reduce) {
	.rc-slogan__word {
		transform: none !important;
		animation: none !important;
	}

	.rc-slogan__light,
	.rc-slogan-pause,
	button.rc-slogan-pause {
		display: none !important;
	}
}

/* Nothing moves when the font was late, so there is nothing to pause; the
   ring keeps its place so nothing below it jumps. Without the script there
   is no motion and no ring from the start. */
.rc-fonts-late .rc-slogan-pause,
.rc-fonts-late button.rc-slogan-pause {
	visibility: hidden;
}

html:not(.rc-js) .rc-slogan-pause,
html:not(.rc-js) button.rc-slogan-pause {
	display: none !important;
}

@media (forced-colors: active) {
	.rc-slogan {
		background: Canvas;
	}

	.rc-slogan__word--when {
		-webkit-text-fill-color: currentColor;
		-webkit-text-stroke: 0;
	}

	.rc-slogan__light {
		display: none;
	}
}

@supports not (mix-blend-mode: lighten) {
	.rc-slogan__light {
		display: none;
	}
}
