/*
Theme Name: Brendan Francisco
Theme URI: https://brendanfrancisco.com
Author: Bruno Braga
Description: Minimal photography portfolio block theme with carousel and grid gallery views.
Version: 0.3.4
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 8.1
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: brendan-francisco
*/

:root {
	--bf-header-h: 64px;
	/* Floating chrome that sits ON media (gallery switcher, lightbox buttons,
	   card index) keeps the dark tint and its own light foreground, whatever
	   the page behind it is: it has to stay legible over a photograph. */
	--bf-control-bg: rgb(0 0 0 / 0.22);
	--bf-control-bg-hover: rgb(0 0 0 / 0.36);
	--bf-on-media: #f4f4f2;
	/* Ink and paper of the current scope. The header crosses a colour boundary
	   on the home, so anything that has to invert against its own foreground
	   (a filled pill, a solid button) reads both from here. */
	--bf-ink: var(--wp--preset--color--contrast);
	--bf-paper: var(--wp--preset--color--base);
	--bf-hero-ink: #e8eae6;
	/* Rules and borders, as a tint of the ink rather than a fixed grey, so the
	   same declaration works on the dark hero and on the white body. */
	--bf-hairline: color-mix(in srgb, currentColor 16%, transparent);
	--bf-drawer-w: min(360px, 85vw);
	--bf-contact-w: min(480px, 100vw);
	--bf-ease: cubic-bezier(0.7, 0, 0.2, 1);
	--bf-push: 0px;

	/* Header at rest is opaque; stuck it is base at 62%, which is what makes
	   the backdrop blur visible at all. */
	--bf-header-bg: rgb(255 255 255 / 0.72);
	--bf-header-blur: 14px;
	--bf-section-gap: clamp(36px, 5vw, 80px);
	/* A flat 1px stroke disappears on a large display. */
	--bf-stroke-w: clamp(1px, 0.15vw, 2.5px);
}

/* Smooth section scrolling, but never for programmatic writes inside a
   horizontal strip, where it turns dragging into mud. */
@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}

html {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

body {
	margin: 0;
}

/* Template-level blocks stack edge to edge; the header is fixed. */
.wp-site-blocks > *,
.bf-header__inner > *,
/* The flow layout's `* + *` block margin counts hidden siblings too, so from
   tablet up — where the toggle is display:none — it lands on the nav and pushes
   the pills off the centre line of the bar. */
.bf-header__start > * {
	margin-block: 0;
}

/* ---------- Header ---------- */

.bf-header {
	position: fixed;
	inset: 0 0 auto 0;
	z-index: 30;
	height: var(--bf-header-h);
	background: var(--wp--preset--color--base);
	transition: background-color 0.3s ease, transform 0.5s var(--bf-ease);
}

.bf-header__inner {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	height: 100%;
	padding-inline: 14px;
}

.bf-header__inner > :last-child {
	justify-self: end;
}

/* Transparent header over the fullscreen carousel */
html[data-bf-view="carousel"] body:has(.bf-viewer) .bf-header {
	background: transparent;
	color: var(--bf-on-media);
}

/*
 * Over the hero the chrome can stay outlined, because the hero's background is
 * a known dark slate. Over a full-bleed photograph it cannot: the next image
 * may be pale marble. There the pills get the same flat tint the viewer's own
 * controls use.
 */
html[data-bf-view="carousel"] body:has(.bf-viewer) :is(.bf-nav__link, .bf-header__contact a, .bf-menu-toggle) {
	border-color: transparent;
	background-color: var(--bf-control-bg);
}

html[data-bf-view="carousel"] body:has(.bf-viewer) :is(.bf-nav__link, .bf-header__contact a, .bf-menu-toggle):hover {
	border-color: transparent;
	background-color: var(--bf-control-bg-hover);
}

/* The title is bare text, so it gets a shadow rather than a pill. */
html[data-bf-view="carousel"] body:has(.bf-viewer) .bf-logo {
	text-shadow: 0 1px 12px rgb(0 0 0 / 0.55);
}

/*
 * The home's header crosses a colour boundary: light type over the dark hero,
 * dark type over the white body. The over-hero state is the DEFAULT so it is
 * already right at first paint, before home.js has set data-bf-header.
 */
body:has(.bf-hero) .bf-header {
	--bf-ink: var(--bf-hero-ink);
	--bf-paper: var(--wp--preset--color--contrast);
	background: transparent;
	color: var(--bf-ink);
}

html[data-bf-header="stuck"] .bf-header {
	--bf-ink: var(--wp--preset--color--contrast);
	--bf-paper: var(--wp--preset--color--base);
	background: var(--bf-header-bg);
	color: var(--bf-ink);
	-webkit-backdrop-filter: blur(var(--bf-header-blur)) saturate(1.4);
	backdrop-filter: blur(var(--bf-header-blur)) saturate(1.4);
	border-bottom: 1px solid var(--bf-hairline);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
	html[data-bf-header="stuck"] .bf-header {
		background: var(--wp--preset--color--base);
	}
}

.bf-header__start {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

/* ---------- Section pills ---------- */

.bf-nav {
	display: none;
	min-width: 0;
}

.bf-nav__list {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Flex, not the default block: an inline-flex pill inside a block item sits on
   that item's text baseline, which rides below the centre of the bar — which is
   what dropped the pills a few pixels under the Contact button. */
.bf-nav__item {
	display: flex;
}

.bf-nav__link {
	display: inline-flex;
	align-items: center;
	height: 38px;
	padding-inline: 16px;
	/* currentColor tint, so one declaration serves both the dark hero and the
	   white stuck header. */
	border: 1px solid color-mix(in srgb, currentColor 34%, transparent);
	border-radius: 999px;
	color: inherit;
	font-size: 14px;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color 0.2s ease, border-color 0.2s ease;
}

.bf-nav__link:hover {
	background-color: color-mix(in srgb, currentColor 12%, transparent);
	border-color: color-mix(in srgb, currentColor 55%, transparent);
}

.bf-nav__link[aria-current="true"] {
	background-color: var(--bf-ink);
	border-color: var(--bf-ink);
	color: var(--bf-paper);
}

.bf-nav__link:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}

/* The pills replace the hamburger from tablet up; both stay in the DOM so the
   drawer script's element lookups and its visible-focusables filter keep
   working untouched. */
@media (min-width: 48em) {
	.bf-nav {
		display: block;
	}

	.bf-header__start .bf-menu-toggle {
		display: none;
	}
}

/* On the home the hero name is the logo, so the header title only appears
   once the header has something to sit on. */
body:has(.bf-hero) .bf-logo {
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
}

html[data-bf-header="stuck"] body:has(.bf-hero) .bf-logo {
	opacity: 1;
	visibility: visible;
}

.bf-logo {
	margin: 0;
	font-size: 22px;
	font-weight: 800;
	line-height: 0.88;
	letter-spacing: -0.02em;
	text-transform: uppercase;
	text-align: center;
}

.bf-logo a {
	color: inherit;
	display: inline-block;
	width: min-content;
	color: inherit;
	text-decoration: none;
}

/* Same reason as .bf-nav__item: the pill must not hang off a paragraph's
   baseline. */
.bf-header__contact {
	display: flex;
	align-items: center;
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	line-height: 1;
}

/* ---------- Floating controls ---------- */

/* Header chrome is outlined, not filled: the same treatment reads correctly
   against the hero photograph and against the white body. */
.bf-menu-toggle,
.bf-header__contact a {
	border: 0;
	background-color: transparent;
	color: inherit;
	transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.bf-menu-toggle:hover,
.bf-header__contact a:hover {
	background-color: color-mix(in srgb, currentColor 12%, transparent);
	border-color: color-mix(in srgb, currentColor 55%, transparent);
}

.bf-menu-toggle:active,
.bf-header__contact a:active {
	transform: scale(0.96);
}

.bf-header__contact a {
	display: inline-flex;
	align-items: center;
	height: 44px;
	padding-inline: 18px;
	box-sizing: border-box;
	border: 1px solid color-mix(in srgb, currentColor 34%, transparent);
	border-radius: 999px;
	font-size: 14px;
	text-decoration: none;
}

.bf-header__contact a:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}

/* ---------- Swash letter ---------- */

/*
 * The brand's signature: one letter of a heading drops to a serif italic.
 * The letter is written in mixed case in the DOM and uppercased by theme.json,
 * so this only has to come back down — and the heading's tight tracking has to
 * be undone, because it was measured for Archivo, not for a serif.
 */
.bf-swash {
	font-family: var(--wp--preset--font-family--instrument-serif);
	font-style: italic;
	font-weight: 400;
	text-transform: lowercase;
	letter-spacing: 0;
	padding-inline: 0.02em;
}

/* ---------- Shared controls ---------- */

.bf-link {
	color: var(--wp--preset--color--contrast);
	text-decoration: underline;
	text-underline-offset: 4px;
}

.bf-link:hover {
	text-decoration: none;
}

.bf-button {
	display: inline-flex;
	align-items: center;
	height: 48px;
	padding-inline: 26px;
	border: 1px solid var(--bf-ink);
	background: var(--bf-ink);
	color: var(--bf-paper);
	font-weight: 700;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.bf-button:hover {
	background: transparent;
	color: var(--bf-ink);
}

/* ---------- Footer ---------- */

.bf-footer {
	border-top: 1px solid var(--bf-hairline);
	background: var(--wp--preset--color--base);
}

.bf-footer__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	padding: 56px 20px;
}

.bf-footer__lead {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.bf-footer__cta {
	margin: 0;
	color: var(--wp--preset--color--muted);
	font-size: 15px;
}

.bf-footer__mail {
	font-size: clamp(24px, 3.4vw, 38px);
	font-weight: 800;
	letter-spacing: -0.02em;
	text-decoration: none;
	text-transform: uppercase;
}

.bf-footer__mail:hover {
	text-decoration: underline;
	text-underline-offset: 6px;
}

/* Brand colours would be the only saturated thing on the page. */
.bf-footer__social .wp-block-social-link {
	color: var(--wp--preset--color--muted);
}

.bf-footer__social .wp-social-link {
	background-color: transparent;
	color: inherit;
	transition: color 0.2s ease;
}

.bf-footer__social .wp-social-link:hover {
	color: var(--wp--preset--color--contrast);
	transform: none;
}

.bf-footer__legal {
	width: 100%;
	margin: 0;
	color: var(--wp--preset--color--muted);
	font-size: 13px;
}

/* ---------- Content pages ---------- */

.bf-main {
	min-height: 100svh;
}

.bf-page {
	padding: calc(var(--bf-header-h) + 64px) 20px 96px;
}

/* ---------- Push (drawer open) ---------- */

.bf-push {
	transform: translateX(var(--bf-push));
	transition: transform 0.5s var(--bf-ease);
}

body.bf-drawer-open {
	--bf-push: var(--bf-drawer-w);
	overflow: hidden;
}

body.bf-contact-open {
	--bf-push: calc(-1 * var(--bf-contact-w));
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.bf-push,
	.bf-header,
	.bf-logo,
	.bf-nav__link {
		transition: none;
	}
}

/* ---------- Contact Form 7 ---------- */

.wpcf7-form p {
	margin: 0 0 20px;
}

.wpcf7-form label {
	display: block;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.wpcf7-form input:not([type="submit"]),
.wpcf7-form textarea {
	box-sizing: border-box;
	width: 100%;
	margin-top: 8px;
	padding: 12px 0;
	border: 0;
	border-bottom: 1px solid var(--wp--preset--color--muted);
	border-radius: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 17px;
}

.wpcf7-form input:focus,
.wpcf7-form textarea:focus {
	outline: none;
	border-bottom-color: var(--wp--preset--color--contrast);
}

.wpcf7-form textarea {
	min-height: 160px;
	resize: vertical;
}

.wpcf7-form input[type="submit"] {
	padding: 14px 32px;
	border: 1px solid var(--wp--preset--color--contrast);
	border-radius: 0;
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.wpcf7-form input[type="submit"]:hover {
	background: transparent;
	color: var(--wp--preset--color--contrast);
}

.wpcf7-not-valid-tip,
.wpcf7-response-output {
	font-size: 14px;
}

.wpcf7 form .wpcf7-response-output {
	margin: 24px 0 0;
	padding: 12px 16px;
}
