/*
Theme Name: Alesandro Life
Theme URI: https://alesandrolife.com
Author: Alesandro Life
Description: Block theme for Alesandro Life, Saša's personal site: experiences, upcoming projects and a way to connect. Every text and image is editable in the WordPress editor.
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 8.1
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: alesandro-life
*/

/*
 * Most styling lives in theme.json (colors, type, spacing, block styles).
 * This file only holds what theme.json can't express.
 */

/* ---------- Base ---------- */

@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}

a {
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}

:where(a, button, input, .wp-element-button):focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 3px;
}

/* Anchored sections (#about, #contact) stop below the sticky header. */
:where(.wp-site-blocks) [id] {
	scroll-margin-top: calc(var(--wp-admin--admin-bar--height, 0px) + 5.5rem);
}

/* Full-width sections meet the header and footer without a gap. */
.wp-site-blocks > main,
.wp-site-blocks > footer {
	margin-block-start: 0;
}

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

.wp-site-blocks > header.wp-block-template-part {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 50;
}

@media (max-width: 600px) {
	/* The admin bar scrolls away on small screens. */
	.admin-bar .wp-site-blocks > header.wp-block-template-part {
		top: 0;
	}
}

.site-header {
	border-bottom: 1px solid var(--wp--preset--color--line);
}

.site-header .wp-block-site-logo img {
	width: clamp(170px, 22vw, 230px);
	height: auto;
}

.site-header .wp-block-navigation-item__content {
	position: relative;
	padding-block: 0.35rem;
}

.site-header .wp-block-navigation-item__content::after {
	content: "";
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	height: 1px;
	background: var(--wp--preset--color--accent);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 0.25s ease;
}

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

/* Mobile menu overlay: large serif links, left-aligned (the header menu itself is right-aligned). */
.wp-block-navigation__responsive-container.is-menu-open,
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container.items-justified-right {
	--navigation-layout-justification-setting: flex-start;
	--navigation-layout-justify: flex-start;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	font-family: var(--wp--preset--font-family--cormorant-garamond);
	font-size: 2.25rem;
	font-weight: 400;
	letter-spacing: -0.01em;
	text-transform: none;
}

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

/* Same side padding as every other section, so the text lines up with the logo. */
.hero.wp-block-cover {
	padding-right: var(--wp--style--root--padding-right);
	padding-left: var(--wp--style--root--padding-left);
}

.hero .hero-rule {
	width: 72px;
	height: 2px;
	margin-left: 0 !important;
	border: 0;
}

@media (max-width: 781px) {
	/* On phones the text is centred both ways, so the shade is deepest across the middle. */
	.hero .wp-block-cover__background {
		background: linear-gradient(180deg, rgba(38, 20, 12, 0.3) 0%, rgba(38, 20, 12, 0.68) 28%, rgba(38, 20, 12, 0.68) 72%, rgba(38, 20, 12, 0.3) 100%) !important;
	}

	.hero .wp-block-cover__inner-container > .wp-block-group > * {
		margin-right: auto !important;
		margin-left: auto !important;
		text-align: center;
	}

	.hero .wp-block-buttons {
		justify-content: center;
	}
}

/* The sunset-orange button lightens on hover (its colours are set on the block, which outrank theme.json's hover). */
.hero .wp-block-button__link.has-accent-background-color {
	transition: background-color 0.2s ease;
}

.hero .wp-block-button__link.has-accent-background-color:hover {
	background-color: var(--wp--preset--color--warm-white) !important;
}

@media (prefers-reduced-motion: reduce) {
	.hero .wp-block-button__link.has-accent-background-color {
		transition: none;
	}
}

/*
 * Entrance: the photo appears first, then the dusk shade slides in and the text rises
 * into place line by line. Front end only (the editor has no .wp-site-blocks).
 * While the photo is still downloading, functions.php adds "is-waiting", which holds
 * everything at the start until the photo has loaded.
 */
@media (prefers-reduced-motion: no-preference) {
	.wp-site-blocks .hero .wp-block-cover__image-background {
		animation: hero-fade 0.9s ease-out both, hero-settle 2.4s cubic-bezier(0.22, 1, 0.36, 1) both;
	}

	.wp-site-blocks .hero .wp-block-cover__background {
		animation: hero-panel 1s cubic-bezier(0.22, 1, 0.36, 1) 0.7s both;
	}

	.wp-site-blocks .hero .wp-block-cover__inner-container > .wp-block-group > * {
		animation: hero-rise 0.8s cubic-bezier(0.22, 1, 0.36, 1) 1.5s both;
	}

	.wp-site-blocks .hero .wp-block-cover__inner-container .hero-rule {
		transform-origin: left;
		animation-name: hero-rule;
	}

	.wp-site-blocks .hero .wp-block-cover__inner-container > .wp-block-group > :nth-child(1) {
		animation-delay: 1s;
	}

	.wp-site-blocks .hero .wp-block-cover__inner-container > .wp-block-group > :nth-child(2) {
		animation-delay: 1.15s;
	}

	.wp-site-blocks .hero .wp-block-cover__inner-container > .wp-block-group > :nth-child(3) {
		animation-delay: 1.25s;
	}

	.wp-site-blocks .hero .wp-block-cover__inner-container > .wp-block-group > :nth-child(4) {
		animation-delay: 1.4s;
	}

	.wp-site-blocks .hero.is-waiting .wp-block-cover__image-background,
	.wp-site-blocks .hero.is-waiting .wp-block-cover__background,
	.wp-site-blocks .hero.is-waiting .wp-block-cover__inner-container > .wp-block-group > * {
		animation-play-state: paused;
	}
}

/* On phones the shade covers the whole photo, so it fades in where it is and the line grows from the middle. */
@media (prefers-reduced-motion: no-preference) and (max-width: 781px) {
	.wp-site-blocks .hero .wp-block-cover__background {
		animation-name: hero-fade;
	}

	.wp-site-blocks .hero .wp-block-cover__inner-container .hero-rule {
		transform-origin: center;
	}
}

@keyframes hero-fade {
	from { opacity: 0; }
}

@keyframes hero-settle {
	from { transform: scale(1.06); }
}

@keyframes hero-panel {
	from { opacity: 0; transform: translateX(-25%); }
}

@keyframes hero-rise {
	from { opacity: 0; transform: translateY(1.5rem); }
}

@keyframes hero-rule {
	from { opacity: 0; transform: scaleX(0); }
}

/* ---------- Fade-up on scroll: homepage sections below the hero ---------- */

/*
 * assets/js/reveal.js adds "reveal" only to blocks still below the screen and
 * "is-revealed" as each one scrolls into view. Without the script nothing is hidden.
 */
@media screen and (prefers-reduced-motion: no-preference) {
	.reveal {
		opacity: 0;
		transform: translateY(2rem);
		transition:
			opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0s),
			transform 0.9s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0s);
	}

	/* Tabbing to a link inside a block shows it straight away. */
	.reveal.is-revealed,
	.reveal:focus-within {
		opacity: 1;
		transform: none;
	}
}

/* ---------- Labels and sections ---------- */

.is-style-section-deep {
	--wp--custom--color--label: var(--wp--preset--color--accent);
}

/* ---------- Cards (experiences and projects) ---------- */

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

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

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

.card .wp-block-post-title a:hover {
	text-decoration: underline;
}

/* "Read more" with the "Button" style: hover and dark sections match the site's buttons. */
.wp-block-read-more.is-style-button {
	transition: background-color 0.2s ease;
}

.wp-block-read-more.is-style-button:hover {
	background-color: var(--wp--preset--color--ink);
}

.is-style-section-deep .wp-block-read-more.is-style-button {
	background-color: var(--wp--preset--color--warm-white);
	color: var(--wp--preset--color--deep);
}

.is-style-section-deep .wp-block-read-more.is-style-button:hover {
	background-color: var(--wp--preset--color--soft);
}

@media (prefers-reduced-motion: reduce) {
	.card .wp-block-post-featured-image img,
	.wp-block-read-more.is-style-button,
	.site-header .wp-block-navigation-item__content::after {
		transition: none;
	}
}

/* ---------- Sliders: Post Template block with the "Slider" styles ---------- */

/*
 * The row fills the content column, centred like every other section. Each edge is as wide
 * as a gap plus part of a card (--fade-width: the cut-off card), and between the edges sit
 * --slides whole cards. A fixed fade (--fade-size) at the outer end of each edge melts
 * whatever slides under it into the background, keeping 45% at the very edge. slider.js
 * makes the row loop, so there is always a cut-off card at both edges. Without the script
 * the row's padding (equal to the edges) lets the first and last cards rest just inside them.
 */
/* Registered, so the card width is worked out on the row (cqw = the Query Loop's width) and
   handed to the cards as a length: core's grid layout makes the row itself a container. */
@property --slider-card {
	syntax: "<length>";
	inherits: true;
	initial-value: 0px;
}

.wp-block-query:has(> .is-style-slider, > .is-style-slider-large) {
	container-type: inline-size;
}

.wp-block-post-template.is-style-slider,
.wp-block-post-template.is-style-slider-large {
	--slides: 3;
	--peek: 0.5;
	--slider-gap: var(--wp--preset--spacing--40);
	--slider-card: calc((100cqw - (var(--slides) + 1) * var(--slider-gap)) / (var(--slides) + 2 * var(--peek)));
	--fade-width: calc(var(--slider-gap) + var(--peek) * var(--slider-card));
	--fade-size: min(var(--fade-width), calc((var(--fade-width) + clamp(2.5rem, 6vw, 6rem)) / 2));
	/* Positioned, so hidden screen-reader text inside "Read more" links is clipped too. */
	position: relative;
	display: flex;
	gap: var(--slider-gap);
	padding-right: var(--fade-width);
	padding-left: var(--fade-width);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-padding-inline: var(--fade-width);
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	mask-image: linear-gradient(
		to right,
		rgb(0 0 0 / 0.45) 0,
		#000 var(--fade-size),
		#000 calc(100% - var(--fade-size)),
		rgb(0 0 0 / 0.45) 100%
	);
}

.wp-block-post-template.is-style-slider-large {
	--slides: 2;
}

/* Few enough posts to fit (slider.js adds "is-static"): a plain row lined up with the heading. */
.wp-block-post-template.is-style-slider.is-static,
.wp-block-post-template.is-style-slider-large.is-static {
	--slider-card: calc((100cqw - (var(--slides) - 1) * var(--slider-gap)) / var(--slides));
	padding-inline: 0;
	overflow-x: visible;
	mask-image: none;
}

/* Drag with the mouse (slider.js adds "is-draggable"); touch screens swipe. */
@media (hover: hover) and (pointer: fine) {
	.wp-block-post-template.is-draggable {
		cursor: grab;
	}

	.wp-block-post-template.is-draggable .wp-block-post-featured-image a {
		cursor: inherit;
	}
}

.wp-block-post-template.is-dragging {
	cursor: grabbing;
	scroll-snap-type: none;
	user-select: none;
}

.wp-block-post-template.is-dragging > li {
	pointer-events: none;
}

.wp-block-post-template.is-style-slider::-webkit-scrollbar,
.wp-block-post-template.is-style-slider-large::-webkit-scrollbar {
	display: none;
}

.wp-block-post-template.is-style-slider > li,
.wp-block-post-template.is-style-slider-large > li {
	flex: 0 0 var(--slider-card);
	margin: 0;
	scroll-snap-align: start;
}

@media (max-width: 1023px) {
	.wp-block-post-template.is-style-slider {
		--slides: 2;
	}

	.wp-block-post-template.is-style-slider-large {
		--slides: 1;
	}
}

@media (max-width: 599px) {
	.wp-block-post-template.is-style-slider,
	.wp-block-post-template.is-style-slider-large {
		--slides: 1;
		--peek: 0.15;
	}
}

.slider-footer .wp-block-button__link {
	white-space: nowrap;
}

.slider-nav {
	display: flex;
	gap: 0.5rem;
}

.slider-nav[hidden] {
	display: none;
}

.slider-nav__button {
	display: inline-grid;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 1px solid currentColor;
	border-radius: 2px;
	background: transparent;
	color: inherit;
	cursor: pointer;
	place-items: center;
	transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.slider-nav__button:hover:not(:disabled) {
	border-color: var(--wp--preset--color--ink);
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--warm-white);
}

.is-style-section-deep .slider-nav__button:hover:not(:disabled) {
	border-color: var(--wp--preset--color--warm-white);
	background: var(--wp--preset--color--warm-white);
	color: var(--wp--preset--color--deep);
}

.slider-nav__button:disabled {
	cursor: default;
	opacity: 0.3;
}

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

/* Phones swipe; the arrows would squeeze the "View all" button onto two lines. Alone in its row, the button is centred. */
@media (max-width: 599px) {
	.slider-nav {
		display: none;
	}

	.wp-block-group.slider-footer {
		justify-content: center;
	}
}

/* ---------- Alternating list: Post Template block with the "Alternating list" style ---------- */

/*
 * Each post is a full-width band holding a Columns block with the image first.
 * Bands alternate between two backgrounds (sand / warm white, or two ocean tones
 * inside a "Deep ocean" section). On wider screens odd rows are reversed, so the
 * first post has its text on the left and the image on the right, the second the
 * other way round, and so on. Phones show the image above the text.
 *
 * The editor adds a hidden copy of the post being edited, so the ":nth-child(... of ...)"
 * rules count only visible rows; the plain rules before them cover older browsers.
 */
.wp-block-post-template.is-style-alternating {
	--row-odd: var(--wp--preset--color--soft);
	--row-even: var(--wp--preset--color--warm-white);
}

.is-style-section-deep .wp-block-post-template.is-style-alternating {
	--row-odd: var(--wp--preset--color--deep);
	--row-even: var(--wp--preset--color--deep-alt);
}

.wp-block-post-template.is-style-alternating > li {
	--row-background: var(--row-odd);
	margin-block-start: 0;
	padding-block: var(--wp--preset--spacing--50);
	background: var(--row-background);
	/* Paint the band edge to edge without widening the page. */
	box-shadow: 0 0 0 100vmax var(--row-background);
	clip-path: inset(0 -100vmax);
}

.wp-block-post-template.is-style-alternating > li:nth-child(even),
.wp-block-post-template.is-style-alternating > li:nth-child(even of :not([style*="display: none"])) {
	--row-background: var(--row-even);
}

.wp-block-post-template.is-style-alternating > li:nth-child(odd of :not([style*="display: none"])) {
	--row-background: var(--row-odd);
}

@media (min-width: 782px) {
	.wp-block-post-template.is-style-alternating > li:nth-child(odd) > .wp-block-columns {
		flex-direction: row-reverse;
	}

	.wp-block-post-template.is-style-alternating > li:nth-child(even of :not([style*="display: none"])) > .wp-block-columns {
		flex-direction: row;
	}

	.wp-block-post-template.is-style-alternating > li:nth-child(odd of :not([style*="display: none"])) > .wp-block-columns {
		flex-direction: row-reverse;
	}
}

/* ---------- Previous / next links on single experiences and projects ---------- */

.wp-block-post-navigation-link {
	display: flex;
	align-items: flex-end;
	gap: 0.6rem;
}

.post-navigation-link-next {
	margin-left: auto;
}

.wp-block-post-navigation-link a {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	text-decoration: none;
}

.post-navigation-link-next a {
	text-align: right;
}

.post-navigation-link__label {
	color: var(--wp--custom--color--label);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.post-navigation-link__title {
	font-family: var(--wp--preset--font-family--cormorant-garamond);
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.3;
}

.wp-block-post-navigation-link a:hover .post-navigation-link__title {
	text-decoration: underline;
}

/* ---------- Social buttons with labels ("Let's connect") match the site's buttons ---------- */

/* Every button is as wide as the widest one: equal grid columns, with the list only as wide as its buttons. */
.wp-block-social-links.has-visible-labels {
	display: grid;
	grid-auto-columns: 1fr;
	grid-auto-flow: column;
	width: fit-content;
}

/* Keep the block's Justification setting working now that the list is narrower than its column. */
.wp-block-social-links.has-visible-labels.is-content-justification-left {
	margin-left: 0 !important;
}

.wp-block-social-links.has-visible-labels.is-content-justification-right {
	margin-right: 0 !important;
}

/* Editor only: the "+" sits just after the buttons instead of taking a column of its own. */
.wp-block-social-links.has-visible-labels > .block-list-appender {
	position: absolute;
	top: 50%;
	left: 100%;
	translate: 1rem -50%;
}

.wp-block-social-links.has-visible-labels .wp-social-link {
	border-radius: 2px;
}

.wp-block-social-links.has-visible-labels .wp-block-social-link-anchor {
	justify-content: center;
	gap: 0.65rem;
	padding: 0.8rem 1.4rem;
}

.wp-block-social-links.has-visible-labels .wp-block-social-link-label {
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

/* Core puts a margin on both sides of the label; the one after it pushed the icon and name off-centre. */
.wp-block-social-links.has-visible-labels .wp-social-link .wp-block-social-link-label {
	margin-inline-end: 0;
}

/* Too narrow for two side by side: stack them, still equal width. */
@media (max-width: 479px) {
	.wp-block-social-links.has-visible-labels {
		grid-auto-flow: row;
	}
}

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

.site-footer .wp-block-social-links .wp-social-link:hover {
	opacity: 0.65;
}
