/* =====================================================================
   CODEARENA UI ENHANCEMENTS 2026
   10 визуальных улучшений: glassmorphism, микро-взаимодействия,
   анимации, неоморфизм, skeleton loading, fluid typography
   ===================================================================== */

/* =====================================================================
   1. GLASSMORPHISM ДЛЯ КАРТОЧЕК И ПАНЕЛЕЙ
   ===================================================================== */
.cat-card,
.level-card,
.path-card,
.panel,
.home-panel,
.ac-card,
.blog-card,
.side-card,
.ac-room-card {
  background: var(--glass-bg) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border) !important;
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-hi) !important;
}

.cat-card:hover,
.level-card:hover,
.path-card:hover,
.ac-card:hover,
.blog-card:hover {
  background: var(--glass-bg-hover) !important;
  border-color: var(--glass-border-hover) !important;
  transform: translateY(-4px) !important;
  box-shadow: var(--glass-shadow-hover), inset 0 1px 0 var(--glass-hi-hover) !important;
}

/* Академия-бэнд с усиленным glow */
.academy-band {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 
    0 8px 32px rgba(67, 227, 155, 0.2),
    inset 0 1px 0 rgba(67, 227, 155, 0.15);
}

.academy-band:hover {
  box-shadow: 
    0 12px 48px rgba(67, 227, 155, 0.3),
    inset 0 1px 0 rgba(67, 227, 155, 0.2);
}

/* =====================================================================
   2. МИКРО-ВЗАИМОДЕЙСТВИЯ ДЛЯ КНОПОК
   ===================================================================== */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Ripple эффект */
.btn::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;
  pointer-events: none;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

/* Glow на hover */
.btn:hover {
  box-shadow: 
    0 0 20px rgba(221, 226, 255, 0.4),
    0 0 40px rgba(221, 226, 255, 0.2) !important;
}

.btn.ghost:hover {
  box-shadow: 
    0 0 16px rgba(190, 200, 255, 0.15),
    inset 0 0 0 1px var(--line-2) !important;
}

/* =====================================================================
   3. УЛУЧШЕННЫЕ ИНДИКАТОРЫ ПРОГРЕССА
   ===================================================================== */
.pbar {
  position: relative;
  overflow: hidden;
}

.pbar i {
  background: linear-gradient(
    90deg,
    var(--c),
    color-mix(in srgb, var(--c) 80%, white) 50%,
    var(--c)
  ) !important;
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  position: relative;
}

.pbar i::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shine 3s infinite;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 0%; }
}

@keyframes shine {
  0% { left: -100%; }
  100% { left: 200%; }
}

/* =====================================================================
   4. НЕОМОРФИЗМ ДЛЯ ИКОНОК
   ===================================================================== */
.itile {
  background: 
    linear-gradient(145deg, 
      color-mix(in srgb, var(--c, var(--silver)) 15%, transparent),
      color-mix(in srgb, var(--c, var(--silver)) 5%, transparent)
    ) !important;
  box-shadow: 
    inset 2px 2px 5px var(--tile-in-dark),
    inset -2px -2px 5px var(--tile-in-light),
    0 4px 12px color-mix(in srgb, var(--c, var(--silver)) 20%, transparent) !important;
  border: 1px solid color-mix(in srgb, var(--c, var(--silver)) 30%, transparent) !important;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.itile:hover,
.cat-card:hover .itile,
.level-card:hover .itile,
.stat:hover .itile {
  transform: translateY(-2px);
  box-shadow: 
    inset 2px 2px 5px var(--tile-in-dark),
    inset -2px -2px 5px var(--tile-in-light),
    0 8px 20px color-mix(in srgb, var(--c, var(--silver)) 35%, transparent) !important;
}

/* =====================================================================
   5. ПЛАВНАЯ АНИМАЦИЯ ПОЯВЛЕНИЯ СЕКЦИЙ
   ===================================================================== */
.fade-in-up {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-in-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Отключить для prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .fade-in-up {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* =====================================================================
   6. УЛУЧШЕННЫЙ ФОКУС ДЛЯ КЛАВИАТУРНОЙ НАВИГАЦИИ
   ===================================================================== */
:focus-visible {
  outline: 2px solid var(--silver) !important;
  outline-offset: 4px !important;
  border-radius: var(--r-in) !important;
  box-shadow: 
    0 0 0 4px rgba(221, 226, 255, 0.15),
    0 0 12px rgba(221, 226, 255, 0.3) !important;
  transition: box-shadow 0.3s ease !important;
}

/* Анимация pulsing для интерактивных элементов */
@keyframes focus-pulse {
  0%, 100% { 
    box-shadow: 
      0 0 0 4px rgba(221, 226, 255, 0.15),
      0 0 12px rgba(221, 226, 255, 0.3);
  }
  50% { 
    box-shadow: 
      0 0 0 6px rgba(221, 226, 255, 0.25),
      0 0 16px rgba(221, 226, 255, 0.5);
  }
}

button:focus-visible, 
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  animation: focus-pulse 2s infinite;
}

@media (prefers-reduced-motion: reduce) {
  button:focus-visible, 
  a:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible {
    animation: none;
  }
}

/* =====================================================================
   7. SKELETON LOADING ДЛЯ СПИСКОВ ЗАДАЧ
   ===================================================================== */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(190, 200, 255, 0.05) 0%,
    rgba(190, 200, 255, 0.12) 50%,
    rgba(190, 200, 255, 0.05) 100%
  ) !important;
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--r-in);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Применить к элементам при загрузке */
.rm.loading,
.trow.loading,
.ac-task-row.loading {
  pointer-events: none;
}

.rm.loading .rm-t b,
.rm.loading .rm-pts,
.trow.loading .t,
.trow.loading .pts,
.ac-task-row.loading .ac-task-t b,
.ac-task-row.loading .ac-xp {
  color: transparent !important;
  background: linear-gradient(
    90deg,
    rgba(190, 200, 255, 0.05) 0%,
    rgba(190, 200, 255, 0.12) 50%,
    rgba(190, 200, 255, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .rm.loading .rm-t b,
  .rm.loading .rm-pts,
  .trow.loading .t,
  .trow.loading .pts {
    animation: none;
    background: rgba(190, 200, 255, 0.08);
  }
}

/* =====================================================================
   8. SMOOTH SCROLL С OFFSET ДЛЯ ЯКОРЕЙ
   ===================================================================== */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 100px; /* высота шапки + отступ */
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* =====================================================================
   9. УЛУЧШЕННАЯ ТИПОГРАФИКА С FLUID CLAMP()
   ===================================================================== */
:root {
  --t-xs: clamp(11px, 0.6875rem + 0.15vw, 12px) !important;
  --t-s: clamp(12px, 0.75rem + 0.2vw, 13px) !important;
  --t-m: clamp(14px, 0.875rem + 0.25vw, 15px) !important;
  --t-l: clamp(16px, 1rem + 0.4vw, 18px) !important;
  --t-xl: clamp(20px, 1.25rem + 0.6vw, 23px) !important;
  --t-2xl: clamp(24px, 1.5rem + 1vw, 29px) !important;
  --t-3xl: clamp(28px, 1.75rem + 1.5vw, 36px) !important;
  --t-4xl: clamp(32px, 2rem + 2vw, 45px) !important;
  --t-5xl: clamp(40px, 2.5rem + 3vw, 56px) !important;
  --t-6xl: clamp(48px, 3rem + 4vw, 70px) !important;
}

/* =====================================================================
   10. HOVER-ЭФФЕКТЫ ДЛЯ ТАБЛИЦЫ ЛИДЕРОВ
   ===================================================================== */
.tbl tr {
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  position: relative;
}

.tbl tr::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--silver);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tbl tr:hover::before {
  opacity: 1;
}

.tbl tr.top1::before { 
  background: linear-gradient(180deg, #FFD700, #FFA500); 
}

.tbl tr.top2::before { 
  background: linear-gradient(180deg, #C0C0C0, #A0A0A0); 
}

.tbl tr.top3::before { 
  background: linear-gradient(180deg, #CD7F32, #8B4513); 
}

.tbl tr:hover {
  background: rgba(190, 200, 255, 0.06) !important;
  transform: translateX(4px);
}

/* Градиент для медалей в рейтинге */
.tbl tr.top1 .rank { 
  background: linear-gradient(135deg, #FFD700, #FFA500);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tbl tr.top2 .rank { 
  background: linear-gradient(135deg, #E0E0E0, #999999);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tbl tr.top3 .rank { 
  background: linear-gradient(135deg, #CD7F32, #8B4513);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* =====================================================================
   ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ
   ===================================================================== */

/* Smooth transitions для всех hover-состояний */
a, button, .chip, .seg a, .toggle, .cchip {
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Улучшенные stat-карточки */
.stat {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: 
    var(--soft-shadow),
    inset 0 1px 0 var(--soft-hi);
}

/* Pulsing для live-индикаторов */
@keyframes live-pulse {
  0%, 100% { 
    box-shadow: 0 0 0 4px rgba(67, 227, 155, 0.15);
    opacity: 1;
  }
  50% { 
    box-shadow: 0 0 0 8px rgba(67, 227, 155, 0.05);
    opacity: 0.8;
  }
}

.chip.live::before,
.done-dot.on {
  animation: live-pulse 2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .chip.live::before,
  .done-dot.on {
    animation: none;
  }
}

/* Улучшенные уведомления (flash) с slide-in */
@keyframes slide-in-right {
  from { 
    opacity: 0; 
    transform: translateX(100px);
  }
  to { 
    opacity: 1; 
    transform: translateX(0);
  }
}

.flash {
  animation: slide-in-right 0.5s cubic-bezier(0.16, 1, 0.3, 1) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Улучшенная луна на главной */
.phase {
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.phase:hover {
  transform: scale(1.02);
}

/* Улучшенный редактор кода */
.ed-bar {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Transition для категорий в фильтрах */
.seg a,
.cchip,
.ac-tabs a {
  position: relative;
}

.seg a::after,
.cchip::after,
.ac-tabs a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.seg a:hover::after,
.cchip:hover::after,
.ac-tabs a:hover::after {
  width: 80%;
  left: 10%;
}

.seg a.on::after,
.cchip.on::after,
.ac-tabs a.on::after {
  width: 80%;
  left: 10%;
}
