/* ==========================================================================
   Turquoise Travel: the sea behind the site (front end)
   inc/sea.php prints the layers and adds body.has-sea; everything below only applies when that class is
   there. Layers, back to front (all fixed, so the page scrolls over them):
     1. the sea photo under its wash (or a flat colour)   2. drifting light   3. the two turtle gutters
   It needs a screen wider than the content column, so: from 1201px up the photo (or flat colour) shows
   in the gutters; from 1400px up the light and the turtles are added. Below 1201px none of it is shown.
   ========================================================================== */

/* ==========================================================================
   SWITCHES: the only lines you need to edit.

   1. --tt-bg  Background under everything. Pick ONE value:
        var(--tt-bg-sea)    sea photo under a dark turquoise wash (current)
        var(--tt-bg-flat)   plain dark turquoise (no photo)
      ...and set --tt-under (below it) to match: --tt-under-sea with the photo, --tt-under-flat with the flat colour.

   2. --tt-drift  Drifting light across the sea. Pick ONE value:
        block   on (current)
        none    off

   3. --tt-surge  Stroke surge: each turtle speeds up on its flipper power stroke and glides between strokes. 0 to
      about 0.8. 0 = off, 0.3 = gentle glide (current), 0.5 = pronounced. The average speed is the same.

   4. --tt-solid  Solid turtles, 0 to 1. 0 = see-through (a tint laid over the sea, so deeper turtles show through
      shallower ones). 1 = the same colours but solid, so a shallower turtle hides the deeper one under it. In
      between is a mix. Solid suits the flat background; on the photo 0 to 0.5 is better.

   5. --tt-gaps  With --tt-solid above 0, plug the gaps between shell plates and where the head and flippers join,
      so a deeper turtle can't show through them. Pick ONE value:  inline = on (current)   none = off

   The turtles' own switches ($pink, $depth, $assorted) are at the top of turquoise_travel_sea_turtles() in inc/sea.php.
   ========================================================================== */
body.has-sea {
	--tt-bg: var(--tt-bg-sea);
	--tt-under: var(--tt-under-sea);
	--tt-drift: block;
	--tt-surge: 0.3;
	--tt-solid: 1;
	--tt-gaps: inline;
}

/* The values the switches above can take. Not switches: leave as they are. */
body.has-sea {
	--tt-under-flat: #1c5766; /* = dark-turquoise in theme.json */
	--tt-under-sea: #145360;  /* measured average of the photo under its wash */
	--tt-bg-flat: linear-gradient(#1c5766, #1c5766);
	--tt-bg-sea: linear-gradient(rgb(18 62 76 / 0.62), rgb(18 62 76 / 0.62)), url("../img/login-sea.jpg");
}

/* The sea shows through only where nothing paints over it. Make the page background itself clear on screens wide
   enough for the gutters (the fixed sea layers sit behind the content). */
@media (min-width: 1201px) {
	body.has-sea,
	body.has-sea .wp-site-blocks {
		background: transparent;
	}
}

/* Layers: negative z-index puts all three behind the page content, which needs no positioning. */
.tt-sea-bg,
.tt-sea-light,
.tt-sea {
	display: none;
	pointer-events: none;
}


	.tt-sea-bg {
		display: block;
		position: fixed;
		inset: 0;
		z-index: -3;
		background: var(--tt-bg) center / cover no-repeat;
	}


/* Layer 2: drifting light. Two soft glows moved with transform (GPU only: animating background-position would
   repaint a full-screen layer every frame). Full width, so a glow drifts smoothly from one gutter to the other. */
@media (min-width: 1400px) {
	.tt-sea-light {
		display: var(--tt-drift, none);
		position: fixed;
		inset: 0;
		z-index: -2;
		overflow: hidden;
	}

	.tt-sea-light::before,
	.tt-sea-light::after {
		content: "";
		position: absolute;
		left: 0;
		top: 0;
		will-change: transform;
	}

	.tt-sea-light::before {
		width: 55vw;
		height: 100vh;
		background: radial-gradient(closest-side, rgb(150 225 235 / 0.24), rgb(150 225 235 / 0));
		animation: tt-light-a 60s ease-in-out infinite alternate;
	}

	.tt-sea-light::after {
		width: 45vw;
		height: 90vh;
		background: radial-gradient(closest-side, rgb(150 225 235 / 0.20), rgb(150 225 235 / 0));
		animation: tt-light-b 60s ease-in-out infinite alternate;
	}
}

@keyframes tt-light-a {
	from { transform: translate(2.25vw, 0); }
	to { transform: translate(42.75vw, 0); }
}

@keyframes tt-light-b {
	from { transform: translate(52.25vw, 10vh); }
	to { transform: translate(2.75vw, 1.5vh); }
}

/* Layer 3: the two turtle gutters. Each <svg> is a 1px anchor on a screen edge, vertically centred; the turtles
   are drawn around it in plain px (see inc/sea.php). The right-hand one is the left mirrored. */
@media (min-width: 1400px) {
	.tt-sea {
		display: block;
		position: fixed;
		top: 50%;
		width: 1px;
		height: 1px;
		overflow: visible;
		z-index: -1;
		fill: #fff;

		/* Length of the wrap loop, px: across = gutter columns shown x 240, plus 100 off-screen and 140 under the
		   content; down = the screen height plus 100 off-screen each side. Changed by the media queries below. */
		--px: 480;
		--py: 1300;
	}

	.tt-sea-l { left: 0; }
	.tt-sea-r { right: 0; transform: scaleX(-1); }
}

/* Gutter columns: column k is shown once the gutter is wider than 240k px (screen wider than 1200 + 480k). */
.tx1, .tx2, .tx3, .tx4, .tx5, .tx6, .ty1, .ty2 { display: none; }

@media (min-width: 1681px) { .tt-sea { --px: 720; } .tx1 { display: inline; } }
@media (min-width: 2161px) { .tt-sea { --px: 960; } .tx2 { display: inline; } }
@media (min-width: 2641px) { .tt-sea { --px: 1200; } .tx3 { display: inline; } }
@media (min-width: 3121px) { .tt-sea { --px: 1440; } .tx4 { display: inline; } }
@media (min-width: 3601px) { .tt-sea { --px: 1680; } .tx5 { display: inline; } }
@media (min-width: 4081px) { .tt-sea { --px: 1920; } .tx6 { display: inline; } }

/* Rows: more once the screen is taller than 1080px and 1440px. */
@media (min-height: 1081px) { .tt-sea { --py: 1700; } .ty1 { display: inline; } }
@media (min-height: 1441px) { .tt-sea { --py: 2600; } .ty2 { display: inline; } }

/*
 * Straight-line swimming that wraps. Across: a turtle's --qx is how far along its loop it starts (the loop begins 100px
 * off the screen edge and runs --px), --sx is its direction (1 or -1) and --ax its speed in px per second.
 * Down: the loop is centred, --uy is the turtle's offset from the centre.
 */
.tt-x,
.tt-y {
	animation-timing-function: linear;
	animation-iteration-count: infinite;
}

.tt-x {
	animation-name: tt-x;
	animation-duration: calc(var(--px) / var(--ax) * 1s);
	animation-delay: calc(-1s * (var(--qx) + (1 - var(--sx)) / 2 * (var(--px) - 2 * var(--qx))) / var(--ax));
}

.tt-y {
	animation-name: tt-y;
	animation-duration: calc(var(--py) / var(--ay) * 1s);
	animation-delay: calc(-1s * (var(--sy) * var(--uy) + var(--py) / 2) / var(--ay));
}

@keyframes tt-x {
	from { transform: translateX(calc((var(--px) * (1 - var(--sx)) / 2 - var(--qx)) * 1px)); }
	to { transform: translateX(calc((var(--px) - var(--qx) - var(--px) * (1 - var(--sx)) / 2) * 1px)); }
}

@keyframes tt-y {
	from { transform: translateY(calc(var(--sy) * var(--py) * -0.5px - var(--uy) * 1px)); }
	to { transform: translateY(calc(var(--sy) * var(--py) * 0.5px - var(--uy) * 1px)); }
}

/*
 * Turtle colour. PHP gives each turtle a tint (--f) and a strength (--o). See-through: the tint is painted
 * at --o opacity over the background. Solid: opacity 1, and the tint is mixed with --tt-under at --o
 * instead, which looks the same against a background of that colour. --tt-solid slides between the two
 * (any value from 0 to 1 gives the same colours; only how much a turtle hides the ones under it changes).
 */
.tt-turtle {
	fill: color-mix(in srgb, var(--f) calc(100% * var(--o) / (var(--o) + var(--tt-solid, 0) * (1 - var(--o)))), var(--tt-under, #1c5766));
	opacity: calc(var(--o) + var(--tt-solid, 0) * (1 - var(--o)));
}

/*
 * The hidden body under each turtle (the "body" path in inc/login.php): the shell, head and flipper roots with
 * every gap closed, painted in the background colour. Its opacity follows --tt-solid, so see-through turtles
 * (0) are exactly as before and --tt-gaps does nothing.
 */
.tt-gaps {
	display: var(--tt-gaps, none);
	opacity: var(--tt-solid, 0);
	fill: var(--tt-under, #1c5766);
}

.tt-body,
.tt-head,
.tt-ft,
.tt-fr,
.tt-rl,
.tt-rb {
	animation-duration: var(--dur, 2.4s);
	animation-delay: var(--delay, 0s);
	animation-timing-function: ease-in-out;
	animation-iteration-count: infinite;
}

.tt-body { transform-origin: 33.4px 27.9px; animation-name: tt-body; }

/*
 * Stroke surge. The front flippers' power stroke is the first 40% of each cycle (see tt-front-top). Forward
 * speed is shaped to match it: it starts building the moment the flippers start to push back (0%), reaches its
 * top at the end of the stroke (40%), then decays like drag through the glide (40% to 100%) back to its slowest
 * just as the next stroke begins. Speed = average x (1 + --tt-surge x curve), with the curve running from -0.67
 * (end of glide) to +1 (end of stroke) and averaging zero, so the turtle covers exactly the same ground per stroke as without it.
 * The keyframes below are the integral of that speed curve: a small back-and-forth shift along the heading
 * (the artwork's nose direction, cos -33.2 / sin -33.2 = 0.837 / -0.548) in the turtle's own units, so it scales
 * with size and is right at any rotation. They share the flippers' --dur and --delay, so every turtle's surge
 * stays locked to its own stroke. To retime it, change the stroke points in the speed curve (0.4 = end of
 * the power stroke) and regenerate the keyframes.
 */
.tt-surge {
	animation-name: tt-surge;
	animation-duration: var(--dur, 2.4s);
	animation-delay: var(--delay, 0s);
	animation-timing-function: linear;
	animation-iteration-count: infinite;
}

@keyframes tt-surge {
	0% { transform: translate(calc(var(--tt-surge, 0) * -2.61px), calc(var(--tt-surge, 0) * 1.71px)); }
	2.5% { transform: translate(calc(var(--tt-surge, 0) * -3.37px), calc(var(--tt-surge, 0) * 2.20px)); }
	5% { transform: translate(calc(var(--tt-surge, 0) * -4.09px), calc(var(--tt-surge, 0) * 2.67px)); }
	7.5% { transform: translate(calc(var(--tt-surge, 0) * -4.73px), calc(var(--tt-surge, 0) * 3.09px)); }
	10% { transform: translate(calc(var(--tt-surge, 0) * -5.26px), calc(var(--tt-surge, 0) * 3.44px)); }
	12.5% { transform: translate(calc(var(--tt-surge, 0) * -5.65px), calc(var(--tt-surge, 0) * 3.70px)); }
	15% { transform: translate(calc(var(--tt-surge, 0) * -5.90px), calc(var(--tt-surge, 0) * 3.86px)); }
	17.5% { transform: translate(calc(var(--tt-surge, 0) * -5.97px), calc(var(--tt-surge, 0) * 3.91px)); }
	20% { transform: translate(calc(var(--tt-surge, 0) * -5.87px), calc(var(--tt-surge, 0) * 3.84px)); }
	22.5% { transform: translate(calc(var(--tt-surge, 0) * -5.59px), calc(var(--tt-surge, 0) * 3.66px)); }
	25% { transform: translate(calc(var(--tt-surge, 0) * -5.13px), calc(var(--tt-surge, 0) * 3.36px)); }
	27.5% { transform: translate(calc(var(--tt-surge, 0) * -4.50px), calc(var(--tt-surge, 0) * 2.95px)); }
	30% { transform: translate(calc(var(--tt-surge, 0) * -3.72px), calc(var(--tt-surge, 0) * 2.44px)); }
	32.5% { transform: translate(calc(var(--tt-surge, 0) * -2.81px), calc(var(--tt-surge, 0) * 1.84px)); }
	35% { transform: translate(calc(var(--tt-surge, 0) * -1.78px), calc(var(--tt-surge, 0) * 1.17px)); }
	37.5% { transform: translate(calc(var(--tt-surge, 0) * -0.68px), calc(var(--tt-surge, 0) * 0.45px)); }
	40% { transform: translate(calc(var(--tt-surge, 0) * 0.46px), calc(var(--tt-surge, 0) * -0.30px)); }
	42.5% { transform: translate(calc(var(--tt-surge, 0) * 1.53px), calc(var(--tt-surge, 0) * -1.00px)); }
	45% { transform: translate(calc(var(--tt-surge, 0) * 2.45px), calc(var(--tt-surge, 0) * -1.60px)); }
	47.5% { transform: translate(calc(var(--tt-surge, 0) * 3.22px), calc(var(--tt-surge, 0) * -2.11px)); }
	50% { transform: translate(calc(var(--tt-surge, 0) * 3.86px), calc(var(--tt-surge, 0) * -2.52px)); }
	52.5% { transform: translate(calc(var(--tt-surge, 0) * 4.35px), calc(var(--tt-surge, 0) * -2.85px)); }
	55% { transform: translate(calc(var(--tt-surge, 0) * 4.73px), calc(var(--tt-surge, 0) * -3.09px)); }
	57.5% { transform: translate(calc(var(--tt-surge, 0) * 4.98px), calc(var(--tt-surge, 0) * -3.26px)); }
	60% { transform: translate(calc(var(--tt-surge, 0) * 5.12px), calc(var(--tt-surge, 0) * -3.35px)); }
	62.5% { transform: translate(calc(var(--tt-surge, 0) * 5.15px), calc(var(--tt-surge, 0) * -3.37px)); }
	65% { transform: translate(calc(var(--tt-surge, 0) * 5.09px), calc(var(--tt-surge, 0) * -3.33px)); }
	67.5% { transform: translate(calc(var(--tt-surge, 0) * 4.93px), calc(var(--tt-surge, 0) * -3.22px)); }
	70% { transform: translate(calc(var(--tt-surge, 0) * 4.68px), calc(var(--tt-surge, 0) * -3.06px)); }
	72.5% { transform: translate(calc(var(--tt-surge, 0) * 4.35px), calc(var(--tt-surge, 0) * -2.85px)); }
	75% { transform: translate(calc(var(--tt-surge, 0) * 3.95px), calc(var(--tt-surge, 0) * -2.59px)); }
	77.5% { transform: translate(calc(var(--tt-surge, 0) * 3.49px), calc(var(--tt-surge, 0) * -2.28px)); }
	80% { transform: translate(calc(var(--tt-surge, 0) * 2.96px), calc(var(--tt-surge, 0) * -1.94px)); }
	82.5% { transform: translate(calc(var(--tt-surge, 0) * 2.38px), calc(var(--tt-surge, 0) * -1.56px)); }
	85% { transform: translate(calc(var(--tt-surge, 0) * 1.75px), calc(var(--tt-surge, 0) * -1.15px)); }
	87.5% { transform: translate(calc(var(--tt-surge, 0) * 1.09px), calc(var(--tt-surge, 0) * -0.71px)); }
	90% { transform: translate(calc(var(--tt-surge, 0) * 0.39px), calc(var(--tt-surge, 0) * -0.25px)); }
	92.5% { transform: translate(calc(var(--tt-surge, 0) * -0.34px), calc(var(--tt-surge, 0) * 0.22px)); }
	95% { transform: translate(calc(var(--tt-surge, 0) * -1.08px), calc(var(--tt-surge, 0) * 0.71px)); }
	97.5% { transform: translate(calc(var(--tt-surge, 0) * -1.84px), calc(var(--tt-surge, 0) * 1.21px)); }
	100% { transform: translate(calc(var(--tt-surge, 0) * -2.61px), calc(var(--tt-surge, 0) * 1.71px)); }
}

.tt-head { transform-origin: 52.9px 16.4px; animation-name: tt-head; }
.tt-ft   { transform-origin: 41.9px 11.4px; animation-name: tt-front-top; }
.tt-fr   { transform-origin: 58.9px 26.9px; animation-name: tt-front-right; }
.tt-rl   { transform-origin: 12.9px 29.9px; animation-name: tt-rear-left; }
.tt-rb   { transform-origin: 29.4px 44.9px; animation-name: tt-rear-bottom; }

/* Front flippers: quick power stroke back (40% of the cycle), slower recovery. The two sides mirror. */
@keyframes tt-front-top {
	0%, 100% { transform: rotate(14deg) scale(0.97); }
	40% { transform: rotate(-22deg) scale(1.05); }
}

@keyframes tt-front-right {
	0%, 100% { transform: rotate(-14deg) scale(0.97); }
	40% { transform: rotate(22deg) scale(1.05); }
}

/* Rear flippers flutter, out of step with each other. */
@keyframes tt-rear-left {
	0%, 100% { transform: rotate(8deg); }
	50% { transform: rotate(-8deg); }
}

@keyframes tt-rear-bottom {
	0%, 100% { transform: rotate(-8deg); }
	50% { transform: rotate(8deg); }
}

/* Head sways and stretches forward a little on each stroke. */
@keyframes tt-head {
	0%, 100% { transform: rotate(6deg) scale(0.98); }
	50% { transform: rotate(-6deg) scale(1.05); }
}

/* Whole turtle surges slightly along its heading and sways. */
@keyframes tt-body {
	0%, 100% { transform: translate(-0.8px, 0.5px) rotate(-1.2deg); }
	50% { transform: translate(1.3px, -0.9px) rotate(1.2deg); }
}

/* ==========================================================================
   OPTIONAL: make the whole page one 1200px column without editing any section.
   The sea only shows beside content that is narrower than the screen. If you edit the sections to "Wide"
   width yourself you don't need this. To try it instead, delete the comment markers on the lines just above and below the rule.
   The shadow lifts the column off the sea and keeps the dark turquoise bands from merging into it.
   ========================================================================== */
/*
@media (min-width: 1201px) {
	body.has-sea .wp-site-blocks {
		width: min(75rem, 100%);
		margin-inline: auto;
		box-shadow: 0 0 70px rgb(0 0 0 / 0.30);
	}
}
*/

@media (prefers-reduced-motion: reduce) {
	.tt-sea-light::before,
	.tt-sea-light::after,
	.tt-x, .tt-y, .tt-surge, .tt-body, .tt-head, .tt-ft, .tt-fr, .tt-rl, .tt-rb {
		animation: none;
	}
}

@media print {
	.tt-sea-bg, .tt-sea-light, .tt-sea {
		display: none;
	}
}