/* Modern UI Enhancements for Parní Kaktus */

/* Zakázání systémového overscroll refresh (vlastní Pull-to-Refresh) */
body {
  overscroll-behavior-y: contain;
}

/* ===== PULL-TO-REFRESH (vlastní indikátor) ===== */
#custom-pull-to-refresh {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12), 0 0 0 2px rgba(6, 128, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  transition: transform 0.15s ease-out;
  pointer-events: none;
}

#custom-pull-to-refresh img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  transition: transform 0.2s ease;
}

#custom-pull-to-refresh img.spinning {
  animation: ptr-spin 0.8s linear infinite;
}

@keyframes ptr-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===== SMOOTH ANIMATIONS & MICROINTERACTIONS ===== */

/* Fade in animation for page load */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translateY(0);
  }
  40%, 43% {
    transform: translateY(-10px);
  }
  70% {
    transform: translateY(-5px);
  }
  90% {
    transform: translateY(-2px);
  }
}

/* Page load animation */
.page-content {
  animation: fadeInUp 0.6s ease-out;
}

/* Enhanced button hover effects */
.modern-button {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateZ(0);
}


.modern-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.modern-button:active {
  transform: translateY(0);
  transition: transform 0.1s;
}

/* Card hover effects */
.modern-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateZ(0);
}

.modern-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* ===== LOADING STATES & SKELETON LOADERS ===== */

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

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

/* ===== TOAST NOTIFICATIONS ===== */

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  animation: slideInFromRight 0.3s ease-out;
  max-width: 400px;
  border-left: 4px solid #068000;
}

.toast.success {
  border-left-color: #068000;
}

.toast.error {
  border-left-color: #dc3545;
}

.toast.warning {
  border-left-color: #ffc107;
}

.toast.info {
  border-left-color: #17a2b8;
}

/* ===== ENHANCED STAT CARDS ===== */

.stat-card {
  background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #068000, #10b981);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: #068000;
  display: block;
  animation: countUp 1s ease-out;
}

@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== MODAL ANIMATIONS ===== */

/* Smooth modal open/close */
.modal {
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content,
.modal-form,
.trophy-modal-content {
  animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Modal close animation */
.modal.closing,
.trophy-modal.closing {
  animation: fadeOut 0.2s ease-out forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.modal-content.closing,
.trophy-modal-content.closing {
  animation: modalSlideOut 0.2s ease-out forwards;
}

@keyframes modalSlideOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
}

/* ===== CARD ANIMATIONS ===== */

/* Staggered fade-in for cards */
.card-grid,
.documents-grid,
.quick-links-grid {
  animation: fadeIn 0.6s ease-out;
}

.card-grid > *,
.documents-grid > *,
.quick-links-grid > * {
  animation: fadeInUp 0.6s ease-out backwards;
}

.card-grid > *:nth-child(1) { animation-delay: 0.05s; }
.card-grid > *:nth-child(2) { animation-delay: 0.1s; }
.card-grid > *:nth-child(3) { animation-delay: 0.15s; }
.card-grid > *:nth-child(4) { animation-delay: 0.2s; }
.card-grid > *:nth-child(5) { animation-delay: 0.25s; }
.card-grid > *:nth-child(6) { animation-delay: 0.3s; }
.card-grid > *:nth-child(7) { animation-delay: 0.35s; }
.card-grid > *:nth-child(8) { animation-delay: 0.4s; }

.documents-grid > *:nth-child(1) { animation-delay: 0.05s; }
.documents-grid > *:nth-child(2) { animation-delay: 0.1s; }
.documents-grid > *:nth-child(3) { animation-delay: 0.15s; }
.documents-grid > *:nth-child(4) { animation-delay: 0.2s; }
.documents-grid > *:nth-child(5) { animation-delay: 0.25s; }
.documents-grid > *:nth-child(6) { animation-delay: 0.3s; }

.quick-links-grid > *:nth-child(1) { animation-delay: 0.05s; }
.quick-links-grid > *:nth-child(2) { animation-delay: 0.1s; }

/* Enhanced card hover with scale */
.document-card,
.quick-link-card,
.player-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateZ(0);
}

.document-card:hover,
.quick-link-card:hover,
.player-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

/* ===== FORM ANIMATIONS ===== */

/* Smooth form input focus */
.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-input:focus,
input:focus,
textarea:focus,
select:focus {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

/* Form validation animations */
.form-input:invalid:not(:placeholder-shown) {
  animation: shake 0.4s ease-in-out;
  border-color: #f56565;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.form-input:valid:not(:placeholder-shown) {
  border-color: #48bb78;
  animation: successPulse 0.3s ease-out;
}

@keyframes successPulse {
  0% { box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(72, 187, 120, 0); }
  100% { box-shadow: 0 0 0 0 rgba(72, 187, 120, 0); }
}

/* ===== NAVIGATION ANIMATIONS ===== */

/* Smooth dropdown menu */
.dropdown-menu,
.dropdown-menu-mobile {
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Navigation link hover with underline */
.nav-link,
.nav-link-mobile {
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link::after,
.nav-link-mobile::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #4caf50, #66bb6a);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link-mobile:hover::after {
  width: 80%;
}

/* ===== BUTTON ENHANCEMENTS ===== */

/* Ripple effect on button click */
.modern-button,
.action-button,
.nav-button {
  position: relative;
  overflow: hidden;
}

.modern-button::before,
.action-button::before,
.nav-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.modern-button:active::before,
.action-button:active::before,
.nav-button:active::before {
  width: 300px;
  height: 300px;
}

/* Ripple effect span */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  transform: scale(0);
  animation: rippleAnimation 0.6s ease-out;
  pointer-events: none;
}

@keyframes rippleAnimation {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Button loading state */
.button-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.button-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== SCROLL ANIMATIONS ===== */

/* Fade in on scroll */
.fade-in-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== GALLERY ANIMATIONS ===== */

/* Smooth image loading */
.gallery-item img,
.player-photo img {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.gallery-item img.loading,
.player-photo img.loading {
  opacity: 0;
  transform: scale(0.95);
}

.gallery-item img.loaded,
.player-photo img.loaded {
  opacity: 1;
  transform: scale(1);
}

/* Gallery modal image transition */
.modal-image,
.trophy-modal-image {
  animation: zoomIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== TOAST ENHANCEMENTS ===== */

.toast {
  animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.toast.closing {
  animation: toastSlideOut 0.3s ease-out forwards;
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.8);
  }
}

/* ===== SEARCH ANIMATIONS ===== */

/* Search input focus animation */
.global-search-input:focus {
  animation: searchFocus 0.3s ease-out;
}

@keyframes searchFocus {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
  }
  100% {
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.1);
  }
}

/* Search results appear */
.search-result-item {
  animation: fadeInUp 0.3s ease-out backwards;
}

.search-result-item:nth-child(1) { animation-delay: 0.05s; }
.search-result-item:nth-child(2) { animation-delay: 0.1s; }
.search-result-item:nth-child(3) { animation-delay: 0.15s; }
.search-result-item:nth-child(4) { animation-delay: 0.2s; }
.search-result-item:nth-child(5) { animation-delay: 0.25s; }

/* ===== PAGE TRANSITIONS ===== */

/* Smooth page transitions */
.page-wrapper {
  animation: pageFadeIn 0.5s ease-out;
}

@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== SECTION ANIMATIONS ===== */

/* Section headers */
.section-header,
.section-title {
  animation: fadeInUp 0.6s ease-out;
}

/* Staggered section content */
.section-content > * {
  animation: fadeInUp 0.6s ease-out backwards;
}

.section-content > *:nth-child(1) { animation-delay: 0.1s; }
.section-content > *:nth-child(2) { animation-delay: 0.2s; }
.section-content > *:nth-child(3) { animation-delay: 0.3s; }
.section-content > *:nth-child(4) { animation-delay: 0.4s; }

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid #068000;
  outline-offset: 2px;
  animation: focusPulse 0.3s ease-out;
}

@keyframes focusPulse {
  0% {
    outline-width: 2px;
  }
  50% {
    outline-width: 4px;
  }
  100% {
    outline-width: 2px;
  }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .toast {
    border: 2px solid #000;
  }
  
  .stat-card {
    border: 1px solid #000;
  }
}

/* Portal hráče – horizontální scroll u tabulek „Statistika soutěže“ (Firefox + doplňuje portal.css) */
body.pk-portal-hrac .portal-skupina-list-wrap {
  scrollbar-color: rgba(76, 175, 80, 0.5) rgba(15, 23, 42, 0.06);
}
