/*
 * Copyright (C) 2026 Fluxer Contributors
 *
 * This file is part of Fluxer.
 *
 * Fluxer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Fluxer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
 */

.folderContainer {
	--folder-accent: var(--brand-primary);
	--folder-fill: 20%;
	--folder-item-size: var(--guild-folder-expanded-surface-size, var(--guild-list-item-box-size, 48px));
	--folder-item-box-size: var(--guild-folder-expanded-surface-size, var(--guild-list-item-box-size, 48px));
	--folder-item-gap: var(--guild-list-item-gap, 4px);
	--folder-item-inset: calc((var(--folder-item-box-size) - var(--folder-item-size)) / 2);
	--folder-expanded-surface-size: var(--guild-folder-expanded-surface-size, var(--folder-item-box-size));
	--folder-surface: color-mix(
		in srgb,
		var(--background-secondary) calc(100% - var(--folder-fill)),
		var(--folder-accent) var(--folder-fill)
	);
	--guild-badge-surface: var(--folder-surface);
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	align-items: center;
}

:global(.theme-light) .folderContainer {
	--folder-fill: 15%;
}

.folderIndicator {
	position: absolute;
	left: -0.15rem;
	display: flex;
	align-items: center;
	justify-content: center;
	height: var(--folder-item-size);
	width: 0.5rem;
	pointer-events: none;
	container-type: layout size;
	z-index: 2;
}

.folderIndicatorBar {
	display: block;
	width: 0.35rem;
	border-radius: 0 var(--radius-full) var(--radius-full) 0;
	background-color: var(--text-primary);
}

.relative {
	position: relative;
	height: var(--folder-item-size);
	width: var(--folder-item-size);
	border-radius: 30%;
}

.collapsedFolder {
	position: relative;
	z-index: 1;
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	grid-template-rows: repeat(2, 1fr);
	gap: 2px;
	height: var(--folder-item-size);
	width: var(--folder-item-size);
	box-sizing: border-box;
	flex-shrink: 0;
	cursor: pointer;
	border-radius: 30%;
	padding: 4px;
	transition:
		border-radius 70ms ease-out,
		background-color 70ms ease-out;
}

.collapsedFolderBackground {
	position: absolute;
	inset: 0;
	height: var(--folder-item-size);
	width: var(--folder-item-size);
	border-radius: 30%;
	background-color: var(--folder-surface);
	pointer-events: none;
	z-index: 0;
}

.miniGuildIcon {
	width: 100%;
	height: 100%;
	border-radius: 30%;
	background-size: cover;
	background-position: center;
	background-color: transparent;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.miniGuildIconWithInitials {
	background-color: var(--background-secondary);
}

.miniGuildInitials {
	font-size: 0.5rem;
	font-weight: 600;
	color: var(--text-primary);
	line-height: 1;
	text-align: center;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.folderBadge {
	position: absolute;
	right: -0.25rem;
	bottom: -0.25rem;
	z-index: 2;
	pointer-events: auto;
	border-radius: var(--radius-md);
}

.folderBadgeActive {
	box-shadow: 0 0 0 3px var(--guild-badge-surface, var(--background-secondary));
}

.expandedFolderBackground {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	width: var(--folder-expanded-surface-size);
	border-radius: calc(var(--folder-item-box-size) * 0.3);
	background-color: var(--folder-surface);
	pointer-events: none;
	z-index: 0;
}

.folderHeader {
	position: relative;
	z-index: 1;
	display: flex;
	height: var(--folder-item-box-size);
	width: 100%;
	box-sizing: border-box;
	align-items: center;
	justify-content: center;
	padding: var(--folder-item-inset);
}

.folderHeaderButton {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	height: var(--folder-item-size);
	width: var(--folder-item-size);
	box-sizing: border-box;
	flex-shrink: 0;
	cursor: pointer;
	border-radius: 30%;
	padding: 4px;
	transition:
		border-radius 70ms ease-out,
		background-color 70ms ease-out;
}

.folderIcon {
	width: 1.5rem;
	height: 1.5rem;
	color: var(--text-primary);
}

.expandedGuilds {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	gap: var(--folder-item-gap);
	padding-top: var(--folder-item-gap);
	padding-bottom: var(--folder-item-gap);
}

.folderTooltipContainer {
	display: flex;
	min-width: 0;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.375rem;
	padding: 0.125rem 0;
}

.folderTooltipName {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 1rem;
	font-weight: 600;
	color: var(--text-primary);
}

.dropIndicatorTop::before {
	content: '';
	position: absolute;
	top: 0;
	left: 50%;
	width: var(--folder-expanded-surface-size);
	transform: translateX(-50%);
	height: 2px;
	background: var(--brand-primary-light);
	border-radius: 1px;
	z-index: 1;
}

.dropIndicatorBottom::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 50%;
	width: var(--folder-expanded-surface-size);
	transform: translateX(-50%);
	height: 2px;
	background: var(--brand-primary-light);
	border-radius: 1px;
	z-index: 1;
}

.dropIndicatorInside .collapsedFolder,
.dropIndicatorInside .folderHeaderButton {
	outline: 2px solid var(--brand-primary-light);
	outline-offset: 2px;
	border-radius: 30%;
}

:global(.theme-light) .dropIndicatorTop::before,
:global(.theme-light) .dropIndicatorBottom::after {
	background: var(--brand-primary);
}

:global(.theme-light) .dropIndicatorInside .collapsedFolder,
:global(.theme-light) .dropIndicatorInside .folderHeaderButton {
	outline-color: var(--brand-primary);
}
