/* ================================================================
 *  creations.css — Gallery / Creations panel styles
 *
 *  Covers:
 *   • .ii-creations-panel    — full-area overlay inside .ii-main
 *   • .ii-creations-grid     — responsive image grid
 *   • .ii-creation-card      — individual image card with hover overlay
 *   • .ii-creations-group    — workspace group container (All tab)
 *   • Skeleton, empty, error states
 * ================================================================ */

/* ──────────────────────────────────────────────────────────────────
 *  Creations Panel  —  absolute overlay inside .ii-main
 * ────────────────────────────────────────────────────────────────── */
.ii-creations-panel {
	position: absolute;
	top: var(--header-sidebar-height, 3rem);
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 51;
	display: flex;
	flex-direction: column;
	background: var(--ii-bg-primary, #f3f4f6);

	/* Hidden state — visibility:hidden ensures NO child captures any event */
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(8px);
	transition:
		opacity 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
		transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
		visibility 0s linear 0.28s;
	/* delay matches animation so it hides AFTER fade-out */
	backface-visibility: hidden;
}

.ii-creations-panel.is-visible {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0);
	transition:
		opacity 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
		transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
		visibility 0s linear 0s;
	/* no delay on show — appears immediately */
}

/* ──────────────────────────────────────────────────────────────────
 *  Standalone page title header
 * ────────────────────────────────────────────────────────────────── */
.ii-panel-page-header {
	padding: 20px 24px 0;
}

/* ──────────────────────────────────────────────────────────────────
 *  Pane Container + Individual Panes
 * ────────────────────────────────────────────────────────────────── */
.ii-creations-body {
	flex: 1;
	position: relative;
	overflow: hidden;
	min-height: 0;
}

.ii-creations-pane {
	position: absolute;
	inset: 0;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 24px 24px 40px;

	/* Hidden state */
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.18s ease;
}

@supports (-moz-appearance: none) {
	.ii-creations-pane {
		scrollbar-width: thin;
		scrollbar-color: var(--ii-bg-active) transparent;
	}
}

.ii-creations-pane.is-active {
	opacity: 1;
	pointer-events: auto;
}

/* ──────────────────────────────────────────────────────────────────
 *  Responsive Image Grid
 * ────────────────────────────────────────────────────────────────── */
.ii-creations-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
	gap: 10px;
}

/* ──────────────────────────────────────────────────────────────────
 *  Creation Card
 * ────────────────────────────────────────────────────────────────── */

/* Staggered reveal for first 8 cards */

/* ── Hover Overlay ── */

/* ──────────────────────────────────────────────────────────────────
 *  Workspace Group  (All Creations tab)
 * ────────────────────────────────────────────────────────────────── */
.ii-creations-group {
	margin-bottom: 36px;
}

.ii-creations-group:last-child {
	margin-bottom: 0;
}

.ii-creations-group-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
	gap: 12px;
}

.ii-creations-group-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.1;
	color: var(--ii-text-primary, #111827);
	text-decoration: none;
	letter-spacing: -0.01em;
	transition: color 0.18s ease;
	min-width: 0;
}

.ii-creations-group-title::before {
	content: '';
	width: 8px;
	height: 8px;
	min-width: 8px;
	background: var(--ii-accent, #2563eb);
	border-radius: 2px;
}

.ii-creations-group-title span {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ii-creations-group-title:hover {
	color: var(--ii-accent, #2563eb);
	text-decoration: none;
}

.ii-creations-group-meta {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}

.ii-creations-group-count {
	font-size: 11px;
	font-weight: 500;
	color: var(--ii-text-tertiary, #9ca3af);
	white-space: nowrap;
}

/* ──────────────────────────────────────────────────────────────────
 *  Show All Button
 * ────────────────────────────────────────────────────────────────── */
.ii-creations-show-more {
	display: flex;
	justify-content: center;
	margin-top: 12px;
}

.ii-creations-show-more-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 22px;
	border: 1.5px dashed var(--ii-border, #e5e7eb);
	border-radius: 10px;
	background: transparent;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--ii-text-secondary, #4b5563);
	cursor: pointer;
	transition: all 0.2s ease;
	font-family: var(--ii-font-body, Inter, sans-serif);
	line-height: 1;
}

.ii-creations-show-more-btn svg {
	width: 13px;
	height: 13px;
	flex-shrink: 0;
	transition: transform 0.2s ease;
}

.ii-creations-show-more-btn:hover {
	background: var(--ii-surface-white, #fff);
	border-color: var(--ii-accent, #2563eb);
	border-style: solid;
	color: var(--ii-accent, #2563eb);
}

/* ──────────────────────────────────────────────────────────────────
 *  Skeleton Loading
 * ────────────────────────────────────────────────────────────────── */
.ii-creations-skeleton-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
	gap: 10px;
}

.ii-creation-skeleton-card {
	aspect-ratio: 1 / 1;
	border-radius: var(--ii-radius-md, 12px);
	background: linear-gradient(
		90deg,
		var(--ii-bg-secondary, #f3f4f6) 25%,
		var(--ii-bg-hover, #e5e7eb) 50%,
		var(--ii-bg-secondary, #f3f4f6) 75%
	);
	background-size: 200% 100%;
	animation: iiSkeletonShimmer 1.8s infinite linear;
}

/* Skeleton for the "All" tab with workspace group headers */
.ii-creations-skeleton-group {
	margin-bottom: 32px;
}

.ii-creations-skeleton-group-title {
	height: 14px;
	width: 140px;
	border-radius: 4px;
	margin-bottom: 14px;
	background: linear-gradient(
		90deg,
		var(--ii-bg-secondary, #f3f4f6) 25%,
		var(--ii-bg-hover, #e5e7eb) 50%,
		var(--ii-bg-secondary, #f3f4f6) 75%
	);
	background-size: 200% 100%;
	animation: iiSkeletonShimmer 1.8s infinite linear;
}

/* ──────────────────────────────────────────────────────────────────
 *  Empty State
 * ────────────────────────────────────────────────────────────────── */
.ii-creations-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 300px;
	gap: 16px;
	text-align: center;
	padding: 48px 24px;
	animation: iiFadeIn 0.3s ease;
}

.ii-creations-empty-icon {
	width: 64px;
	height: 64px;
	border-radius: 16px;
	background: var(--ii-surface-white, #fff);
	border: 1px solid var(--ii-border, #e5e7eb);
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--ii-text-tertiary, #9ca3af);
}

.ii-creations-empty-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--ii-text-primary, #111827);
	margin: 0;
}

.ii-creations-empty-desc {
	font-size: 13px;
	color: var(--ii-text-tertiary, #9ca3af);
	margin: 0;
	max-width: 280px;
	line-height: 1.55;
}

.ii-creations-empty .ii-empty-state-btn {
	margin-top: 4px;
}

/* ──────────────────────────────────────────────────────────────────
 *  Error State
 * ────────────────────────────────────────────────────────────────── */
.ii-creations-error {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 200px;
	gap: 12px;
	text-align: center;
	padding: 32px;
	animation: iiFadeIn 0.25s ease;
}

.ii-creations-error p {
	font-size: 13.5px;
	color: var(--ii-error-text);
	margin: 0;
}

.ii-creations-retry-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 18px;
	border-radius: 8px;
	border: 1px solid var(--ii-retry-border);
	background: var(--ii-retry-bg);
	color: var(--ii-retry-color);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	font-family: var(--ii-font-body, Inter, sans-serif);
	transition: all 0.2s ease;
}

.ii-creations-retry-btn:hover {
	background: var(--ii-retry-hover-bg);
	border-color: var(--ii-retry-hover-border);
}

/* ──────────────────────────────────────────────────────────────────
 *  Responsive adjustments
 * ────────────────────────────────────────────────────────────────── */
@media (min-width: 900px) {
	.ii-creations-grid,
	.ii-creations-skeleton-grid {
		grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
	}
}

@media (max-width: 640px) {
	.ii-creations-pane {
		padding: 16px 16px 32px;
	}

	.ii-creations-grid,
	.ii-creations-skeleton-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 8px;
	}
}

/* ──────────────────────────────────────────────────────────────────
 *  Reduced-motion overrides
 * ────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.ii-creations-panel {
		transition: opacity 0.15s ease;
		transform: none !important;
	}
}

/* ──────────────────────────────────────────────────────────────────
 *  Standalone Creations page — undo overlay positioning
 *  Scoped to .ii-app--creations so overlay behaviour on other pages
 *  (studio etc.) is not affected.
 * ────────────────────────────────────────────────────────────────── */
.ii-app--creations .ii-creations-panel {
	position: relative;
	top: auto;
	left: auto;
	right: auto;
	bottom: auto;
	z-index: auto;
	flex: 1;
	min-height: 0;
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: none;
	transition: none;
}

.ii-app--creations .ii-creations-body {
	position: static;
	overflow-x: hidden;
	overflow-y: auto;
}

.ii-app--creations .ii-creations-pane {
	position: static;
	overflow: visible;
	opacity: 1;
	pointer-events: auto;
}

/* =============================================================
 *  Fan direction: upper-right (translate X+ Y- + CW rotation)
 *  Back layers:   deepest (--3) → most-faded; closest (--1) → least-faded
 * ============================================================= */

/* ── Outer cell — provides spacing so fanned cards don't clip ── */
.ii-bubble-stack {
	position: relative;
	aspect-ratio: 1 / 1;
	cursor: pointer;
	/* Reserve space for the rightward fan:
       right padding = max translate-X of back-3 (14px) + small buffer  */
	padding-right: 20px;
	padding-top: 14px;
	outline: none;
	-webkit-tap-highlight-color: transparent;
}

.ii-bubble-stack:focus-visible .ii-bubble-front {
	box-shadow:
		0 0 0 2px var(--ii-accent, #7c5ef1),
		var(--ii-card-shadow, 0 4px 20px rgba(0, 0, 0, 0.18));
}

/* ── Stacking context ── */
.ii-bubble-inner {
	position: relative;
	width: 100%;
	height: 100%;
}

/* ── Base card ── */
.ii-bubble-card {
	position: absolute;
	inset: 0;
	border-radius: var(--ii-radius-md, 12px);
	overflow: hidden;
	border: 1px solid var(--ii-card-border, rgba(255, 255, 255, 0.12));
	background: var(--ii-card-bg, rgba(255, 255, 255, 0.06));
	/* Glassmorphic depth */
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	will-change: transform, opacity;
	transform-origin: bottom left;
}

/* ── Front card ── */
.ii-bubble-front {
	z-index: 4;
	transform: none;
	opacity: 1;
	transition:
		transform 220ms var(--ii-ease-out, cubic-bezier(0.22, 0.68, 0, 1.2)),
		box-shadow 220ms ease;
	box-shadow: var(--ii-card-shadow, 0 4px 20px rgba(0, 0, 0, 0.18));
}

.ii-bubble-stack:hover .ii-bubble-front,
.ii-bubble-stack:focus-visible .ii-bubble-front {
	transform: translateY(-3px) scale(1.018);
	box-shadow:
		0 8px 28px rgba(0, 0, 0, 0.22),
		0 2px 8px rgba(0, 0, 0, 0.12);
}

/* ── Back card — base (shared) ── */
.ii-bubble-back {
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
	transition:
		transform 220ms var(--ii-ease-out, cubic-bezier(0.22, 0.68, 0, 1.2)),
		opacity 220ms ease;
}

/*
 * Layer numbering (CSS class) corresponds to VISUAL depth:
 *   --1 = closest to front   (least faded, smallest offset)
 *   --2 = middle
 *   --3 = deepest             (most  faded, largest offset)
 *
 * z-index order must match: back-1 above back-2 above back-3
 */

/* Layer 1 — closest to front */
.ii-bubble-back--1 {
	z-index: 3;
	opacity: 0.62;
	transform: translateX(5px) translateY(-3px) rotate(2deg);
}

/* Layer 2 — middle */
.ii-bubble-back--2 {
	z-index: 2;
	opacity: 0.4;
	transform: translateX(9px) translateY(-6px) rotate(3.8deg);
}

/* Layer 3 — deepest */
.ii-bubble-back--3 {
	z-index: 1;
	opacity: 0.22;
	transform: translateX(13px) translateY(-9px) rotate(5.5deg);
}

/* Subtle fan-open on hover */
.ii-bubble-stack:hover .ii-bubble-back--1,
.ii-bubble-stack:focus-visible .ii-bubble-back--1 {
	transform: translateX(7px) translateY(-5px) rotate(2.5deg);
	opacity: 0.7;
}

.ii-bubble-stack:hover .ii-bubble-back--2,
.ii-bubble-stack:focus-visible .ii-bubble-back--2 {
	transform: translateX(13px) translateY(-9px) rotate(4.5deg);
	opacity: 0.46;
}

.ii-bubble-stack:hover .ii-bubble-back--3,
.ii-bubble-stack:focus-visible .ii-bubble-back--3 {
	transform: translateX(18px) translateY(-12px) rotate(6.5deg);
	opacity: 0.26;
}

/* ── Image inside card ── */
.ii-bubble-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	pointer-events: none;
	user-select: none;
}

/* ── Count badge (×N) ── */
.ii-bubble-count {
	position: absolute;
	bottom: 7px;
	left: 8px;
	background: rgba(0, 0, 0, 0.55);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	color: #fff;
	font-size: 10px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.02em;
	padding: 3px 6px;
	border-radius: var(--ii-radius-rounded);
	pointer-events: none;
	user-select: none;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
	.ii-bubble-card,
	.ii-bubble-front,
	.ii-bubble-back {
		transition: none !important;
	}

	.ii-bubble-stack:hover .ii-bubble-front,
	.ii-bubble-stack:focus-visible .ii-bubble-front {
		transform: none;
	}

	.ii-bubble-stack:hover .ii-bubble-back--1,
	.ii-bubble-stack:focus-visible .ii-bubble-back--1 {
		transform: translateX(5px) translateY(-3px) rotate(2deg);
	}

	.ii-bubble-stack:hover .ii-bubble-back--2,
	.ii-bubble-stack:focus-visible .ii-bubble-back--2 {
		transform: translateX(9px) translateY(-6px) rotate(3.8deg);
	}

	.ii-bubble-stack:hover .ii-bubble-back--3,
	.ii-bubble-stack:focus-visible .ii-bubble-back--3 {
		transform: translateX(13px) translateY(-9px) rotate(5.5deg);
	}
}
