/*
Theme Name: Barcus Folio
Theme URI: https://aaronbarcus.com
Author: Aaron Barcus
Description: A quiet, photography-first block theme. Plain white pages, a small letter-spaced menu, a full-bleed photo page with a white menu laid over the image, and a set of gallery layouts (mixed, masonry, stacked, filmstrip, grid) built on the core Gallery block.
Version: 1.4.0
Requires at least: 6.6
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: barcus-folio
Tags: photography, portfolio, block-patterns, block-styles, full-site-editing, one-column, wide-blocks
*/

/* ------------------------------------------------------------------ base */

html {
	scroll-behavior: smooth;
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

.wp-site-blocks {
	position: relative;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100svh;
}

.admin-bar .wp-site-blocks {
	min-height: calc(100svh - 32px);
}

/* Short pages: keep the footer at the bottom of the window. */
.wp-site-blocks > main {
	flex: 1 0 auto;
}

.has-large-font-size {
	line-height: 1.45;
}

.has-x-large-font-size,
.has-xx-large-font-size {
	line-height: 1.2;
}

::selection {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

a {
	transition: color 0.2s ease, opacity 0.2s ease;
}

/* Text links inside running copy get a hairline underline. */
.entry-content p a,
.wp-block-post-content p a {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.3em;
}

/* ---------------------------------------------------------------- header */

.folio-header {
	padding: clamp(1.5rem, 3.4vw, 2.75rem) var(--wp--style--root--padding-right) clamp(1.5rem, 3.4vw, 2.75rem) var(--wp--style--root--padding-left);
	gap: 1.5rem;
}

.folio-header .wp-block-site-title a {
	text-decoration: none;
	white-space: nowrap;
}

.folio-header .wp-block-site-logo img {
	max-height: 48px;
	width: auto;
}

/* Menu links: a hairline that draws in on hover and stays on the current page. */
.folio-header .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content {
	position: relative;
	padding-block: 0.4em;
	text-decoration: none;
}

.folio-header .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content::after {
	content: "";
	position: absolute;
	left: 0;
	/* the letter-spacing leaves a gap after the last letter; stop the line short of it */
	right: 0.16em;
	bottom: 0;
	height: 1px;
	background: currentColor;
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.folio-header .wp-block-navigation-item > .wp-block-navigation-item__content:hover::after,
.folio-header .wp-block-navigation-item > .wp-block-navigation-item__content:focus-visible::after,
.folio-header .wp-block-navigation-item.current-menu-item > .wp-block-navigation-item__content::after {
	transform: scaleX(1);
}

.folio-header .wp-block-navigation a:hover {
	color: inherit;
}

/* The white version that sits on top of a photo. */
.folio-header.is-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 20;
}

/* Keep it in normal flow inside the Site Editor so it stays easy to select. */
.editor-styles-wrapper .folio-header.is-overlay {
	position: relative;
	background: #1c1c1c;
}

/* Mobile menu panel. */
.wp-block-navigation__responsive-container.is-menu-open {
	padding: clamp(1.5rem, 3vw, 2.25rem) var(--wp--style--root--padding-right);
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	justify-content: center;
	align-items: center;
	min-height: 70vh;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content,
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container,
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	align-items: center !important;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	gap: 2rem;
	font-size: 1rem;
}

/* ---------------------------------------------------------------- footer */

.folio-footer {
	padding: 2rem var(--wp--style--root--padding-right) 2.25rem var(--wp--style--root--padding-left);
	margin-top: 0;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--wp--preset--color--muted);
	gap: 0.75rem 2rem;
}

.folio-footer p {
	margin: 0;
}

.folio-footer a {
	color: inherit;
	text-decoration: none;
}

.folio-footer a:hover {
	color: var(--wp--preset--color--contrast);
}

/* ------------------------------------------------- full-bleed photo page */

.folio-fullbleed {
	background-color: #1c1c1c;
	min-height: 100vh;
	min-height: 100svh !important;
	padding: clamp(6rem, 14vh, 9rem) var(--wp--style--root--padding-right) clamp(3rem, 8vh, 5rem) var(--wp--style--root--padding-left);
}

.admin-bar .folio-fullbleed {
	min-height: calc(100vh - 32px);
	min-height: calc(100svh - 32px) !important;
}

@media (max-width: 782px) {
	.admin-bar .folio-fullbleed {
		min-height: calc(100svh - 46px) !important;
	}
}

/* Text starts a set distance down the screen (Appearance > Folio Setup). */
.folio-fullbleed {
	align-items: flex-start !important;
	padding-top: 0 !important;
}

.folio-fullbleed .wp-block-cover__inner-container {
	width: 100%;
	margin-top: max(6.5rem, var(--folio-text-top, 46svh));
}

.folio-fullbleed p {
	margin-block: 0.9rem;
	letter-spacing: 0.02em;
}

/* Anything sitting on a photo: links follow the text colour. */
.wp-block-cover a:not(.wp-element-button) {
	color: inherit;
}

.wp-block-cover a:not(.wp-element-button):hover {
	opacity: 0.7;
}

/* "White menu over first photo" template: first block runs under the menu. */
.folio-hero-main > .wp-block-post-content > :first-child {
	margin-top: 0;
}

/* Small down-arrow used in the hero pattern. */
.folio-scroll-hint a {
	display: inline-block;
	text-decoration: none !important;
	animation: folio-nudge 2.4s ease-in-out infinite;
}

@keyframes folio-nudge {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(6px); }
}

/* --------------------------------------------------------------- images */

.wp-block-image img {
	height: auto;
}

.wp-block-image figcaption,
.wp-block-image .wp-element-caption {
	text-align: left;
	margin-top: 0.75rem;
	margin-bottom: 0;
}

.wp-block-image.aligncenter figcaption,
.wp-block-image.aligncenter .wp-element-caption {
	text-align: center;
}

/* Lightbox: plain white stage, no zoom button chrome. */
.wp-lightbox-overlay .scrim {
	background-color: var(--wp--preset--color--base) !important;
}

.wp-lightbox-overlay .close-button {
	top: 1.5rem;
	right: 1.5rem;
}

.wp-lightbox-container img {
	cursor: zoom-in;
}

/* ------------------------------------------------------- gallery styles */

/* Shared: natural proportions and captions underneath for the editorial styles. */
.wp-block-gallery.is-style-folio-mixed figure.wp-block-image,
.wp-block-gallery.is-style-folio-masonry figure.wp-block-image,
.wp-block-gallery.is-style-folio-stacked figure.wp-block-image {
	width: 100% !important;
	margin: 0 !important;
	display: block !important;
	flex-grow: 0 !important;
}

.wp-block-gallery.is-style-folio-mixed figure.wp-block-image img,
.wp-block-gallery.is-style-folio-masonry figure.wp-block-image img,
.wp-block-gallery.is-style-folio-stacked figure.wp-block-image img {
	width: 100% !important;
	height: auto !important;
	flex: none !important;
	object-fit: contain !important;
	display: block;
}

.wp-block-gallery.is-style-folio-mixed figure.wp-block-image figcaption,
.wp-block-gallery.is-style-folio-masonry figure.wp-block-image figcaption,
.wp-block-gallery.is-style-folio-stacked figure.wp-block-image figcaption {
	position: static !important;
	background: none !important;
	color: var(--wp--preset--color--muted) !important;
	text-shadow: none !important;
	text-align: left !important;
	padding: 0.75rem 0 0 !important;
	margin: 0 !important;
	max-height: none !important;
	overflow: visible !important;
	font-size: var(--wp--preset--font-size--small) !important;
	letter-spacing: 0.06em;
}

.wp-block-gallery.is-style-folio-mixed figure.wp-block-image::before,
.wp-block-gallery.is-style-folio-masonry figure.wp-block-image::before,
.wp-block-gallery.is-style-folio-stacked figure.wp-block-image::before {
	display: none !important;
}

/* Mixed — an editorial rhythm of large, small, paired and full-width frames.
   Add photos in any number; the layout repeats every eight. */
.wp-block-gallery.is-style-folio-mixed {
	display: grid !important;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	column-gap: clamp(1rem, 3vw, 3rem);
	row-gap: clamp(3rem, 9vw, 8.5rem);
	align-items: center;
}

.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 1) { grid-column: 1 / span 7; }
.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 2) { grid-column: 9 / span 4; align-self: end; }
.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 3) { grid-column: 4 / span 6; }
.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 4) { grid-column: 1 / span 5; align-self: start; }
.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 5) { grid-column: 7 / span 6; }
.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 6) { grid-column: 1 / -1; }
.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 7) { grid-column: 2 / span 4; }
.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 8) { grid-column: 7 / span 5; }

@media (max-width: 720px) {
	.wp-block-gallery.is-style-folio-mixed {
		row-gap: 2.5rem;
	}
	.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(n) {
		grid-column: 1 / -1;
		align-self: auto;
	}
	.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 2),
	.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 7) {
		grid-column: 4 / -1;
	}
	.wp-block-gallery.is-style-folio-mixed > figure.wp-block-image:nth-of-type(8n + 4) {
		grid-column: 1 / span 9;
	}
}

/* Masonry — uncropped photos flowing down columns. Uses the block's Columns setting. */
.wp-block-gallery.is-style-folio-masonry {
	display: block !important;
	column-count: 3;
	column-gap: var(--wp--style--gallery-gap-default, 1.25rem);
}

.wp-block-gallery.is-style-folio-masonry.columns-1 { column-count: 1; }
.wp-block-gallery.is-style-folio-masonry.columns-2 { column-count: 2; }
.wp-block-gallery.is-style-folio-masonry.columns-4 { column-count: 4; }
.wp-block-gallery.is-style-folio-masonry.columns-5 { column-count: 5; }
.wp-block-gallery.is-style-folio-masonry.columns-6 { column-count: 6; }

.wp-block-gallery.is-style-folio-masonry > figure.wp-block-image {
	break-inside: avoid;
	margin-bottom: var(--wp--style--gallery-gap-default, 1.25rem) !important;
}

@media (max-width: 900px) {
	.wp-block-gallery.is-style-folio-masonry:not(.columns-1) { column-count: 2; }
}

@media (max-width: 480px) {
	.wp-block-gallery.is-style-folio-masonry:not(.columns-1) { column-count: 1; }
}

/* Stacked — one photo at a time, generous air between. */
.wp-block-gallery.is-style-folio-stacked {
	display: flex !important;
	flex-direction: column;
	flex-wrap: nowrap;
	gap: clamp(2.5rem, 7vw, 6rem) !important;
	max-width: 1040px;
	margin-left: auto;
	margin-right: auto;
}

/* Filmstrip — a single row that scrolls sideways. */
.wp-block-gallery.is-style-folio-filmstrip {
	flex-wrap: nowrap !important;
	align-items: stretch;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x proximity;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 0.25rem;
}

.wp-block-gallery.is-style-folio-filmstrip::-webkit-scrollbar {
	display: none;
}

.wp-block-gallery.is-style-folio-filmstrip > figure.wp-block-image {
	flex: 0 0 auto !important;
	width: auto !important;
	height: clamp(280px, 68vh, 760px);
	scroll-snap-align: start;
}

.wp-block-gallery.is-style-folio-filmstrip > figure.wp-block-image img {
	height: 100% !important;
	width: auto !important;
	max-width: none !important;
	flex: none !important;
	object-fit: cover;
}

/* Rotating — one photo at a time, centred, fading to the next.
   The stacking only applies on the live site (.folio-rotator is added when the
   page is rendered), so in the editor the photos stay a normal, editable grid. */
.wp-block-gallery.folio-rotator {
	display: block !important;
	position: relative;
	height: var(--folio-h, 76svh);
	max-height: 1600px;
	margin-top: var(--folio-top, 48px) !important;
	margin-bottom: var(--folio-bottom, 48px) !important;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.wp-block-gallery.folio-rotator > figure.wp-block-image {
	position: absolute !important;
	inset: 0;
	width: 100% !important;
	height: 100%;
	margin: 0 !important;
	display: flex !important;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 1.1s ease;
	pointer-events: none;
}

.wp-block-gallery.folio-rotator > figure.wp-block-image:first-of-type,
.wp-block-gallery.folio-rotator.is-ready > figure.wp-block-image.is-active {
	opacity: 1;
}

.wp-block-gallery.folio-rotator.is-ready > figure.wp-block-image:not(.is-active) {
	opacity: 0;
}

.wp-block-gallery.folio-rotator > figure.wp-block-image:nth-of-type(n + 21) {
	display: none !important;
}

.wp-block-gallery.folio-rotator > figure.wp-block-image img {
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	flex: none !important;
	object-fit: contain !important;
	animation: none !important;
}

.wp-block-gallery.folio-rotator figcaption,
.wp-block-gallery.folio-rotator > figure.wp-block-image::before,
.wp-block-gallery.folio-rotator button {
	display: none !important;
}

/* Phones: sit the photo directly under the header rather than floating mid-box. */
@media (max-width: 720px) {
	.wp-block-gallery.folio-rotator {
		margin-top: min(var(--folio-top, 48px), 24px) !important;
	}
	.wp-block-gallery.folio-rotator > figure.wp-block-image img {
		object-position: center top;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-gallery.folio-rotator > figure.wp-block-image { transition: none; }
}

/* Tight grid — cropped tiles with a hairline gap. */
.wp-block-gallery.is-style-folio-tight {
	--wp--style--unstable-gallery-gap: 3px !important;
	gap: 3px !important;
}

.wp-block-gallery.is-style-folio-tight figure.wp-block-image img {
	aspect-ratio: 1;
}

/* Default grid: square off the corners and soften hover. */
.wp-block-gallery figure.wp-block-image img {
	border-radius: 0;
}

/* Image style: Matted — the photo sits on a wide paper-coloured mat. */
.wp-block-image.is-style-folio-matted {
	background: var(--wp--preset--color--soft);
	padding: clamp(1.5rem, 7vw, 6rem);
}

.wp-block-image.is-style-folio-matted img {
	display: block;
	margin-inline: auto;
	max-height: 80vh;
	width: auto;
}

/* -------------------------------------------------------- pattern pieces */

/* Shooting details beside a photo. */
.folio-details p {
	margin: 0;
	padding: 0.7rem 0;
	border-top: 1px solid var(--wp--preset--color--line);
	display: flex;
	gap: 1rem;
}

.folio-details p:last-child {
	border-bottom: 1px solid var(--wp--preset--color--line);
}

.folio-details strong {
	flex: 0 0 6.5rem;
	font-weight: 400;
	font-size: var(--wp--preset--font-size--small);
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--wp--preset--color--muted);
	padding-top: 0.25em;
}

/* Series index tiles. */
.folio-index .wp-block-image {
	margin-bottom: 0.9rem;
}

.folio-index .wp-block-image img {
	aspect-ratio: 4 / 5;
	object-fit: cover;
	width: 100%;
	transition: opacity 0.3s ease;
}

.folio-index .wp-block-image a:hover img {
	opacity: 0.85;
}

.folio-index h3,
.folio-index p {
	margin-block: 0.2rem;
}

.folio-quote {
	font-weight: 200;
	line-height: 1.3;
}

/* Outline button style used by the prints pattern. */
.wp-block-button.is-style-outline > .wp-block-button__link {
	border-width: 1px;
	padding: 0.9rem 1.75rem;
}

.folio-eyebrow {
	letter-spacing: 0.28em;
	text-transform: uppercase;
}

.folio-eyebrow a {
	text-decoration: none !important;
}

.folio-biglinks a {
	text-decoration: none !important;
	border-bottom: 1px solid transparent;
	transition: border-color 0.3s ease;
}

.folio-biglinks a:hover {
	color: inherit;
	border-bottom-color: currentColor;
}

.folio-post-nav {
	letter-spacing: 0.2em;
	text-transform: uppercase;
	font-size: var(--wp--preset--font-size--small);
	border-top: 1px solid var(--wp--preset--color--line);
	padding-top: 1.5rem;
}

.folio-post-grid .wp-block-post-title a {
	text-decoration: none;
}

.folio-post-grid .wp-block-post-featured-image img {
	transition: opacity 0.3s ease;
}

.folio-post-grid .wp-block-post-featured-image a:hover img {
	opacity: 0.85;
}

@media (max-width: 900px) {
	.folio-post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

@media (max-width: 520px) {
	.folio-post-grid { grid-template-columns: 1fr !important; }
}

/* --------------------------------------------------------------- motion */

/* Photos ease in as they enter the viewport (modern browsers; harmless elsewhere). */
@media (prefers-reduced-motion: no-preference) {
	@supports (animation-timeline: view()) {
		body:not(.block-editor-page) .wp-block-post-content .wp-block-image img {
			animation: folio-rise linear both;
			animation-timeline: view();
			animation-range: entry 0% entry 55%;
		}
	}

	.folio-header {
		animation: folio-fade 0.9s ease both;
	}
}

@keyframes folio-rise {
	from { opacity: 0; transform: translateY(24px); }
	to { opacity: 1; transform: none; }
}

@keyframes folio-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	.folio-scroll-hint a { animation: none; }
}

/* Full-width covers: keep overlaid text off the screen edge. */
.wp-block-cover.alignfull:not(.folio-fullbleed) {
	padding: clamp(1.5rem, 4vw, 3rem) var(--wp--style--root--padding-left);
}
