/* ========================================================================== 
   Flux — iOS-расписание (dark) + animations
   ========================================================================== */
:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #08090c;
  --card-bg: #0e0f15;
  --card-border: rgba(255, 255, 255, 0.08);

  /* text */
  --text-primary: #f5f5f7;
  --text-secondary: #b8b8c2;
  --text-tertiary: #65656f;

  /* accent */
  --accent: #8b7cff;
  --accent-soft: rgba(139, 124, 255, 0.16);
  --accent-deep: #5b48d9;

  /* glass */
  --glass-bg: rgba(8, 9, 12, 0.78);
  --separator: rgba(255, 255, 255, 0.08);

  /* segmented */
  --segment-bg: rgba(255, 255, 255, 0.05);
  --segment-active: rgba(139, 124, 255, 0.22);
  --segment-active-shadow:
    0 0 20px rgba(139, 124, 255, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.25);

  /* misc */
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);
  --skeleton-bg: rgba(255, 255, 255, 0.05);
  --badge-bg: rgba(139, 124, 255, 0.18);
  --type-badge-bg: rgba(255, 255, 255, 0.06);
  --radius: 16px;

  /* easings */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* атмосферные свечения + мягкое «дыхание» */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 900px 700px at 50% -20%, rgba(139, 124, 255, 0.16), transparent 60%),
    radial-gradient(ellipse 600px 600px at 100% 100%, rgba(201, 255, 61, 0.04), transparent 60%),
    radial-gradient(ellipse 600px 600px at 0% 80%, rgba(124, 212, 255, 0.04), transparent 60%);
  animation: atmosphereBreathe 14s ease-in-out infinite;
}

@keyframes atmosphereBreathe {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.85; transform: scale(1.03); }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", sans-serif;
}

html, body {
  background-color: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  padding-bottom: calc(85px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ========================================================================== 
   Header
   ========================================================================== */
.liquid-glass-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--glass-bg);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border-bottom: 0.5px solid var(--separator);
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  animation: headerSlideDown 0.6s var(--ease-out) both;
}

@keyframes headerSlideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* тонкая светящаяся полоска внизу шапки */
.liquid-glass-header::after {
  content: '';
  position: absolute;
  left: 10%; right: 10%; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139, 124, 255, 0.7), transparent);
  opacity: 0.7;
  animation: shineLine 6s ease-in-out infinite;
}

@keyframes shineLine {
  0%, 100% { opacity: 0.35; transform: scaleX(1); }
  50%      { opacity: 0.85; transform: scaleX(1.15); }
}

.header-content {
  max-width: 600px;
  margin: 0 auto;
}

.header-content h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, #ffffff 30%, #a99dff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.group-badge {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--accent);
  background: var(--badge-bg);
  padding: 3px 10px;
  border-radius: 12px;
  -webkit-text-fill-color: var(--accent);
  border: 1px solid rgba(139, 124, 255, 0.22);
  box-shadow: 0 0 16px rgba(139, 124, 255, 0.15);
  animation: badgeGlow 3.5s ease-in-out infinite;
}

@keyframes badgeGlow {
  0%, 100% { box-shadow: 0 0 16px rgba(139, 124, 255, 0.15); }
  50%      { box-shadow: 0 0 24px rgba(139, 124, 255, 0.4); }
}

/* ========================================================================== 
   Segmented Controls
   ========================================================================== */
.segmented-control {
  display: flex;
  background: var(--segment-bg);
  padding: 2px;
  border-radius: 9px;
  position: relative;
  border: 1px solid var(--card-border);
  overflow: hidden;
}

.segment {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 0;
  border-radius: 7px;
  cursor: pointer;
  transition:
    background 0.25s var(--ease-out),
    color 0.25s var(--ease-out),
    transform 0.15s var(--ease-out),
    box-shadow 0.3s var(--ease-out);
  text-align: center;
  position: relative;
}

.segment.active {
  background: var(--segment-active);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--segment-active-shadow);
  animation: segmentPop 0.35s var(--ease-spring);
}

@keyframes segmentPop {
  0%   { transform: scale(0.92); }
  100% { transform: scale(1); }
}

.segment:active {
  transform: scale(0.96);
  opacity: 0.85;
}

/* ========================================================================== 
   Cards container + staggered entrance
   ========================================================================== */
.cards-container {
  max-width: 600px;
  margin: 16px auto 0;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.25s var(--ease-out),
    transform 0.25s var(--ease-out);
}

.cards-container.fade-out {
  opacity: 0;
  transform: translateY(8px) scale(0.99);
}

/* плавное появление каждой карточки друг за другом */
.cards-container > * {
  animation: cardEnter 0.55s var(--ease-out) both;
}

.cards-container > *:nth-child(1) { animation-delay: 0.05s; }
.cards-container > *:nth-child(2) { animation-delay: 0.10s; }
.cards-container > *:nth-child(3) { animation-delay: 0.15s; }
.cards-container > *:nth-child(4) { animation-delay: 0.20s; }
.cards-container > *:nth-child(5) { animation-delay: 0.25s; }
.cards-container > *:nth-child(6) { animation-delay: 0.30s; }
.cards-container > *:nth-child(n+7) { animation-delay: 0.35s; }

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* ========================================================================== 
   Skeleton + shimmer
   ========================================================================== */
.skeleton-card {
  height: 120px;
  background: var(--skeleton-bg);
  border-radius: var(--radius);
  animation: iosPulse 1.6s ease-in-out infinite;
  border: 1px solid var(--card-border);
  position: relative;
  overflow: hidden;
}

.skeleton-card::after {
  content: '';
  position: absolute;
  top: 0; left: -60%;
  width: 60%; height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(139, 124, 255, 0.12),
    transparent
  );
  animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-card:nth-child(2)::after { animation-delay: 0.2s; }
.skeleton-card:nth-child(3)::after { animation-delay: 0.4s; }

@keyframes iosPulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.85; }
}

@keyframes shimmer {
  0%   { left: -60%; }
  100% { left: 160%; }
}

/* ========================================================================== 
   Day
   ========================================================================== */
.day-header {
  font-size: 13px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  margin-left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.today-badge {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: 0 0 16px rgba(139, 124, 255, 0.35);
  animation: todayPulse 2s ease-in-out infinite;
}

@keyframes todayPulse {
  0%, 100% {
    box-shadow: 0 0 16px rgba(139, 124, 255, 0.35);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 26px rgba(139, 124, 255, 0.65);
    transform: scale(1.05);
  }
}

.day-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 0.5px solid var(--card-border);
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    border-color 0.3s var(--ease-out),
    box-shadow 0.3s var(--ease-out);
}

.day-card:hover {
  border-color: rgba(139, 124, 255, 0.3);
  box-shadow:
    var(--shadow-card),
    0 0 40px rgba(139, 124, 255, 0.1);
}

/* ========================================================================== 
   Lesson rows
   ========================================================================== */
.lesson-row {
  display: flex;
  padding: 14px 16px;
  position: relative;
  transition: background-color 0.2s var(--ease-out);
  overflow: hidden;
}

/* ripple-волна при клике/тапе */
.lesson-row::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--tap-x, 50%) var(--tap-y, 50%), rgba(139, 124, 255, 0.18), transparent 60%);
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
  pointer-events: none;
}

.lesson-row:active::before { opacity: 1; }

.lesson-row:active {
  background-color: rgba(255, 255, 255, 0.04);
}

.lesson-row:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 84px;
  right: 0;
  height: 0.5px;
  background: var(--separator);
}

/* время */
.time-col {
  width: 68px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 1px;
}

.start-time {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  transition: color 0.3s var(--ease-out);
}

.end-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}

.info-col {
  flex: 1;
  min-width: 0;
  user-select: text;
  -webkit-user-select: text;
}

.lesson-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 5px;
  word-break: break-word;
}

.lesson-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 3px;
  flex-wrap: wrap;
}

.type-badge {
  background: var(--type-badge-bg);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 600;
  font-size: 11px;
  border: 1px solid var(--card-border);
  transition: all 0.25s var(--ease-out);
}

.lesson-row:hover .type-badge {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(139, 124, 255, 0.3);
}

.lesson-teacher {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  transition: color 0.25s var(--ease-out);
}

/* ===== Текущая пара — светящаяся полоса + пульс ===== */
.lesson-row.current {
  background: var(--accent-soft);
  animation: currentGlow 3s ease-in-out infinite;
}

@keyframes currentGlow {
  0%, 100% { background: var(--accent-soft); }
  50%      { background: rgba(139, 124, 255, 0.22); }
}

.lesson-row.current::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
  box-shadow: 0 0 12px rgba(139, 124, 255, 0.5);
  animation: currentBar 2s ease-in-out infinite;
}

@keyframes currentBar {
  0%, 100% { box-shadow: 0 0 12px rgba(139, 124, 255, 0.5); }
  50%      { box-shadow: 0 0 20px rgba(139, 124, 255, 0.9); }
}

.lesson-row.current .start-time {
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 0 12px rgba(139, 124, 255, 0.6);
}

/* пульсирующая точка «сейчас» рядом со временем */
.lesson-row.current .start-time::after {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: livePulse 1.6s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes livePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.4); opacity: 0.6; }
}

.day-off {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  animation: cardEnter 0.5s var(--ease-out) both;
}

/* ========================================================================== 
   Tab Bar
   ========================================================================== */
.liquid-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--glass-bg);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border-top: 0.5px solid var(--separator);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  animation: tabBarSlideUp 0.7s var(--ease-out) both;
}

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

.tab-btn {
  background: none;
  border: none;
  outline: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition:
    transform 0.2s var(--ease-spring),
    opacity 0.15s ease,
    color 0.25s ease;
  width: 72px;
  position: relative;
}

.tab-btn svg {
  width: 24px;
  height: 24px;
  transition: transform 0.25s var(--ease-spring);
}

.tab-btn:active {
  transform: scale(0.9);
  opacity: 0.7;
}

.tab-btn:active svg {
  transform: scale(0.85);
}

.tab-btn.active {
  color: var(--accent);
}

.tab-btn.active svg {
  transform: translateY(-1px);
  filter: drop-shadow(0 0 8px rgba(139, 124, 255, 0.6));
}

/* точка под активным табом */
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: livePulse 1.6s ease-in-out infinite;
}

.footer-info {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 28px 0 16px;
  font-weight: 400;
  animation: cardEnter 0.6s var(--ease-out) both;
}

/* ========================================================================== 
   PWA Popup
   ========================================================================== */
#pwa-popup {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--glass-bg);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border: 0.5px solid var(--separator);
  border-radius: 16px;
  padding: 14px 18px;
  width: 90%;
  max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s var(--ease-spring);
  z-index: 999;
}

#pwa-popup.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.pwa-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.pwa-desc {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
  line-height: 1.4;
}

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