/*
Theme Name: Barker
Theme URI: https://3vl.ca
Author: 3VL INC
Author URI: https://3vl.ca
Description: Block theme for the Mayfair Theatre. Templates, parts and patterns are edited in the Site Editor; movie, event and venue data comes from the barker-core must-use plugin.
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 8.1
Version: 2.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: block-theme, full-site-editing, barker
Text Domain: barker-block
*/

/*
 * Only what theme.json cannot express lives here. Loaded on the front end and in the editor.
 */

/* Header, main and footer are full-bleed bands: no gap between them. */
.wp-site-blocks > * {
	margin-block-start: 0;
}

/* Keep long titles (and the odd 80-character URL in a post) from overflowing narrow screens. */
:where(.wp-site-blocks) :where(h1, h2, h3, .wp-block-post-title) {
	overflow-wrap: break-word;
	text-wrap: balance;
}

/* Visible keyboard focus in the brand colour. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

/* Header and footer sit on the dark ink background: invert the focus ring there. */
.barker-site-header :focus-visible,
.barker-site-footer :focus-visible {
	outline-color: var(--wp--preset--color--accent);
}

/* Movie cards in query loops: equal-height, poster on top. Hover only tints the title (no lift). */
.barker-card {
	height: 100%;
}

.barker-card .wp-block-post-featured-image img,
.barker-card .wp-block-barker-poster img {
	aspect-ratio: 2 / 3;
	object-fit: cover;
	width: 100%;
}

.barker-card .wp-block-post-title a {
	transition: color 120ms ease-out;
}

.barker-card:is(:hover, :focus-within) .wp-block-post-title a {
	color: var(--wp--preset--color--primary);
}

/*
 * Blog, archive and search results: an editorial list divided by hairlines. The title link
 * stretches over the whole entry so anywhere is clickable; "Read more" stays on top of it.
 */
.barker-post-list {
	margin: 0;
	padding: 0;
	list-style: none;
	border-top: 1px solid var(--wp--preset--color--line);
}

.barker-post-list > li {
	margin: 0;
	padding-block: var(--wp--preset--spacing--50);
	border-bottom: 1px solid var(--wp--preset--color--line);
}

.barker-card--post {
	position: relative;
	height: auto;
}

.barker-card--post .wp-block-post-date {
	color: var(--wp--preset--color--primary);
	font-weight: 600;
}

.barker-card--post .wp-block-post-title {
	margin-top: var(--wp--preset--spacing--10);
	line-height: 1.15;
}

.barker-card--post .wp-block-post-title a {
	color: inherit;
	text-decoration: none;
}

.barker-card--post .wp-block-post-title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.barker-card--post .wp-block-post-excerpt__excerpt {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	color: var(--wp--preset--color--muted);
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
}

.barker-card--post .wp-block-post-excerpt__more-text {
	margin: var(--wp--preset--spacing--20) 0 0;
}

.barker-card--post .wp-block-post-excerpt__more-link {
	position: relative;
	z-index: 1;
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-decoration: none;
	text-transform: uppercase;
}

.barker-card--post .wp-block-post-excerpt__more-link::after {
	content: "\2192";
	display: inline-block;
	margin-left: 0.4em;
	transition: transform 120ms ease-out;
}

.barker-card--post:hover .wp-block-post-excerpt__more-link::after,
.barker-card--post .wp-block-post-excerpt__more-link:focus-visible::after {
	transform: translateX(3px);
}

/* The stretched title link would draw its focus ring around the whole entry: keep it on the text */
.barker-card--post .wp-block-post-title a:focus-visible {
	outline: none;
}

.barker-card--post .wp-block-post-title a:focus-visible::after {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 4px;
}

/* Posts with a featured image: small thumbnail beside the text */
.barker-card--post:has(.wp-block-post-featured-image) {
	display: grid;
	grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
	column-gap: var(--wp--preset--spacing--40);
	align-content: start;
}

.barker-card--post:has(.wp-block-post-featured-image) > * {
	grid-column: 2;
}

.barker-card--post .wp-block-post-featured-image {
	grid-column: 1;
	grid-row: 1 / span 3;
	margin: 0;
}

.barker-card--post .wp-block-post-featured-image img {
	aspect-ratio: 4 / 3;
	border-radius: 4px;
}

/* Small uppercase label used above section headings ("Now playing", "Plan your visit"). */
.barker-eyebrow {
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

/*
 * Dialogs opened by Barker blocks (showtime share / calendar, subscribe, poster zoom).
 * barker-core gives them structure; this is the look.
 */
dialog[class$="__dialog"] {
	width: min(28rem, calc(100vw - 2rem));
	padding: var(--wp--preset--spacing--40);
	border-radius: 10px;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	box-shadow: 0 24px 64px rgb(0 0 0 / 0.35);
}

dialog[class$="__dialog"]::backdrop {
	background: rgb(22 19 15 / 0.7);
	backdrop-filter: blur(2px);
}

dialog[class$="__dialog"] :is(h2, h3) {
	margin: 0 0 var(--wp--preset--spacing--30);
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.15;
}

/* Link lists inside dialogs read as a stack of full-width buttons */
dialog[class$="__dialog"] ul {
	display: grid;
	gap: var(--wp--preset--spacing--20);
	margin: 0;
	padding: 0;
	list-style: none;
}

dialog[class$="__dialog"] ul a {
	display: block;
	padding: 0.7em 1em;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 6px;
	color: inherit;
	font-weight: 600;
	text-decoration: none;
}

dialog[class$="__dialog"] ul a:hover {
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary);
}

/* The close button at the foot of each dialog */
dialog[class$="__dialog"] form[method="dialog"] {
	display: flex;
	justify-content: flex-end;
	margin-top: var(--wp--preset--spacing--30);
}

dialog[class$="__dialog"] form[method="dialog"] button {
	padding: 0.5em 1em;
	border: 0;
	border-radius: 6px;
	background: var(--wp--preset--color--surface);
	color: inherit;
	font: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	cursor: pointer;
}

dialog[class$="__dialog"] form[method="dialog"] button:hover {
	background: var(--wp--preset--color--line);
}

/*
 * Movie and event pages: the poster overlaps the backdrop hero on wide screens.
 */
@media (min-width: 782px) {
	.barker-movie-intro > .wp-block-column:first-child {
		position: relative;
		z-index: 1;
		margin-top: calc(-1 * clamp(5rem, 12vw, 11rem));
	}
}

/* Phones: a smaller poster that still overlaps the hero, so the title and showtimes stay near the top */
@media (max-width: 781px) {
	.barker-movie-intro > .wp-block-column:first-child {
		position: relative;
		z-index: 1;
		max-width: 10rem;
		margin-top: -5rem;
	}
}

.barker-movie-intro .wp-block-post-title {
	margin-top: 0;
}

/* An unset tagline renders an empty paragraph; don't leave its gap */
.barker-movie-intro p:empty {
	display: none;
}

/*
 * Blog sidebar (parts/sidebar-blog.html): newsletter, categories and archives beside the post grid.
 */
.barker-blog-sidebar__section + .barker-blog-sidebar__section {
	padding-top: var(--wp--preset--spacing--40);
	border-top: 1px solid var(--wp--preset--color--line);
}

/* The lists below reset their margins, so the gap under each heading lives on the heading */
.barker-blog-sidebar__section > .wp-block-heading {
	margin-bottom: var(--wp--preset--spacing--30);
}

.barker-blog-sidebar :is(.wp-block-categories, .wp-block-archives) {
	margin: 0;
	padding: 0;
	list-style: none;
}

.barker-blog-sidebar :is(.wp-block-categories, .wp-block-archives) li {
	break-inside: avoid;
	padding-block: 0.3rem;
	border-bottom: 1px solid var(--wp--preset--color--line);
}

.barker-blog-sidebar :is(.wp-block-categories, .wp-block-archives) a {
	color: inherit;
	font-size: var(--wp--preset--font-size--small);
	text-decoration: none;
}

.barker-blog-sidebar :is(.wp-block-categories, .wp-block-archives) a:hover {
	color: var(--wp--preset--color--primary);
}

/* Categories and years read as wrapped pill chips instead of long vertical lists */
.barker-blog-sidebar :is(.wp-block-categories, .barker-archive-years) {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.barker-blog-sidebar :is(.wp-block-categories, .barker-archive-years) li {
	padding: 0;
	border-bottom: 0;
}

.barker-blog-sidebar :is(.wp-block-categories, .barker-archive-years) a {
	display: block;
	padding: 0.3em 0.8em;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 999px;
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	line-height: 1.4;
}

.barker-blog-sidebar :is(.wp-block-categories, .barker-archive-years) a:hover {
	border-color: var(--wp--preset--color--primary);
}

/* The current category or year, when viewing its archive */
.barker-blog-sidebar .wp-block-categories .current-cat a,
.barker-blog-sidebar .barker-archive-years a[aria-current] {
	border-color: var(--wp--preset--color--contrast);
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/* Month-level browsing stays one click away in a dropdown */
.barker-blog-sidebar .barker-archive-months {
	margin-top: var(--wp--preset--spacing--30);
}

.barker-blog-sidebar .barker-archive-months label {
	display: block;
	margin-bottom: 0.35rem;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
}

.barker-blog-sidebar .barker-archive-months select {
	width: 100%;
	padding: 0.55em 0.75em;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 6px;
	background: var(--wp--preset--color--base);
	color: inherit;
	font: inherit;
	font-size: var(--wp--preset--font-size--small);
}

/* Phones: the sidebar follows the posts, with a rule between them */
@media (max-width: 781px) {
	.barker-blog-layout .barker-blog-sidebar {
		padding-top: var(--wp--preset--spacing--50);
		border-top: 1px solid var(--wp--preset--color--line);
	}
}

@media (prefers-reduced-motion: reduce) {
	.barker-card .wp-block-post-title a,
	.barker-card--post .wp-block-post-excerpt__more-link::after {
		transition: none;
	}
}

/* Home page sections (written by wp barker migrate-content): links stay readable on the dark band */
.barker-section.has-contrast-background-color a:where(:not(.wp-element-button)) {
	color: var(--wp--preset--color--accent);
}

/* Footer address: "Ottawa, Ontario K1S 3X3" from the separate venue options */
.barker-venue-city:not(:empty)::after {
	content: ",";
}

/*
 * Header menu: the items are full page titles, so keep each on one line and switch to the menu
 * button until there is room for the whole row (core only collapses below 600px).
 */
.barker-site-header .wp-block-navigation-item__label,
.barker-site-header .wp-block-site-title {
	white-space: nowrap;
}

@media (min-width: 600px) {
	.barker-site-header .wp-block-navigation__container {
		flex-wrap: nowrap;
	}
}

@media (min-width: 600px) and (max-width: 1219px) {
	.barker-site-header .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}

	.barker-site-header .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}
}

/* Header: the logo replaces the text name when one is set (the logo image carries the site name as alt) */
.barker-site-header .wp-block-site-logo ~ .wp-block-site-title {
	display: none;
}

/*
 * The theatre photo (Barker backdrop option, set as --barker-backdrop in functions.php) behind the header,
 * darkened so the menu reads; plain ink when no photo is set.
 */
.barker-site-header {
	background-color: var(--wp--preset--color--contrast);
	background-image: linear-gradient(rgba(22, 19, 15, 0.82), rgba(22, 19, 15, 0.82)), var(--barker-backdrop, none);
	background-position: center 35%;
	background-size: cover;
}

/* Home hero: the same photo, darkest behind the text; the ink-to-blue gradient when no photo is set */
.barker-hero {
	padding-top: var(--wp--preset--spacing--70);
	background-color: var(--wp--preset--color--contrast);
	background-image:
		linear-gradient(90deg, rgba(22, 19, 15, 0.92) 0%, rgba(22, 19, 15, 0.6) 55%, rgba(22, 19, 15, 0.3) 100%),
		var(--barker-backdrop, var(--wp--preset--gradient--ink-to-blue));
	background-position: center 35%;
	background-size: cover;
}

/* Home page: the header sits over the hero, so the photo runs behind both as on the old site */
body.home .wp-site-blocks > header.wp-block-template-part {
	position: absolute;
	top: var(--wp-admin--admin-bar--height, 0px);
	right: 0;
	left: 0;
	z-index: 10;
}

body.home .barker-site-header {
	background: none;
}

body.home .barker-hero {
	padding-top: calc(var(--wp--preset--spacing--70) + var(--barker-header-height, 6rem));
}
