/* "Възрастови групи" (templates/age-groups.php, assets/js/agegroups.js): the original sea comes alive – light falls
   from the surface, bubbles rise, a school of fish and a lone fish swim by (each the way its drawing looks: the school
   to the right, fish-3 to the left), seaweed sways on the bottom. Every skill's sea creature swims in its own way and
   does its own trick under the pointer (and blows bubbles at a touch); a new group comes with a wave of light. Three
   things move each creature, so none of them cancels another: the figure comes in, the picture idles, the span plays. */

.ag > .wrapper { position: relative; z-index: 1; }
.ag-sea { position: absolute; z-index: 0; inset: 0; overflow: hidden; pointer-events: none; }
.ag .two-col-list figure { overflow: visible; }

/* light from the surface */
.ag-rays { position: absolute; left: 0; right: 0; top: 0; height: 640px; }
.ag-rays i { position: absolute; top: -40px; width: 120px; height: 680px; background: linear-gradient(rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 80%); transform-origin: 50% 0; rotate: 18deg; filter: blur(6px); animation: ag-shimmer 7s ease-in-out infinite alternate; }
.ag-rays i:nth-child(1) { left: 6%; width: 90px; }
.ag-rays i:nth-child(2) { left: 24%; width: 150px; animation-delay: -2s; animation-duration: 9s; }
.ag-rays i:nth-child(3) { left: 47%; width: 70px; animation-delay: -4s; }
.ag-rays i:nth-child(4) { left: 64%; width: 130px; animation-delay: -1s; animation-duration: 11s; }
.ag-rays i:nth-child(5) { left: 86%; width: 100px; animation-delay: -6s; animation-duration: 8s; }
@keyframes ag-shimmer { from { opacity: .25; rotate: 15deg; } to { opacity: 1; rotate: 21deg; } }

.ag-bubbles { position: absolute; inset: 0; }

/* fish passing far away */
.ag-swim { position: absolute; opacity: .45; background: no-repeat center / contain; }
.ag-swim--school { top: 26%; left: -260px; width: 220px; height: 120px; background-image: url('../images/fish-4.svg'); animation: ag-right 55s linear -12s infinite; }
.ag-swim--lone { top: 62%; left: 100%; width: 90px; height: 64px; background-image: url('../images/fish-3.svg'); animation: ag-left 38s linear -20s infinite; }
@keyframes ag-right { from { left: -260px; translate: 0 0; } 50% { translate: 0 30px; } to { left: 100%; translate: 0 0; } }
@keyframes ag-left { from { left: 100%; translate: 0 0; } 50% { translate: 0 -24px; } to { left: -120px; translate: 0 0; } }

/* seaweed on the bottom */
.ag-weeds { position: absolute; left: 0; right: 0; bottom: 0; height: 190px; }
.ag-weeds i { position: absolute; bottom: -10px; left: calc(var(--w) * 11.5% + 3%); width: 16px; height: var(--h, 140px); border-radius: 60% 60% 0 0 / 22% 22% 0 0; background: linear-gradient(90deg, #1f7a45, #3fb36b 60%, #2a8f52); transform-origin: 50% 100%; animation: ag-sway calc(3.5s + (var(--w) * .7s)) ease-in-out calc(var(--w) * -.9s) infinite alternate; opacity: .85; }
.ag-weeds i::before, .ag-weeds i::after { content: ''; position: absolute; width: 14px; height: 34px; border-radius: 50%; background: inherit; }
.ag-weeds i::before { left: -10px; top: 30%; rotate: -30deg; }
.ag-weeds i::after { right: -10px; top: 55%; rotate: 30deg; }
.ag-weeds i:nth-child(3n) { background: linear-gradient(90deg, #2b6f8f, #4aa3b8 60%, #2b6f8f); }
@keyframes ag-sway { from { rotate: -7deg; } to { rotate: 7deg; } }

/* a new group: a wave of light washes over the page */
.ag-wash { position: absolute; z-index: 2; left: -10%; right: -10%; top: 60px; height: 900px; pointer-events: none; opacity: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .28) 48%, rgba(190, 235, 255, .4) 52%, transparent 70%); }
.ag-wash.is-on { animation: ag-wash .9s cubic-bezier(.4, 0, .3, 1); }
@keyframes ag-wash { from { opacity: 1; translate: -70% 0; } to { opacity: 1; translate: 70% 0; } }
.ag .tab-content.is-new { animation: ag-come .7s cubic-bezier(.3, 1.2, .5, 1); }
@keyframes ag-come { from { opacity: 0; translate: 0 26px; } to { opacity: 1; translate: 0 0; } }

/* ---------- The creatures ---------- */
.ag-skill figure span { transition: scale .35s cubic-bezier(.34, 1.6, .64, 1); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ag-skill figure img { transform-origin: 50% 70%; }
.ag-js .ag-skill:not(.is-in) figure { opacity: 0; }
.ag-skill.is-in figure { animation: var(--in, ag-in-pop) 1.1s cubic-bezier(.3, 1.2, .5, 1) backwards; }
@keyframes ag-in-pop { from { opacity: 0; translate: 0 60px; scale: .6; } to { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes ag-in-right { from { opacity: 0; translate: -180px 30px; rotate: -12deg; } 40% { opacity: 1; } to { opacity: 1; translate: 0 0; rotate: 0deg; } }
@keyframes ag-in-left { from { opacity: 0; translate: 180px 30px; rotate: 12deg; } 40% { opacity: 1; } to { opacity: 1; translate: 0 0; rotate: 0deg; } }
@keyframes ag-in-spin { from { opacity: 0; scale: 0; rotate: -200deg; } to { opacity: 1; scale: 1; rotate: 0deg; } }
@keyframes ag-in-side { from { opacity: 0; translate: 200px 0; } 70% { translate: -10px 0; } to { opacity: 1; translate: 0 0; } }

/* the dolphin (it looks right): comes from the left, rides the waves, leaps on the spot */
.ag-skill--dolphin { --in: ag-in-right; }
.ag-skill--dolphin figure img { animation: ag-bob 3.6s ease-in-out infinite alternate; }
.ag-skill--dolphin figure span:hover, .ag-skill--dolphin.is-play figure span { animation: ag-leap .9s cubic-bezier(.4, 0, .4, 1); }
@keyframes ag-bob { from { translate: 0 -6px; rotate: -3deg; } to { translate: 0 6px; rotate: 3deg; } }
@keyframes ag-leap { 0% { translate: 0 0; rotate: 0deg; } 40% { translate: 0 -46px; rotate: -22deg; } 70% { translate: 0 6px; rotate: 16deg; } 100% { translate: 0 0; rotate: 0deg; } }
/* the starfish: turns slowly, spins under the pointer */
.ag-skill--star { --in: ag-in-spin; }
.ag-skill--star figure img { animation: ag-turn 24s linear infinite; transform-origin: 50% 50%; }
.ag-skill--star figure span:hover, .ag-skill--star.is-play figure span { animation: ag-spin .9s cubic-bezier(.3, 0, .3, 1); }
@keyframes ag-turn { to { rotate: 360deg; } }
@keyframes ag-spin { 50% { scale: 1.15; } to { rotate: 216deg; } }
/* the snail (it looks right): crawls in slowly from the left, stretches as it goes */
.ag-skill--snail { --in: ag-in-right; }
.ag-skill--snail.is-in figure { animation-duration: 2.6s; animation-timing-function: cubic-bezier(.2, .6, .3, 1); }
.ag-skill--snail figure img { animation: ag-creep 2.2s ease-in-out infinite; transform-origin: 30% 100%; }
.ag-skill--snail figure span:hover, .ag-skill--snail.is-play figure span { scale: 1.08; }
@keyframes ag-creep { 0%, 100% { scale: 1 1; } 50% { scale: 1.05 .97; } }
/* the clam: breathes, hops under the pointer and the pearl shines */
.ag-skill--clamshell figure img { animation: ag-breathe 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
.ag-skill--clamshell figure span:hover, .ag-skill--clamshell.is-play figure span { animation: ag-hop .7s cubic-bezier(.3, 0, .4, 1); }
.ag-skill--clamshell figure span::after { content: ''; position: absolute; left: 50%; top: 52%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .95) 0 12%, rgba(255, 255, 255, 0) 60%); opacity: 0; transition: opacity .3s, scale .4s; pointer-events: none; }
.ag-skill--clamshell figure span { position: relative; }
.ag-skill--clamshell figure span:hover::after, .ag-skill--clamshell.is-play figure span::after { opacity: 1; scale: 1.6; }
@keyframes ag-breathe { 0%, 100% { scale: 1 1; } 50% { scale: 1.03 .95; } }
@keyframes ag-hop { 0%, 100% { translate: 0 0; scale: 1 1; } 25% { scale: 1.08 .9; } 55% { translate: 0 -30px; scale: .95 1.06; } 80% { translate: 0 0; scale: 1.05 .94; } }
/* the octopus: pulses up like a jet, squishes under the pointer */
.ag-skill--octopus figure img { animation: ag-jet 2.8s ease-in-out infinite; transform-origin: 50% 40%; }
.ag-skill--octopus figure span:hover, .ag-skill--octopus.is-play figure span { animation: ag-hop .7s cubic-bezier(.3, 0, .4, 1); }
@keyframes ag-jet { 0%, 100% { translate: 0 0; scale: 1 1; } 30% { translate: 0 4px; scale: 1.06 .94; } 60% { translate: 0 -10px; scale: .95 1.06; } }
/* the school of fish (it looks right): comes from the left, rocks gently, wriggles under the pointer */
.ag-skill--fish-4 { --in: ag-in-right; }
.ag-skill--fish-4 figure img { animation: ag-bob 3s ease-in-out infinite alternate; }
.ag-skill--fish-4 figure span:hover, .ag-skill--fish-4.is-play figure span { animation: ag-wriggle .6s ease-in-out; }
@keyframes ag-wriggle { 25% { rotate: -6deg; } 50% { rotate: 5deg; } 75% { rotate: -3deg; } }
/* the crab: comes walking sideways, as crabs do, and steps from side to side */
.ag-skill--crab { --in: ag-in-side; }
.ag-skill--crab figure img { animation: ag-step 4s ease-in-out infinite; transform-origin: 50% 100%; }
.ag-skill--crab figure span:hover, .ag-skill--crab.is-play figure span { animation: ag-hop .7s cubic-bezier(.3, 0, .4, 1); }
@keyframes ag-step { 0%, 100% { translate: 0 0; rotate: 0deg; } 20% { translate: -14px 0; rotate: -3deg; } 40% { translate: -14px 0; rotate: 0deg; } 60% { translate: 12px 0; rotate: 3deg; } 80% { translate: 12px 0; rotate: 0deg; } }
/* the fish (it looks left): comes from the right */
.ag-skill--fish-3 { --in: ag-in-left; }
.ag-skill--fish-3 figure img { animation: ag-bob 3.3s ease-in-out infinite alternate; }
.ag-skill--fish-3 figure span:hover, .ag-skill--fish-3.is-play figure span { animation: ag-wriggle .6s ease-in-out; }

/* bubbles blown at a touch */
.ag-pop { position: absolute; z-index: 3; left: 0; top: 0; width: var(--s, 12px); height: var(--s, 12px); border: 2px solid rgba(255, 255, 255, .8); border-radius: 50%; background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, .8) 0 14%, transparent 16%); pointer-events: none; }

/* the lists read like the paragraphs (their lines were squeezed together, only an item in a <p> had air) */
.ag .tab-content li { line-height: 1.55; }
.ag .tab-content li + li { margin-top: 6px; }

@media only screen and (max-width: 768px) {
	/* the last lines kept clear of the seaweed on the bottom */
	.ocean.ag { padding-bottom: 150px; }
	/* the empty sand above the sea was 210px high, with the yellow fish cut in half by the left edge: now the fish
	   (it looks right) bobs whole at the water's edge and the sea starts right under it */
	.above-ocean { height: 86px; }
	.above-ocean + .ocean { margin-top: 24px; }
	.above-ocean .fish-1 { left: 7%; top: 6px; margin-left: 0; transform: scale(.5); transform-origin: 0 0; animation: ag-bob 3s ease-in-out infinite alternate; }
	.ag-swim--school { width: 140px; height: 76px; }
	.ag-rays i:nth-child(2n) { display: none; }
	.ag-weeds { height: 130px; }
	.ag-weeds i { height: calc(var(--h, 140px) * .65); }
}
@media (prefers-reduced-motion: reduce) {
	.ag-swim, .ag-bubbles { display: none; }
	.ag-rays i, .ag-weeds i, .ag-skill figure img { animation: none !important; }
}
