/*
Theme Name: Appus Photos
Theme URI: https://photos.appus.fr
Author: Appus
Author URI: https://appus.fr
Description: Thème galerie photo pour Appus Photos. Système « 1b » : sombre, monochrome, la photo comme seule couleur. Thème de blocs (FSE) : mosaïque de photos, lightbox native, données structurées, optimisé performances et accessibilité.
Requires at least: 6.7
Tested up to: 6.9
Requires PHP: 8.1
Version: 1.1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: appus-photos
Tags: blog, photography, dark, one-column, custom-colors, editor-style, full-site-editing, block-patterns, threaded-comments, translation-ready
*/

/* La police Figtree (assets/fonts) est distribuée sous licence SIL Open Font License 1.1.
   Copyright 2022 The Figtree Project Authors (https://github.com/erikdkennedy/figtree) */

:root {
	color-scheme: dark;
	/* Voile sous les titres en surimpression (réglable). */
	--photo-scrim: linear-gradient(180deg, rgba(13, 15, 16, 0) 45%, rgba(13, 15, 16, 0.78) 100%);
	--photo-scrim-hover: linear-gradient(180deg, rgba(13, 15, 16, 0) 45%, rgba(13, 15, 16, 0.48) 100%);
	--photo-gap: 6px;
}

/* =====================================================================
   En-tête du site
   ===================================================================== */

.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	background: color-mix(in srgb, var(--wp--preset--color--base) 86%, transparent);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--wp--preset--color--line);
}

@supports not (background: color-mix(in srgb, red 50%, transparent)) {
	.site-header {
		background: var(--wp--preset--color--base);
	}
}

/* =====================================================================
   Vignettes photo (mosaïque : accueil, archives, recherche)
   ===================================================================== */

.photo-card {
	position: relative;
	overflow: hidden;
	background: var(--wp--preset--color--surface);
	height: 100%;
}

.photo-card .wp-block-post-featured-image {
	margin: 0;
	height: 100%;
}

.photo-card .wp-block-post-featured-image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Voile permanent : le titre reste lisible sur n'importe quelle photo */
.photo-card__body {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	align-items: flex-start;
	gap: 0.3rem;
	padding: 1rem;
	background: var(--photo-scrim);
	transition: background 0.2s ease-out;
	pointer-events: none;
}

.photo-card:hover .photo-card__body,
.photo-card:focus-within .photo-card__body {
	background: var(--photo-scrim-hover);
}

.photo-card__body a {
	pointer-events: auto;
}

/* Le titre en blanc pur pour tenir sur les photos claires */
.photo-card .wp-block-post-title {
	color: #fff;
	margin: 0;
}

.photo-card .wp-block-post-title a {
	color: #fff;
	text-decoration: none;
	transition: text-decoration-color 0.2s ease-out;
}

.photo-card:hover .wp-block-post-title a,
.photo-card:focus-within .wp-block-post-title a {
	text-decoration: underline;
	text-underline-offset: 4px;
}

/* Catégorie en capitales espacées, clair sur voile */
.photo-card__meta,
.photo-card__meta .wp-block-post-terms,
.photo-card__meta .wp-block-post-terms a {
	color: #c9ccc6;
}

/* Toute la vignette est cliquable : lien étiré depuis le titre */
.photo-card .wp-block-post-title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.photo-card__meta {
	position: relative;
	z-index: 2;
}

.photo-card:focus-within {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}

.photo-card .wp-block-post-title a:focus-visible {
	outline: none;
}

/* --- Mosaïque : la dernière photo occupe un bloc 2×2, tuiles carrées --- */
@media (min-width: 700px) {
	.home .wp-block-post-template,
	.blog .wp-block-post-template,
	.archive .wp-block-post-template,
	.search .wp-block-post-template {
		grid-auto-flow: dense;
	}

	.home .wp-block-post-template > li:first-child,
	.blog .wp-block-post-template > li:first-child {
		grid-column: span 2;
		grid-row: span 2;
	}

	/* Étiquette « Dernière photo » sur la vignette héros de l'accueil */
	.home .wp-block-post-template > li:first-child .photo-card__body::before,
	.blog .wp-block-post-template > li:first-child .photo-card__body::before {
		content: "Dernière photo";
		order: -1;
		align-self: flex-start;
		font-size: var(--wp--preset--font-size--meta);
		letter-spacing: 0.2em;
		text-transform: uppercase;
		color: #c9ccc6;
		margin-bottom: 0.4rem;
	}

	.home .wp-block-post-template > li:first-child .wp-block-post-title,
	.blog .wp-block-post-template > li:first-child .wp-block-post-title {
		font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.9rem);
		font-weight: 300;
	}
}

/* Vignettes carrées (mosaïque). Réglable : passer 1/1 en 3/2 pour moins recadrer. */
.wp-block-post-template.is-layout-grid > li .photo-card {
	aspect-ratio: 1 / 1;
}

/* Le héros occupe un bloc 2×2 : il reste carré pour s'aligner exactement
   sur deux rangées de tuiles, quelle que soit l'orientation de la photo
   (une photo portrait ne doit pas étirer le bloc et casser la grille). */
@media (min-width: 700px) {
	.home .wp-block-post-template > li:first-child .photo-card,
	.blog .wp-block-post-template > li:first-child .photo-card {
		aspect-ratio: 1 / 1;
		height: auto;
	}
}

/* =====================================================================
   Article : galerie en mosaïque déterministe
   ===================================================================== */

/* La galerie utilise sa disposition native (colonnes uniformes, rangées
   recadrées à hauteur égale). On règle seulement le joint et les angles. */
.wp-block-post-content .wp-block-gallery.has-nested-images {
	--wp--style--unstable-gallery-gap: var(--photo-gap);
	gap: var(--photo-gap);
}

.wp-block-post-content .wp-block-gallery.has-nested-images figure.wp-block-image,
.wp-block-post-content .wp-block-gallery.has-nested-images figure.wp-block-image img {
	border-radius: 0;
}

/* Bandeau méta d'article : catégorie en capitales espacées */
.post-meta-row,
.post-meta-row .wp-block-post-terms,
.post-meta-row .wp-block-post-terms a {
	color: var(--wp--preset--color--muted);
	text-transform: uppercase;
	letter-spacing: 0.2em;
	font-size: var(--wp--preset--font-size--meta);
}

/* =====================================================================
   Navigation entre articles
   ===================================================================== */

.post-nav .wp-block-post-navigation-link {
	max-width: 48%;
}

/* =====================================================================
   Pagination
   ===================================================================== */

.wp-block-query-pagination .page-numbers {
	display: inline-grid;
	place-items: center;
	min-width: 2.4em;
	min-height: 2.4em;
	padding: 0.3em;
	border: 1px solid var(--wp--preset--color--line);
	color: var(--wp--preset--color--muted);
}

.wp-block-query-pagination .page-numbers.current {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	border-color: var(--wp--preset--color--contrast);
}

.wp-block-query-pagination a.page-numbers:hover {
	color: var(--wp--preset--color--contrast);
	border-color: var(--wp--preset--color--contrast);
}

.wp-block-query-pagination .wp-block-query-pagination-previous,
.wp-block-query-pagination .wp-block-query-pagination-next {
	border: none;
	color: var(--wp--preset--color--contrast);
	font-weight: 500;
}

/* =====================================================================
   Formulaires (commentaires, recherche) sur fond sombre
   ===================================================================== */

.wp-block-post-comments-form input:not([type="submit"]):not([type="checkbox"]),
.wp-block-post-comments-form textarea,
.wp-block-search__input {
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 0;
	padding: 0.75rem 0.9rem;
	width: 100%;
	box-sizing: border-box;
}

.wp-block-post-comments-form input:not([type="submit"]):focus,
.wp-block-post-comments-form textarea:focus,
.wp-block-search__input:focus {
	border-color: var(--wp--preset--color--contrast);
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}

.wp-block-search__button {
	border-radius: 0;
	margin-left: 0;
}

/* Commentaires : filet à gauche, pas d'avatar ni de date en avant */
.wp-block-comment-template .wp-block-comment-author-name {
	font-weight: 500;
}

/* =====================================================================
   Visionneuse plein écran (galerie photo par photo)
   ===================================================================== */

.apx-lightbox[hidden] {
	display: none;
}

.apx-lightbox {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	background: rgba(10, 11, 13, 0.96);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.apx-lb__figure {
	grid-column: 2;
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	max-height: 100vh;
	padding: 2.5rem 0;
}

.apx-lb__img {
	max-width: min(94vw, 1600px);
	max-height: 82vh;
	width: auto;
	height: auto;
	object-fit: contain;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.apx-lb__cap {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	text-align: center;
	max-width: 60ch;
}

.apx-lb__cap[hidden] {
	display: none;
}

/* Boutons de navigation et de fermeture */
.apx-lb__nav,
.apx-lb__close {
	appearance: none;
	background: none;
	border: 0;
	cursor: pointer;
	color: var(--wp--preset--color--contrast);
	position: relative;
}

.apx-lb__nav {
	width: clamp(48px, 7vw, 84px);
	height: 100%;
	font-size: 0;
}

.apx-lb__prev { grid-column: 1; }
.apx-lb__next { grid-column: 3; }

.apx-lb__nav::before {
	content: "";
	display: block;
	width: 18px;
	height: 18px;
	margin: 0 auto;
	border-top: 2px solid currentColor;
	border-right: 2px solid currentColor;
	opacity: 0.75;
	transition: opacity 0.2s ease-out;
}

.apx-lb__prev::before { transform: rotate(-135deg); }
.apx-lb__next::before { transform: rotate(45deg); }

.apx-lb__nav:hover::before,
.apx-lb__nav:focus-visible::before {
	opacity: 1;
}

.apx-lb__close {
	position: absolute;
	top: 0.75rem;
	right: 0.9rem;
	width: 44px;
	height: 44px;
	font-size: 0;
	z-index: 2;
}

.apx-lb__close::before,
.apx-lb__close::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 2px;
	background: currentColor;
	opacity: 0.8;
}

.apx-lb__close::before { transform: translate(-50%, -50%) rotate(45deg); }
.apx-lb__close::after { transform: translate(-50%, -50%) rotate(-45deg); }

.apx-lb__close:hover::before,
.apx-lb__close:hover::after,
.apx-lb__close:focus-visible::before,
.apx-lb__close:focus-visible::after {
	opacity: 1;
}

.apx-lb__count {
	position: absolute;
	bottom: 1rem;
	left: 50%;
	transform: translateX(-50%);
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--meta);
	letter-spacing: 0.2em;
}

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

@media (max-width: 599px) {
	.apx-lb__nav {
		position: absolute;
		bottom: 0;
		height: 64px;
		width: 50%;
	}
	.apx-lb__prev { left: 0; grid-column: auto; }
	.apx-lb__next { right: 0; grid-column: auto; }
	.apx-lb__img { max-height: 74vh; }
}

/* =====================================================================
   Accessibilité
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
	.photo-card__body {
		transition: none;
	}
}

:where(a, button, input, textarea, summary):focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}

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