/**
 * Documentation block styles.
 *
 * Deliberately restrained: color, type and spacing come from the theme
 * through the block supports and theme.json, so a docs site keeps looking
 * like itself. What is here is structure the theme cannot supply — list
 * resets, the tree indent, the breadcrumb separator, and the focus and
 * current-page affordances that must not be left to chance.
 */

/* Layout ----------------------------------------------------------------- */

/*
 * The single-document template's outer group already gives the page its side
 * gutter, and the breadcrumbs above the row start at that edge. A theme that
 * pads every Columns block (the Background Candy theme adds `.container`, a
 * class rule) moved the sidebar 24px in from the breadcrumbs. Two classes
 * here, so the reset wins over a one-class theme rule.
 */
.wp-block-columns.ppdocs-layout {
	padding-left: 0;
	padding-right: 0;
}

/* Navigation ------------------------------------------------------------- */

/*
 * Narrow-screen toggle (assets/js/nav.js). `hidden` must win over any theme
 * rule that sets display on buttons or divs, or a closed panel would show.
 */
.ppdocs-nav__toggle[hidden],
.ppdocs-nav__panel[hidden] {
	display: none;
}

.ppdocs-nav__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75em;
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 0.5rem 0.75rem;
	border: 1px solid currentColor;
	border-radius: 0.25rem;
	background: transparent;
	color: inherit;
	font: inherit;
	font-weight: 600;
	text-align: start;
	cursor: pointer;
}

/* A chevron drawn with borders: it takes the text color, and in forced-colors
   mode the system color, with no icon font or image. Down when closed, up
   when open. It is decoration: the state is aria-expanded. */
.ppdocs-nav__toggle::after {
	content: "";
	flex: none;
	width: 0.5em;
	height: 0.5em;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: translateY(-25%) rotate(45deg);
}

.ppdocs-nav__toggle[aria-expanded="true"]::after {
	transform: translateY(25%) rotate(-135deg);
}

.ppdocs-nav__toggle + .ppdocs-nav__panel {
	margin-top: 0.75rem;
}

.ppdocs-nav__title {
	font-size: 1rem;
	margin: 0 0 0.5em;
}

.ppdocs-nav__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* Nested levels indent; the top level does not, so the tree starts flush. */
.ppdocs-nav__list:not(.ppdocs-nav__list--level-0) {
	margin-left: 1em;
	padding-left: 0.75em;
	border-left: 1px solid currentColor;
	/* The rule is a structural hint, not content — keep it quiet against text. */
	border-left-color: color-mix(in srgb, currentColor 20%, transparent);
}

.ppdocs-nav__link {
	display: block;
	padding: 0.25em 0;
	text-decoration: none;
}

.ppdocs-nav__link:hover,
.ppdocs-nav__link:focus-visible {
	text-decoration: underline;
}

/*
 * The current page is marked by weight AND a marker, never by color alone —
 * color alone fails SC 1.4.1 and disappears in forced-colors mode.
 */
.ppdocs-nav__item.is-current > .ppdocs-nav__link {
	font-weight: 700;
}

.ppdocs-nav__item.is-current > .ppdocs-nav__link::before {
	content: "";
	display: inline-block;
	width: 0.25em;
	height: 1em;
	margin-right: 0.5em;
	vertical-align: -0.15em;
	background: currentColor;
}

/* Contents --------------------------------------------------------------- */

.ppdocs-toc__title {
	font-size: 1rem;
	margin: 0 0 0.5em;
}

.ppdocs-toc__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.ppdocs-toc__item--level-3 {
	padding-left: 1em;
}

.ppdocs-toc__link {
	display: block;
	padding: 0.2em 0;
}

/* Breadcrumbs ------------------------------------------------------------ */

.ppdocs-breadcrumbs__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25em 0.5em;
	list-style: none;
	margin: 0;
	padding: 0;
}

.ppdocs-breadcrumbs__item {
	display: flex;
	align-items: center;
	gap: 0.5em;
}

/*
 * The separator is generated content on the item rather than markup, so it
 * never lands in copied text. Generated content is still in the accessibility
 * tree — NVDA on Firefox read it as "slash" — so the second declaration gives
 * it empty alternative text. Browsers without that syntax keep the first one.
 */
.ppdocs-breadcrumbs__item + .ppdocs-breadcrumbs__item::before {
	content: "/";
	content: "/" / "";
	opacity: 0.5;
}

.ppdocs-breadcrumbs__current {
	font-weight: 600;
}

/* Search ----------------------------------------------------------------- */

.ppdocs-search__form {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5em;
}

.ppdocs-search__label {
	flex: 1 0 100%;
}

.ppdocs-search__input {
	flex: 1 1 12em;
	min-width: 0;
	min-height: 44px;
	padding: 0.5rem 0.75rem;
	border: 1px solid currentColor;
	font: inherit;
	color: inherit;
	background: transparent;
}

/*
 * The button's look comes from the theme through .wp-element-button. These are
 * only a floor for themes with no button styles, so they sit in :where() and
 * any theme rule wins over them.
 */
:where(.ppdocs-search__submit) {
	min-height: 44px;
	padding: 0.5rem 1rem;
	font: inherit;
	cursor: pointer;
}

/*
 * WordPress ships .screen-reader-text, but a docs site may run a theme that
 * does not. Defining it here means a hidden label is never a visible one.
 */
.ppdocs-search .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Products --------------------------------------------------------------- */

.ppdocs-products__list {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
	gap: 1.5rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

/*
 * The card edge is a grouping hint, not a control boundary: the links inside
 * are the controls. Keep it quiet against text, the same as the tree rule.
 */
.ppdocs-products__item {
	padding: 1.25rem;
	border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
	border-radius: 0.5rem;
}

/* A card heading sits in a narrow column; the theme's page-level heading
   size would wrap a short product name onto several lines. */
.ppdocs-products__name {
	margin: 0 0 0.5em;
	font-size: var(--wp--preset--font-size--large, 1.5rem);
}

.ppdocs-products__description {
	margin: 0 0 0.75em;
}

.ppdocs-products__sections {
	list-style: none;
	margin: 0;
	padding: 0;
}

.ppdocs-products__section-link {
	display: block;
	padding: 0.25em 0;
}

/* Pager ------------------------------------------------------------------ */

.ppdocs-pager {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 1rem;
}

.ppdocs-pager__link {
	display: flex;
	flex-direction: column;
	max-width: 100%;
}

/* With no previous document, next still sits at the end of the row. */
.ppdocs-pager__link--next {
	margin-inline-start: auto;
	text-align: end;
}

.ppdocs-pager__label {
	font-size: 0.875em;
}

/* Shared ----------------------------------------------------------------- */

/*
 * Never remove the focus ring — only replace it with one that is at least as
 * visible. This keeps a consistent indicator when a theme has reset outlines.
 */
.ppdocs-nav__toggle:focus-visible,
.ppdocs-nav__link:focus-visible,
.ppdocs-toc__link:focus-visible,
.ppdocs-breadcrumbs__link:focus-visible,
.ppdocs-search__input:focus-visible,
.ppdocs-products__link:focus-visible,
.ppdocs-products__section-link:focus-visible,
.ppdocs-pager__link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/*
 * The submit button takes its colors from the theme, so its text can be light
 * on a dark fill. A ring outside the button would then be light on the page
 * background. Drawn inside, the ring is the text color on the button's own
 * fill, which a theme already has to make readable.
 */
.ppdocs-search__submit:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -4px;
}

@media (forced-colors: active) {
	.ppdocs-nav__item.is-current > .ppdocs-nav__link::before {
		background: CanvasText;
	}

	.ppdocs-nav__list:not(.ppdocs-nav__list--level-0),
	.ppdocs-products__item {
		border-color: CanvasText;
	}
}
