/*
Theme Name: Diafragma
Theme URI: https://github.com/poudenes/Framed-Wordpress-Theme
Author: Peter Oudenes
Author URI: https://www.oudenes.photography
Description: Dark, photography-focused block theme with five fullscreen homepage blocks (Frame Slider, Viewfinder, Iris, Darkroom, Contact Sheet), a lightbox with filmstrip and EXIF, galleries and a calm sidebar. Built for travel and landscape photographers.
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 7.4
Version: 0.7.2
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: diafragma
Domain Path: /languages
Tags: photography, portfolio, blog, dark, full-site-editing, block-patterns, wide-blocks, featured-images
*/

/*
 * Most styling lives in theme.json. This file holds only what theme.json
 * cannot express: the frame, header behaviour, hero, gallery and preloader.
 */

:root {
	--op-frame: var(--wp--custom--frame--width, 15px);
	--op-frame-color: var(--wp--custom--frame--color, #000);
	--op-admin-bar: 0px;
}

.admin-bar {
	--op-admin-bar: var(--wp-admin--admin-bar--height, 32px);
}

/* ---------- Frame ---------- */

/* A thin fixed border around the viewport: the "framed" look (front end only). */
body:not(.editor-styles-wrapper)::after {
	content: "";
	position: fixed;
	inset: var(--op-admin-bar) 0 0 0;
	z-index: 1000;
	border: var(--op-frame) solid var(--op-frame-color);
	pointer-events: none;
}

.wp-site-blocks {
	padding: var(--op-frame);
}

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

/* The template-part wrapper is the sticky element, so it sticks for the whole page. */
.wp-site-blocks > :has(> .op-site-header) {
	position: sticky;
	top: calc(var(--op-admin-bar) + var(--op-frame));
	z-index: 100;
}

.wp-site-blocks > :has(> .op-site-header) + * {
	margin-block-start: 0;
}

.op-site-header {
	transition: background-color 0.3s ease;
}

/* Fullscreen pages: the header floats transparently over the first block. */
.op-has-overlay-header .wp-site-blocks > :has(> .op-site-header) {
	position: fixed;
	top: calc(var(--op-admin-bar) + var(--op-frame));
	left: var(--op-frame);
	right: var(--op-frame);
}

.op-has-overlay-header .op-site-header {
	background-color: transparent !important;
}

.op-has-overlay-header .op-site-header.is-scrolled {
	background-color: var(--wp--preset--color--base) !important;
}

/* Site title as logo, optionally in two tones (see "Site title accent" in Settings → General). */
.op-site-header .wp-block-site-title {
	flex-shrink: 0;
	text-transform: uppercase;
	letter-spacing: 0.01em;
	line-height: 1;
}

.wp-block-site-title a {
	text-decoration: none;
}

.op-title-accent {
	color: var(--wp--preset--color--accent);
	font-weight: 400;
}

/*
 * While the homepage slider shows its white frame, the white header text
 * (the site title and the menu) turns black so it stays readable.
 * The open mobile menu keeps its own colours.
 */
.op-site-header .wp-block-site-title a,
.op-primary-nav .wp-block-navigation__responsive-container,
.op-primary-nav .wp-block-navigation__responsive-container-open {
	transition: color 0.3s ease;
}

.op-fs-framing .op-site-header:not(.is-scrolled) .wp-block-site-title a,
.op-fs-framing .op-site-header:not(.is-scrolled) .op-primary-nav .wp-block-navigation__responsive-container-open,
.op-fs-framing .op-site-header:not(.is-scrolled) .op-primary-nav .wp-block-navigation__responsive-container:not(.is-menu-open) {
	color: var(--wp--preset--color--base) !important;
}

/* Mobile menu: full-screen overlay with large links. */
.op-primary-nav .wp-block-navigation__responsive-container.is-menu-open {
	padding: calc(var(--op-frame) + 2rem) calc(var(--op-frame) + 30px);
	border: var(--op-frame) solid var(--op-frame-color);
}

.op-primary-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	font-size: 1.5rem;
}

.op-primary-nav .wp-block-navigation__responsive-container-open {
	margin-left: auto;
}

@media (max-width: 599px) {
	.op-site-header {
		justify-content: space-between !important;
	}
}

/* ---------- Hero ---------- */

.op-hero {
	margin-block-start: 0;
}

.op-hero h1 {
	text-shadow: 0 2px 24px rgba(0, 0, 0, 0.25);
}

@media (max-width: 599px) {
	.op-hero {
		min-height: 300px !important;
	}
}

/* ---------- Content with sidebar ---------- */

.op-body {
	margin-block-start: 0;
}

@media (max-width: 781px) {
	/* Sidebar drops below the content, like the original. */
	.op-with-sidebar .op-sidebar-column {
		margin-top: var(--wp--preset--spacing--50);
	}
}

.op-recent-posts .wp-block-post-featured-image img {
	object-fit: cover;
}

/* ---------- Gallery ---------- */

.wp-block-gallery.has-nested-images figure.wp-block-image {
	transform-style: preserve-3d;
	transition: transform 0.4s ease;
	will-change: transform;
}

.wp-block-gallery.has-nested-images figure.wp-block-image img {
	transition: opacity 0.3s ease;
}

.wp-block-gallery.has-nested-images figure.wp-block-image:hover img {
	opacity: 0.85;
}

/* One photo per row on phones, like the original. */
@media (max-width: 599px) {
	.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) {
		width: 100%;
	}
}

/* ---------- Lightbox with filmstrip ---------- */

.op-lb-trigger {
	cursor: zoom-in;
}

.op-lb-open {
	overflow: hidden;
}

.op-lb {
	box-sizing: border-box;
	width: 100vw;
	max-width: none;
	height: 100dvh;
	max-height: none;
	margin: 0;
	padding: 0;
	border: var(--op-frame) solid var(--op-frame-color);
	background: rgba(0, 0, 0, 0.96);
	color: var(--wp--preset--color--contrast);
}

.op-lb[open] {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto auto;
	animation: op-lb-in 0.3s ease;
}

.op-lb::backdrop {
	background: #000;
}

@keyframes op-lb-in {
	from { opacity: 0; }
}

.op-lb__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 20px;
}

.op-lb__count {
	margin: 0;
	font-size: 13px;
	letter-spacing: 2px;
	color: var(--wp--preset--color--contrast-2);
}

.op-lb__close,
.op-lb__arrow,
.op-lb__thumb {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
}

.op-lb__close {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	transition: color 0.25s ease, transform 0.25s ease;
}

.op-lb__close:hover {
	color: var(--wp--preset--color--accent);
	transform: rotate(90deg);
}

.op-lb__stage {
	position: relative;
	display: grid;
	grid-template-columns: 64px minmax(0, 1fr) 64px;
	align-items: center;
	min-height: 0;
	touch-action: pan-y;
}

.op-lb__figure {
	grid-column: 2;
	grid-row: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 100%;
	min-height: 0;
	margin: 0;
}

.op-lb__img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	min-height: 0;
	object-fit: contain;
	transition: opacity 0.3s ease;
}

.op-lb__img.is-loading {
	opacity: 0;
}

.op-lb__caption {
	padding-top: 10px;
	font-size: 14px;
	text-align: center;
	color: var(--wp--preset--color--contrast-2);
}

.op-lb__arrow {
	display: grid;
	place-items: center;
	width: 64px;
	height: 64px;
	color: var(--wp--preset--color--accent);
	transition: color 0.25s ease, transform 0.25s ease;
}

.op-lb__arrow:hover {
	color: var(--wp--preset--color--contrast);
}

.op-lb__arrow--prev { grid-column: 1; grid-row: 1; }
.op-lb__arrow--next { grid-column: 3; grid-row: 1; }

.op-lb__arrow--prev:hover { transform: translateX(-4px); }
.op-lb__arrow--next:hover { transform: translateX(4px); }

/* Camera settings of the photo on screen, like the readout in a viewfinder. */
.op-lb__exif {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: baseline;
	column-gap: 28px;
	row-gap: 4px;
	min-height: 1.5em;
	margin: 0;
	padding: 14px 20px 0;
	line-height: 1.5;
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 2px;
	font-variant-numeric: tabular-nums;
	color: var(--wp--preset--color--contrast-2);
}

.op-lb__exif span {
	white-space: nowrap;
}

.op-lb__exif-camera {
	text-transform: uppercase;
}

.op-lb__exif-aperture,
.op-lb__exif-shutter {
	color: var(--wp--preset--color--contrast);
}

.op-lb__exif-aperture {
	text-transform: lowercase;
}

/* The filmstrip: all photos in a row, the current one with a thin red border. */
.op-lb__strip {
	display: flex;
	gap: 8px;
	padding: 14px 20px;
	overflow-x: auto;
	scrollbar-width: thin;
	scrollbar-color: #333 transparent;
}

.op-lb__thumb {
	flex: 0 0 auto;
	height: 70px;
	opacity: 0.45;
	outline: 2px solid transparent;
	outline-offset: 2px;
	transition: opacity 0.25s ease, outline-color 0.25s ease;
}

.op-lb__thumb img {
	display: block;
	height: 100%;
	width: auto;
	aspect-ratio: 3 / 2;
	object-fit: cover;
}

.op-lb__thumb:hover {
	opacity: 0.8;
}

.op-lb__thumb.is-active {
	opacity: 1;
	outline-color: var(--wp--preset--color--accent);
}

.op-lb__close:focus-visible,
.op-lb__arrow:focus-visible,
.op-lb__thumb:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}

.op-lb.is-single .op-lb__arrow,
.op-lb.is-single .op-lb__strip {
	visibility: hidden;
}

@media (max-width: 599px) {
	.op-lb__stage {
		grid-template-columns: 0 minmax(0, 1fr) 0;
	}

	/* On phones: swipe instead of arrows. */
	.op-lb__arrow {
		display: none;
	}

	.op-lb__thumb {
		height: 48px;
	}

	.op-lb__strip {
		padding: 10px 12px;
		gap: 6px;
	}

	.op-lb__exif {
		column-gap: 16px;
		padding: 10px 12px 0;
		font-size: 10px;
		letter-spacing: 1px;
	}

	/* No room for the camera and date on a phone. */
	.op-lb__exif-camera,
	.op-lb__exif-date {
		display: none;
	}
}

/* ---------- Post cards ---------- */

.op-card .wp-block-post-featured-image {
	overflow: hidden;
}

.op-card .wp-block-post-featured-image img {
	transition: transform 0.6s ease;
}

.op-card:hover .wp-block-post-featured-image img {
	transform: scale(1.05);
}

.op-card-title a:hover {
	color: var(--wp--preset--color--contrast);
	opacity: 0.8;
}

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

.op-site-footer p {
	margin: 0;
}

/* ---------- Preloader ---------- */

.op-preloader {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none; /* Only shown when JS is running (see .js below). */
	place-items: center;
	background-color: var(--wp--preset--color--base);
	opacity: 0.97;
	transition: opacity 0.6s ease, visibility 0.6s ease;
}

.op-preloader.is-done {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.op-preloader__frame {
	position: relative;
	width: 64px;
	height: 64px;
}

.op-preloader__frame::before,
.op-preloader__frame::after {
	content: "";
	position: absolute;
	inset: 0;
	border: 2px solid var(--wp--preset--color--contrast);
	animation: op-frame 2.4s ease-in-out infinite;
}

.op-preloader__frame::after {
	border-color: var(--wp--preset--color--accent);
	animation-delay: -1.2s;
}

@keyframes op-frame {
	0% { transform: scale(0.4) rotate(0deg); opacity: 0; }
	40% { opacity: 1; }
	100% { transform: scale(1.2) rotate(90deg); opacity: 0; }
}

/* The head script adds .js; without JS the preloader never blocks the page. */
.js .op-preloader {
	display: grid;
}

.js.op-preloaded .op-preloader {
	display: none;
}

