/**
 * Portal Animations
 *
 * Smooth transitions and micro-interactions for the guest portal.
 *
 * @package MphbGuestServices
 * @since 2.0.0
 */

/* ========================================
 * CSS Custom Properties for Animations
 * ======================================== */

:root {
	--gs-anim-duration-fast: 150ms;
	--gs-anim-duration-base: 250ms;
	--gs-anim-duration-slow: 400ms;
	--gs-anim-duration-slower: 600ms;
	--gs-anim-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
	--gs-anim-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
	--gs-anim-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
	--gs-anim-stagger-delay: 60ms;
}

/* ========================================
 * Keyframe Definitions
 * ======================================== */

@keyframes gs-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@keyframes gs-fade-in-up {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes gs-fade-in-down {
	from {
		opacity: 0;
		transform: translateY(-20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes gs-fade-in-scale {
	from {
		opacity: 0;
		transform: scale(0.95);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

@keyframes gs-slide-in-right {
	from {
		opacity: 0;
		transform: translateX(30px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

@keyframes gs-slide-in-left {
	from {
		opacity: 0;
		transform: translateX(-30px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

@keyframes gs-pulse {
	0%, 100% {
		opacity: 1;
	}
	50% {
		opacity: 0.6;
	}
}

@keyframes gs-shimmer {
	0% {
		background-position: -200% 0;
	}
	100% {
		background-position: 200% 0;
	}
}

@keyframes gs-spin-pulse {
	0% {
		transform: rotate(0deg) scale(1);
		box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.18);
	}
	50% {
		transform: rotate(180deg) scale(1.1);
		box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.25);
	}
	100% {
		transform: rotate(360deg) scale(1);
		box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.18);
	}
}

@keyframes gs-flag-wave {
	0%, 100% {
		transform: perspective(100px) rotateY(0deg) scaleX(1);
	}
	25% {
		transform: perspective(100px) rotateY(-5deg) scaleX(0.98);
	}
	50% {
		transform: perspective(100px) rotateY(5deg) scaleX(1.02);
	}
	75% {
		transform: perspective(100px) rotateY(-3deg) scaleX(0.99);
	}
}

@keyframes gs-theme-glow {
	0%, 100% {
		color: rgba(255, 255, 255, 0.9);
		filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
	}
	50% {
		color: #fbbf24;
		filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.6));
	}
}

/* ========================================
 * Header Icon Animations
 * ======================================== */

/* Status dot - gentle spin pulse */
.gs-nav-status-dot {
	animation: gs-spin-pulse 3s ease-in-out infinite;
}

/*
 * Status dot — data-status attribute (T9: offline pastille support)
 *
 * Colors for the 4 SSR-driven states (online, offline, maintenance, cutoff)
 * already live in assets/portal.css:2088-2095, driven by the parent
 * .gs-nav-chip-status.status-<state> class. We mirror them here as
 * data-status selectors so the JS network listener can flip the dot without
 * touching the parent chip, AND we add a 5th `disconnected` state.
 *
 * Specificity note: the existing parent rule (.gs-nav-chip-status.status-X
 * .gs-nav-status-dot) outranks a bare `.gs-nav-status-dot[data-status="X"]`,
 * so we chain the chip class to make these win when the JS swaps the dot to
 * `disconnected` while the chip parent still says `status-online`.
 */
.gs-nav-chip-status .gs-nav-status-dot[data-status="online"]      { background: var(--gs-color-success); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.18); }
.gs-nav-chip-status .gs-nav-status-dot[data-status="offline"]     { background: var(--gs-color-warning); box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.25); }
.gs-nav-chip-status .gs-nav-status-dot[data-status="maintenance"] { background: var(--gs-color-error);   box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.25); }
.gs-nav-chip-status .gs-nav-status-dot[data-status="cutoff"]      { background: var(--gs-color-warning); box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.25); }
.gs-nav-chip-status .gs-nav-status-dot[data-status="disconnected"] {
	background: #fbbf24;
	box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.25);
	animation: gs-pulse-faster 1.5s ease-in-out infinite;
}

@keyframes gs-pulse-faster {
	0%, 100% { opacity: 1; transform: scale(1); }
	50%      { opacity: 0.4; transform: scale(0.92); }
}

/* Flag - subtle wave in the wind */
.gs-lang-flag {
	animation: gs-flag-wave 4s ease-in-out infinite;
	transform-origin: left center;
}

/* Theme icon - fade between white and yellow */
.gs-theme-icon {
	animation: gs-theme-glow 4s ease-in-out infinite;
}

/* ========================================
 * Panel Transitions
 * ======================================== */

/*
 * Note: We avoid using transform on .gs-panel because it creates a new
 * containing block which breaks position:fixed for overlays/spinners inside.
 * Using opacity-only transition for panels.
 */
.gs-panel {
	opacity: 0;
	transition: opacity var(--gs-anim-duration-base) var(--gs-anim-ease-out);
}

.gs-panel.is-active {
	opacity: 1;
}

/* ========================================
 * Card Hover Effects
 * ======================================== */

.gs-info-card {
	transition:
		transform var(--gs-anim-duration-base) var(--gs-anim-ease-out),
		box-shadow var(--gs-anim-duration-base) var(--gs-anim-ease-out);
}

.gs-info-card:hover {
	transform: translateY(-4px);
	box-shadow:
		0 16px 40px rgba(15, 23, 42, 0.12),
		0 8px 16px rgba(15, 23, 42, 0.08);
}

/* Clickable cards get cursor */
.gs-card-clickable {
	cursor: pointer;
}

.gs-card-clickable:active {
	transform: translateY(-2px);
}

/* Hero cards within info cards */
.gs-info-card .gs-hero {
	transition: filter var(--gs-anim-duration-base) var(--gs-anim-ease-out);
}

.gs-info-card:hover .gs-hero {
	filter: brightness(1.05);
}

/* ========================================
 * Staggered Page Load Animations
 * ======================================== */

/* Cards waiting to animate */
.gs-info-card.gs-anim-stagger {
	opacity: 0;
	transform: translateY(24px);
}

/* Animated state */
.gs-info-card.gs-anim-stagger.gs-anim-in {
	animation: gs-fade-in-up var(--gs-anim-duration-slow) var(--gs-anim-ease-out) forwards;
}

/* Stagger delay classes (applied by JS) */
.gs-anim-delay-1 { animation-delay: calc(var(--gs-anim-stagger-delay) * 1) !important; }
.gs-anim-delay-2 { animation-delay: calc(var(--gs-anim-stagger-delay) * 2) !important; }
.gs-anim-delay-3 { animation-delay: calc(var(--gs-anim-stagger-delay) * 3) !important; }
.gs-anim-delay-4 { animation-delay: calc(var(--gs-anim-stagger-delay) * 4) !important; }
.gs-anim-delay-5 { animation-delay: calc(var(--gs-anim-stagger-delay) * 5) !important; }
.gs-anim-delay-6 { animation-delay: calc(var(--gs-anim-stagger-delay) * 6) !important; }
.gs-anim-delay-7 { animation-delay: calc(var(--gs-anim-stagger-delay) * 7) !important; }
.gs-anim-delay-8 { animation-delay: calc(var(--gs-anim-stagger-delay) * 8) !important; }

/* ========================================
 * Button & Interactive Element Effects
 * ======================================== */

/* Primary buttons */
.gs-btn,
button[type="submit"],
.gs-submit-btn {
	transition:
		background var(--gs-anim-duration-fast) var(--gs-anim-ease-out),
		transform var(--gs-anim-duration-fast) var(--gs-anim-ease-out),
		box-shadow var(--gs-anim-duration-fast) var(--gs-anim-ease-out);
}

.gs-btn:active,
button[type="submit"]:active,
.gs-submit-btn:active {
	transform: scale(0.98);
}

/* Link hover underline animation */
.gs-card-empty-link,
.gs-hero-title-link {
	position: relative;
	text-decoration: none;
}

.gs-card-empty-link::after,
.gs-hero-title-link::after {
	content: '';
	position: absolute;
	bottom: -2px;
	left: 0;
	width: 0;
	height: 2px;
	background: currentColor;
	transition: width var(--gs-anim-duration-base) var(--gs-anim-ease-out);
}

.gs-card-empty-link:hover::after,
.gs-hero-title-link:hover::after {
	width: 100%;
}

/* ========================================
 * Form Input Focus Animations
 * ======================================== */

.gs-input,
.gs-select,
.gs-textarea,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
	transition:
		border-color var(--gs-anim-duration-fast) var(--gs-anim-ease-out),
		box-shadow var(--gs-anim-duration-fast) var(--gs-anim-ease-out),
		background var(--gs-anim-duration-fast) var(--gs-anim-ease-out);
}

/* ========================================
 * Progress Bar Animations
 * ======================================== */

.gs-progress-fill {
	transition: width var(--gs-anim-duration-slower) var(--gs-anim-ease-out);
}

.gs-progress-thumb {
	transition: left var(--gs-anim-duration-slower) var(--gs-anim-ease-out);
}

/* ========================================
 * Badge & Status Animations
 * ======================================== */

.gs-hero-badge,
.gs-status-badge {
	transition:
		background var(--gs-anim-duration-base) var(--gs-anim-ease-out),
		color var(--gs-anim-duration-base) var(--gs-anim-ease-out),
		transform var(--gs-anim-duration-base) var(--gs-anim-ease-out);
}

/* Pending status pulse */
.gs-badge-is-pending,
.gs-status-badge--pending {
	animation: gs-pulse 2s var(--gs-anim-ease-in-out) infinite;
}

/* ========================================
 * Modal Enhancements
 * ======================================== */

.gs-modal-overlay {
	transition:
		opacity var(--gs-anim-duration-base) var(--gs-anim-ease-out),
		backdrop-filter var(--gs-anim-duration-base) var(--gs-anim-ease-out);
}

.gs-modal {
	transition:
		opacity var(--gs-anim-duration-base) var(--gs-anim-ease-out),
		transform var(--gs-anim-duration-base) var(--gs-anim-ease-spring);
}

/* ========================================
 * Navigation Animations
 * ======================================== */

.gs-nav a,
.gs-sidebar-link {
	position: relative;
	transition:
		color var(--gs-anim-duration-fast) var(--gs-anim-ease-out),
		background var(--gs-anim-duration-fast) var(--gs-anim-ease-out);
}

/* Active indicator slide */
.gs-nav a.is-active::before,
.gs-sidebar-link.is-active::before {
	transition: transform var(--gs-anim-duration-base) var(--gs-anim-ease-spring);
}

/* ========================================
 * Loading & Skeleton States
 * ======================================== */

.gs-skeleton {
	background: linear-gradient(
		90deg,
		var(--gs-color-surface) 25%,
		var(--gs-color-surface-hover) 50%,
		var(--gs-color-surface) 75%
	);
	background-size: 200% 100%;
	animation: gs-shimmer 1.5s infinite;
	border-radius: var(--gs-radius-sm);
}

/* ========================================
 * Collapse/Expand Animations
 * ======================================== */

.gs-collapse-content {
	transition:
		max-height var(--gs-anim-duration-base) var(--gs-anim-ease-out),
		opacity var(--gs-anim-duration-base) var(--gs-anim-ease-out);
	overflow: hidden;
}

.gs-collapse-trigger svg,
.gs-collapse-trigger .gs-icon {
	transition: transform var(--gs-anim-duration-base) var(--gs-anim-ease-out);
}

.gs-collapse-trigger[aria-expanded="true"] svg,
.gs-collapse-trigger[aria-expanded="true"] .gs-icon {
	transform: rotate(180deg);
}

/* ========================================
 * Icon Hover Animations
 * ======================================== */

.gs-summary-icon {
	transition: transform var(--gs-anim-duration-base) var(--gs-anim-ease-spring);
}

.gs-summary-stat:hover .gs-summary-icon {
	transform: scale(1.1);
}

/* ========================================
 * Dark Mode Adjustments
 * ======================================== */

.mphb-gs-shell[data-theme="dark"] .gs-info-card:hover,
.mphb-gs-shell[data-theme="dark"] .gs-card-clickable:hover {
	box-shadow:
		0 16px 40px rgba(0, 0, 0, 0.3),
		0 8px 16px rgba(0, 0, 0, 0.2);
}

.mphb-gs-shell[data-theme="dark"] .gs-skeleton {
	background: linear-gradient(
		90deg,
		#20242c 25%,
		#292d36 50%,
		#20242c 75%
	);
	background-size: 200% 100%;
}

@media (prefers-color-scheme: dark) {
	.mphb-gs-shell[data-theme="auto"] .gs-info-card:hover,
	.mphb-gs-shell[data-theme="auto"] .gs-card-clickable:hover {
		box-shadow:
			0 16px 40px rgba(0, 0, 0, 0.3),
			0 8px 16px rgba(0, 0, 0, 0.2);
	}

	.mphb-gs-shell[data-theme="auto"] .gs-skeleton {
		background: linear-gradient(
			90deg,
			#20242c 25%,
			#292d36 50%,
			#20242c 75%
		);
		background-size: 200% 100%;
	}
}

/* ========================================
 * Reduced Motion Support
 * ======================================== */

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}

	.gs-info-card:hover {
		transform: none;
	}

	.gs-panel {
		opacity: 1;
		transform: none;
	}

	.gs-info-card.gs-anim-stagger {
		opacity: 1;
		transform: none;
	}
}

/* ─────────────────────────────────────────────────────────────
   T13 — Offline submit affordances
   Visual cue on submit buttons when the tablet is offline,
   so guests know the action will be queued (or is blocked).
   ───────────────────────────────────────────────────────────── */

/* Queueable: dim + progress cursor (action sera mise en file). */
body[data-network-status="disconnected"] form[data-offline-queueable="true"] button[type="submit"],
body[data-network-status="disconnected"] form[data-offline-queueable="true"] input[type="submit"] {
	opacity: 0.7;
	cursor: progress;
}

/* Blocked: fully disabled affordance (connexion requise). */
body[data-network-status="disconnected"] form[data-offline-blocked="true"] button[type="submit"],
body[data-network-status="disconnected"] form[data-offline-blocked="true"] input[type="submit"] {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}

