/* ==========================================================================
   profile.css
   User profile, library, status form (UAS), reviews, follow controls,
   edit profile form.
   ========================================================================== */

/* ==========================================================================
   Profile page
   ========================================================================== */

.profile-page {
	max-width: 1100px;
	margin: 0 auto;
	padding: var(--s-4) var(--s-6) var(--s-10);
}

.profile-hero {
	position: relative;
	display: flex;
	align-items: flex-end;
	gap: var(--s-6);
	padding: var(--s-7);
	margin-bottom: var(--s-7);
	background: var(--surface-1);
	-webkit-backdrop-filter: var(--glass-blur);
	backdrop-filter: var(--glass-blur);
	border: 1px solid var(--border);
	border-radius: var(--r-2xl);
	overflow: hidden;
	box-shadow: var(--inner-hi);
}

.profile-hero::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 1px;
	background: linear-gradient(
		90deg,
		transparent,
		var(--aurora-soft),
		transparent
	);
}

.profile-avatar {
	flex-shrink: 0;
	width: 96px;
	height: 96px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--font-display);
	font-size: var(--text-3xl);
	font-weight: 700;
	color: white;
	background: var(--aurora-violet);
	border-radius: 50%;
	box-shadow:
		0 8px 32px color-mix(in srgb, var(--violet) 40%, transparent),
		inset 0 2px 0 rgba(255, 255, 255, 0.3);
	position: relative;
}

.profile-avatar::after {
	content: "";
	position: absolute;
	inset: -3px;
	border-radius: 50%;
	background: var(--aurora);
	z-index: -1;
	opacity: 0.5;
	filter: blur(8px);
}

.profile-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: var(--s-3);
}

.profile-username {
	font-family: var(--font-display);
	font-size: var(--text-3xl);
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--text);
	margin: 0;
	display: flex;
	align-items: center;
	gap: var(--s-3);
	flex-wrap: wrap;
}

.profile-email {
	color: var(--text-3);
	font-size: var(--text-sm);
	font-family: var(--font-mono);
}

.profile-stats {
	display: flex;
	align-items: center;
	gap: var(--s-5);
	flex-wrap: wrap;
	color: var(--text-2);
	font-size: var(--text-sm);
}

.profile-stats span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.profile-stats strong {
	color: var(--text);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.profile-library__crumb {
	margin: 0;
}

.profile-library__back {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: var(--s-1) var(--s-2);
	color: var(--text-2);
	font-size: var(--text-sm);
	text-decoration: none;
	border-radius: var(--r-sm);
	transition:
		color var(--dur-fast) var(--ease),
		background var(--dur-fast) var(--ease);
}

.profile-library__back:hover,
.profile-library__back:focus-visible {
	color: var(--text);
	background: var(--surface-1);
	text-decoration: none;
}

.profile-library__back:focus-visible {
	outline: none;
	box-shadow: 0 0 0 2px var(--border-accent);
}

@media (prefers-reduced-motion: reduce) {
	.profile-library__back {
		transition: none;
	}
}

.profile-actions {
	display: flex;
	align-items: center;
	gap: var(--s-2);
	flex-shrink: 0;
	flex-wrap: wrap;
}

@media (max-width: 640px) {
	.profile-hero {
		flex-direction: column;
		align-items: flex-start;
		padding: var(--s-5);
	}
	.profile-avatar {
		width: 80px;
		height: 80px;
		font-size: var(--text-2xl);
	}
	.profile-username {
		font-size: var(--text-2xl);
	}
}

/* ==========================================================================
   Library grid (grouped by status)
   ========================================================================== */

.profile-library {
	display: flex;
	flex-direction: column;
	gap: var(--s-7);
}

.library-group {
	display: flex;
	flex-direction: column;
	gap: var(--s-4);
}

.library-group__header {
	display: flex;
	align-items: center;
	gap: var(--s-3);
	font-family: var(--font-display);
	font-size: var(--text-lg);
	font-weight: 600;
	color: var(--text);
	padding-bottom: var(--s-2);
	border-bottom: 1px solid var(--border);
}

/* ==========================================================================
   Filter tabs (dedicated library page)
   ========================================================================== */

/* Shared pill-nav primitive: glass surface, aurora accent on active/focus.
   Use .pill-nav--tabs for equal-width tabs, .pill-nav--pager for prev/next pagination. */

.pill-nav {
	display: flex;
	align-items: center;
	gap: 2px;
	padding: var(--s-1);
	background: var(--surface-1);
	-webkit-backdrop-filter: var(--glass-blur);
	backdrop-filter: var(--glass-blur);
	border: 1px solid var(--border);
	border-radius: var(--r-md);
	box-shadow: var(--inner-hi);
	overflow-x: auto;
	scrollbar-width: none;
	scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
	.pill-nav {
		scroll-behavior: auto;
	}
}

.pill-nav::-webkit-scrollbar {
	display: none;
}

.pill-nav__item {
	flex: 1 1 0;
	min-width: max-content;
	min-height: 44px;
	padding: var(--s-2) var(--s-4);
	font-family: var(--font-sans);
	font-size: var(--text-sm);
	font-weight: 500;
	color: var(--text-2);
	text-decoration: none;
	text-align: center;
	white-space: nowrap;
	border-radius: var(--r-sm);
	border: 1px solid transparent;
	transition:
		background var(--dur-fast) var(--ease),
		color var(--dur-fast) var(--ease),
		border-color var(--dur-fast) var(--ease);
}

.pill-nav__item:hover {
	background: var(--surface-2);
	color: var(--text);
	text-decoration: none;
}

.pill-nav__item--active {
	background: var(--surface-3);
	color: var(--text);
	border-color: var(--border-accent);
	font-weight: 600;
}

.pill-nav__item:focus-visible {
	outline: none;
	border-color: var(--border-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 25%, transparent);
}

.pill-nav__item[aria-disabled="true"],
.pill-nav__item.is-disabled {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}

/* Tabs variant: full-width equal items, wraps to horizontal scroll on narrow viewports. */
.pill-nav--tabs {
	margin-bottom: var(--s-5);
}

@media (max-width: 640px) {
	.pill-nav--tabs {
		gap: 0;
	}
	.pill-nav--tabs .pill-nav__item {
		flex: 0 0 auto;
		padding: var(--s-2) var(--s-3);
		font-size: var(--text-xs);
	}
}

/* Pager variant: prev / info / next layout, narrower padding. */
.pill-nav--pager {
	gap: 0;
	justify-content: center;
	margin-top: var(--s-6);
}

/* Tracking status display (used by user_app_statuses/show turbo-frame). */
.tracking-status {
	display: inline-flex;
	align-items: center;
	gap: var(--s-2);
	padding: var(--s-1) var(--s-2);
	color: var(--text-2);
	font-size: var(--text-sm);
}

.pill-nav--pager .pill-nav__item {
	flex: 0 0 auto;
	padding: var(--s-2) var(--s-4);
}

.pill-nav__info {
	flex: 0 0 auto;
	padding: var(--s-2) var(--s-3);
	font-size: var(--text-sm);
	color: var(--text-3);
	font-variant-numeric: tabular-nums;
	min-width: max-content;
}

@media (prefers-reduced-motion: reduce) {
	.pill-nav__item {
		transition: none;
	}
}

.library-group__count {
	color: var(--text-3);
	font-size: var(--text-sm);
	font-weight: 500;
	font-variant-numeric: tabular-nums;
	margin-left: auto;
}

.library-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.library-list__row {
	display: flex;
	align-items: center;
	gap: var(--s-3);
	min-height: 44px;
	padding: var(--s-2) var(--s-3);
	border-radius: var(--r-md);
	transition: background var(--dur-fast) var(--ease);
	text-decoration: none;
	color: var(--text);
}

.library-list__row:hover {
	background: var(--surface-1);
	color: var(--text);
	text-decoration: none;
}

.library-list__row:focus-visible {
	outline: none;
	background: var(--surface-2);
	box-shadow: 0 0 0 2px var(--border-accent);
}

.library-list__row img,
.library-list__row .library-list__image {
	width: 80px;
	height: 45px;
	object-fit: cover;
	border-radius: var(--r-sm);
	flex-shrink: 0;
	background: var(--surface-2);
}

.library-list__placeholder {
	width: 80px;
	height: 45px;
	background: var(--surface-2);
	border-radius: var(--r-sm);
	flex-shrink: 0;
}

.library-list__title {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: var(--text-sm);
	font-weight: 500;
}

.library-list__status {
	flex-shrink: 0;
	font-size: 10px;
	padding: 2px 7px;
}

.library-list__see-all,
.library-group__see-all {
	margin-top: var(--s-1);
}

.library-list__see-all-link,
.library-group__see-all-link {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: var(--s-2) var(--s-3);
	font-size: var(--text-xs);
	font-weight: 500;
	color: var(--text-2);
	background: transparent;
	border: 1px dashed var(--border);
	border-radius: var(--r-md);
	text-decoration: none;
	transition:
		background var(--dur-fast) var(--ease),
		color var(--dur-fast) var(--ease),
		border-color var(--dur-fast) var(--ease);
}

.library-list__see-all-link:hover,
.library-group__see-all-link:hover {
	background: var(--surface-1);
	color: var(--text);
	border-color: var(--border-strong);
	border-style: solid;
	text-decoration: none;
}

.library-list__see-all-link:focus-visible,
.library-group__see-all-link:focus-visible {
	outline: none;
	border-color: var(--border-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 25%, transparent);
}

/* Skeleton state: prevent shimmer from leaking clicks; row is non-interactive. */
.library-list--skeleton {
	pointer-events: none;
}

.library-list__row--skeleton {
	cursor: default;
}

.library-list__row--skeleton:hover {
	background: transparent;
}

.library-list-skeleton {
	/* Wrapper for the skeleton partial; lets us hang aria-live on the boundary
     while keeping the actual placeholder rows marked aria-hidden. */
	display: contents;
}

@media (prefers-reduced-motion: reduce) {
	.library-list__row,
	.library-list__row:focus-visible,
	.library-list__see-all-link,
	.library-list__see-all-link:hover,
	.library-group__see-all-link,
	.library-group__see-all-link:hover {
		transition: none;
	}
}

/* ==========================================================================
   Follow controls
   ========================================================================== */

.profile-stats-row {
	display: flex;
	align-items: center;
	gap: var(--s-5);
	flex-wrap: wrap;
	font-size: var(--text-sm);
	color: var(--text-2);
	margin-bottom: var(--s-3);
}

.profile-stats-row > span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.profile-stats-row strong {
	color: var(--text);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   User App Status (UAS) form
   ========================================================================== */

.uas-form {
	display: flex;
	flex-direction: column;
	gap: var(--s-5);
	padding: var(--s-5);
	background: var(--surface-1);
	-webkit-backdrop-filter: var(--glass-blur);
	backdrop-filter: var(--glass-blur);
	border: 1px solid var(--border);
	border-radius: var(--r-lg);
	box-shadow: var(--inner-hi);
}

.uas-form__row {
	display: flex;
	gap: var(--s-5);
	align-items: flex-start;
	flex-wrap: wrap;
}

.uas-form__field {
	display: flex;
	flex-direction: column;
	gap: var(--s-2);
	min-width: 0;
}

.uas-form__label {
	font-size: var(--text-xs);
	color: var(--text-3);
	text-transform: uppercase;
	letter-spacing: var(--tracking-wide);
	font-weight: 600;
}

.uas-form__select {
	height: 44px;
	min-height: 44px;
	padding: 0 var(--s-3);
	font-size: var(--text-sm);
	color: var(--text);
	background: var(--surface-1);
	border: 1px solid var(--border);
	border-radius: var(--r-md);
	box-shadow: var(--inner-hi);
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a8afc1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 36px;
	cursor: pointer;
	min-width: 160px;
}

.uas-form__select:focus {
	outline: none;
	border-color: var(--border-accent);
	background: var(--surface-2);
	box-shadow:
		0 0 0 3px var(--border-accent-soft),
		var(--inner-hi);
}

.uas-form__select option {
	color: var(--text);
	background-color: #1a1a1a;
	padding: 6px 10px;
}

.uas-form__select::picker(select) {
	background: #1a1a1a;
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: var(--r-md);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.uas-form .stars {
	display: flex;
	gap: 3px;
}

.uas-form .star {
	cursor: pointer;
	transition: transform var(--dur-fast) var(--ease);
}

.uas-form .star:hover {
	transform: scale(1.15);
}

.uas-form .star-rating-clear {
	margin-left: var(--s-2);
	padding: 0 var(--s-2);
	min-height: 44px;
	background: transparent;
	color: var(--text-3);
	font-size: var(--text-xs);
	font-weight: 500;
	border: 1px solid var(--border);
	border-radius: var(--r-sm);
	cursor: pointer;
	transition:
		color var(--dur-fast) var(--ease),
		border-color var(--dur-fast) var(--ease),
		background var(--dur-fast) var(--ease);
}

.uas-form .star-rating-clear:hover {
	color: var(--text);
	background: var(--surface-1);
	border-color: var(--border-strong);
}

.uas-form .star-rating-clear:focus-visible {
	outline: none;
	border-color: var(--border-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 25%, transparent);
}

@media (prefers-reduced-motion: reduce) {
	.uas-form .star-rating-clear {
		transition: none;
	}
}

.uas-form__editor {
	border: 1px solid var(--border);
	border-radius: var(--r-md);
	overflow: hidden;
	background: var(--surface-1);
}

.uas-form__editor trix-toolbar {
	background: var(--surface-2);
	border-bottom: 1px solid var(--border);
	padding: var(--s-2);
	border-radius: 0;
}

.uas-form__editor trix-editor {
	background: transparent;
	color: var(--text);
	border: none;
	border-radius: 0;
	min-height: 120px;
	padding: var(--s-3) var(--s-4);
	font-size: var(--text-sm);
	line-height: var(--leading-relaxed);
}

.uas-form__editor trix-editor:focus {
	outline: none;
}

.uas-form__editor trix-editor::placeholder,
.uas-form__editor trix-editor:empty::before {
	color: var(--text-3);
}

.uas-form__actions {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: var(--s-3);
}

.save-indicator {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--success);
	font-size: var(--text-sm);
	font-weight: 500;
	opacity: 1;
	transition: opacity var(--dur-slow) var(--ease);
}

.save-indicator[hidden] {
	display: none;
}
.save-indicator.fade-out {
	opacity: 0;
}

/* Entrance pulse: scale up from 0.85 with a brief glow ring.
   Triggered by adding the .pulse class on save success. */
@keyframes save-pulse {
	0% {
		transform: scale(0.85);
		box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 40%, transparent);
	}
	60% {
		transform: scale(1.05);
		box-shadow: 0 0 0 8px color-mix(in srgb, var(--success) 0%, transparent);
	}
	100% {
		transform: scale(1);
		box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 0%, transparent);
	}
}

.save-indicator.pulse {
	animation: save-pulse 480ms var(--ease-out);
	border-radius: var(--r-sm);
}

/* Checkmark draw: stroke-dasharray trick on the SVG path inside .save-indicator. */
.save-indicator svg path {
	stroke-dasharray: 30;
	stroke-dashoffset: 30;
}

.save-indicator.pulse svg path {
	animation: draw-check 360ms var(--ease-out) 80ms forwards;
}

@keyframes draw-check {
	to {
		stroke-dashoffset: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.save-indicator.pulse,
	.save-indicator.pulse svg path {
		animation: none;
	}
	.save-indicator.pulse svg path {
		stroke-dashoffset: 0;
	}
}

.star-rating-value {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 500px) {
	.uas-form__row {
		flex-direction: column;
		gap: var(--s-3);
	}
	.uas-form__select {
		width: 100%;
	}
}

/* ==========================================================================
   Reviews list
   ========================================================================== */

.reviews-list {
	display: flex;
	flex-direction: column;
	gap: var(--s-4);
}

.review-card {
	display: flex;
	gap: var(--s-4);
	padding: var(--s-5);
	background: var(--surface-1);
	-webkit-backdrop-filter: var(--glass-blur);
	backdrop-filter: var(--glass-blur);
	border: 1px solid var(--border);
	border-radius: var(--r-lg);
	transition:
		border-color var(--dur) var(--ease),
		transform var(--dur) var(--ease);
	box-shadow: var(--inner-hi);
}

.review-card:hover {
	border-color: var(--border-strong);
	transform: translateY(-1px);
}

.review-card__sidebar {
	flex-shrink: 0;
}

.review-card__avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: var(--r-md);
	background: var(--aurora-violet);
	color: white;
	font-weight: 700;
	font-size: var(--text-md);
	user-select: none;
	box-shadow: 0 4px 12px color-mix(in srgb, var(--violet) 30%, transparent);
}

.review-card__body {
	flex: 1;
	min-width: 0;
}

.review-card__header {
	display: flex;
	align-items: center;
	gap: var(--s-3);
	margin-bottom: var(--s-2);
	flex-wrap: wrap;
}

.review-card__username {
	font-weight: 600;
	color: var(--text);
	font-size: var(--text-md);
}

.review-card__rating {
	display: flex;
	align-items: center;
}

.review-card__rating .stars {
	display: flex;
	gap: 2px;
}

.review-card__date {
	font-size: var(--text-xs);
	color: var(--text-3);
	margin-left: auto;
	font-variant-numeric: tabular-nums;
}

.review-card__content {
	color: var(--text-2);
	font-size: var(--text-sm);
	line-height: var(--leading-relaxed);
}

.review-card__content p {
	margin: 0 0 var(--s-2);
}
.review-card__content p:last-child {
	margin-bottom: 0;
}

.reviews-pagination {
	display: flex;
	justify-content: center;
	margin-top: var(--s-5);
}
