/**
 * Flowing Wall - Infinite Scrolling Animation
 * Inspired by Flowing-CD-Wall project
 * Integrated with ToolsKit theme system
 */

/* ========== Container Styles ========== */
.flowing-wall-container {
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  padding: 20px 0;
}

.flowing-wall-header {
  text-align: center;
  padding: 20px;
  margin-bottom: 30px;
}

.flowing-wall-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.flowing-wall-header p {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

/* ========== Control Panel ========== */
.flowing-wall-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.control-btn {
  padding: 10px 20px;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.3s;
}

.control-btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.control-btn.active {
  background-color: #10b981;
}

.speed-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-right: 5px;
}

/* ========== Scroll Row ========== */
.scroll-row {
  display: flex;
  width: 100vw;
  overflow: hidden;
  margin: 15px 0;
  /* Edge fade effect */
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}

.scroll-content {
  display: flex;
  white-space: nowrap;
  animation: scroll-left var(--scroll-duration, 30s) linear infinite;
  animation-delay: calc(var(--scroll-duration, 30s) * -1);
}

.scroll-content:nth-child(2) {
  animation: scroll-left2 var(--scroll-duration, 30s) linear infinite;
  animation-delay: calc(var(--scroll-duration, 30s) / -2);
}

/* Pause animation on hover */
.scroll-row:hover .scroll-content {
  animation-play-state: paused;
}

/* ========== Animations ========== */
@keyframes scroll-left {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}

@keyframes scroll-left2 {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-200%);
  }
}

/* Reverse animation for alternating rows */
.scroll-row.reverse .scroll-content {
  animation: scroll-right var(--scroll-duration, 30s) linear infinite;
  animation-delay: calc(var(--scroll-duration, 30s) * -1);
}

.scroll-row.reverse .scroll-content:nth-child(2) {
  animation: scroll-right2 var(--scroll-duration, 30s) linear infinite;
  animation-delay: calc(var(--scroll-duration, 30s) / -2);
}

@keyframes scroll-right {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes scroll-right2 {
  0% {
    transform: translateX(-200%);
  }
  100% {
    transform: translateX(0);
  }
}

/* ========== Card Styles ========== */
.knowledge-card {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 200px;
  height: 220px;
  margin: 0 10px;
  padding: 20px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.knowledge-card:hover {
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
}

/* Card types with gradient backgrounds */
.card-idiom {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.card-poem {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.card-word {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

.card-emoji {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.card-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  word-break: break-word;
  white-space: normal;
  line-height: 1.3;
}

.card-subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
  white-space: normal;
  line-height: 1.4;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ========== Detail Modal ========== */
.detail-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s;
}

.detail-modal.show {
  display: flex;
}

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

.detail-content {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: 40px;
  border-radius: 20px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s;
  position: relative;
}

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

.detail-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s;
  line-height: 1;
  padding: 5px 10px;
}

.detail-close:hover {
  color: var(--text-primary);
}

.detail-emoji {
  font-size: 4rem;
  text-align: center;
  margin-bottom: 20px;
}

.detail-title {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 20px;
  color: var(--accent);
}

.detail-info {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.detail-info strong {
  color: var(--text-primary);
  display: block;
  margin-top: 15px;
  margin-bottom: 5px;
}

/* ========== Exit Hint ========== */
.exit-hint {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.9rem;
  z-index: 100;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-10px);
  }
}

/* ========== Responsive Design ========== */
@media screen and (max-width: 768px) {
  .flowing-wall-header h1 {
    font-size: 1.8rem;
  }

  .flowing-wall-header p {
    font-size: 1rem;
  }

  .knowledge-card {
    width: 160px;
    height: 180px;
    padding: 15px;
  }

  .card-emoji {
    font-size: 2rem;
  }

  .card-title {
    font-size: 1.2rem;
  }

  .card-subtitle {
    font-size: 0.8rem;
  }

  .detail-content {
    padding: 30px 20px;
  }

  .detail-title {
    font-size: 1.5rem;
  }

  .detail-info {
    font-size: 1rem;
  }

  /* Mobile: reduce to 2 rows (hide 3rd row - words) */
  .flowing-wall-container .scroll-row:nth-of-type(3) {
    display: none !important;
  }
}

@media screen and (max-width: 480px) {
  .knowledge-card {
    width: 140px;
    height: 160px;
    padding: 12px;
    margin: 0 8px;
  }

  .card-emoji {
    font-size: 1.8rem;
  }

  .card-title {
    font-size: 1.1rem;
  }

  .card-subtitle {
    font-size: 0.75rem;
  }
}

/* ========== Paused State ========== */
.flowing-wall-container.paused .scroll-content {
  animation-play-state: paused !important;
}

/* ========== Speed Classes ========== */
.speed-slow {
  --scroll-duration: 40s;
}

.speed-medium {
  --scroll-duration: 25s;
}

.speed-fast {
  --scroll-duration: 15s;
}
