/**
 * Jump links bar.
 *
 * Figma: Pacific College Library, "Jumplinks Bar", node 6971:7899, which
 * carries all three shapes. On the page:
 *   1440px  node 3140:23750  (1360 x 72, inset 40 from each edge)
 *    768px  node 3140:23794  ( 728 x 52, inset 20)
 *    390px  node 3142:23899  ( 350 x 52, inset 20)
 *
 * Small-screen first: a pill that opens into a list, becoming a row of
 * links at 1024.
 *
 * THE BAR STRADDLES THE JOIN BETWEEN TWO SECTIONS. It is not a band of its
 * own - it sits half over the banner above and half over the section below,
 * and takes no height of its own in the flow. The negative margins are what
 * do that; the clearance underneath is further down this file.
 */

.pchs-jumplinks {
	position: relative;
	/* Over both neighbours. They are static, so this is enough; the
	   banner's `isolation: isolate` contains its own children and does
	   not stack against a sibling. */
	z-index: 2;
	display: block;
	/* Half above the join, half below, and nothing added to the page's
	   height - Figma 3142:23899 sits 26 either side of it. */
	margin-top: -26px;
	margin-bottom: -26px;
	padding-inline: calc(var(--wp--preset--spacing--20) + var(--pchs-page-gutter));
}

/*
 * THE SECTION UNDERNEATH MAKES ROOM.
 *
 * The Library's annotation on node 6971:7899: "Any page with jumplinks bar
 * module, the components touching it (above and below) will have the
 * following adjusted padding - Wide 120px, Middle 80px, Narrow 64px."
 * Measured against the frames, only the one BELOW needs it: the banner's
 * words already stop well short of its own foot.
 *
 * Two classes, so this beats a section's own single-class padding whichever
 * stylesheet the browser happens to apply last. Every section in the theme
 * is a full-width block and carries `alignfull`.
 */
.pchs-jumplinks + .alignfull {
	/*
	 * Published as a property as well as applied, because a section whose
	 * picture reaches its top edge cannot take this as padding - it would
	 * push the picture down too. "Image and text" in its full layout reads
	 * the property and puts the same space inside its words instead.
	 */
	--pchs-jumplinks-clearance: 64px; /* Figma: Narrow */
	padding-top: var(--pchs-jumplinks-clearance);
}

.pchs-jumplinks__toggle {
	display: flex;
	width: 100%;
	min-height: 52px; /* Figma 3142:23899 */
	align-items: center;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--20);
	/*
	 * 14 top and bottom, not the 16 the Library names. 16 either side of a
	 * 24px line box makes 56, and every frame draws this pill at 52 - so
	 * the padding is what gives, rather than the line-height, which would
	 * crowd a section name long enough to wrap onto two lines.
	 */
	padding: 14px var(--wp--preset--spacing--24);
	border: 0;
	border-radius: var(--wp--custom--radius--full);
	background-color: var(--wp--preset--color--white);
	box-shadow: var(--wp--preset--shadow--lg);
	color: var(--wp--preset--color--blue-500);
	cursor: pointer;
	font-family: var(--wp--preset--font-family--navigation);
	font-size: var(--wp--preset--font-size--lg); /* 20px */
	font-weight: 500;
	line-height: 1.2;
	text-align: left;
}

/*
 * The button ships hidden and view.js reveals it. Without the script there
 * is nothing to open the list with, so the list stays open instead - see
 * the rule below. A control that does nothing is worse than no control.
 */
.pchs-jumplinks__toggle[hidden] {
	display: none;
}

/* Open: the pill goes grey and the chevron turns over. Figma 6952:3782. */
.pchs-jumplinks__toggle[aria-expanded="true"] {
	background-color: var(--wp--preset--color--gray-500);
}

.pchs-jumplinks__toggle[aria-expanded="true"] .pchs-jumplinks__chevron {
	transform: rotate(180deg);
}

.pchs-jumplinks__toggle:focus-visible {
	outline: 2px solid var(--wp--preset--color--blue-300);
	outline-offset: 2px;
}

.pchs-jumplinks__chevron {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s ease;
}

/* The list, which on this size is the dropdown under the pill. */
.pchs-jumplinks__list {
	display: flex;
	flex-direction: column;
	/* 10px between the pill and the panel - Figma 6952:4084. */
	margin: var(--wp--preset--spacing--10) 0 0;
	padding: var(--wp--preset--spacing--16) var(--wp--preset--spacing--24);
	border-radius: var(--wp--custom--radius--lg); /* 24px */
	background-color: var(--wp--preset--color--white);
	box-shadow: var(--wp--preset--shadow--lg);
	list-style: none;
}

/*
 * Closed. `hidden` rather than display:none in a class, because the script
 * toggles the attribute and a screen reader must not reach a list that is
 * not on screen.
 */
.pchs-jumplinks__list[hidden] {
	display: none;
}

@media (prefers-reduced-motion: reduce) {

	.pchs-jumplinks__chevron {
		transition: none;
	}
}


/* ------------------------------------------------------------
   768px and up
   Figma node 3140:23794. The same pill, a little wider, and the
   section below makes more room.
   ------------------------------------------------------------ */

@media (min-width: 768px) {

	.pchs-jumplinks {
		padding-inline: calc(var(--wp--preset--spacing--20) + var(--pchs-page-gutter));
	}

	.pchs-jumplinks + .alignfull {
		--pchs-jumplinks-clearance: 80px; /* Figma: Middle */
	}
}


/* ------------------------------------------------------------
   1024px and up
   Figma node 3140:23750: every link on one line inside a single
   wide pill, and no button at all.
   ------------------------------------------------------------ */

@media (min-width: 1024px) {

	.pchs-jumplinks {
		margin-top: -33px; /* Figma 3140:23750, 710 against a join at 743 */
		margin-bottom: -39px;
		padding-inline: calc(var(--wp--preset--spacing--40) + var(--pchs-page-gutter));
	}

	.pchs-jumplinks + .alignfull {
		--pchs-jumplinks-clearance: 120px; /* Figma: Wide */
	}

	/* No pill here: the links are all on show, so there is nothing to
	   open. view.js leaves the button alone at this width. */
	.pchs-jumplinks__toggle {
		display: none;
	}

	/*
	 * 24 above and 20 below, which is what makes the bar 72 tall around a
	 * 28px link. Not the same top and bottom: the links have 4px of lead
	 * inside them, so the ink sits centred even though the box does not.
	 */
	.pchs-jumplinks__list {
		display: flex;
		flex-direction: row;
		align-items: flex-start;
		justify-content: space-between;
		margin: 0;
		padding: 24px var(--wp--preset--spacing--40) 20px;
		border-radius: var(--wp--custom--radius--full);
	}

	/* The list is never closed at this width, whatever the script did
	   before the screen was widened. */
	.pchs-jumplinks__list[hidden] {
		display: flex;
	}
}


/* Wider than the design: handled by --pchs-page-gutter in the padding
   above, which needs no breakpoint. */


/* ------------------------------------------------------------
   IN THE EDITOR
   The bar is drawn in its wide shape at any width, and without
   its negative margins.

   Both for the same reason: an editor is working on the links,
   and a closed pill hides them while a bar pulled up over its
   neighbour is hard to click. Neither affects a visitor - the
   class is only added by editor.js.
   ------------------------------------------------------------ */

.pchs-jumplinks--editing {
	margin-top: 0;
	margin-bottom: 0;
}

.pchs-jumplinks--editing .pchs-jumplinks__toggle {
	display: none;
}

.pchs-jumplinks--editing .pchs-jumplinks__list {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	margin: 0;
	padding: 24px var(--wp--preset--spacing--40) 20px;
	border-radius: var(--wp--custom--radius--full);
}

.pchs-jumplinks--editing .pchs-jump-link + .pchs-jump-link {
	border-top: 0;
}
