/*
Theme Name: Ball Noir
Theme URI: https://www.ballnoir.nl/
Author: Ball Noir
Description: Custom block theme for Ball Noir, ported from the Squarespace site. Textured paper and marble sections, wave dividers and subtle motion.
Requires at least: 6.6
Tested up to: 6.8
Requires PHP: 7.4
Version: 1.0.0
License: GNU General Public License v2 or later
Text Domain: ballnoir
*/

:root {
	--bn-ease: cubic-bezier(.22, .61, .36, 1);
	--bn-wave: 2vw;
	--bn-header-h: 96px;
	--bn-screen: calc(100svh - var(--bn-header-h) - var(--wp-admin--admin-bar--height, 0px));
}

html { scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img { height: auto; }
:where(.wp-site-blocks) > * { margin-block-start: 0; }
.wp-site-blocks { display: flex; flex-direction: column; min-height: 100svh; }
.wp-site-blocks > main { flex: 1 0 auto; }

a { text-underline-offset: .18em; text-decoration-thickness: 1px; transition: color .25s ease, text-decoration-color .25s ease; }
a:hover { text-decoration-color: transparent; }
:focus-visible { outline: 2px solid var(--wp--preset--color--umber); outline-offset: 3px; }

/* ---------------------------------------------------------------- Page transitions
   Cross-document View Transitions: header and footer stay put, the page content
   cross-fades with a slight rise. Browsers without support navigate as usual. */
@view-transition { navigation: auto; }
.bn-header { view-transition-name: bn-header; }
.bn-footer { view-transition-name: bn-footer; }
::view-transition-old(root) { animation: bn-page-out .28s var(--bn-ease) both; }
::view-transition-new(root) { animation: bn-page-in .6s var(--bn-ease) both; }
@keyframes bn-page-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes bn-page-in { from { opacity: 0; transform: translateY(14px); } }

/* ---------------------------------------------------------------- Header */
.bn-header {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 100;
	background: var(--wp--preset--color--white);
	min-height: var(--bn-header-h);
	padding-left: var(--wp--style--root--padding-left) !important;
	padding-right: var(--wp--style--root--padding-right) !important;
	box-sizing: border-box;
	transition: box-shadow .4s ease, min-height .4s var(--bn-ease), padding .4s var(--bn-ease);
}
@media (max-width: 600px) { .admin-bar .bn-header { top: 0; } }
.is-scrolled .bn-header { box-shadow: 0 6px 24px -14px rgba(40, 30, 20, .45); min-height: 72px; }
.bn-header .wp-block-site-logo img { transition: width .4s var(--bn-ease); }
.is-scrolled .bn-header .wp-block-site-logo img { width: 64px !important; }

.bn-header .wp-block-navigation { text-transform: uppercase; }
.bn-header .wp-block-navigation-item__content {
	text-decoration: none;
	padding-bottom: 2px;
	background: linear-gradient(currentColor, currentColor) left bottom / 0 1px no-repeat;
	transition: background-size .35s var(--bn-ease), color .25s ease;
}
.bn-header .wp-block-navigation-item__content:hover,
.bn-header .wp-block-navigation-item__content:focus-visible,
.bn-header .current-menu-item > .wp-block-navigation-item__content,
.bn-header .current-menu-ancestor > .wp-block-navigation-item__content { background-size: 100% 1px; }

/* Dropdowns: fade + slide instead of popping in */
.bn-header .wp-block-navigation .wp-block-navigation__submenu-container {
	text-transform: none;
	border: 0 !important;
	padding: .6rem 0;
	min-width: 170px !important;
	background: var(--wp--preset--color--white);
	box-shadow: 0 14px 30px -16px rgba(40, 30, 20, .4);
	transform: translateY(8px);
	transition: opacity .25s ease, transform .3s var(--bn-ease), visibility .25s;
}
.bn-header .wp-block-navigation .has-child:hover > .wp-block-navigation__submenu-container,
.bn-header .wp-block-navigation .has-child:focus-within > .wp-block-navigation__submenu-container { transform: none; }
.bn-header .wp-block-navigation__submenu-container .wp-block-navigation-item__content { padding: .35rem 1.1rem; background-position: 1.1rem calc(100% - .3rem); }
.bn-header .wp-block-navigation__submenu-container .wp-block-navigation-item__content:hover { background-size: calc(100% - 2.2rem) 1px; }
.bn-header .wp-block-navigation__submenu-icon { display: none; }

/* Mobile overlay */
.bn-header .wp-block-navigation__responsive-container.is-menu-open {
	background: var(--wp--preset--color--white) url(assets/img/texture-paper.jpg) center / cover;
	padding: 2rem;
	animation: bn-fade-in .35s ease both;
}
.bn-header .is-menu-open .wp-block-navigation__responsive-container-content { gap: 1.1rem; font-size: 1.6rem; font-family: var(--wp--preset--font-family--heading); }
.bn-header .is-menu-open .wp-block-navigation__submenu-container { box-shadow: none; background: transparent; transform: none; font-size: 1.15rem; padding-top: .6rem; }
.bn-header .is-menu-open .wp-block-navigation__submenu-container .wp-block-navigation-item__content { padding: .2rem 0; }
@keyframes bn-fade-in { from { opacity: 0; } }

.bn-social .wp-social-link { transition: transform .3s var(--bn-ease), opacity .25s; }
.bn-social .wp-social-link:hover { transform: translateY(-2px); opacity: .7; }
@media (max-width: 781px) {
	.bn-header .bn-social { display: none; }
	.bn-header__left { flex: 1; }
	.bn-header .wp-block-navigation { margin-left: auto; }
}

/* ---------------------------------------------------------------- Section backgrounds */
.is-style-bn-paper, .is-style-bn-camera, .is-style-bn-gramophone, .is-style-bn-dark, .is-style-bn-quill {
	position: relative;
	isolation: isolate;
	overflow: clip;
	background-color: var(--wp--preset--color--parchment);
}
/* The texture sits on an oversized layer so it can drift (parallax) without exposing its edges */
[class*="is-style-bn-"]::before {
	content: "";
	position: absolute;
	inset: -10% 0;
	z-index: -1;
	background: var(--bn-bg) center / cover no-repeat;
	transform: translate3d(0, var(--bn-par, 0px), 0);
	will-change: transform;
	pointer-events: none;
}
.wp-block-separator[class*="is-style-bn-"]::before { content: none; }
.is-style-bn-paper { --bn-bg: url(assets/img/texture-paper.jpg); }
.is-style-bn-camera { --bn-bg: url(assets/img/bg-camera.jpg); }
.is-style-bn-gramophone { --bn-bg: url(assets/img/bg-gramophone.jpg); }
.is-style-bn-dark, .is-style-bn-quill { background-color: var(--wp--preset--color--ink); color: #e9e6e1; }
.is-style-bn-dark { --bn-bg: url(assets/img/texture-dark.jpg); }
.is-style-bn-quill { --bn-bg: url(assets/img/bg-quill.jpg); }
:is(.is-style-bn-dark, .is-style-bn-quill) :is(h1, h2, h3, h4, h5, h6, a) { color: var(--wp--preset--color--white); }

/* A "screen" section fills the viewport under the header and centres its content */
.bn-screen {
	min-height: var(--bn-screen);
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding-block: var(--wp--preset--spacing--50);
	box-sizing: border-box;
}
.bn-screen > * { width: 100%; box-sizing: border-box; }
.bn-section { padding-block: var(--wp--preset--spacing--60); }
.bn-tall { min-height: min(38vw, 760px); display: flex; flex-direction: column; justify-content: center; }
.bn-tall > * { width: 100%; box-sizing: border-box; }

/* Wave divider: the section's bottom edge is a soft wave that overlaps the next section */
.has-wave {
	position: relative;
	z-index: 2;
	margin-bottom: calc(-1 * var(--bn-wave)) !important;
	padding-bottom: calc(var(--wp--preset--spacing--60) + var(--bn-wave));
	-webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - var(--bn-wave) + 1px) no-repeat, url(assets/img/wave.svg) bottom / 100% var(--bn-wave) no-repeat;
	mask: linear-gradient(#000 0 0) top / 100% calc(100% - var(--bn-wave) + 1px) no-repeat, url(assets/img/wave.svg) bottom / 100% var(--bn-wave) no-repeat;
}
.has-wave + * { padding-top: calc(var(--wp--preset--spacing--60) + var(--bn-wave)); }
.wp-block-cover.has-wave { padding-bottom: 0; }
.wp-block-cover.has-wave + * { padding-top: calc(var(--wp--preset--spacing--50) + var(--bn-wave)); }

/* Top wave: the section's top edge is a wave that overlaps the section above */
.has-wave-top {
	position: relative;
	z-index: 3;
	margin-top: calc(-1 * var(--bn-wave)) !important;
	padding-top: calc(var(--wp--preset--spacing--60) + var(--bn-wave));
	-webkit-mask: linear-gradient(#000 0 0) bottom / 100% calc(100% - var(--bn-wave) + 1px) no-repeat, url(assets/img/wave-top.svg) top / 100% var(--bn-wave) no-repeat;
	mask: linear-gradient(#000 0 0) bottom / 100% calc(100% - var(--bn-wave) + 1px) no-repeat, url(assets/img/wave-top.svg) top / 100% var(--bn-wave) no-repeat;
}

/* The section above a top-wave section loses a wave's height to the overlap, so give it back */
:is(.bn-section, .bn-screen, .bn-tall):has(+ .has-wave-top) { padding-bottom: calc(var(--wp--preset--spacing--60) + var(--bn-wave)); }

/* Both waves on one section */
.has-wave.has-wave-top {
	-webkit-mask: linear-gradient(#000 0 0) 0 calc(var(--bn-wave) - 1px) / 100% calc(100% - 2 * var(--bn-wave) + 2px) no-repeat, url(assets/img/wave-top.svg) top / 100% var(--bn-wave) no-repeat, url(assets/img/wave.svg) bottom / 100% var(--bn-wave) no-repeat;
	mask: linear-gradient(#000 0 0) 0 calc(var(--bn-wave) - 1px) / 100% calc(100% - 2 * var(--bn-wave) + 2px) no-repeat, url(assets/img/wave-top.svg) top / 100% var(--bn-wave) no-repeat, url(assets/img/wave.svg) bottom / 100% var(--bn-wave) no-repeat;
}

.bn-card-date { color: var(--wp--preset--color--umber); margin: .9rem 0 0; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }
.bn-card-date + .wp-block-post-title { margin-top: .3rem; }
:is(.is-style-bn-dark, .is-style-bn-quill) .bn-card-date { color: #e9e6e1; }

/* ---------------------------------------------------------------- Live: past shows */
.bn-year { display: grid; grid-template-columns: 7rem 1fr; gap: 0 2rem; max-width: 56rem; margin: 0 auto; padding: 1.1rem 0; border-top: 1px solid rgba(94, 78, 58, .22); }
h2 + .bn-year { margin-top: 1.5rem; }
.bn-year > .wp-block-heading { margin: 0; font-size: 1.5rem; line-height: 1.3; }
.bn-year .wp-block-table { margin: 0; }
.bn-shows table { width: 100%; border: 0; border-collapse: collapse; }
.bn-shows td { border: 0; padding: .3rem 1rem .3rem 0; vertical-align: top; }
.bn-shows td:first-child { white-space: nowrap; width: 8.5rem; font-variant-numeric: tabular-nums; }
.bn-shows td:last-child { padding-right: 0; text-align: right; }
@media (max-width: 700px) {
	.bn-year { grid-template-columns: 1fr; gap: .4rem; }
	.bn-shows tr { display: block; padding: .35rem 0; }
	.bn-shows td { display: block; padding: 0; width: auto !important; text-align: left !important; }
	.bn-shows td:first-child { font-weight: 600; }
}

/* ---------------------------------------------------------------- Hero */
.bn-hero { overflow: hidden; min-height: min(56vw, calc(100svh - var(--bn-header-h))) !important; padding: 0 !important; }
.bn-hero .wp-block-cover__image-background { animation: bn-kenburns 16s var(--bn-ease) both; transform-origin: 50% 40%; }
@keyframes bn-kenburns { from { transform: scale(1.08); } to { transform: scale(1); } }

/* ---------------------------------------------------------------- Typography helpers */
.bn-title { text-transform: uppercase; text-align: center; }
.wp-block-separator.is-style-bn-short {
	/* Keeps the text column's width and position; only a short line is drawn on the left */
	border: 0 !important;
	height: 1px;
	background: linear-gradient(currentColor, currentColor) left / 60px 1px no-repeat !important;
	opacity: .6;
}
.bn-meta p { margin: 0 0 .9rem; }

/* ---------------------------------------------------------------- Buttons */
.wp-block-button__link, .wp-element-button {
	transition: background-color .3s ease, transform .35s var(--bn-ease), box-shadow .35s var(--bn-ease);
}
.wp-block-button__link:hover, .wp-element-button:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -12px rgba(0, 0, 0, .55); }
.is-style-bn-dark .wp-block-button__link, .is-style-bn-quill .wp-block-button__link { box-shadow: 0 0 0 1px rgba(255, 255, 255, .5); }

/* ---------------------------------------------------------------- Images */
.bn-zoom { overflow: hidden; }
.bn-zoom img, .bn-card .wp-block-post-featured-image img { transition: transform 1.1s var(--bn-ease), filter .6s ease; }
.bn-zoom:hover img, .bn-card:hover .wp-block-post-featured-image img { transform: scale(1.045); }
.bn-card .wp-block-post-featured-image { overflow: hidden; }
.bn-members { gap: 1.2rem clamp(1.5rem, 7vw, 6.5rem) !important; max-width: 900px !important; }
.bn-members .bn-member { width: 226px; text-align: center; }
.bn-members .bn-member img { filter: saturate(.85) sepia(.08); aspect-ratio: 1; object-fit: cover; width: 100%; }
.bn-members .bn-member:hover img { filter: none; }
.bn-members .bn-member p { margin-top: .5rem; }

/* ---------------------------------------------------------------- News */
.bn-card { text-align: center; }
.bn-card .wp-block-post-title { font-size: var(--wp--preset--font-size--large); margin-top: 1rem; }
.bn-card .wp-block-post-title a { text-decoration: none; }
.bn-card .wp-block-post-excerpt { font-size: var(--wp--preset--font-size--small); margin-top: .5rem; }
.bn-card .wp-block-post-excerpt__more-text { margin-top: .6rem; }
.bn-card .wp-block-read-more, .bn-card .wp-block-post-excerpt__more-link { font-size: var(--wp--preset--font-size--small); }
.bn-news-grid .bn-card .wp-block-post-title { font-size: var(--wp--preset--font-size--x-large); }
.bn-news-grid .bn-card .wp-block-post-excerpt { font-size: var(--wp--preset--font-size--medium); }
.bn-post-nav a { text-decoration: none; font-family: var(--wp--preset--font-family--heading); font-size: var(--wp--preset--font-size--large); }
.bn-post-nav a:hover { opacity: .7; }
.bn-post-nav .wp-block-post-navigation-link__arrow-previous { display: inline-block; transition: transform .3s var(--bn-ease); }
.bn-post-nav a:hover .wp-block-post-navigation-link__arrow-previous { transform: translateX(-4px); }

/* ---------------------------------------------------------------- Embeds */
.bn-grid-3 { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 781px) { .bn-grid-3 { grid-template-columns: 1fr; } }
.bn-grid-3 > * { margin: 0 !important; }
.wp-block-embed { margin-block: 0; }
.bn-frame iframe, .bn-spotify iframe { display: block; width: 100%; border: 0; border-radius: 12px; }
.bn-frame { margin: 0; }

/* Lightweight YouTube: a thumbnail until clicked, then the real player (no YouTube cookies before that) */
.bn-yt { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; margin: 0; }
.bn-yt__btn { all: unset; cursor: pointer; position: absolute; inset: 0; display: block; }
.bn-yt__btn img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 1.1s var(--bn-ease), filter .5s ease; filter: brightness(.82); }
.bn-yt__btn:hover img, .bn-yt__btn:focus-visible img { transform: scale(1.04); filter: brightness(.95); }
.bn-yt__btn::before { content: ""; position: absolute; inset: 0 0 auto; height: 40%; background: linear-gradient(rgba(0,0,0,.65), transparent); z-index: 1; }
.bn-yt__title { position: absolute; z-index: 2; top: .8rem; left: 1rem; right: 1rem; color: #fff; font: 600 .95rem/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bn-yt__play { position: absolute; z-index: 2; left: 50%; top: 50%; width: 68px; height: 48px; margin: -24px 0 0 -34px; border-radius: 14px; background: #ff0033; transition: transform .35s var(--bn-ease), background .25s; }
.bn-yt__play::after { content: ""; position: absolute; left: 27px; top: 14px; border-style: solid; border-width: 10px 0 10px 17px; border-color: transparent transparent transparent #fff; }
.bn-yt__btn:hover .bn-yt__play { transform: scale(1.1); }
.bn-yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; animation: bn-fade-in .5s ease both; }
.bn-yt figcaption { display: none; }

/* ---------------------------------------------------------------- Contact form */
.bn-form {
	max-width: 546px;
	margin-inline: auto;
	background: var(--wp--preset--color--white);
	padding: 2rem;
	box-sizing: border-box;
	color: #111;
	text-align: left;
}
.bn-form fieldset { border: 0; padding: 0; margin: 0 0 1.2rem; }
.bn-form legend { padding: 0; margin-bottom: .3rem; }
.bn-form .bn-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.bn-form label { display: block; margin-bottom: 1.2rem; font-size: .95rem; }
.bn-form label span { color: #666; font-size: .85em; margin-left: .3em; }
.bn-form input[type=text], .bn-form input[type=email], .bn-form textarea {
	display: block; width: 100%; box-sizing: border-box; margin-top: .35rem;
	border: 1px solid transparent; border-radius: 22px; background: #e5e6e8;
	padding: .75rem 1rem; font: inherit; color: #111;
	transition: border-color .25s, background-color .25s, box-shadow .25s;
}
.bn-form textarea { min-height: 110px; border-radius: 18px; resize: vertical; }
.bn-form input:focus, .bn-form textarea:focus { outline: none; background: #fff; border-color: var(--wp--preset--color--umber); box-shadow: 0 0 0 3px rgba(105, 85, 68, .15); }
.bn-form .bn-check { display: flex; gap: .5rem; align-items: center; margin-top: -.6rem; }
.bn-form .bn-check input { accent-color: var(--wp--preset--color--umber); }
.bn-form .bn-hp { position: absolute; left: -9999px; }
.bn-form-msg { max-width: 546px; margin: 0 auto 1rem; padding: 1rem 1.2rem; background: #fff; border-left: 3px solid var(--wp--preset--color--umber); animation: bn-fade-in .5s ease both; }

/* ---------------------------------------------------------------- Footer */
.bn-footer { background: #000 url(assets/img/texture-dark.jpg) center / cover; color: #fff; text-align: center; }
.bn-footer p { margin: 0; font-size: .9rem; }
.bn-footer.has-wave-top { padding-top: calc(1.4rem + var(--bn-wave)) !important; }
/* The last section overlaps into the footer's wave, so give it back that height */
main :is(.bn-section, .bn-screen, .bn-tall):last-child { padding-bottom: calc(var(--wp--preset--spacing--60) + var(--bn-wave)); }

.bn-footer .bn-social { display: none; }
@media (max-width: 781px) { .bn-footer .bn-social { display: flex; } }
/* The icons are olive for the light header; on the black footer they need to be white */
.bn-footer .bn-social .wp-social-link, .bn-footer .bn-social .wp-social-link a { color: #fff !important; }

/* ---------------------------------------------------------------- Scroll reveal
   Only active when JS runs (html.bn-js) and the visitor has not asked for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
	.bn-js .bn-reveal {
		opacity: 0;
		transform: translateY(22px);
		transition: opacity .9s var(--bn-ease), transform .9s var(--bn-ease);
		transition-delay: var(--bn-delay, 0s);
	}
	.bn-js .bn-reveal.is-in { opacity: 1; transform: none; }
}
@media print {
	.bn-js .bn-reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
}
@media (prefers-reduced-motion: reduce) {
	*, ::before, ::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
	::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
	html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------------- Small screens */
@media (max-width: 781px) {
	:root { --bn-header-h: 76px; --bn-wave: 4vw; }
	.bn-form { padding: 1.4rem; }
	.bn-form .bn-row { grid-template-columns: 1fr; }
	.bn-hero { min-height: 70vw !important; }
}
