/* theme.css */
.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: clamp(15px, 3vw, 20px);
  padding: clamp(15px, 3vw, 20px);
}

.puzzle-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: clamp(12px, 2.5vw, 15px);
  background: white;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.puzzle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.puzzle-header h3 {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  margin: 0;
}

.puzzle-board {
  width: 100%;
  aspect-ratio: 1;
  margin: 10px 0;
  position: relative;
}

.puzzle-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 10px;
}

.solved-icon {
  color: #4CAF50;
  font-size: 1.8em;
}

.puzzle-practice {
  color: #666;
  font-style: italic;
}

.solve-button {
  padding: clamp(6px, 1.5vw, 8px) clamp(12px, 3vw, 16px);
  background-color: #73a3de;
  color: white;
  border: none;
  border-radius: 6px;
  text-decoration: none;
  transition: background-color 0.3s;
  font-size: clamp(0.85rem, 2vw, 0.9rem);
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.solve-button:hover {
  background-color: #5a8ad0;
}

.unsolved-puzzle {
  transition: box-shadow 0.5s ease;
}

@keyframes highlightPuzzle {
  0% { box-shadow: 0 0 5px rgba(115, 163, 222, 0.5); }
  50% { box-shadow: 0 0 15px rgba(115, 163, 222, 0.9); }
  100% { box-shadow: 0 0 5px rgba(115, 163, 222, 0.5); }
}

/* Стили для модального окна */
.video-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.7);
  z-index: 1000;
}

.video-modal-content {
  position: relative;
  width: 80%;
  max-width: 800px;
  margin: 50px auto;
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.video-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 20px 0;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Стили для индикатора хода в задаче */
.turn-indicator {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  margin-right: 8px;
  position: relative;
  top: 2px;
}

.turn-white {
  border-bottom: 16px solid #ffffff;
  filter: drop-shadow(0px 1px 1px rgba(0, 0, 0, 0.5));
}

.turn-black {
  border-bottom: 16px solid #000000;
}

.turn-indicator-container {
  display: flex;
  align-items: center;
  margin-top: 5px;
  margin-bottom: 10px;
  padding-left: 5px;
  font-size: clamp(0.85rem, 2vw, 0.95rem);
}

/* Стили для пагинации */
.pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 30px 0;
  gap: 5px;
}

.pagination-item {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #dee2e6;
  background-color: #fff;
  color: #333;
  text-decoration: none;
  border-radius: 4px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.pagination-item:hover {
  background-color: #f0f0f0;
  border-color: #ced4da;
  z-index: 2;
}

.pagination-item.active {
  background-color: #007bff;
  border-color: #007bff;
  color: white;
  z-index: 3;
}

.pagination-item.dots {
  border: none;
  padding: 0 5px;
}

.pagination-item.disabled {
  color: #6c757d;
  pointer-events: none;
  background-color: #fff;
  border-color: #dee2e6;
}

/* Стили для кнопки печати */
.print-button {
  width: 36px;
  height: 36px;
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.3s;
}

.print-button:hover {
  background-color: #e2e6ea;
}

.print-button i {
  color: #495057;
}

.print-button.added {
  background-color: #d4edda;
  border-color: #c3e6cb;
}

.print-button.added i {
  color: #155724;
}

/* Анимация добавления */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.pulse {
  animation: pulse 0.5s ease-in-out;
}

/* СТИЛИ ДЛЯ ЗАГОЛОВКА ТЕМЫ */
.theme-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: clamp(15px, 3vw, 25px);
  margin-bottom: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

/* ПЕРВЫЙ ЭЛЕМЕНТ - НАЗВАНИЕ ТЕМЫ */
.theme-title-section {
  text-align: center;
  margin-bottom: clamp(15px, 3vw, 20px);
  order: 0;
  padding-top: 0;
}

.theme-main-title {
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  font-weight: 700;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  line-height: 1.2;
  word-wrap: break-word;
  hyphens: auto;
}

/* ВТОРОЙ ЭЛЕМЕНТ - НОМЕР ТЕМЫ */
.theme-subtitle-section {
  text-align: center;
  margin-bottom: clamp(15px, 3vw, 20px);
  order: 2;
  padding: clamp(8px, 2vw, 12px);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  backdrop-filter: blur(5px);
}

.theme-subtitle-section .theme-subtitle {
  font-size: clamp(0.8rem, 2vw, 1rem);
  opacity: 0.9;
  font-weight: 500;
  margin: 0;
  color: white;
}

/* ТРЕТИЙ ЭЛЕМЕНТ - ПРОГРЕСС И СТАТИСТИКА */
.theme-progress-section {
  order: 3;
  margin-bottom: clamp(15px, 3vw, 20px);
}

.theme-progress-section .theme-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(15px, 3vw, 25px);
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 12px);
  padding: clamp(8px, 2vw, 12px) clamp(12px, 3vw, 16px);
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  min-width: 100px;
  max-width: 160px;
  transition: transform 0.3s ease, background 0.3s ease;
}

.stat-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.2);
}

.stat-icon {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  opacity: 0.9;
  min-width: clamp(24px, 5vw, 30px);
  text-align: center;
  flex-shrink: 0;
}

.stat-icon.solved {
  color: #4CAF50;
}

.stat-content {
  text-align: left;
  min-width: 0;
  flex: 1;
}

.stat-number {
  font-size: clamp(1.1rem, 2.8vw, 1.4rem);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 2px;
}

.stat-label {
  font-size: clamp(0.65rem, 1.8vw, 0.75rem);
  opacity: 0.8;
  line-height: 1.1;
  word-wrap: break-word;
}

.progress-stat {
  position: relative;
}

.circular-progress {
  position: relative;
  width: 60px;
  height: 60px;
}

.progress-ring {
  transform: rotate(-90deg);
  width: 60px;
  height: 60px;
}

.progress-ring-background,
.progress-ring-circle {
  fill: none;
  stroke-width: 5;
}

.progress-ring-background {
  stroke: rgba(255, 255, 255, 0.2);
}

.progress-ring-circle {
  stroke: #4CAF50;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease-in-out;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.progress-percentage {
  font-size: clamp(0.7rem, 1.8vw, 0.85rem);
  font-weight: 700;
  line-height: 1;
}

/* ЧЕТВЕРТЫЙ ЭЛЕМЕНТ - ОПИСАНИЕ */
.theme-description {
  text-align: center;
  margin-bottom: clamp(15px, 3vw, 20px);
  padding: clamp(12px, 2.5vw, 15px);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  backdrop-filter: blur(5px);
  order: 4;
}

.theme-description p {
  margin: 0;
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  line-height: 1.5;
  opacity: 0.9;
}

/* ПЯТЫЙ ЭЛЕМЕНТ - КНОПКИ */
.theme-buttons {
  display: flex;
  justify-content: center;
  gap: clamp(6px, 1.5vw, 10px);
  flex-wrap: wrap;
  order: 5;
}

.theme-buttons .u-btn {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1vw, 6px);
  padding: clamp(8px, 1.5vw, 10px) clamp(10px, 2vw, 14px);
  font-size: clamp(0.75rem, 1.6vw, 0.85rem);
  font-weight: 600;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.15);
  color: white;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  text-decoration: none;
  border-radius: 20px;
  white-space: nowrap;
  min-height: 38px;
}

.theme-buttons .u-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-back {
  background: rgba(220, 53, 69, 0.8) !important;
  border-color: rgba(220, 53, 69, 0.8) !important;
}

.btn-back:hover {
  background: rgba(220, 53, 69, 1) !important;
  border-color: rgba(220, 53, 69, 1) !important;
}

.btn-continue {
  background: rgba(40, 167, 69, 0.8) !important;
  border-color: rgba(40, 167, 69, 0.8) !important;
  display: flex !important;
}

.btn-continue:hover {
  background: rgba(40, 167, 69, 1) !important;
  border-color: rgba(40, 167, 69, 1) !important;
}

.btn-instructions {
  background: rgba(0, 123, 255, 0.8) !important;
  border-color: rgba(0, 123, 255, 0.8) !important;
}

.btn-instructions:hover {
  background: rgba(0, 123, 255, 1) !important;
  border-color: rgba(0, 123, 255, 1) !important;
}

.btn-video {
  background: rgba(255, 193, 7, 0.8) !important;
  border-color: rgba(255, 193, 7, 0.8) !important;
  color: #212529 !important;
}

.btn-video:hover {
  background: rgba(255, 193, 7, 1) !important;
  border-color: rgba(255, 193, 7, 1) !important;
  color: #212529 !important;
}

/* Медиа-запросы для больших экранов */
@media (min-width: 1200px) {
  .theme-progress-section .theme-stats {
      max-width: 600px;
      margin-left: auto;
      margin-right: auto;
  }

  .theme-main-title {
      font-size: 2.2rem;
  }

  .theme-subtitle-section .theme-subtitle {
      font-size: 0.95rem;
  }
}

/* Медиа-запросы для планшетов и мобильных */
@media (max-width: 768px) {
  .btn-text-desktop {
      display: none !important;
  }

  .theme-buttons .u-btn {
      min-width: 40px;
      padding: 8px;
      justify-content: center;
  }

  .theme-buttons .u-btn i {
      margin: 0;
  }

  .theme-header {
      padding: clamp(12px, 2.5vw, 18px);
  }

  .theme-progress-section .theme-stats {
      gap: 12px;
      margin-bottom: clamp(12px, 2.5vw, 16px);
  }

  .stat-item {
      min-width: 85px;
      max-width: 130px;
      padding: 6px 10px;
  }

  .circular-progress {
      width: 45px;
      height: 45px;
  }

  .progress-ring {
      width: 45px;
      height: 45px;
  }

  .progress-ring-background,
  .progress-ring-circle {
      cx: 22.5;
      cy: 22.5;
      r: 18;
      stroke-width: 4;
  }

  .theme-buttons {
      gap: 6px;
  }
}

@media (max-width: 480px) {
  .theme-header {
      margin-left: -10px;
      margin-right: -10px;
      border-radius: 0 0 15px 15px;
      padding: 15px;
  }

  .theme-progress-section .theme-stats {
      flex-direction: row;
      justify-content: space-around;
      gap: 6px;
  }

  .stat-item {
      flex-direction: column;
      text-align: center;
      gap: 2px;
      padding: 8px 6px;
      min-width: 70px;
      max-width: 80px;
  }

  .stat-content {
      text-align: center;
  }

  .circular-progress {
      width: 40px;
      height: 40px;
  }

  .progress-ring {
      width: 40px;
      height: 40px;
  }

  .progress-ring-background,
  .progress-ring-circle {
      cx: 20;
      cy: 20;
      r: 16;
      stroke-width: 3;
  }

  .theme-buttons .u-btn {
      min-width: 36px;
      min-height: 36px;
      padding: 8px;
      border-radius: 18px;
  }
}

@media (max-width: 375px) {
  .theme-header {
      padding: 12px;
  }

  .theme-title-section {
      margin-bottom: 10px;
  }

  .theme-main-title {
      font-size: 1rem;
      line-height: 1.1;
  }

  .theme-subtitle-section .theme-subtitle {
      font-size: 0.7rem;
  }

  .theme-progress-section .theme-stats {
      gap: 4px;
      margin-bottom: 10px;
  }

  .stat-item {
      min-width: 60px;
      max-width: 70px;
      padding: 6px 4px;
  }

  .stat-number {
      font-size: 0.8rem;
  }

  .stat-label {
      font-size: 0.5rem;
  }

  .circular-progress {
      width: 35px;
      height: 35px;
  }

  .progress-ring {
      width: 35px;
      height: 35px;
  }

  .progress-ring-background,
  .progress-ring-circle {
      cx: 17.5;
      cy: 17.5;
      r: 14;
      stroke-width: 2.5;
  }

  .progress-percentage {
      font-size: 0.55rem;
  }

  .theme-buttons .u-btn {
      min-width: 32px;
      min-height: 32px;
      padding: 6px;
  }

  .theme-buttons .u-btn i {
      font-size: 0.8rem;
  }
}

@media (max-width: 320px) {
  .theme-header {
      padding: 10px;
  }

  .theme-title-section {
      margin-bottom: 8px;
  }

  .theme-main-title {
      font-size: 0.95rem;
      line-height: 1;
  }

  .theme-subtitle-section .theme-subtitle {
      font-size: 0.6rem;
  }

  .theme-progress-section .theme-stats {
      gap: 3px;
      margin-bottom: 8px;
  }

  .stat-item {
      min-width: 50px;
      max-width: 60px;
      padding: 4px 2px;
  }

  .stat-icon {
      font-size: 0.9rem;
      min-width: 16px;
  }

  .stat-number {
      font-size: 0.75rem;
  }

  .stat-label {
      font-size: 0.45rem;
  }

  .circular-progress {
      width: 30px;
      height: 30px;
  }

  .progress-ring {
      width: 30px;
      height: 30px;
  }

  .progress-ring-background,
  .progress-ring-circle {
      cx: 15;
      cy: 15;
      r: 12;
      stroke-width: 2;
  }

  .progress-percentage {
      font-size: 0.45rem;
  }

  .theme-buttons .u-btn {
      min-width: 30px;
      min-height: 30px;
      padding: 5px;
  }

  .theme-buttons .u-btn i {
      font-size: 0.75rem;
  }
}

/* Улучшения для accessibility */
@media (prefers-reduced-motion: reduce) {
  .theme-buttons .u-btn,
  .stat-item,
  .progress-ring-circle {
      transition: none;
  }

  .theme-buttons .u-btn:hover {
      transform: none;
  }

  .stat-item:hover {
      transform: none;
  }
}

/* Темная тема для устройств с поддержкой */
@media (prefers-color-scheme: dark) {
  .puzzle-card {
      background: #2d3748;
      border-color: #4a5568;
      color: #e2e8f0;
  }

  .solve-button {
      background-color: #4299e1;
  }

  .solve-button:hover {
      background-color: #3182ce;
  }
}

/* Стили для высоких DPI экранов */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .theme-header {
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  }

  .theme-main-title {
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  }
}
