/*
Theme Name: Saint Benedict Medal
Description: One page about the Saint Benedict Medal. A drawn, three-dimensional medal stays fixed at the centre of the screen and turns as the page is read.
Requires at least: 6.7
Tested up to: 6.9
Requires PHP: 7.2
Version: 0.1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: benedict-medal
Tags: full-site-editing, block-patterns, wide-blocks, accessibility-ready
*/

:root {
	--gold: var(--wp--preset--color--primary);
	--gold-line: rgba(201, 162, 77, 0.55);
	--gold-faint: rgba(201, 162, 77, 0.22);
	--ink: var(--wp--preset--color--background);
	--surface: var(--wp--preset--color--surface);
	--ivory: var(--wp--preset--color--text);
	--muted: var(--wp--preset--color--muted);
	--oxblood: var(--wp--preset--color--accent);
	--label-font: var(--wp--preset--font-family--josefin-sans);
	--ease-out: cubic-bezier(0.22, 1, 0.36, 1);
	--step: 9px;
	--stepped: polygon(
		var(--step) 0, calc(100% - var(--step)) 0, calc(100% - var(--step)) var(--step), 100% var(--step),
		100% calc(100% - var(--step)), calc(100% - var(--step)) calc(100% - var(--step)), calc(100% - var(--step)) 100%,
		var(--step) 100%, var(--step) calc(100% - var(--step)), 0 calc(100% - var(--step)), 0 var(--step), var(--step) var(--step)
	);
}

/* ---------- base ---------- */

html {
	background: var(--ink);
	color-scheme: dark;
	scrollbar-color: #4a4130 var(--ink);
	-webkit-text-size-adjust: 100%;
}
body {
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
	overflow-x: clip;
}
::selection {
	background: var(--gold);
	color: var(--ink);
}
:focus-visible {
	outline: 2px solid var(--ivory);
	outline-offset: 4px;
}
.wp-site-blocks {
	position: relative;
	z-index: 1;
}
.wp-site-blocks > * + * {
	margin-block-start: 0;
}
.wp-site-blocks main {
	padding-block: var(--wp--preset--spacing--lg) var(--wp--preset--spacing--xl);
}
.wp-site-blocks main.is-flush {
	padding-block: 0;
}
p, h1, h2, h3 {
	text-wrap: balance;
}
a {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	transition: color 200ms ease;
}

/* ---------- the fixed medal ---------- */

.medal-stage {
	position: fixed;
	inset: 0;
	height: 100lvh;
	z-index: 0;
	pointer-events: none;
	overflow: hidden;
	opacity: 0;
	transition: opacity 1400ms ease;
}
.medal-stage.is-ready {
	opacity: 1;
}
.medal-stage canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}
.medal-rays {
	--size: calc(var(--rad, 200px) * 4.2);
	position: absolute;
	left: 50%;
	top: var(--cy, 33%);
	width: var(--size);
	height: var(--size);
	translate: -50% -50%;
	rotate: var(--spin, 0deg);
	border-radius: 50%;
	opacity: var(--rays, 0);
	background: repeating-conic-gradient(from 0deg, rgba(201, 162, 77, 0.2) 0deg 0.5deg, transparent 0.5deg 5deg);
	-webkit-mask-image: radial-gradient(closest-side, transparent 49%, #000 51%, rgba(0, 0, 0, 0.35) 68%, transparent 100%);
	mask-image: radial-gradient(closest-side, transparent 49%, #000 51%, rgba(0, 0, 0, 0.35) 68%, transparent 100%);
}

.progress-line {
	position: fixed;
	inset: 0 0 auto 0;
	height: 1px;
	z-index: 5;
	background: var(--gold);
	transform: scaleX(0);
	transform-origin: 0 50%;
	pointer-events: none;
}

/* Without WebGL or without scripts: a still picture of the medal, and all the text. */
html:not(.js) .plate.pose-opening,
html.no-medal .plate.pose-opening {
	background: url(assets/images/medal-still.jpg) center clamp(48px, 7svh, 80px) / min(84vw, 54svh) no-repeat;
}
html:not(.js) .plate:not(.pose-opening),
html.no-medal .plate:not(.pose-opening) {
	min-height: 0;
	padding-block: var(--wp--preset--spacing--lg);
}

/* ---------- header ---------- */

.site-header {
	position: absolute;
	inset: 0 0 auto 0;
	z-index: 3;
	padding-block: 22px;
	text-align: center;
}
.site-header .wp-block-site-title {
	font-family: var(--label-font);
	font-size: 0.75rem;
	font-weight: 400;
	letter-spacing: 0.3em;
	text-transform: uppercase;
	line-height: 1.4;
	color: var(--muted);
	margin: 0;
}
.site-header .wp-block-site-title a {
	color: inherit;
	text-decoration: none;
}
.site-header .wp-block-site-title a:hover {
	color: var(--ivory);
}

/* ---------- chapters ---------- */

/* A plate is one screen: the medal holds the upper part, the words the lower. */
.plate {
	min-height: 100vh;
	min-height: 100svh;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	align-items: center;
	padding-block: 40svh clamp(28px, 6svh, 72px);
	text-align: center;
}
.plate > .plate-body {
	width: 100%;
	max-width: 34em;
	margin: 0;
	padding: 20px clamp(12px, 3vw, 28px);
	background: rgba(13, 13, 17, 0.8);
}
.plate > .plate-body.is-clear {
	background: none;
	max-width: 40em;
}
.plate > .plate-body.is-wide {
	width: min(1200px, 100vw - 2 * clamp(1.25rem, 5vw, 4rem));
	max-width: none;
	flex: none;
}
.chapter {
	padding-block: var(--wp--preset--spacing--xl);
	text-align: center;
}
.plate-body > *,
.chapter > * {
	margin-block: 0;
}
.plate-body > * + * {
	margin-block-start: 16px;
}
.chapter > * + * {
	margin-block-start: 24px;
}
.chapter > .year {
	margin-block-start: 0;
}

.plate h1 {
	font-size: clamp(1.875rem, 4.2vw, 3.75rem);
	margin: 0;
}
.lead {
	font-size: var(--wp--preset--font-size--lead);
	line-height: 1.45;
}
.label,
.chapter-mark {
	font-family: var(--label-font);
	font-size: var(--wp--preset--font-size--label);
	font-weight: 400;
	letter-spacing: 0.3em;
	text-transform: uppercase;
	line-height: 1.5;
	color: var(--muted);
}

/* Roman numeral, then a short gold rule with a diamond. */
.chapter-mark {
	color: var(--gold);
	padding-bottom: 26px;
	position: relative;
}
.chapter-mark::before,
.chapter-mark::after {
	content: "";
	position: absolute;
	left: 50%;
	bottom: 8px;
}
.chapter-mark::before {
	width: 88px;
	height: 1px;
	margin-left: -44px;
	background: linear-gradient(90deg, var(--gold) 0 34px, transparent 34px 54px, var(--gold) 54px);
	transition: transform 600ms var(--ease-out);
}
.chapter-mark::after {
	width: 7px;
	height: 7px;
	margin: 0 0 -3px -3.5px;
	background: var(--gold);
	rotate: 45deg;
}

.scroll-cue {
	margin-block-start: 28px !important;
}
.scroll-cue::after {
	content: "";
	display: block;
	width: 1px;
	height: 34px;
	margin: 12px auto 0;
	background: linear-gradient(var(--gold), transparent);
}

/* ---------- caption plate: letters, Latin, translation, meaning ---------- */

.plate > .caption-plate {
	background: rgba(22, 22, 28, 0.88);
	border: 1px solid var(--gold-line);
	outline: 1px solid var(--gold-faint);
	outline-offset: 6px;
	padding: clamp(20px, 3.4svh, 34px) clamp(18px, 4vw, 44px);
	width: calc(100% - 14px);
}
.caption-plate h3 {
	font-size: clamp(1.5rem, 4.4vw, 2.5rem);
	letter-spacing: 0.34em;
	margin-right: -0.34em;
	line-height: 1.15;
}
.caption-plate h3.is-phrase {
	font-size: clamp(1.125rem, 2.6vw, 1.5rem);
	letter-spacing: 0.2em;
	margin-right: -0.2em;
	line-height: 1.35;
}
.latin {
	font-style: italic;
	font-size: var(--wp--preset--font-size--lead);
	line-height: 1.4;
}
.latin strong {
	font-style: normal;
	font-weight: 400;
	color: var(--gold);
}
.caption-plate .label {
	margin-block-start: 10px;
}
.caption-plate .label + p {
	margin-block-start: 4px;
}
.meaning {
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.55;
	color: #cfc7b4;
}

/* ---------- history ---------- */

.years {
	margin-block-start: var(--wp--preset--spacing--lg);
}
.year {
	padding-block: clamp(36px, 9svh, 96px);
}
.year > * {
	margin-block: 0;
	position: relative;
}
.year-number {
	font-family: var(--label-font);
	font-weight: 300;
	font-size: clamp(5rem, 22vw, 15rem);
	line-height: 0.8;
	letter-spacing: 0.06em;
	margin-right: -0.06em;
	color: transparent;
	-webkit-text-stroke: 1px rgba(201, 162, 77, 0.5);
	will-change: transform;
	user-select: none;
}
.year-title {
	margin-block-start: -0.35em;
	color: var(--gold);
	font-family: var(--label-font);
	font-size: var(--wp--preset--font-size--label);
	letter-spacing: 0.3em;
	text-transform: uppercase;
}
.year-title + p {
	max-width: 30em;
	margin: 12px auto 0;
}

/* ---------- Saint Benedict ---------- */

.framed {
	width: min(100%, 351px);
	margin: var(--wp--preset--spacing--lg) auto 0;
}
.framed img {
	display: block;
	width: 100%;
	height: auto;
	filter: saturate(0.85);
	border: 1px solid var(--gold-line);
	outline: 1px solid var(--gold-faint);
	outline-offset: 6px;
}
.framed figcaption {
	margin-top: 22px;
	font-family: var(--label-font);
	font-size: 0.75rem;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	line-height: 1.7;
	color: var(--muted);
	text-align: center;
}
.chapter .prose {
	max-width: 34em;
	margin: 28px auto 0;
}
.chapter h2 + .lead {
	margin-block-start: 20px;
}
.chapter .chapter-mark + h2,
.plate-body .chapter-mark + h2 {
	margin-block-start: 6px;
}

/* ---------- choose your medal ---------- */

.metal-choices {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: clamp(12px, 3vw, 28px);
	margin-block-start: 20px !important;
}
.metal-choice {
	position: relative;
	isolation: isolate;
	margin: 0 !important;
	padding: clamp(16px, 2.6svh, 26px) clamp(10px, 2vw, 24px);
	cursor: pointer;
	border: 1px solid rgba(154, 146, 127, 0.4);
	background: rgba(13, 13, 17, 0.72);
	transition: border-color 300ms ease;
	-webkit-tap-highlight-color: transparent;
}
.metal-choice:hover {
	border-color: var(--gold-line);
}
.metal-choice > * {
	margin: 0;
}
.metal-choice > * + * {
	margin-block-start: 6px;
}
.metal-choice::before,
.metal-choice::after {
	content: "";
	position: absolute;
	z-index: -1;
	clip-path: var(--stepped);
	opacity: 0;
	transition: opacity 300ms ease;
}
.metal-choice::before {
	inset: -1px;
	background: var(--gold);
}
.metal-choice::after {
	inset: 0;
	background: var(--surface);
}
.metal-choice.is-selected {
	border-color: transparent;
	background: none;
}
.metal-choice.is-selected::before,
.metal-choice.is-selected::after {
	opacity: 1;
}
.metal-name {
	font-family: var(--label-font);
	font-size: 1.0625rem;
	letter-spacing: 0.3em;
	margin-right: -0.3em;
	text-transform: uppercase;
	color: var(--ivory);
	padding-top: 16px;
	position: relative;
}
/* the small oxblood mark of the chosen metal */
.metal-name::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 0;
	width: 8px;
	height: 8px;
	margin-left: -4px;
	rotate: 45deg;
	border: 1px solid rgba(154, 146, 127, 0.5);
	transition: background-color 300ms ease, border-color 300ms ease;
}
.is-selected .metal-name {
	color: var(--gold);
}
.is-selected .metal-name::before {
	background: var(--oxblood);
	border-color: var(--gold);
}
.metal-note {
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.4;
	color: #cfc7b4;
}
.metal-price {
	font-size: var(--wp--preset--font-size--lead);
	line-height: 1.3;
}

.wp-block-button__link {
	position: relative;
	isolation: isolate;
	background: none !important;
	transition: color 200ms ease;
}
.wp-block-button__link::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: var(--gold);
	clip-path: var(--stepped);
	transition: background-color 200ms ease;
}
.wp-block-button__link:hover::before {
	background: #dfbd69;
}
.wp-block-button__link:active::before {
	background: #b48d3c;
}
.small-print {
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.5;
	color: var(--muted);
}

/* ---------- closing and footer ---------- */

.pax {
	font-family: var(--label-font);
	font-weight: 300;
	font-size: clamp(4rem, 17vw, 12rem);
	letter-spacing: 0.3em;
	margin-right: -0.3em;
	line-height: 1;
	text-transform: uppercase;
	color: var(--gold);
}
.pax + .label {
	margin-block-start: var(--wp--preset--spacing--lg);
}
.label + .sources {
	margin-block-start: 12px;
}
.pose-rest {
	padding-bottom: var(--wp--preset--spacing--lg);
}
.sources {
	max-width: 36em;
	margin-inline: auto;
}
.site-footer {
	padding-block: 0 var(--wp--preset--spacing--lg);
	text-align: center;
	position: relative;
}
.language-list ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px 0;
}
.language-list li {
	display: flex;
	align-items: center;
}
.language-list li + li::before {
	content: "";
	width: 5px;
	height: 5px;
	rotate: 45deg;
	background: var(--gold-line);
	margin-inline: 4px;
}
.language-list a {
	display: block;
	padding: 14px 12px;
	font-family: var(--label-font);
	font-size: var(--wp--preset--font-size--label);
	letter-spacing: 0.24em;
	margin-right: -0.24em;
	text-transform: uppercase;
	text-decoration: none;
	color: var(--muted);
}
.language-list a:hover {
	color: var(--ivory);
}
.language-list a[aria-current] {
	color: var(--gold);
}
.site-footer .small-print {
	margin-block-start: 20px;
	font-family: var(--label-font);
	font-size: 0.875rem;
	letter-spacing: 0.08em;
	text-transform: none;
	color: var(--muted);
}
.site-footer .small-print a {
	color: var(--ivory);
	text-decoration: none;
	border-bottom: 1px solid var(--gold-line);
	padding-bottom: 2px;
}
.site-footer .small-print a:hover {
	color: var(--gold);
}

/* ---------- motion ---------- */

.has-motion .plate > *,
.has-motion .chapter > * {
	opacity: 0;
	translate: 0 12px;
	transition: opacity 600ms ease, translate 600ms var(--ease-out);
}
.has-motion .plate > .is-in,
.has-motion .chapter > .is-in {
	opacity: 1;
	translate: 0 0;
}
.has-motion .chapter-mark::before {
	transform: scaleX(0);
}
.has-motion .is-in .chapter-mark::before,
.has-motion .chapter-mark.is-in::before {
	transform: scaleX(1);
	transition-delay: 200ms;
}

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

/* ---------- small screens ---------- */

@media (max-width: 600px) {
	h1, h2 {
		letter-spacing: 0.08em;
	}
	.plate {
		padding-bottom: 22px;
	}
	.plate > .plate-body {
		padding-inline: 4px;
	}
	.plate > .caption-plate {
		padding-inline: 16px;
	}
	.plate-body > * + * {
		margin-block-start: 12px;
	}
	.latin {
		font-size: 1.1875rem;
	}
	.metal-name {
		font-size: 0.9375rem;
		letter-spacing: 0.22em;
		margin-right: -0.22em;
	}
}
