/*
 * The funnel guide page (/promotion-funnel-guide/), block r2s/funnel-guide.
 * Loaded only on a page that contains that block (see functions.php).
 * Uses only theme tokens. Stage colours come from data-tone (sky, lavender, mint, butter, peach).
 */

.r2s-guide {
	display: grid;
	/* minmax(0, 1fr): the wide matrix table scrolls inside its box instead of widening the page. */
	grid-template-columns: minmax(0, 1fr);
	margin-block: 0 !important;
}

/* Sections line up with the hero: the wide width plus the page's side padding. */
.r2s-guide-section,
.r2s-guide .r2s-band__inner {
	box-sizing: border-box;
	max-width: calc(var(--wp--style--global--wide-size) + var(--wp--style--root--padding-left, 1rem) + var(--wp--style--root--padding-right, 1rem));
}

.r2s-guide-section {
	width: 100%;
	margin-inline: auto;
	padding: var(--wp--preset--spacing--70) var(--wp--style--root--padding-right, 1rem) var(--wp--preset--spacing--70) var(--wp--style--root--padding-left, 1rem);
}

.r2s-guide-subhead {
	margin: var(--wp--preset--spacing--60) 0 var(--wp--preset--spacing--40);
	font-size: var(--wp--preset--font-size--large);
}

.r2s-guide-muted {
	color: var(--wp--preset--color--muted);
}

/* ---------- "On this page" links ---------- */

.r2s-guide-nav {
	position: sticky;
	top: 0;
	z-index: 5;
	width: 100%;
	max-width: none;
	border-block: 1px solid var(--wp--preset--color--line);
	background: color-mix(in srgb, var(--wp--preset--color--background) 92%, transparent);
	backdrop-filter: blur(8px);
}

.r2s-guide-nav ul {
	display: flex;
	gap: 0.25rem;
	box-sizing: border-box;
	max-width: calc(var(--wp--style--global--wide-size) + var(--wp--style--root--padding-left, 1rem) + var(--wp--style--root--padding-right, 1rem));
	margin: 0 auto;
	padding: 0.5rem calc(var(--wp--style--root--padding-right, 1rem) - 0.9rem) 0.5rem calc(var(--wp--style--root--padding-left, 1rem) - 0.9rem);
	overflow-x: auto;
	list-style: none;
	scrollbar-width: none;
}

.r2s-guide-nav a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding-inline: 0.9rem;
	border-radius: var(--wp--custom--radius--pill);
	color: var(--wp--preset--color--ink);
	font-weight: 600;
	white-space: nowrap;
	text-decoration: none;
}

.r2s-guide-nav a:hover {
	background: var(--wp--preset--color--surface);
}

/* Section headings land below the sticky links when jumped to. */
.r2s-guide [id] {
	scroll-margin-top: 5rem;
}

/* ---------- Effectiveness matrix ---------- */

.r2s-matrix__picker {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-block-end: var(--wp--preset--spacing--30);
}

.r2s-matrix__picker[hidden] {
	display: none;
}

.r2s-matrix__stage {
	min-height: 44px;
	padding: 0.4rem 1.1rem;
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--ink) 20%, transparent);
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--ink);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background-color var(--wp--custom--motion--fast), border-color var(--wp--custom--motion--fast);
}

.r2s-matrix__stage:hover {
	border-color: var(--wp--preset--color--ink);
}

.r2s-matrix__stage[aria-pressed="true"] {
	border-color: var(--wp--preset--color--ink);
	background: var(--r2s-bg);
	color: var(--r2s-ink);
	box-shadow: inset 0 0 0 1px var(--wp--preset--color--ink);
}

.r2s-matrix__summary {
	min-height: 1.6em;
	margin: 0 0 var(--wp--preset--spacing--30);
	font-weight: 600;
}

.r2s-matrix__scroll {
	/* "relative" keeps the hidden screen-reader words inside the scroll box, not past the page edge. */
	position: relative;
	overflow-x: auto;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--panel);
	background: var(--wp--preset--color--surface);
}

.r2s-matrix__table {
	width: 100%;
	min-width: 52rem;
	border-collapse: collapse;
}

.r2s-matrix__table th,
.r2s-matrix__table td {
	padding: 0.9rem 1rem;
	border-block-end: 1px solid var(--wp--preset--color--line);
	text-align: start;
	vertical-align: middle;
	transition: background-color var(--wp--custom--motion--fast), opacity var(--wp--custom--motion--fast);
}

.r2s-matrix__table tbody tr:last-child > * {
	border-block-end: 0;
}

/* Stage headings carry their pastel tone, like a colour key down each column. */
.r2s-matrix__table thead th {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--base);
	font-weight: 700;
	letter-spacing: 0.01em;
}

.r2s-matrix__table thead th[data-stage] {
	background: var(--r2s-bg);
	color: var(--r2s-ink);
}

.r2s-matrix__table thead th:first-child {
	position: sticky;
	left: 0;
	z-index: 2;
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--muted);
	font-family: inherit;
	font-weight: 600;
}

/* The mechanic name column stays in view while the table scrolls sideways on a phone. */
.r2s-matrix__table tbody th {
	position: sticky;
	left: 0;
	z-index: 1;
	min-width: 13rem;
	background: var(--wp--preset--color--surface);
	font-weight: 400;
}

@media (max-width: 599px) {
	.r2s-matrix__table tbody th {
		min-width: 9.5rem;
	}

	.r2s-matrix__table th,
	.r2s-matrix__table td {
		padding-inline: 0.75rem;
	}
}

.r2s-matrix__name {
	display: block;
	font-weight: 700;
}

.r2s-matrix__links {
	display: block;
	margin-block-start: 0.15rem;
	color: var(--wp--preset--color--muted);
}

.r2s-matrix__links a {
	color: var(--wp--preset--color--accent-ink);
	font-weight: 600;
}

/* A picked stage: its column is tinted, rows that are not a strong fit fade back. */
.r2s-matrix.is-picking td.is-picked,
.r2s-matrix.is-picking th.is-picked {
	background: color-mix(in srgb, var(--wp--preset--color--highlight) 70%, var(--wp--preset--color--surface));
}

.r2s-matrix.is-picking thead th.is-picked {
	box-shadow: inset 0 -3px 0 var(--wp--preset--color--ink);
}

/* Rows that are not a strong fit: only the bars fade, so every word stays readable. */
.r2s-matrix tr.is-dim .r2s-fit__bars {
	opacity: 0.35;
}

.r2s-matrix tr.is-strong th {
	box-shadow: inset 4px 0 0 var(--wp--preset--color--ink);
}

/* One score: three bars plus a word (never colour alone). */
.r2s-fit {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	white-space: nowrap;
}

.r2s-fit__bars {
	display: inline-flex;
	align-items: flex-end;
	gap: 3px;
	height: 1.1rem;
}

.r2s-fit__bars i {
	display: block;
	width: 7px;
	border-radius: 2px;
	background: color-mix(in srgb, var(--wp--preset--color--ink) 14%, transparent);
}

.r2s-fit__bars i:nth-child(1) { height: 40%; }
.r2s-fit__bars i:nth-child(2) { height: 70%; }
.r2s-fit__bars i:nth-child(3) { height: 100%; }

.r2s-fit[data-score="1"] i:nth-child(-n + 1),
.r2s-fit[data-score="2"] i:nth-child(-n + 2),
.r2s-fit[data-score="3"] i {
	background: var(--wp--preset--color--accent-ink);
}

.r2s-fit[data-score="3"] .r2s-fit__word {
	font-weight: 700;
}

.r2s-fit[data-score="1"] .r2s-fit__word {
	color: var(--wp--preset--color--muted);
}

.r2s-matrix__legend {
	display: grid;
	gap: 0.5rem;
	margin-block-start: var(--wp--preset--spacing--30);
}

.r2s-matrix__legend p {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1.5rem;
	margin: 0;
}

.r2s-matrix__legend-title {
	font-weight: 700;
}

.r2s-matrix__note {
	max-width: 46rem;
	color: var(--wp--preset--color--muted);
}

.r2s-guide-points {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
	gap: var(--wp--preset--spacing--30);
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: point;
}

.r2s-guide-points li {
	padding: var(--wp--preset--spacing--40);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--card);
	background: var(--wp--preset--color--surface);
	counter-increment: point;
}

.r2s-guide-points li::before {
	content: counter(point, decimal-leading-zero);
	display: block;
	margin-block-end: 0.5rem;
	color: var(--wp--preset--color--accent-ink);
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 250;
	line-height: 1;
}

.r2s-guide-points strong {
	display: block;
	margin-block-end: 0.25rem;
}

/* ---------- Stage by stage ---------- */

.r2s-stages {
	display: grid;
	gap: var(--wp--preset--spacing--30);
	margin: 0;
	padding: 0;
	list-style: none;
}

.r2s-stage {
	display: grid;
	gap: var(--wp--preset--spacing--40);
	padding: clamp(1.25rem, 3vw, 2rem);
	border-radius: var(--wp--custom--radius--panel);
	background: var(--r2s-bg);
	color: var(--r2s-ink);
}

.r2s-stage__head > * {
	margin: 0;
}

/* Big thin numbers: Pill Gothic Thin. */
.r2s-stage__num {
	display: block;
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(3rem, 6vw, 4.5rem);
	font-weight: 250;
	line-height: 0.9;
	letter-spacing: -0.02em;
}

.r2s-stage__label {
	margin-block-start: 0.75rem !important;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.r2s-stage__title {
	margin-block-start: 0.25rem !important;
	font-size: var(--wp--preset--font-size--x-large);
}

.r2s-stage__advice {
	max-width: 32rem;
	margin-block-start: 0.75rem !important;
}

.r2s-stage__facts {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
	gap: var(--wp--preset--spacing--30);
	margin: 0;
}

.r2s-stage__facts > div {
	padding: var(--wp--preset--spacing--30);
	border-radius: var(--wp--custom--radius--control);
	background: color-mix(in srgb, var(--wp--preset--color--surface) 70%, transparent);
}

.r2s-stage__facts dt {
	margin-block-end: 0.25rem;
	font-weight: 700;
}

.r2s-stage__facts dd {
	margin: 0;
}

.r2s-stage__measure {
	grid-column: 1 / -1;
}

.r2s-stage__question {
	display: block;
	margin-block-start: 0.35rem;
	font-style: italic;
}

@media (min-width: 960px) {
	.r2s-stage {
		grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr);
		align-items: start;
	}
}

.r2s-guide-callout {
	display: grid;
	gap: 0.5rem;
	margin-block-start: var(--wp--preset--spacing--50);
	padding: clamp(1.25rem, 3vw, 2rem);
	border-radius: var(--wp--custom--radius--panel);
	background: var(--wp--preset--color--highlight);
}

.r2s-guide-callout p {
	max-width: 48rem;
	margin: 0;
}

.r2s-guide-callout__title {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	line-height: 1.15;
}

/* ---------- By sector ---------- */

.r2s-sectors__tabs {
	display: flex;
	gap: 0.25rem;
	margin-block-end: var(--wp--preset--spacing--40);
	padding: 0.3rem;
	overflow-x: auto;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--surface);
	width: fit-content;
	max-width: 100%;
	box-sizing: border-box;
}

.r2s-sectors__tabs[hidden] {
	display: none;
}

.r2s-sectors__tab {
	flex: none;
	min-height: 44px;
	padding: 0.4rem 1.2rem;
	border: 0;
	border-radius: var(--wp--custom--radius--pill);
	background: transparent;
	color: var(--wp--preset--color--ink);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.r2s-sectors__tab:hover {
	background: var(--wp--preset--color--background);
}

.r2s-sectors__tab[aria-selected="true"] {
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--surface);
}

/* Without the script every sector is listed, so each needs space below it. */
.r2s-sectors__panel + .r2s-sectors__panel {
	margin-block-start: var(--wp--preset--spacing--50);
}

.r2s-sectors.is-tabbed .r2s-sectors__panel {
	margin-block-start: 0;
}

.r2s-sectors__panel:focus-visible {
	outline-offset: 6px;
}

.r2s-sectors__name {
	margin: 0 0 var(--wp--preset--spacing--30);
	font-size: var(--wp--preset--font-size--large);
}

.r2s-sectors.is-tabbed .r2s-sectors__name {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.r2s-sectors__stages {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
	gap: var(--wp--preset--spacing--20);
	margin: 0;
	padding: 0;
	list-style: none;
}

.r2s-sectors__stages li {
	display: grid;
	align-content: start;
	gap: 0.5rem;
	min-height: 9rem;
	padding: var(--wp--preset--spacing--40);
	border-radius: var(--wp--custom--radius--card);
	background: var(--r2s-bg);
	color: var(--r2s-ink);
}

.r2s-sectors__stage {
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.r2s-sectors__idea {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 700;
	line-height: 1.2;
}

.r2s-sectors__note {
	max-width: 48rem;
	margin: var(--wp--preset--spacing--40) 0 0;
	color: var(--wp--preset--color--muted);
}

.r2s-sectors__note strong {
	color: var(--wp--preset--color--ink);
}

/* ---------- How much gamification ---------- */

.r2s-levels {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
	gap: var(--wp--preset--spacing--30);
	margin: 0;
	padding: 0;
	list-style: none;
}

.r2s-level {
	padding: clamp(1.25rem, 3vw, 2rem);
	border-radius: var(--wp--custom--radius--panel);
	background: var(--r2s-bg);
	color: var(--r2s-ink);
}

.r2s-level__meter {
	display: block;
	font-size: var(--wp--preset--font-size--medium);
	letter-spacing: 0.2em;
}

.r2s-level h3 {
	margin: 0.5rem 0 var(--wp--preset--spacing--30);
	font-size: var(--wp--preset--font-size--large);
}

.r2s-level dl {
	display: grid;
	gap: var(--wp--preset--spacing--30);
	margin: 0;
}

.r2s-level dt {
	font-weight: 700;
}

.r2s-level dd {
	margin: 0;
}

.r2s-guide-split {
	display: grid;
	gap: var(--wp--preset--spacing--40);
	margin-block-start: var(--wp--preset--spacing--60);
}

.r2s-guide-section > .r2s-guide-split {
	margin-block-start: 0;
}

.r2s-guide-split h2,
.r2s-guide-split h3 {
	margin-block: 0 var(--wp--preset--spacing--30);
}

.r2s-guide-split p {
	margin-block: 0 var(--wp--preset--spacing--30);
}

.r2s-guide-split .r2s-ticks {
	margin-block-end: var(--wp--preset--spacing--40);
}

@media (min-width: 900px) {
	.r2s-guide-split {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
	}
}

/* ---------- Closing message ---------- */

.r2s-guide-close__quote {
	max-width: 52rem;
	margin: 0 0 var(--wp--preset--spacing--50);
	padding: 0 0 0 var(--wp--preset--spacing--40);
	border-inline-start: 3px solid var(--wp--preset--color--accent);
}

.r2s-guide-close__quote p {
	margin: 0;
	font-size: var(--wp--preset--font-size--medium);
	line-height: 1.5;
}

.r2s-guide-close__title {
	max-width: 22ch;
	margin: 0 0 var(--wp--preset--spacing--50);
	color: inherit;
	font-size: var(--wp--preset--font-size--xx-large);
}

.r2s-guide-close__stages {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
	gap: var(--wp--preset--spacing--20);
	margin: 0 0 var(--wp--preset--spacing--50);
	padding: 0;
	list-style: none;
}

.r2s-guide-close__stages li {
	display: grid;
	gap: 0.25rem;
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
	border-radius: var(--wp--custom--radius--card);
	background: var(--r2s-bg);
	color: var(--r2s-ink);
}

.r2s-guide-close__stages strong {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--medium);
}

.r2s-guide-close__lede {
	max-width: 44rem;
	margin: 0 0 var(--wp--preset--spacing--30);
	color: color-mix(in srgb, var(--wp--custom--on-deep) 82%, transparent);
}

.r2s-guide-close__link {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--wp--preset--color--accent);
	font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
	.r2s-matrix__table th,
	.r2s-matrix__table td,
	.r2s-matrix__stage {
		transition: none;
	}
}

/* ---------- Page hero (made in the page content, see scripts/fill-content.php) ---------- */

.r2s-guide-core {
	max-width: 36rem;
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
	border-inline-start: 3px solid var(--wp--preset--color--accent);
	border-radius: 0 var(--wp--custom--radius--control) var(--wp--custom--radius--control) 0;
	background: var(--wp--preset--color--surface);
}

.r2s-guide-caveat {
	margin-block: var(--wp--preset--spacing--50) 0 !important;
	color: var(--wp--preset--color--muted);
}

/* The funnel: five stage bands, each narrower than the one above. */
.r2s-funnel-visual {
	display: grid;
	justify-items: center;
	gap: 0.4rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.r2s-funnel-visual li {
	width: 100%;
}

.r2s-funnel-visual li:nth-child(2) { width: 90%; }
.r2s-funnel-visual li:nth-child(3) { width: 80%; }
.r2s-funnel-visual li:nth-child(4) { width: 70%; }
.r2s-funnel-visual li:nth-child(5) { width: 60%; }

.r2s-funnel-visual a {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: center;
	gap: 0 0.6rem;
	min-height: 44px;
	padding: 0.9rem 1rem;
	border-radius: var(--wp--custom--radius--card);
	background: var(--r2s-bg);
	color: var(--r2s-ink);
	text-align: center;
	text-decoration: none;
	transition: transform var(--wp--custom--motion--fast);
}

.r2s-funnel-visual a:hover {
	transform: scale(1.02);
}

.r2s-funnel-visual strong {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--medium);
}

@media (prefers-reduced-motion: reduce) {
	.r2s-funnel-visual a {
		transition: none;
	}

	.r2s-funnel-visual a:hover {
		transform: none;
	}
}
