@import url("meista-flowers-preview.css");

@view-transition {
	navigation: auto;
}

/* Shared transition styling for Meistä and every worker profile.
   Timing comes from the site's page transition settings in index.css. */

.team-transition::view-transition-old(root),
.team-transition::view-transition-new(root) {
	animation: none;
	mix-blend-mode: normal;
}

/* Hold one opaque flower backdrop throughout the portrait/content transition.
   Cross-fading or recapturing it with the page can expose the canvas below. */
.team-transition .pageWrapper::before {
	view-transition-name: team-background;
}
.team-transition::view-transition-group(team-background) {
	animation: none;
	z-index: 1;
}
.team-transition::view-transition-old(team-background) {
	animation: none;
	opacity: 1;
	mix-blend-mode: normal;
}
.team-transition::view-transition-new(team-background) {
	animation: none;
	visibility: hidden;
}

.team-transition .teamIntroTitle {
	view-transition-name: team-title;
}

.team-transition .teamIntroText {
	view-transition-name: team-intro;
}

/* Keep the surrounding tiles still while the selected portrait moves. */
.team-transition .carousel {
	view-transition-name: team-cards;
}

.team-transition::view-transition-group(team-title),
.team-transition::view-transition-group(team-intro),
.team-transition::view-transition-group(team-cards) {
	animation: none;
	z-index: 2;
}

.team-transition::view-transition-old(team-title),
.team-transition::view-transition-old(team-intro),
.team-transition::view-transition-old(team-cards),
.team-transition::view-transition-new(team-title),
.team-transition::view-transition-new(team-intro),
.team-transition::view-transition-new(team-cards),
.team-transition::view-transition-old(team-list-content),
.team-transition::view-transition-new(team-list-content) {
	animation: none;
	opacity: 1;
	mix-blend-mode: normal;
}

.team-transition .teamContent {
	view-transition-name: team-list-content;
}

.team-transition .profiiliContent {
	view-transition-name: team-profile-content;
}

/* A sidebar booking button sits outside the profile sheet. Give it its own
   snapshot above the opaque backdrop instead of leaving it in the root below. */
.team-transition .profileSidebar .profiiliCTAButton {
	view-transition-name: team-profile-booking;
}

.team-transition::view-transition-group(team-list-content),
.team-transition::view-transition-group(team-profile-content),
.team-transition::view-transition-group(team-profile-surface),
.team-transition::view-transition-group(team-profile-booking) {
	animation: none;
}

.team-transition::view-transition-old(team-profile-content),
.team-transition::view-transition-old(team-profile-booking),
.team-transition::view-transition-old(team-profile-surface) {
	animation: var(--page-transition-duration) var(--page-transition-easing) both team-profile-slide-out;
	mix-blend-mode: normal;
}

.team-transition::view-transition-new(team-profile-content),
.team-transition::view-transition-new(team-profile-booking),
.team-transition::view-transition-new(team-profile-surface) {
	animation: var(--page-transition-duration) var(--page-transition-easing) both team-profile-slide-in;
	mix-blend-mode: normal;
}

/* Move the whole sheet beyond the viewport, including Safari's toolbar area. */
@keyframes team-profile-slide-in {
	from {
		transform: translateY(100vh);
		transform: translateY(100lvh);
	}
}

@keyframes team-profile-slide-out {
	to {
		transform: translateY(100vh);
		transform: translateY(100lvh);
	}
}

/* Strict layer order: backdrop, Meistä, sliding surface, profile content,
   selected portrait, navigation. No tile fades through the sliding sheet. */
.team-transition::view-transition-group(root) {
	z-index: 0;
}

.team-transition::view-transition-group(team-list-content) {
	z-index: 2;
}

.team-transition::view-transition-group(team-profile-surface) {
	z-index: 3;
}

.team-transition::view-transition-group(team-profile-content),
.team-transition::view-transition-group(team-profile-booking) {
	z-index: 4;
}

.team-transition::view-transition-group(team-portrait) {
	z-index: 5;
}

.team-transition::view-transition-group(header-btn-back),
.team-transition::view-transition-group(header-btn-menu),
.team-transition::view-transition-group(header-btn-fwd) {
	z-index: 6;
}

@media (max-width: 900px) {
	/* Original carousel transition: fade the overview, move the selected
	   portrait independently, and slide only the profile's reading section. */
	.team-transition {
		--page-transition-duration: 600ms;
	}
	.team-transition::view-transition-group(root) {
		animation: none;
	}
	.team-transition::view-transition-old(team-title),
	.team-transition::view-transition-old(team-intro),
	.team-transition::view-transition-old(team-cards),
	.team-transition::view-transition-old(team-profile-booking) {
		animation: var(--page-transition-duration) var(--page-transition-easing) both team-intro-out;
	}
	.team-transition::view-transition-new(team-title),
	.team-transition::view-transition-new(team-intro),
	.team-transition::view-transition-new(team-cards),
	.team-transition::view-transition-new(team-profile-booking) {
		animation: var(--page-transition-duration) var(--page-transition-easing) both team-intro-in;
	}
	.team-transition::view-transition-new(team-profile-content) {
		animation-name: slide-from-down;
	}
	.team-transition::view-transition-old(team-profile-content) {
		animation-name: slide-to-down;
		animation-timing-function: cubic-bezier(0.8, 0, 0.6, 1);
	}
}

@keyframes team-intro-out {
	from { opacity: 1; }
	to { opacity: 0; }
}

@keyframes team-intro-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

/* Card morph animation */
::view-transition-group(team-portrait) {
	animation-duration: var(--page-transition-duration);
	animation-timing-function: var(--page-transition-easing);
}


:root {
	scrollbar-width: none;
	background-color: rgb(255, 249, 240);
}

body {
	background-color: rgb(255, 249, 240);
	color: rgb(100, 70, 40);
	font-family: 'Sans-serif';
	font-size: clamp(1rem, 2vw, 1.375rem);
	margin: 0;
	padding: 0;
	backface-visibility: hidden;
	position: relative;
	overflow-x: hidden;
	min-height: 100vh;
}

.html {
	padding: 0;
	margin: 0;
	scroll-behavior: smooth;
}

a {
	color: inherit;
}

.pageWrapper {
	/* Both photographs include the original cream backing and share a crop. */
	--team-flower-image: linear-gradient(to top, transparent, rgb(255, 249, 240) 90%),
		url(/IMG/meista-flowers.webp), var(--team-flower-preview);
	background-color: rgb(255, 249, 240);
	min-height: 100%;
	position: relative;
	isolation: isolate;
}

/* Size against the large viewport so Safari's expanding/collapsing toolbar
   cannot resize the flower image or expose an edge while scrolling. */
.pageWrapper::before {
	content: '';
	position: fixed;
	inset: 0 0 auto;
	height: 100vh;
	height: 100lvh;
	z-index: -1;
	pointer-events: none;
	background-color: rgb(255, 249, 240);
	background-image: var(--team-flower-image);
	background-size: cover;
	background-position: 28% 76%;
}

.pageWrapper > .introductionWrapper {
	background-color: transparent;
}

.teamContent {
	background-color: rgb(255, 249, 240);
	display: flow-root;
}

.headerButtonsContainer {
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	flex-grow: 1;
	min-width: 100%;
}

.headerButton {
	display: flex;
	justify-content: center;
	align-items: center;
	width: 30%;
	padding-block: 5px;
	padding-inline: 5px;
	margin: 10px 5px;
	background-color: linen;
	box-shadow: 0px 0px 2px rgb(100, 70, 40);
	color: rgb(100, 70, 40);
	opacity: 0.9;
	border-radius: 10px;
	font-family: 'Alex Brush', cursive;
	font-size: clamp(1.5rem, 2vw, 2rem);
	text-decoration: none;
	text-wrap: nowrap;
	font-weight: normal;

	transition: opacity 0.2s, box-shadow 0.2s;
}

.headerButton:hover {
	cursor: pointer;
	opacity: 1;
	box-shadow: 0px 0px 4px rgb(100, 70, 40);
}

.rotated {
	float: left;
	-webkit-transform: rotate(-100deg);
}

.introductionContainer {
	padding-bottom: 5%;
	text-align: center;
}

.portrait {
	border-radius: 5px;
	object-fit: cover;
	min-width: 100%;
	max-height: 400px;
	aspect-ratio: 2/3;
}

.pageWrapper {
	background-color: rgb(255, 249, 240);
}

.carousel {
	padding-bottom: 10%;
	inline-size: 100cqi;
	list-style-type: none;
	scroll-padding: 5%;

	display: grid;
	grid-auto-flow: column;
	gap: 5%;

	&::scroll-marker-group {
		padding-block: 0;
		block-size: 44px;
		/* match buttons */
	}

	&::before,

	&::after {
		content: "";
		display: block;
		inline-size: 10cqi;


	}

	.carousel__slide {
		container-type: scroll-state;
		scroll-snap-align: center;
		scroll-snap-stop: always;
	}

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

		/* @container not scroll-state(snapped: inline) {
					figcaption {
						transform: translateY(100%);
					}
				} */
	}

	&::scroll-button(right),
	&::scroll-button(left) {
		position-area: var(--_inner-under);
	}
}

/* Keep the mobile text-to-portrait proportions at every viewport width.
   The page's viewport-based font size must not enlarge text on fixed cards.
   Use rem for both so larger default text also gets a larger portrait. */
.carousel .card,
.profiiliCard {
	inline-size: calc(25rem * 2 / 3);
	font-size: 1rem;
}
.carousel .portrait,
.profiiliCard .portrait {
	display: block;
	width: 100%;
	height: 25rem;
	max-height: none;
}
.carousel .figheader h2,
.carousel .figheader h3,
.profiiliCard .figheader h2,
.profiiliCard .figheader h3 {
	font-family: 'Alex Brush', Georgia, serif;
}

.carouselHint {
	padding: 0;
	margin: 0 auto;
}
.carouselHint h1 { margin: .25em 0 0; }

.id-anchor {
	display: block;
	position: relative;
	top: -1000px;
	visibility: hidden;
}

.card {
	background: gray;
	border-radius: 5px;
	box-shadow: 0px 0px 10px 2px gray;
	margin: 10% 0;
	overflow: clip;
	align-content: end;

	>figure {
		display: grid;
		place-items: center stretch;
		margin: 0;
		padding: 0;

		>* {
			grid-area: 1 / 1;
		}

		>figcaption {
			max-inline-size: 100%;
			display: grid;
			justify-items: center;
			height: 100%;
			transition:
				transform 0.3s ease-in-out,
				opacity 0.3s ease-in-out;
			background: linear-gradient(to top, #000, 10%, #ffffff00);
			padding-inline: 10%;
			/* padding-block: 5px 5px; this causes weird lines bottom*/

			text-align: center;

			&:focus-within {
				transform: translateY(0%);
			}

			& h2 {
				color: whitesmoke;
				margin-bottom: 0;
				text-shadow: 2px 1px 1px rgb(100, 70, 40);
				;
			}

			& h3 {
				color: whitesmoke;
				margin: 0;
				text-shadow: 1px 1px rgb(100, 70, 40);

			}

			& h4 {
				color: whitesmoke;
				margin: 0;
			}

			& p {
				color: gainsboro;
				align-self: self-end;
			}
		}
	}
}

/* `.carousel` elements
 * -------------------------------------------------------------------------*/


.carousel {
	anchor-name: --carousel;
	container-type: inline-size;

	/* scroll styles */
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;

	&:focus-visible {
		scrollbar-color: transparent;
		outline: none;
	}

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

.carousel__slide {
	scroll-snap-align: start;

	:where(.carousel--offscreen-inert) & {
		animation: offscreen-inert ease-out both;
		animation-timeline: view(x);
	}

	:where(.carousel--unsnapped-inert) & {
		animation: offscreen-inert ease-out both;
		animation-timeline: view(x);
	}

	:where(.carousel--unsnapped-inert) & {
		container-type: scroll-state;

		&>* {
			@container not scroll-state(snapped) {
				interactivity: inert;
			}
		}
	}
}

/* Larger screens show the whole team in normal reading order. Keep the same
   portrait dimensions and typography as the mobile carousel and profiles. */
@media (min-width: 901px) {
	.carousel {
		inline-size: min(90%, 75rem);
		margin-inline: auto;
		padding-block: 1rem 4rem;
		grid-auto-flow: row;
		grid-template-columns: repeat(auto-fit, calc(25rem * 2 / 3));
		justify-content: center;
		gap: 2rem;
		overflow: visible;
		scroll-snap-type: none;
		container-type: normal;
	}
	.carousel::before,
	.carousel::after { display: none; }
	.carousel .carousel__slide { scroll-snap-align: none; }
	.carousel .carousel__slide > a { display: block; }
	.carousel .card { margin: 0; }
	.carouselHint { display: none; }
}

/* `.carousel` states
 * -------------------------------------------------------------------------*/

.carousel--scroll-markers {
	scroll-marker-group: before;

	&::scroll-marker-group {
		position: absolute;
		position-anchor: --carousel;

		container: marker-group / inline-size;

		display: grid;
		gap: var(--size-2);
		place-content: safe center;
		box-sizing: border-box;
		border-radius: 50%;

		scrollbar-width: none;
		scroll-behavior: smooth;
	}

	.carousel__slide {
		&::scroll-marker {
			content: "" / attr(data-label);
			scroll-snap-align: center;
			aspect-ratio: 1;
			border: 1px solid light-dark(var(--gray-6), var(--surface-4));
			border-radius: 5px;
			cursor: pointer;
			-webkit-tap-highlight-color: transparent;
			text-decoration: none;
			-webkit-tap-highlight-color: transparent;
			transition:
				transform 0.3s var(--ease-spring-2),
				outline-offset 0.25s var(--ease-3);
			animation: scale-in-and-out linear both;
			animation-timeline: view(x);

			/* todo: remove once marker `interactivity` is inherited from `::scroll-marker-group` */
			interactivity: auto;
		}

		&::scroll-marker:target-current {
			background: var(--link);
			border-color: var(--link);
		}

		@media (forced-colors: active) {
			&::scroll-marker:target-current {
				background: Highlight;
				border-color: Highlight;
			}
		}

		&::scroll-marker:not(:active):hover {
			transform: scale(1.25);
		}

		/* todo: switch backt of focus-visible */
		&::scroll-marker:not(:active):focus {
			outline: 2px solid var(--link);
			outline-offset: 2px;
		}

		:where(.carousel--vertical) &::scroll-marker {
			animation-timeline: view(y);
		}
	}
}

/* TODO:
  up, down
  use scroll-state(scrollable) to auto generate buttons */
.carousel--scroll-buttons {
	&::scroll-button(*) {
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;

		position: absolute;
		z-index: 1;
		position-anchor: --carousel;

		font-size: var(--font-size-3);
		inline-size: 44px;
		margin: var(--size-3);

		font-family: "Material Symbols Outlined";
		line-height: 1;
		font-variation-settings:
			"FILL" 0,
			"wght" 100,
			"GRAD" 0,
			"opsz" 24;

		display: flex;
		place-items: center;
		place-content: center;
		aspect-ratio: 1;
		background: none;
		border: 1px solid var(--surface-3);
		border-radius: var(--radius-round);

		transition:
			transform 0.3s var(--ease-spring-3),
			opacity 0.5s var(--ease-3),
			background-color 0.3s var(--ease-3),
			outline-offset 0.25s var(--ease-3);

		@media (forced-colors: active) {
			background: Canvas;
		}
	}

	&::scroll-button(*):not(:disabled):is(:hover, :focus-visible) {
		background-color: light-dark(white, var(--surface-1));
		border-color: var(--surface-4);
		font-variation-settings: "opsz" 30;
		transform: scale(1.1);
	}

	&::scroll-button(*):not(:active):focus-visible {
		outline-offset: 2px;
		outline: 2px solid var(--link);
	}

	&::scroll-button(right):not(:disabled):active {
		transform: translateX(5px) scale(0.95);
	}

	&::scroll-button(left):not(:disabled):active {
		transform: translateX(-5px) scale(0.95);
	}

	&::scroll-button(up):not(:disabled):active {
		transform: translateY(-5px) scale(0.95);
	}

	&::scroll-button(down):not(:disabled):active {
		transform: translateY(5px) scale(0.95);
	}

	&::scroll-button(*):disabled {
		opacity: 25%;
		cursor: not-allowed;
	}
}

/* .carousel {
	list-style: none;
	margin: 5rem;
	padding: 1rem;
	border: 5px solid white;
	display: grid;
	gap: 2rem;
	grid-auto-flow: column;
	grid-auto-columns: 30%;

	overflow-x: auto;
	scroll-snap-type: x mandatory;

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

	anchor-name: --carousel;

	scroll-marker-group: after;

	&::scroll-marker-group {
		display: flex;
		justify-content: center;
		gap: 0.5rem;
		padding: 1rem;
	}

	>li {
		scroll-snap-align: center;

		&::scroll-marker {
			content: " ";
			width: 20px;
			height: auto;
			aspect-ratio: 1 / 1;
			border-radius: 100%;
			border: 2px solid CanvasText;
		}

		&::scroll-marker:target-current {
			background: LinkText;
		}

	}

	&::scroll-button(*) {
		position: fixed;
		position-anchor: --carousel;
		margin: 1rem;
		font: inherit;
		background-color: linen;
		border: 0;
		border-radius: 5px;
		box-shadow: 0px 0px 3px black;
		font-weight: 700;
	}

	&::scroll-button(right) {
		content: ">";
		position-area: center right;
	}

	&::scroll-button(left) {
		content: "<";
		position-area: center left;
	}
}

.card {

	text-align: center;

	>img {
		width: 100%;
		height: 100%;
		position: relative;
		object-fit: cover;
		border-radius: 10px;
	}
}

.cardText {
	width: 100%;
	height: 100%;
	position: relative;
	border-radius: inherit;
	background: linear-gradient(180deg, rgba(0, 0, 0, 0) 14.06%, #1E1E1E 100%);
display: flex;
align-items: flex-end;
text-align: center;
}

*/

.teamContent .introductionContainer img { max-width: 100%; height: auto; }
