/*
 * Stacks Docs — the Document List on a page.
 *
 * One look for featured documents and the folders below them: bordered
 * panels of rows — a file tile, the name with a line under it, and an
 * outlined Download button. Colours and corners come from Stacks › Docs ›
 * Page style (printed as the variables below on each list), so every list on
 * a site matches without per-page styling. The font is always the theme's.
 */

.stacks-docs {
	--stacks-docs-ink: #1b323c;
	--stacks-docs-tile: #6b99ac;
	--stacks-docs-accent: #ce5c2a;
	--stacks-docs-panel: #fff;
	--stacks-docs-radius: 6px;
	--stacks-docs-line: color-mix(in srgb, var(--stacks-docs-ink) 14%, transparent);
	--stacks-docs-muted: color-mix(in srgb, var(--stacks-docs-ink) 78%, transparent);
	display: grid;
	gap: 20px;
	color: var(--stacks-docs-ink);
}

.stacks-docs *,
.stacks-docs *::before,
.stacks-docs *::after {
	box-sizing: border-box;
}

.stacks-docs .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
	white-space: nowrap;
}

.stacks-docs [hidden] {
	display: none !important;
}

.stacks-docs--empty {
	margin: 0;
	padding: 16px;
	color: var(--stacks-docs-muted, #555);
	border: 1px dashed currentColor;
	border-radius: 8px;
}

.stacks-docs--empty p {
	margin: 0;
}

/* ---------- Panels and rows ---------- */

.stacks-docs__panel,
.stacks-docs__group {
	margin: 0;
	padding: 0;
	overflow: hidden;
	list-style: none;
	background: var(--stacks-docs-panel);
	border: 2px solid var(--stacks-docs-ink);
	border-radius: var(--stacks-docs-radius);
}

.stacks-docs__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.stacks-docs__row {
	display: flex;
	align-items: center;
	gap: 16px;
	margin: 0;
	padding: 16px 18px;
}

.stacks-docs__row + .stacks-docs__row {
	border-top: 1px solid var(--stacks-docs-line);
}

.stacks-docs__file {
	display: inline-flex;
	flex: 0 0 auto;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1px;
	width: 38px;
	height: 38px;
	color: #fff;
	background: var(--stacks-docs-tile);
	border-radius: calc(var(--stacks-docs-radius) * .8);
}

.stacks-docs__file svg {
	display: block;
	width: 16px;
	height: 16px;
}

.stacks-docs__ext {
	font-size: 7px;
	font-weight: 700;
	letter-spacing: .04em;
	line-height: 1;
}

.stacks-docs__body {
	display: grid;
	flex: 1 1 auto;
	gap: 3px;
	min-width: 0;
}

.stacks-docs__title {
	color: var(--stacks-docs-ink);
	font-size: 1.05em;
	font-weight: 700;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

.stacks-docs__desc {
	color: var(--stacks-docs-muted);
	font-size: .85em;
	line-height: 1.4;
}

.stacks-docs__button {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-width: 112px;
	min-height: 40px;
	padding: 8px 16px;
	color: var(--stacks-docs-ink);
	background: transparent;
	border: 2px solid var(--stacks-docs-ink);
	border-radius: calc(var(--stacks-docs-radius) * .8);
	font-size: .95em;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.stacks-docs__button svg {
	flex: 0 0 auto;
	color: var(--stacks-docs-accent);
	transition: color .15s ease;
}

.stacks-docs__button:hover,
.stacks-docs__button:focus-visible {
	color: #fff;
	background: var(--stacks-docs-accent);
	border-color: var(--stacks-docs-accent);
}

.stacks-docs__button:hover svg,
.stacks-docs__button:focus-visible svg {
	color: #fff;
}

.stacks-docs__button:focus-visible {
	outline: 2px solid var(--stacks-docs-ink);
	outline-offset: 2px;
}

/* ---------- Folders (accordions) ---------- */

.stacks-docs__groups {
	display: grid;
	gap: 12px;
}

.stacks-docs__summary {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	cursor: pointer;
	list-style: none;
}

.stacks-docs__summary::-webkit-details-marker {
	display: none;
}

.stacks-docs__summary::after {
	content: "";
	flex: none;
	width: 9px;
	height: 9px;
	margin-left: 4px;
	color: var(--stacks-docs-accent);
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translateY(-3px);
	transition: transform .15s ease;
}

.stacks-docs__group[open] > .stacks-docs__summary {
	border-bottom: 1px solid var(--stacks-docs-line);
}

.stacks-docs__group[open] > .stacks-docs__summary::after {
	transform: rotate(-135deg) translateY(-2px);
}

.stacks-docs__summary:focus-visible {
	outline: 2px solid var(--stacks-docs-ink);
	outline-offset: -4px;
}

.stacks-docs__group-name {
	flex: 1;
	font-size: 1.1em;
	font-weight: 700;
}

.stacks-docs__count {
	color: var(--stacks-docs-muted);
	font-size: .85em;
	white-space: nowrap;
}

.stacks-docs__year {
	margin: 0;
	padding: 12px 18px 4px;
	color: var(--stacks-docs-accent);
	font-size: .78em;
	font-weight: 700;
	letter-spacing: .12em;
	text-transform: uppercase;
}

.stacks-docs__year + .stacks-docs__list .stacks-docs__row:first-child {
	padding-top: 10px;
}

/* ---------- Search ---------- */

/*
 * Built like a folder row: full width, the same 2px border, corners and
 * height, so it reads as the top of the list rather than a stray form field.
 * The input selectors are deliberately specific — themes (Pro/X included)
 * style input[type="search"] and would otherwise win with a thin grey box.
 */

.stacks-docs__search {
	display: grid;
	gap: 8px;
	margin-bottom: -8px; /* sits closer to the folders it searches */
}

.stacks-docs .stacks-docs__search-label {
	color: var(--stacks-docs-accent);
	font-size: .8em;
	font-weight: 700;
	letter-spacing: .2em;
	line-height: 1.2;
	text-transform: uppercase;
}

.stacks-docs__search-field {
	position: relative;
	display: flex;
	align-items: center;
}

.stacks-docs__search-icon {
	position: absolute;
	left: 18px;
	color: var(--stacks-docs-accent);
	pointer-events: none;
}

.stacks-docs .stacks-docs__search-field input.stacks-docs__search-input[type="search"] {
	width: 100%;
	height: auto;
	min-height: 58px;
	margin: 0;
	padding: 14px 52px 14px 50px;
	color: var(--stacks-docs-ink);
	background: var(--stacks-docs-panel);
	border: 2px solid var(--stacks-docs-ink);
	border-radius: var(--stacks-docs-radius);
	box-shadow: none;
	font-family: inherit;
	font-size: 1.05em;
	font-weight: 600;
	line-height: 1.3;
	-webkit-appearance: none;
	appearance: none;
}

.stacks-docs .stacks-docs__search-field input.stacks-docs__search-input[type="search"]::placeholder {
	color: var(--stacks-docs-muted);
	font-weight: 400;
	opacity: 1;
}

.stacks-docs .stacks-docs__search-field input.stacks-docs__search-input[type="search"]:focus {
	outline: 2px solid var(--stacks-docs-accent);
	outline-offset: 2px;
	border-color: var(--stacks-docs-ink);
	box-shadow: none;
}

/* Our own clear button replaces the browser's small grey one. */
.stacks-docs__search-input::-webkit-search-cancel-button,
.stacks-docs__search-input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
}

.stacks-docs .stacks-docs__search-clear {
	position: absolute;
	right: 10px;
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	color: var(--stacks-docs-ink);
	background: transparent;
	border: 0;
	border-radius: 50%;
	box-shadow: none;
	cursor: pointer;
}

.stacks-docs .stacks-docs__search-clear:hover,
.stacks-docs .stacks-docs__search-clear:focus-visible {
	color: #fff;
	background: var(--stacks-docs-accent);
}

.stacks-docs .stacks-docs__search-clear:focus-visible {
	outline: 2px solid var(--stacks-docs-ink);
	outline-offset: 2px;
}

.stacks-docs__search-status {
	min-height: 1.4em;
	margin: 0;
	color: var(--stacks-docs-muted);
	font-size: .9em;
	font-weight: 600;
}

.stacks-docs__search-status:empty {
	min-height: 0;
}

/* ---------- Narrow spaces ---------- */

.stacks-docs {
	container: stacks-docs / inline-size;
}

@container stacks-docs (max-width: 520px) {
	.stacks-docs__row {
		flex-wrap: wrap;
		gap: 12px 14px;
	}

	.stacks-docs__body {
		flex-basis: calc(100% - 56px);
	}

	.stacks-docs__button {
		margin-left: 52px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.stacks-docs__summary::after,
	.stacks-docs__button,
	.stacks-docs__button svg {
		transition: none;
	}
}
