/* The customer facing page and the panel shell that the shortcode also uses. */

/*
 * The whole page sits on one card of its own, title and all. A shop theme paints its
 * pages in any colour it likes, and on that card the fields and the rows always show.
 */
.mls3-browse {
	box-sizing: border-box;
	width: 100%;
	max-width: 900px;
	margin-inline: auto;
	margin-block: clamp(1.5rem, 4vw, 3rem);
	padding: clamp(1.25rem, 3vw, 2rem);
	color: var(--mls3-fg);
	font-family: var(--mls3-font);
	background: var(--mls3-bg);
	border: 1px solid var(--mls3-border);
	border-radius: var(--mls3-radius);
	box-shadow: var(--mls3-shadow-1);
}

.mls3-browse *,
.mls3-browse *::before,
.mls3-browse *::after {
	box-sizing: border-box;
}

.mls3-browse__head {
	margin-block-end: var(--mls3-space-4);
}

.mls3-browse__title {
	margin: 0;
	padding: 0;
	color: var(--mls3-fg);
	font-family: inherit;
	font-size: clamp(1.4rem, 3vw, 1.75rem);
	font-weight: 650;
	letter-spacing: -.02em;
	line-height: 1.25;
}

.mls3-browse__note {
	margin: 6px 0 0;
	color: var(--mls3-muted);
	font-size: var(--mls3-size-sm);
	line-height: 1.6;
}

/*
 * Panel
 *
 * The search field and the sort field sit on the page itself, and the list under them is
 * the card, the way a file manager looks. The panel is only the column that holds both.
 */

.mls3-panel {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	min-height: 220px;
}

/* With the list hidden, the card is the whole panel, so it needs no room around it. */
.mls3-panel--locked {
	min-height: 0;
}

.mls3-panel--locked .mls3-notice {
	margin-block-end: 0;
}

/* The card above the list, for a visitor who may not download the files yet. */

.mls3-notice {
	position: relative;
	display: flex;
	flex: 0 0 auto;
	flex-direction: column;
	gap: var(--mls3-space-4);
	align-items: center;
	margin-block-end: var(--mls3-space-4);
	padding: clamp(1.5rem, 4vw, 2.25rem) var(--mls3-space-4);
	overflow: hidden;
	text-align: center;
	background: linear-gradient(165deg, var(--mls3-selected), var(--mls3-bg) 70%);
	border: 1px solid var(--mls3-accent-soft);
	border-radius: var(--mls3-radius);
}

/* A soft light behind the lock, so the card does not read as a flat box. */
.mls3-notice::before {
	position: absolute;
	inset-block-start: -180px;
	inset-inline-start: 50%;
	width: 360px;
	height: 360px;
	content: "";
	background: radial-gradient(circle, var(--mls3-accent-soft), transparent 65%);
	transform: translateX(-50%);
	opacity: .8;
	pointer-events: none;
}

.mls3-notice__icon,
.mls3-notice__text,
.mls3-notice__action {
	position: relative;
}

.mls3-notice__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 54px;
	height: 54px;
	color: var(--mls3-accent-fg);
	background: linear-gradient(180deg, var(--mls3-accent), var(--mls3-accent-strong));
	border-radius: 18px;
	box-shadow: 0 0 0 6px var(--mls3-accent-soft), 0 14px 26px -14px var(--mls3-accent);
}

.mls3-notice__icon svg {
	width: 24px;
	height: 24px;
}

.mls3-notice__text {
	margin: 0;
	max-width: 80ch;
	color: var(--mls3-fg);
	font-size: calc(var(--mls3-size) + 1px);
	line-height: 1.75;
}

.mls3-notice__text a {
	color: var(--mls3-accent);
	font-weight: 600;
}

.mls3-notice__action {
	display: inline-flex;
	text-decoration: none !important;
	gap: var(--mls3-space-2);
	align-items: center;
	padding: 13px 28px;
	color: var(--mls3-accent-fg);
	font-size: var(--mls3-size);
	font-weight: 650;
	line-height: 1.2;
	text-decoration: none;
	background: linear-gradient(180deg, var(--mls3-accent), var(--mls3-accent-strong));
	border-radius: 999px;
	box-shadow: 0 14px 26px -14px var(--mls3-accent), inset 0 1px 0 rgba(255, 255, 255, .28);
	transition: transform var(--mls3-dur) var(--mls3-ease), box-shadow var(--mls3-dur) var(--mls3-ease), filter var(--mls3-dur) var(--mls3-ease);
}

.mls3-notice__action:hover,
.mls3-notice__action:focus {
	color: var(--mls3-accent-fg);
	text-decoration: none;
	box-shadow: 0 18px 30px -14px var(--mls3-accent), inset 0 1px 0 rgba(255, 255, 255, .28);
	transform: translateY(-2px);
	filter: brightness(1.06);
}

.mls3-notice__action:active {
	transform: translateY(0);
	filter: brightness(.98);
}

.mls3-notice__action:focus-visible {
	outline: 2px solid var(--mls3-accent);
	outline-offset: 3px;
}

.mls3-panel__tree {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-height: 0;
}

.mls3-panel .mls3-tree {
	background: none;
}

.mls3-panel__noscript {
	margin: 0;
	padding: var(--mls3-space-4);
	color: var(--mls3-muted);
	font-family: var(--mls3-font);
	font-size: var(--mls3-size-sm);
}

/*
 * A shop theme paints every button and every field on its pages, and it often does that
 * with a stronger rule than a single class. Every control of the panel is written with
 * both class names, so the panel takes that paint off first and then gives the control
 * its own look in the rules below.
 */
.mls3-panel .mls3-tree .mls3-tree__twisty,
.mls3-panel .mls3-tree .mls3-tree__action,
.mls3-panel .mls3-tree .mls3-tree__search-input,
.mls3-panel .mls3-tree .mls3-tree__search-clear,
.mls3-panel .mls3-tree .mls3-tree__sort-select,
.mls3-panel .mls3-tree .mls3-tree__more,
.mls3-panel .mls3-tree .mls3-tree__retry {
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	color: inherit;
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	background: none;
	border: 0 solid transparent;
	border-radius: 0;
	box-shadow: none;
	appearance: none;
	-webkit-appearance: none;
}

/* The same for the list itself, which a theme likes to give bullets, margins and indents. */
.mls3-panel .mls3-tree ul,
.mls3-panel .mls3-tree li,
.mls3-panel .mls3-tree p {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* The rows that are not files: an empty folder, an error, and the load more button. */
.mls3-panel .mls3-tree .mls3-tree__state {
	padding: var(--mls3-space-4);
}

.mls3-panel .mls3-tree .mls3-tree__state.is-inline {
	padding: var(--mls3-space-2) var(--mls3-space-3);
}

.mls3-panel .mls3-tree .mls3-tree__more-row {
	padding: var(--mls3-space-2);
}

/* Search and sort */

.mls3-panel .mls3-tree__bar {
	position: static;
	gap: var(--mls3-space-3);
	padding: 0 0 var(--mls3-space-4);
	background: none;
	border-block-end: 0;
}

.mls3-panel .mls3-tree__search-icon {
	display: none;
}

.mls3-panel .mls3-tree .mls3-tree__search-input,
.mls3-panel .mls3-tree .mls3-tree__sort-select {
	height: 42px;
	font-size: var(--mls3-size);
	line-height: 42px;
	background: var(--mls3-field);
	border-radius: var(--mls3-radius);
	cursor: pointer;
}

.mls3-panel .mls3-tree .mls3-tree__search-input {
	padding: 0 var(--mls3-space-3);
	cursor: text;
}

.mls3-panel .mls3-tree .mls3-tree__search-input::placeholder {
	color: var(--mls3-muted);
	opacity: 1;
}

.mls3-panel .mls3-tree .mls3-tree__search-input:focus {
	outline: 2px solid var(--mls3-accent);
	outline-offset: -2px;
	box-shadow: none;
}

/*
 * The clear button stands inside the search field, on its trailing edge. A shop theme
 * often gives every button a place of its own, so the button is put back in its own
 * corner here with both class names.
 */
.mls3-panel .mls3-tree .mls3-tree__search-clear {
	position: absolute;
	inset-inline-end: 8px;
	inset-block-start: 50%;
	padding: 4px 8px;
	color: var(--mls3-muted);
	font-size: var(--mls3-size-sm);
	border-radius: var(--mls3-radius-sm);
	transform: translateY(-50%);
	cursor: pointer;
}

.mls3-panel .mls3-tree .mls3-tree__search-clear[hidden] {
	display: none;
}

.mls3-panel .mls3-tree .mls3-tree__search-clear:hover {
	color: var(--mls3-fg);
	background: var(--mls3-row-hover);
}

.mls3-panel .mls3-tree__sort {
	position: relative;
}

.mls3-panel .mls3-tree .mls3-tree__sort-select {
	max-width: none;
	padding: 0 40px 0 var(--mls3-space-3);
}

.mls3-panel .mls3-tree .mls3-tree__sort-select:focus-visible {
	outline: 2px solid var(--mls3-accent);
	outline-offset: -2px;
}

/* The two buttons the list itself can show. */
.mls3-panel .mls3-tree .mls3-tree__more,
.mls3-panel .mls3-tree .mls3-tree__retry {
	padding: 6px var(--mls3-space-3);
	font-size: var(--mls3-size-sm);
	background: var(--mls3-bg);
	border: 1px solid var(--mls3-border);
	border-radius: var(--mls3-radius-sm);
	cursor: pointer;
}

.mls3-panel .mls3-tree .mls3-tree__more:hover,
.mls3-panel .mls3-tree .mls3-tree__retry:hover {
	background: var(--mls3-row-hover);
}

/* The arrow of the sort field, painted in the text colour so both skins fit it. */
.mls3-panel .mls3-tree__sort::after {
	position: absolute;
	inset-inline-end: 14px;
	top: 50%;
	width: 14px;
	height: 14px;
	color: var(--mls3-muted);
	content: "";
	background: currentColor;
	transform: translateY(-50%);
	pointer-events: none;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 11.2 2.8 6l1.2-1.2L8 8.8l4-4L13.2 6 8 11.2Z'/%3E%3C/svg%3E") no-repeat center / contain;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 11.2 2.8 6l1.2-1.2L8 8.8l4-4L13.2 6 8 11.2Z'/%3E%3C/svg%3E") no-repeat center / contain;
}

[dir="rtl"] .mls3-panel .mls3-tree__sort-select,
[dir="rtl"].mls3-panel .mls3-tree__sort-select {
	padding: 0 var(--mls3-space-3) 0 40px;
}

/* List */

/*
 * The card: the rows, and under them the line that counts the whole panel. The height
 * of the rows is capped here and not on the panel, so a locked message above them never
 * takes room away from the list.
 */
.mls3-panel .mls3-tree__body {
	max-height: 62vh;
	overflow: hidden;
	background: var(--mls3-bg);
	border: 1px solid var(--mls3-border);
	border-radius: var(--mls3-radius);
}

.mls3-panel .mls3-tree__list {
	padding: 0;
}

.mls3-panel .mls3-tree .mls3-tree__summary {
	padding: 10px var(--mls3-space-4);
	background: var(--mls3-surface);
	border-block-start: 1px solid var(--mls3-border);
}

.mls3-panel .mls3-tree__children {
	margin-inline-start: 0;
	padding-inline-start: 0;
	border-inline-start: 0;
}

/*
 * Two lines: the name on top, its size and its date under it. Every row indents itself
 * by its own depth, so the line between two rows runs the whole width of the card.
 */
.mls3-panel .mls3-tree__row {
	grid-template-columns: 18px 34px minmax(0, 1fr) auto auto;
	grid-template-areas:
		"twisty icon name badge action"
		"twisty icon meta badge action";
	column-gap: var(--mls3-space-2);
	row-gap: 1px;
	margin-inline: 0;
	padding: var(--mls3-space-2) var(--mls3-space-3);
	padding-inline-start: calc(var(--mls3-space-3) + (var(--mls3-row-level, 1) - 1) * 18px);
	border-block-start: 1px solid var(--mls3-border);
	border-inline-start: 3px solid transparent;
	border-radius: 0;
}

.mls3-panel .mls3-tree__list > .mls3-tree__item:first-child > .mls3-tree__row {
	border-block-start-color: transparent;
}

.mls3-panel .mls3-tree__row:hover,
.mls3-panel .mls3-tree__row:focus-visible,
.mls3-panel .mls3-tree__item.is-folder[aria-expanded="true"] > .mls3-tree__row {
	background: var(--mls3-selected);
	border-inline-start-color: var(--mls3-accent);
}

.mls3-panel .mls3-tree__item.is-locked > .mls3-tree__row {
	cursor: default;
}

/* Only a folder can open, so only a folder row shows the arrow. */
.mls3-panel .mls3-tree .mls3-tree__twisty {
	grid-area: twisty;
	width: 18px;
	height: 18px;
	color: var(--mls3-muted);
	cursor: pointer;
}

.mls3-panel .mls3-tree .mls3-tree__twisty:hover,
.mls3-panel .mls3-tree .mls3-tree__twisty:focus {
	background: none;
}

.mls3-panel .mls3-tree__twisty::before {
	width: 7px;
	height: 7px;
	border-width: 2px;
}

/* A soft square in the colour of the file kind carries the icon. */
.mls3-panel .mls3-tree__icon {
	grid-area: icon;
	width: 34px;
	height: 34px;
	background: hsl(var(--mls3-ft-h) var(--mls3-tile-s) var(--mls3-tile-l));
	border-radius: var(--mls3-radius-sm);
}

.mls3-panel .mls3-tree__icon svg {
	width: 18px;
	height: 18px;
}

.mls3-panel .mls3-tree__icon.is-generic {
	background: var(--mls3-surface);
}

/* A folder is amber here, like the folder of a desktop file manager. */
.mls3-panel .mls3-tree__item.is-folder > .mls3-tree__row > .mls3-tree__icon {
	--mls3-ft-h: 38;

	color: hsl(var(--mls3-ft-h) var(--mls3-ft-s) var(--mls3-ft-l));
}

.mls3-panel .mls3-tree__name {
	grid-area: name;
	font-weight: 500;
}

.mls3-panel .mls3-tree__badge {
	grid-area: badge;
	align-self: center;
}

.mls3-panel .mls3-tree__meta {
	display: block;
	grid-area: meta;
	font-family: var(--mls3-mono);
}

.mls3-panel .mls3-tree__actions {
	grid-area: action;
}

/*
 * A customer should never have to hunt for the download, so the button stays on screen.
 * Hovering the row is what promotes it from quiet to solid.
 */
.mls3-panel .mls3-tree .mls3-tree__action {
	justify-content: center;
	width: 34px;
	height: 34px;
	color: var(--mls3-muted);
	background: var(--mls3-bg);
	border: 1px solid var(--mls3-border);
	border-radius: var(--mls3-radius-sm);
	opacity: 1;
	cursor: pointer;
}

.mls3-panel .mls3-tree__action svg {
	width: 16px;
	height: 16px;
}

.mls3-panel .mls3-tree .mls3-tree__row:hover .mls3-tree__action,
.mls3-panel .mls3-tree .mls3-tree__action:focus-visible {
	color: var(--mls3-accent-fg);
	background: var(--mls3-accent);
	border-color: var(--mls3-accent);
}

/* A locked file keeps the same button, quiet and dead, so the row keeps its shape. */
.mls3-panel .mls3-tree .mls3-tree__action.is-locked,
.mls3-panel .mls3-tree .mls3-tree__row:hover .mls3-tree__action.is-locked {
	color: var(--mls3-muted);
	background: var(--mls3-surface);
	border-color: var(--mls3-border);
	cursor: not-allowed;
}

/*
 * Expired and forbidden. The whole page is one of these cards, so it stands taller and
 * carries a heading. Everything else it wears comes from the card above.
 */

.mls3-notice--page {
	gap: var(--mls3-space-3);
	margin-block-end: 0;
	padding: clamp(2rem, 6vw, 3.25rem) var(--mls3-space-4);
}

.mls3-notice--page .mls3-notice__icon {
	width: 64px;
	height: 64px;
	margin-block-end: var(--mls3-space-2);
	border-radius: 22px;
}

.mls3-notice--page .mls3-notice__icon svg {
	width: 30px;
	height: 30px;
}

.mls3-notice__title {
	position: relative;
	margin: 0;
	padding: 0;
	color: var(--mls3-fg);
	font-family: inherit;
	font-size: clamp(1.25rem, 3vw, 1.5rem);
	font-weight: 650;
	letter-spacing: -.01em;
	line-height: 1.3;
}

/* The quiet way out, under the button the shop wrote. */
.mls3-notice__link {
	position: relative;
	color: var(--mls3-muted);
	font-size: var(--mls3-size-sm);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.mls3-notice__link:hover,
.mls3-notice__link:focus {
	color: var(--mls3-accent);
}

@media ( prefers-reduced-motion: reduce ) {
	.mls3-browse *,
	.mls3-panel * {
		transition: none !important;
	}
}

/* On a phone the two lines stay, only everything around them gets tighter. */
@media ( max-width: 600px ) {
	.mls3-panel .mls3-tree__row {
		grid-template-columns: 16px 32px minmax(0, 1fr) auto auto;
		padding-inline: var(--mls3-space-2);
		padding-inline-start: calc(var(--mls3-space-2) + (var(--mls3-row-level, 1) - 1) * 14px);
	}

	.mls3-panel .mls3-tree__icon,
	.mls3-panel .mls3-tree__action {
		width: 32px;
		height: 32px;
	}

	.mls3-panel .mls3-tree__bar {
		gap: var(--mls3-space-2);
	}

	/* On a small screen the locked message stays small, so the rows keep the screen. */
	.mls3-notice {
		gap: var(--mls3-space-3);
		padding: var(--mls3-space-4) var(--mls3-space-3);
	}

	.mls3-notice__icon {
		width: 44px;
		height: 44px;
		border-radius: 14px;
	}

	.mls3-notice__icon svg {
		width: 20px;
		height: 20px;
	}

	.mls3-notice__text {
		font-size: var(--mls3-size);
		line-height: 1.65;
	}

	.mls3-notice__action {
		padding: 11px 22px;
	}
}
