/* =====================================================================
   Academy CC tag, Edge Dots "Pop" (many subtitle languages)
   Loads after academy-cc-edge-every.css and only touches course cards
   with FIVE OR MORE subtitle languages (the number is the admin's: see
   "From" below). On hover the category pill wobbles like a soap bubble
   (a rainbow film runs round its rim), swells and pops into a spray of
   the language colours; once it has cleared, the CC mark and every code
   glide to the middle of the row, each dot blown up into its bubble on
   the way, and the bubbles float gently while the card is hovered.
   Leaving, the codes fold back to dots, the set slides home and the
   pill is blown back up with a spring.

   Why (Marc, 2026-11-28/29): a Technical course is about to have five
   languages ("CC EN ES +3" today). He picked direction A of three
   ("Install A"), asked that the codes "go center after TECHNICAL clears
   the room", and that Pop start at five: with four, Every language's
   own fix stays (the CC mark steps aside and all four show).

   How. While the card is hovered the tag is laid over the whole
   category row (position: absolute; inset: 0), so the Every language
   rule sees the whole row (207px on the four-across grid) and opens
   every code with the mark beside them (26n + 22: five 152px), and the
   tag slides left by half the room that leaves. The category keeps its
   place in the layout: it is only unseen (and not clickable) while
   hovered, so nothing on the card moves. At rest the tag is in the
   row's flow exactly as today, so the dots, a long category's closed-up
   dots and the pill are today's own (audit 2026-11-29: the first build
   kept the tag laid over the row at rest, which put the dots on top of
   a long category name). Hover screens only; touch screens keep today's
   row. A keyboard user (focus ring anywhere on the card) keeps today's
   row entirely, category link included (same audit: Tab used to skip
   the hidden link). Reduced motion: the category just goes and the set
   is simply in the middle.

   Leaving, the tag drops back into the row at once; the browser is only
   asked to keep it right-anchored and above the pill until the codes
   have folded ("transition-behavior: allow-discrete"). Browsers without
   that (before Chrome 117, Safari 17.4, Firefox 129) skip this whole
   sheet and keep today's hover.

   Smoothness (same day, Marc: "a little cheap and fast"). The pill is
   hidden and brought back with transitions, never by an animation's
   held values, so leaving at any moment fades it back instead of
   cutting to it; the droplets fly out one by one and shrink away; the
   fold and the slide home take their time. It starts the moment the
   card is hovered, like every other hover on the card (2026-12-01,
   Marc: a first .06s wait "makes it too different from all the other
   hovers"; removed, the rest of the clock moved .06s earlier).

   From. Every rule here is scoped to rows whose language list has a
   sixth child (five codes and the "+N" chip): ":nth-child(6)". That one
   number is the threshold. This file is the "from 5" sheet; for "from 4"
   or "from 6" Assets::enqueue_cc_edge_pop_layer() prints the same sheet
   inline with the number rewritten to 5 or 7. Change nothing else there.

   Switch: Academy LMS → Design → Edge Dots → "Many languages" → "Pop"
   (the default) / "Plain" (loads nothing), and "Pop from" → 4 / 5 (the
   default) / 6 languages. Options academy_cc_edge_pop and
   academy_cc_edge_pop_from; admin preview ?cc_pop=pop|plain and
   ?cc_pop_from=4|5|6; filters academy/cc_edge_pop and
   academy/cc_edge_pop_from. Loaded only while Edge Dots (v2b) is live
   and its hover rule is Every language. A missing file is a silent
   no-op. Ledger: M2-PATCHES.md "Pop".
   ===================================================================== */
@supports (transition-behavior: allow-discrete) {
	@media (hover: hover) {
		.academy-course .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) {
			position: relative;
		}
		/* Hovered: the tag is laid over the whole row. */
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-cc-edge {
			position: absolute;
			inset: 0;
			z-index: 2;
			align-items: center;
			justify-content: flex-end;
			transition: none;
		}
		/* Leaving: it drops back into the row's flow at once, so the dots
		   close up exactly as today's row has them. Only its right-hand
		   anchoring is kept for a moment (today's row lets a set that is
		   too wide spill to the right; the codes are still folding and
		   must fold in place), and it stays above the pill until they
		   have. */
		.academy-course .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-cc-edge {
			transition: justify-content 0s linear .46s, z-index 0s linear .46s;
			transition-behavior: allow-discrete;
		}
		/* Where even the closed-up dots do not fit (a very long category),
		   today's row lets them ride into the card's padding. The same
		   place, said as a margin, so the set can slide to and from it.
		   It is 0 on every other row. */
		.academy-course:not(:hover):not(:focus-within):not(.academy-course--tooltip-open) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) .academy-cc-tag {
			margin-right: min(0px, calc(100cqw - 28px - 3px * var(--cc-n)));
		}
		/* A keyboard user gets today's row at once, category link and all. */
		.academy-course:has(:focus-visible) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-cc-edge,
		.academy-course:has(:focus-visible) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) .academy-cc-tag {
			transition: none;
		}
		/* Hovered: the category is not seen, and not clickable once it has gone. */
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-course__meta--category {
			opacity: 0;
			visibility: hidden;
			transition: opacity .16s ease, visibility 0s linear .16s;
		}
		.academy-course:not(:hover):not(:focus-within):not(.academy-course--tooltip-open) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-course__meta--category {
			transition: opacity .24s ease .1s;
		}

		/* The glide to the middle. The set's final width is the mark (21) and
		   its gap (4), then 23 per code and 3 between them: 26n + 22. It
		   slides left by half the room that leaves, starting at
		   --academy-cc-pop-glide. Never to the right: with eight languages
		   the mark steps aside and the set already fills the row. Leaving, it
		   slides back home as the codes fold. */
		.academy-course .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) .academy-cc-tag {
			transition: translate .5s cubic-bezier(.45, 0, .2, 1), margin-right .3s cubic-bezier(.4, 0, .2, 1);
		}
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) .academy-cc-tag {
			translate: min(0px, calc((100cqw - (26px * var(--cc-n) + 22px)) / -2)) 0;
			transition: translate .7s cubic-bezier(.32, .24, .16, 1.06) var(--academy-cc-pop-glide, .18s), margin-right .3s cubic-bezier(.4, 0, .2, 1);
		}
	}
	/* Reduced motion: the set is simply in the middle (the codes and the mark
	   already open without motion there, academy-cc-tag.css's own rule). */
	@media (hover: hover) and (prefers-reduced-motion: reduce) {
		.academy-course .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-cc-edge,
		.academy-course .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) .academy-cc-tag,
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) .academy-cc-tag {
			transition: none;
		}
	}

	@media (hover: hover) and (prefers-reduced-motion: no-preference) {
		/* The clock. It starts at once, with the card's other hovers;
		   the pill wobbles and swells until --academy-cc-pop-t, when it
		   pops; the set starts for the middle just after. */
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) {
			--academy-cc-pop-t: .34s;
			--academy-cc-pop-glide: .38s;
		}
		/* -- the pill -------------------------------------------------------
		   At the pop its tint and its name are faded out in a blink and it
		   is then made unclickable (a look that locks the tint in another
		   way just loses it at that moment); it is never made transparent as
		   a whole, so the film and the spray (its own ::before and ::after)
		   can play on and always burst from the middle of whichever pill it
		   is. These are transitions, so leaving at any moment brings it
		   back from wherever it is. Only its size is animated (the wobble,
		   the swell, the burst), and then waits small for the way back. */
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-course__meta--category {
			overflow: visible;
			opacity: 1;
			visibility: hidden;
			background-color: transparent;
			--ao-accent-soft: transparent; /* the M2 look paints the pill from this token, !important */
			border-color: transparent;
			box-shadow: none;
			scale: .5;
			transition:
				background-color .07s linear var(--academy-cc-pop-t),
				border-color .07s linear var(--academy-cc-pop-t),
				box-shadow .07s linear var(--academy-cc-pop-t),
				visibility 0s linear calc(var(--academy-cc-pop-t) + .07s);
			animation: academy-cc-pop-pill .86s linear backwards;
		}
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-course__meta--category > a {
			opacity: 0;
			transition: opacity .07s linear var(--academy-cc-pop-t);
		}
		/* …and the way back: once the codes have begun to fold, the tint
		   and the name return and the pill is blown back up. */
		.academy-course:not(:hover):not(:focus-within):not(.academy-course--tooltip-open) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-course__meta--category {
			transition:
				background-color .3s ease .2s,
				border-color .3s ease .2s,
				box-shadow .3s ease .2s,
				scale .7s cubic-bezier(.34, 1.36, .64, 1) .2s;
		}
		.academy-course:not(:hover):not(:focus-within):not(.academy-course--tooltip-open) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-course__meta--category > a {
			transition: opacity .3s ease .2s;
		}
		/* the soap film: a rainbow ring that runs round the rim while it
		   wobbles, then opens out and thins away with the burst */
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-course__meta--category::before {
			content: '';
			position: absolute;
			inset: -2px;
			padding: 2px;
			border-radius: inherit;
			background: conic-gradient(from var(--academy-cc-pop-film, 0deg), #ff8fcf, #ffd36e, #9ff0b8, #8fc8ff, #c5a2ff, #ff8fcf);
			-webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
			mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
			visibility: visible;
			pointer-events: none;
			animation: academy-cc-pop-film .86s linear both;
		}
		/* the spray: ten droplets in the language colours, each flung its own
		   distance from the pill's middle (near and far by turns, so it never
		   reads as a ring), falling a little and shrinking away */
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) > .academy-course__meta--category::after {
			content: '';
			position: absolute;
			left: 50%;
			top: 50%;
			width: 4px;
			height: 4px;
			margin: -2px 0 0 -2px;
			border-radius: 50%;
			background: transparent;
			visibility: visible;
			pointer-events: none;
			animation: academy-cc-pop-spray .46s cubic-bezier(.2, .65, .3, 1) var(--academy-cc-pop-t) both;
		}

		/* -- the codes: each dot is blown up into its bubble just after the
		      pop, left to right, as the set glides, then they float. The tag's
		      own open delay (--cc-wait) is set to the same moment, so a dot
		      stays a dot until it inflates. */
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) .academy-cc-tag__lang:not(.academy-cc-tag__lang--more) {
			--cc-wait: calc(var(--academy-cc-pop-t) + .06s + var(--cc-i) * 70ms);
			animation:
				academy-cc-pop-inflate .72s linear var(--cc-wait),
				academy-cc-pop-bob 2.8s ease-in-out calc(var(--academy-cc-pop-t) + .95s + var(--cc-i) * 190ms) infinite;
		}
		/* the CC mark takes the shock of the pop */
		.academy-course:is(:hover, :focus-within, .academy-course--tooltip-open):not(:has(:focus-visible)) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) .academy-cc-tag__cc {
			animation: academy-cc-pop-nudge .5s cubic-bezier(.34, 1.36, .64, 1) calc(var(--academy-cc-pop-t) + .02s) both;
		}
		/* Leaving: the codes fold a little slower than the tag's own .22s,
		   the last one first. */
		.academy-course:not(:hover):not(:focus-within):not(.academy-course--tooltip-open) .academy-course__meta-row:has(> .academy-cc-edge .academy-cc-tag__langs > :nth-child(6)) .academy-cc-tag__lang:not(.academy-cc-tag__lang--more) {
			transition-duration: .3s, .3s, .3s, .3s, .3s, .3s, .1s;
			transition-delay: calc((var(--cc-n) - 1 - var(--cc-i)) * 18ms);
		}
	}
}

@property --academy-cc-pop-film { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

/* .86s, from the hover: the wobble to .26s, the swell to .34s (the pop, at
   --academy-cc-pop-t), the burst to .41s; then it only holds its size while
   the film and the spray play on. */
@keyframes academy-cc-pop-pill {
	0%     { scale: 1; animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
	8%     { scale: 1.07 .93; animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
	17.5%  { scale: .96 1.06; animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
	25.5%  { scale: 1.03 .985; animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
	30.5%  { scale: 1.005 1; animation-timing-function: cubic-bezier(.5, 0, .85, .6); }
	39.5%  { scale: 1.2; animation-timing-function: cubic-bezier(.2, .8, .3, 1); }
	47.5%  { scale: 1.36; }
	100%   { scale: 1.36; }
}
@keyframes academy-cc-pop-film {
	0%     { opacity: 0; --academy-cc-pop-film: 0deg; scale: 1; animation-timing-function: cubic-bezier(.5, 0, .8, .7); }
	7%     { opacity: 1; }
	39.5%  { opacity: 1; --academy-cc-pop-film: 320deg; scale: 1; animation-timing-function: cubic-bezier(.2, .7, .3, 1); }
	54%    { opacity: 0; --academy-cc-pop-film: 360deg; scale: 1.16 1.3; }
	100%   { opacity: 0; --academy-cc-pop-film: 360deg; scale: 1.16 1.3; }
}
@keyframes academy-cc-pop-spray {
	0% {
		opacity: 0;
		box-shadow:
			0 0 0 0 #4f86f0, 0 0 0 0 #f0704f, 0 0 0 0 #ee9a2e, 0 0 0 0 #ec5f93, 0 0 0 0 #9772ea,
			0 0 0 0 #4f86f0, 0 0 0 0 #f0704f, 0 0 0 0 #ee9a2e, 0 0 0 0 #ec5f93, 0 0 0 0 #9772ea;
	}
	8%  { opacity: 0; }
	20% { opacity: 1; }
	55% {
		opacity: 1;
		box-shadow:
			-34px -2px 0 .5px #4f86f0, -15px -9px 0 -.5px #f0704f, -10px -19px 0 .5px #ee9a2e, 3px -12px 0 -.5px #ec5f93, 19px -14px 0 .5px #9772ea,
			26px -1px 0 -.5px #4f86f0, 27px 11px 0 .5px #f0704f, 7px 11px 0 -.5px #ee9a2e, -11px 20px 0 .5px #ec5f93, -20px 6px 0 -.5px #9772ea;
		animation-timing-function: cubic-bezier(.4, 0, .8, .6);
	}
	100% {
		opacity: 1;
		box-shadow:
			-37px 2px 0 -2px #4f86f0, -16px -6px 0 -2px #f0704f, -11px -16px 0 -2px #ee9a2e, 3px -9px 0 -2px #ec5f93, 21px -11px 0 -2px #9772ea,
			28px 2px 0 -2px #4f86f0, 29px 15px 0 -2px #f0704f, 8px 14px 0 -2px #ee9a2e, -12px 24px 0 -2px #ec5f93, -21px 9px 0 -2px #9772ea;
	}
}
@keyframes academy-cc-pop-inflate {
	0%   { transform: none; animation-timing-function: cubic-bezier(.3, 0, .5, 1); }
	30%  { transform: translateY(-3px) scale(1.16, 1.1); animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
	50%  { transform: translateY(-.5px) scale(1.08, .9); animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
	68%  { transform: translateY(-1.2px) scale(.96, 1.05); animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
	84%  { transform: translateY(0) scale(1.02, .99); animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
	100% { transform: none; }
}
@keyframes academy-cc-pop-bob {
	0%, 100% { translate: 0 0; }
	50%      { translate: 0 -1.5px; }
}
@keyframes academy-cc-pop-nudge {
	0%   { translate: 0 0; }
	30%  { translate: -1.5px 0; }
	100% { translate: 0 0; }
}
