/*
 * Block styles used inside page content: section headings with tracker
 * pattern numbers, release meta lines, tracklist tables, video panels and
 * the copper-bar separator. Loaded in the editor too.
 */

@counter-style pm-hex {
	system: numeric;
	symbols: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F";
	pad: 2 "0";
}

.pm-front,
.pm-page {
	counter-reset: pm-pattern -1;
}

.pm-section {
	padding-block: var(--wp--preset--spacing--60);
}

.pm-section + .pm-section {
	border-top: 1px solid rgb(58 48 112 / 0.5);
}

/* Each section heading carries its tracker pattern number: PAT 00, 01... */
.pm-section > .wp-block-heading:first-child {
	counter-increment: pm-pattern;
}

.pm-section > .wp-block-heading:first-child::before {
	content: "PAT " counter(pm-pattern, pm-hex) / "";
	display: block;
	margin-bottom: 0.75rem;
	color: var(--pm-aurora);
	font-family: var(--pm-mono);
	font-size: 0.8rem;
	font-weight: 500;
	letter-spacing: 0.2em;
}

.pm-section__intro {
	max-width: 40rem;
	color: var(--pm-haze);
}

/* Sections are wide for the release columns; running prose keeps a
   readable measure. */
.pm-section > p {
	max-width: 46rem;
}

.pm-meta {
	margin-top: 0.5rem;
	color: var(--pm-aurora);
	font-family: var(--pm-mono);
	font-size: var(--wp--preset--font-size--small);
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/* His own release notes, set apart from the editorial copy by the rule. */
.pm-note {
	margin-block: 1.25rem;
	padding-left: 1.25rem;
	border-left: 2px solid var(--pm-violet);
	color: var(--pm-haze);
}

.pm-note > p {
	margin-block: 0 0.75rem;
}

.pm-note > p:last-child {
	margin-bottom: 0;
}

.pm-credits {
	color: var(--pm-haze);
	font-family: var(--pm-mono);
	font-size: 0.8rem;
}

.wp-block-details {
	margin-top: 1.5rem;
	border: 1px solid var(--pm-line);
	background: rgb(21 16 51 / 0.6);
}

.wp-block-details summary {
	padding: 0.75rem 1rem;
	color: var(--pm-text);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	cursor: pointer;
}

.wp-block-details summary:hover {
	color: var(--pm-magenta);
}

.wp-block-details[open] summary {
	border-bottom: 1px solid var(--pm-line);
}

.wp-block-details > :not(summary) {
	margin: 0;
}

.wp-block-table.is-style-pattern {
	margin: 0;
	overflow-x: auto;
}

/* Core draws a 3px currentColor rule under thead; the pattern uses the line colour. */
.wp-block-table.is-style-pattern :where(thead, tfoot) {
	border: 0;
}

.wp-block-table.is-style-pattern table {
	width: 100%;
	border-collapse: collapse;
	counter-reset: pm-row -1;
}

.wp-block-table.is-style-pattern :where(th, td) {
	padding: 0.35rem 1rem;
	border: 0;
	text-align: left;
}

.wp-block-table.is-style-pattern thead th {
	color: var(--pm-haze);
	font-weight: 400;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	border-bottom: 1px solid var(--pm-line);
}

.wp-block-table.is-style-pattern tbody tr {
	counter-increment: pm-row;
}

/* Every fourth row is lit, like the beat rows in a tracker pattern. */
.wp-block-table.is-style-pattern tbody tr:nth-child(4n + 1) {
	background: rgb(185 150 255 / 0.08);
}

.wp-block-table.is-style-pattern tbody tr:hover {
	background: rgb(255 112 216 / 0.12);
}

.wp-block-table.is-style-pattern tbody td:first-child::before {
	content: counter(pm-row, pm-hex) / "";
	display: inline-block;
	width: 2.5ch;
	margin-right: 1.25ch;
	color: var(--pm-aurora);
}

.wp-block-table.is-style-pattern :where(th, td):last-child {
	width: 1%;
	color: var(--pm-haze);
	text-align: right;
	white-space: nowrap;
}

.wp-block-table.is-style-pattern a {
	color: var(--pm-text);
	text-decoration-color: rgb(185 150 255 / 0.5);
	text-underline-offset: 3px;
}

.wp-block-table.is-style-pattern a:hover {
	color: var(--pm-magenta);
}

.wp-block-group.is-style-panel {
	position: relative;
	padding: var(--wp--preset--spacing--40);
	border: 1px solid var(--pm-line);
	background:
		repeating-linear-gradient(0deg, rgb(238 234 255 / 0.025) 0 1px, transparent 1px 3px),
		linear-gradient(160deg, var(--pm-dusk), var(--pm-deep));
}

.wp-block-group.is-style-panel::before {
	content: "";
	position: absolute;
	inset: 0 0 auto;
	height: 2px;
	background: var(--pm-copper);
}

.wp-block-group.is-style-panel h3 {
	margin-top: 0;
}

.pm-videos .is-style-panel > .wp-block-buttons {
	padding-top: var(--wp--preset--spacing--30);
}

/*
 * Side by side, the panels share heading, text and button rows through
 * subgrid, so a heading that wraps to more lines does not push one panel's
 * text and button out of line with the others. 782px is where core columns
 * stop stacking.
 */
@media (min-width: 782px) {
	.wp-block-columns.pm-videos {
		display: grid;
		grid-auto-columns: minmax(0, 1fr);
		grid-auto-flow: column;
		grid-template-rows: repeat(3, auto);
		row-gap: 0;
	}

	.pm-videos > .wp-block-column,
	.pm-videos .is-style-panel {
		display: grid;
		grid-row: span 3;
		grid-template-rows: subgrid;
	}

	/*
	 * Narrow panels would otherwise break "ASSEMBLY" mid-word. Viewport units
	 * stand in for container units, whose containment would break the subgrid;
	 * the rem floor keeps the heading growing with text zoom.
	 */
	.pm-videos .is-style-panel > h3 {
		font-size: clamp(1.125rem, 2.4vw, var(--wp--preset--font-size--large));
	}

	.pm-videos .is-style-panel > .wp-block-buttons {
		align-items: stretch;
	}

	.pm-videos .is-style-panel .wp-block-button {
		flex: 1;
	}

	.pm-videos .is-style-panel .wp-block-button__link {
		display: grid;
		height: 100%;
		place-items: center;
	}
}

/* Each panel shows a channel scope, as a tracker does per channel. */
.pm-videos .is-style-panel > h3::before {
	content: "";
	display: block;
	height: 3rem;
	margin-bottom: var(--wp--preset--spacing--30);
	border: 1px solid var(--pm-line);
	background: var(--pm-scope) center / 100% 100% no-repeat, var(--pm-night);
}

.pm-videos > .wp-block-column:nth-child(3n+1) {
	--pm-scope: url("../img/scope-sample.svg");
}

.pm-videos > .wp-block-column:nth-child(3n+2) {
	--pm-scope: url("../img/scope-square.svg");
}

.pm-videos > .wp-block-column:nth-child(3n) {
	--pm-scope: url("../img/scope-saw.svg");
}

.wp-block-separator.is-style-copper {
	height: 4px;
	border: 0;
	background: var(--pm-copper);
	opacity: 1;
}
