/* Rabin Craft — Orbit Dock. Needs core.css.
   orbit-dock.js measures the stage and sets its geometry on the root in px (unitless numbers): --cx/--cy
   (circle centre), --r (radius), --dr (disc radius), --node and --badge (sizes), --cap-l/--cap-w/--cap-h
   (capsule box), --ax/--hx (anchor and hub centres) and --tl/--tt/--tw (caption box, relative to the
   root). It moves the nodes and badges with inline transforms, marks the docked item .is-active in the
   list, sets --dock-c to its colour, and adds .is-pulse on each arrival (ripples and the capsule beam).
   Without the script the stage hides and the items show as a grid. */

/* Registered so the dock's colour fades from one item's colour to the next */
@property --dock-c {
	syntax: "<color>";
	inherits: true;
	initial-value: #3c44ff;
}

.mkit-dock {
	--dock-node-bg: color-mix(in srgb, var(--mkit-accent) 10%, var(--mkit-chip-bg));
	--dock-c: var(--mkit-accent);
	--dock-beam: rgba(255, 255, 255, .55);
	position: relative;
	width: 100%;
	overflow-x: clip;
	color: var(--mkit-muted);
	transition: --dock-c .6s var(--mkit-ease);
}

.mkit--light .mkit-dock,
.mkit-dock.mkit--light {
	--dock-node-bg: #fff;
	--dock-beam: color-mix(in srgb, var(--dock-c) 45%, transparent);
}

.mkit-dock__stage {
	position: relative;
	width: 100%;
	max-width: var(--mkit-dock-max, 640px);
	margin-inline: auto;
	aspect-ratio: var(--mkit-dock-aspect, 1 / .95);
	touch-action: pan-y; /* sideways swipes turn the wheel, vertical ones scroll the page */
	cursor: grab;
	user-select: none;
	-webkit-user-select: none;
}

.mkit-dock--full .mkit-dock__stage {
	aspect-ratio: var(--mkit-dock-aspect, 1 / 1);
}

.mkit-dock.is-dragging :is(.mkit-dock__stage, .mkit-dock__node) {
	cursor: grabbing;
}

/* A tinted disc, faded towards the hub side by a mask (a gradient to transparent shows a hard edge in
   some browsers). The full ring is brightest along the ring. */
.mkit-dock__disc {
	position: absolute;
	left: calc((var(--cx, 200) - var(--dr, 200)) * 1px);
	top: calc((var(--cy, 200) - var(--dr, 200)) * 1px);
	width: calc(var(--dr, 200) * 2px);
	height: calc(var(--dr, 200) * 2px);
	border-radius: 50%;
	background: color-mix(in srgb, var(--mkit-accent) 18%, transparent);
	-webkit-mask-image: linear-gradient(90deg, transparent 32%, rgba(0, 0, 0, .5) 70%, #000);
	mask-image: linear-gradient(90deg, transparent 32%, rgba(0, 0, 0, .5) 70%, #000);
	pointer-events: none;
}

.mkit-dock--left .mkit-dock__disc {
	-webkit-mask-image: linear-gradient(270deg, transparent 32%, rgba(0, 0, 0, .5) 70%, #000);
	mask-image: linear-gradient(270deg, transparent 32%, rgba(0, 0, 0, .5) 70%, #000);
}

.mkit-dock--full .mkit-dock__disc {
	background: color-mix(in srgb, var(--mkit-accent) 15%, transparent);
	-webkit-mask-image: radial-gradient(closest-side, rgba(0, 0, 0, .2) 40%, rgba(0, 0, 0, .65) 76%, #000 86%, transparent);
	mask-image: radial-gradient(closest-side, rgba(0, 0, 0, .2) 40%, rgba(0, 0, 0, .65) 76%, #000 86%, transparent);
}

.mkit-dock__wheel {
	position: absolute;
	inset: 0;
	-webkit-mask-image: linear-gradient(transparent 2%, rgba(0, 0, 0, .35) 14%, #000 28%, #000 72%, rgba(0, 0, 0, .35) 86%, transparent 98%);
	mask-image: linear-gradient(transparent 2%, rgba(0, 0, 0, .35) 14%, #000 28%, #000 72%, rgba(0, 0, 0, .35) 86%, transparent 98%);
}

.mkit-dock--full .mkit-dock__wheel {
	-webkit-mask-image: none;
	mask-image: none;
}

/* The dashed track the nodes travel on (only its live side on a half wheel) */
.mkit-dock__track {
	position: absolute;
	left: calc((var(--cx, 200) - var(--r, 200)) * 1px);
	top: calc((var(--cy, 200) - var(--r, 200)) * 1px);
	box-sizing: border-box;
	width: calc(var(--r, 200) * 2px);
	height: calc(var(--r, 200) * 2px);
	border-radius: 50%;
	border: 1px dashed color-mix(in srgb, var(--mkit-text) 18%, transparent);
	-webkit-mask-image: linear-gradient(90deg, transparent 45%, #000 85%);
	mask-image: linear-gradient(90deg, transparent 45%, #000 85%);
}

.mkit-dock--left .mkit-dock__track {
	-webkit-mask-image: linear-gradient(270deg, transparent 45%, #000 85%);
	mask-image: linear-gradient(270deg, transparent 45%, #000 85%);
}

.mkit-dock--full .mkit-dock__track {
	-webkit-mask-image: none;
	mask-image: none;
}

.mkit-dock__node,
.mkit-dock__badge,
.mkit-dock__hub {
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: var(--dock-node-bg);
	color: var(--c, var(--mkit-accent-soft));
	box-shadow: 0 8px 22px -6px var(--mkit-shadow), 0 0 0 1px color-mix(in srgb, var(--mkit-text) 8%, transparent);
}

.mkit-dock__node {
	position: absolute;
	left: 0;
	top: 0;
	width: calc(var(--node, 60) * 1px);
	height: calc(var(--node, 60) * 1px);
	margin: calc(var(--node, 60) * -.5px) 0 0 calc(var(--node, 60) * -.5px);
	padding: 0;
	border: 0;
	opacity: 0;
	cursor: pointer;
	will-change: transform, opacity;
	transition: box-shadow .25s var(--mkit-ease);
}

.mkit-dock__node:hover {
	box-shadow: 0 10px 26px -6px color-mix(in srgb, var(--mkit-accent) 60%, transparent), 0 0 0 1px color-mix(in srgb, var(--mkit-accent-soft) 50%, transparent);
}

:is(.mkit-dock__node, .mkit-dock__badge, .mkit-dock__hub) :is(svg, img, i) {
	width: 48%;
	height: 48%;
	font-size: calc(var(--node, 60) * .45px);
	object-fit: contain;
}

/* Item images read as app icons; the hub image (a logo, perhaps wide) is shown whole */
:is(.mkit-dock__node, .mkit-dock__badge) img {
	width: 58%;
	height: 58%;
	border-radius: 24%;
	object-fit: cover;
}

.mkit-dock__hub img {
	width: 62%;
	height: 62%;
}

:is(.mkit-dock__node, .mkit-dock__badge, .mkit-dock__hub) b {
	font-size: .9rem;
	font-weight: 700;
	color: var(--mkit-text);
}

/* Name tags: inside each node, pushed into the ring along the unit vector orbit-dock.js sets (--ux/--uy),
   anchored by the side facing the node, so they never cover the icon. .is-quiet hides one. */
.mkit-dock__tag {
	--lr: calc(var(--node, 60) * .5 + 8);
	position: absolute;
	left: 50%;
	top: 50%;
	padding: .3em .7em;
	border: 1px solid color-mix(in srgb, var(--mkit-text) 12%, transparent);
	border-radius: 999px;
	background: color-mix(in srgb, var(--mkit-chip-bg) 82%, transparent);
	color: var(--mkit-text);
	font-family: var(--mkit-font-mono);
	font-size: max(11px, calc(var(--node, 60) * .2px));
	font-weight: 500;
	letter-spacing: .04em;
	line-height: 1.2;
	white-space: nowrap;
	pointer-events: none;
	translate: calc(var(--ux, 0) * var(--lr) * 1px + (var(--ux, 0) - 1) * 50%) calc(var(--uy, 0) * var(--lr) * 1px + (var(--uy, 0) - 1) * 50%);
	transition: opacity .35s var(--mkit-ease);
}

.mkit-dock__node.is-quiet .mkit-dock__tag {
	opacity: 0;
}

/* Full ring: a dotted inner orbit with a light travelling round it */
.mkit-dock__inner {
	position: absolute;
	left: calc((var(--cx, 200) - var(--r, 200) * .62) * 1px);
	top: calc((var(--cy, 200) - var(--r, 200) * .62) * 1px);
	width: calc(var(--r, 200) * 1.24px);
	height: calc(var(--r, 200) * 1.24px);
	border-radius: 50%;
	border: 1px dotted color-mix(in srgb, var(--mkit-accent-soft) 32%, transparent);
	pointer-events: none;
	animation: mkit-dock-orbit 24s linear infinite;
}

.mkit-dock__inner::before,
.mkit-dock__inner::after {
	content: "";
	position: absolute;
	top: -4px;
	left: 50%;
	width: 8px;
	height: 8px;
	margin-left: -4px;
	border-radius: 50%;
	background: var(--dock-c);
	box-shadow: 0 0 12px 3px color-mix(in srgb, var(--dock-c) 55%, transparent);
}

.mkit-dock__inner::after {
	top: auto;
	bottom: -3px;
	width: 5px;
	height: 5px;
	margin-left: -2.5px;
	opacity: .6;
}

@keyframes mkit-dock-orbit {
	to { rotate: 360deg; }
}

/* ---- the capsule */
.mkit-dock__capsule {
	position: absolute;
	left: calc(var(--cap-l, 40) * 1px);
	top: calc((var(--cy, 200) - var(--cap-h, 120) / 2) * 1px);
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: calc(var(--cap-w, 300) * 1px);
	height: calc(var(--cap-h, 120) * 1px);
	padding: 0 calc((var(--cap-h, 120) - var(--badge, 90)) / 2 * 1px);
	overflow: hidden;
	border-radius: 999px;
	border: 1.25px solid transparent;
	background:
		linear-gradient(90deg, color-mix(in srgb, var(--mkit-chip-bg) 88%, transparent), color-mix(in srgb, var(--mkit-chip-bg) 70%, transparent)) padding-box,
		linear-gradient(90deg, color-mix(in srgb, var(--mkit-accent-soft) 30%, transparent), color-mix(in srgb, var(--mkit-accent-soft) 85%, transparent) 55%, var(--dock-c) 100%) border-box;
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	box-shadow: 0 16px 40px -12px var(--mkit-shadow);
}

.mkit--light .mkit-dock__capsule {
	background:
		linear-gradient(90deg, rgba(248, 251, 255, .9), rgba(255, 255, 255, .74)) padding-box,
		linear-gradient(90deg, color-mix(in srgb, var(--mkit-accent) 25%, #fff), color-mix(in srgb, var(--mkit-accent) 70%, #fff) 55%, var(--dock-c) 100%) border-box;
}

.mkit-dock--left .mkit-dock__capsule {
	flex-direction: row-reverse;
}

/* Facing left the badge is at the capsule's left end, so its bright border end is too */
.mkit-dock--left .mkit-dock__capsule {
	background:
		linear-gradient(270deg, color-mix(in srgb, var(--mkit-chip-bg) 88%, transparent), color-mix(in srgb, var(--mkit-chip-bg) 70%, transparent)) padding-box,
		linear-gradient(270deg, color-mix(in srgb, var(--mkit-accent-soft) 30%, transparent), color-mix(in srgb, var(--mkit-accent-soft) 85%, transparent) 55%, var(--dock-c) 100%) border-box;
}

.mkit--light .mkit-dock--left .mkit-dock__capsule,
.mkit-dock--left.mkit--light .mkit-dock__capsule {
	background:
		linear-gradient(270deg, rgba(248, 251, 255, .9), rgba(255, 255, 255, .74)) padding-box,
		linear-gradient(270deg, color-mix(in srgb, var(--mkit-accent) 25%, #fff), color-mix(in srgb, var(--mkit-accent) 70%, #fff) 55%, var(--dock-c) 100%) border-box;
}

/* A glow behind the docked badge, in its colour */
.mkit-dock__glow {
	position: absolute;
	right: 0;
	top: 50%;
	width: calc(var(--badge, 90) * 1.8px);
	aspect-ratio: 1;
	translate: 18% -50%;
	border-radius: 50%;
	background: radial-gradient(circle, color-mix(in srgb, var(--dock-c) 30%, transparent), transparent 70%);
	pointer-events: none;
}

.mkit-dock--left .mkit-dock__glow {
	right: auto;
	left: 0;
	translate: -18% -50%;
}

/* On each arrival a beam of light runs down the capsule from the badge to the hub */
.mkit-dock__beam {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 38%;
	background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--dock-c) 30%, transparent) 38%, var(--dock-beam) 50%, color-mix(in srgb, var(--dock-c) 30%, transparent) 62%, transparent);
	opacity: 0;
	pointer-events: none;
}

.mkit-dock.is-pulse .mkit-dock__beam {
	animation: mkit-dock-beam .7s cubic-bezier(.45, 0, .25, 1);
}

.mkit-dock--left.is-pulse .mkit-dock__beam {
	animation-name: mkit-dock-beam-ltr;
}

@keyframes mkit-dock-beam {
	from { opacity: 1; translate: 230% 0; }
	80% { opacity: 1; }
	to { opacity: 0; translate: -60% 0; }
}

@keyframes mkit-dock-beam-ltr {
	from { opacity: 1; translate: -100% 0; }
	80% { opacity: 1; }
	to { opacity: 0; translate: 190% 0; }
}

/* …and rings ripple out from the anchor, then from the hub as the beam reaches it */
.mkit-dock__ring {
	position: absolute;
	left: calc((var(--ax, 300) - var(--badge, 90) / 2) * 1px);
	top: calc((var(--cy, 200) - var(--badge, 90) / 2) * 1px);
	z-index: 4;
	width: calc(var(--badge, 90) * 1px);
	height: calc(var(--badge, 90) * 1px);
	border-radius: 50%;
	border: 1.5px solid var(--dock-c);
	opacity: 0;
	pointer-events: none;
}

.mkit-dock__ring--hub {
	left: calc((var(--hx, 100) - var(--badge, 90) / 2) * 1px);
}

.mkit-dock.is-pulse .mkit-dock__ring {
	animation: mkit-dock-ring 1s cubic-bezier(.2, .7, .3, 1);
}

.mkit-dock.is-pulse .mkit-dock__ring--hub {
	animation-delay: .45s;
}

@keyframes mkit-dock-ring {
	from { opacity: .9; scale: .95; }
	to { opacity: 0; scale: 1.7; }
}

.mkit-dock__hub,
.mkit-dock__slot {
	position: relative;
	z-index: 1;
	flex: none;
	width: calc(var(--badge, 90) * 1px);
}

.mkit-dock__badge {
	box-shadow: 0 10px 26px -8px color-mix(in srgb, var(--c, var(--mkit-accent)) 50%, transparent), 0 0 0 1px color-mix(in srgb, var(--mkit-text) 8%, transparent);
}

.mkit-dock__hub {
	height: calc(var(--badge, 90) * 1px);
	color: var(--mkit-accent-soft);
	box-shadow: 0 10px 28px -8px var(--mkit-shadow), 0 0 0 1px color-mix(in srgb, var(--mkit-accent-soft) 30%, transparent);
}

.mkit-dock__slot {
	height: 100%;
}

.mkit-dock__badge {
	position: absolute;
	left: 0;
	top: 50%;
	width: calc(var(--badge, 90) * 1px);
	height: calc(var(--badge, 90) * 1px);
	margin-top: calc(var(--badge, 90) * -.5px);
	opacity: 0;
	will-change: transform;
}

/* The docked item's name and a counter in the capsule's middle (when orbit-dock.js finds room: .has-mid) */
.mkit-dock__mid {
	position: relative;
	z-index: 1;
	display: none;
	flex: 1;
	flex-direction: column;
	align-items: center;
	gap: .25em;
	min-width: 0;
	padding-inline: .75em;
	text-align: center;
}

.mkit-dock.has-mid .mkit-dock__mid {
	display: flex;
}

.mkit-dock__count {
	font-family: var(--mkit-font-mono);
	font-size: max(10px, calc(var(--badge, 90) * .12px));
	letter-spacing: .14em;
	color: var(--mkit-muted);
}

.mkit-dock__count b {
	font-weight: 500;
	color: var(--dock-c);
}

.mkit-dock__mid-names {
	display: grid;
	width: 100%;
}

.mkit-dock__mid-name {
	grid-area: 1 / 1;
	overflow: hidden;
	color: var(--mkit-text);
	font-size: max(13px, calc(var(--badge, 90) * .2px));
	font-weight: 600;
	letter-spacing: -.01em;
	white-space: nowrap;
	text-overflow: ellipsis;
	opacity: 0;
	translate: 0 .5em;
	transition: opacity .2s ease-in, translate .2s ease-in;
}

.mkit-dock__mid-name.is-active {
	opacity: 1;
	translate: 0 0;
	transition: opacity .4s var(--mkit-ease) .2s, translate .4s var(--mkit-ease) .2s;
}

/* ---- caption: the docked item's name and text under the capsule */
.mkit-dock__list {
	display: grid;
	margin: 0;
	padding: 0;
	list-style: none;
}

.mkit-dock__item {
	display: flex;
	flex-direction: column;
	gap: .3rem;
	margin: 0;
}

.mkit-dock__name {
	color: var(--mkit-text);
	font-size: 1.2rem;
	font-weight: 600;
}

.mkit-dock__text {
	max-width: 32ch;
	font-size: .9rem;
	line-height: 1.5;
}

.mkit-dock__link {
	display: inline-flex;
	align-items: center;
	gap: .35em;
	margin-top: .2rem;
	color: var(--mkit-accent-soft);
	font-size: .875rem;
	font-weight: 600;
	text-decoration: none;
}

/* Beside the capsule's hub end (orbit-dock.js sets the box), or centred under the stage (.is-below) */
.mkit-dock[data-mkit-ready]:not(.is-below) .mkit-dock__list {
	position: absolute;
	left: calc(var(--tl, 40) * 1px);
	top: calc(var(--tt, 300) * 1px);
	width: calc(var(--tw, 300) * 1px);
	translate: 0 -50%;
}

.mkit-dock--right[data-mkit-ready]:not(.is-below) .mkit-dock__list {
	text-align: right;
}

.mkit-dock--right[data-mkit-ready]:not(.is-below) .mkit-dock__item {
	align-items: flex-end;
}

/* Full ring: inside the ring, centred under the hub */
.mkit-dock--full[data-mkit-ready]:not(.is-below) .mkit-dock__list {
	translate: none;
	text-align: center;
}

.mkit-dock--full[data-mkit-ready]:not(.is-below) .mkit-dock__item {
	align-self: start;
	align-items: center;
}

.mkit-dock.is-below .mkit-dock__list {
	max-width: 34ch;
	margin: .5rem auto 0;
	text-align: center;
}

.mkit-dock.is-below .mkit-dock__item {
	align-items: center;
}

/* Only the docked item shows, but all stay in the accessibility tree; tabbing to a link docks its item */
.mkit-dock[data-mkit-ready] .mkit-dock__item {
	grid-area: 1 / 1;
	align-self: center;
	opacity: 0;
	translate: 0 8px;
	pointer-events: none;
	transition: opacity .18s ease-in, translate .18s ease-in;
}

/* The outgoing item is gone before the next one fades in, so the two never overlap */
.mkit-dock[data-mkit-ready] .mkit-dock__item.is-active {
	opacity: 1;
	translate: 0 0;
	pointer-events: auto;
	transition: opacity .4s var(--mkit-ease) .18s, translate .4s var(--mkit-ease) .18s;
}

.mkit-dock[data-mkit-ready]:not([data-caption]) .mkit-dock__list {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
}

/* Without the script: no wheel, the items as a simple grid */
.mkit-dock:not([data-mkit-ready]) .mkit-dock__stage {
	display: none;
}

.mkit-dock:not([data-mkit-ready]) .mkit-dock__list {
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 1.25rem;
}

@media (prefers-reduced-motion: reduce) {
	.mkit-dock__inner {
		animation: none;
	}
}
