@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

@keyframes fadeInDust {
  0% {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
    filter: blur(8px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

@keyframes slideInRight {
  0% {
    opacity: 0;
    transform: translateX(30px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Базовые цвета для темной темы */
:root {
  --bg-primary: #0a0b0d;
  --bg-secondary: #1a1d23;
  --bg-tertiary: #252831;
  --surface: #2a2e3a;
  --surface-hover: #343842;
  
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  
  --border-primary: #334155;
  --border-secondary: #475569;
  
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* Светлая тема */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  
  --border-primary: #e2e8f0;
  --border-secondary: #cbd5e1;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
  line-height: 1.6;
  font-weight: 400;
}

header {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-primary);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 2rem;
  animation: fadeInDust 0.8s ease-out forwards;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.5rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.025em;
}

.logo i {
  font-size: 1.8rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.theme-toggle {
  position: relative;
  width: 60px;
  height: 30px;
  background: var(--bg-tertiary);
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  overflow: hidden;
}

.theme-toggle::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: var(--accent-gradient);
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  left: 2px;
  box-shadow: var(--shadow-md);
}

[data-theme="light"] .theme-toggle::before {
  transform: translateX(28px);
}

.theme-toggle i {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all 0.3s ease;
  z-index: 1;
}

.theme-toggle .fa-sun {
  color: var(--warning);
}

.theme-toggle .fa-moon {
  color: var(--accent-primary);
}

nav {
  display: flex;
  gap: 0.5rem;
  animation: slideInRight 0.8s ease-out 0.2s forwards;
  opacity: 0;
}

nav button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  white-space: nowrap;
  font-family: inherit;
}

nav button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  opacity: 0;
  transition: opacity 0.3s ease;
}

nav button span {
  position: relative;
  z-index: 1;
}

nav button:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

nav button.active {
  color: white;
  background: var(--accent-primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

nav button.active::before {
  opacity: 1;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
  animation: fadeInDust 0.8s ease-out 0.4s forwards;
  opacity: 0;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  font-size: 1.1rem;
  color: var(--text-muted);
  animation: bounceIn 0.6s ease-out;
}

.post {
  background: var(--surface);
  border-radius: var(--radius-xl);
  margin-bottom: 2.5rem;
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-primary);
  position: relative;
  animation: fadeInDust 0.8s ease-out both;
  transition: all 0.3s ease;
  overflow: hidden;
}

.post::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-gradient);
}

.post:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.post h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.post p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

figure {
  margin: 2rem 0;
  text-align: center;
}

figure img {
  max-width: 100%;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-primary);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

figure img:hover {
  transform: scale(1.02) rotateZ(0.5deg);
  box-shadow: var(--shadow-xl);
}

figcaption {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-style: italic;
}

.macros {
  margin-top: 2rem;
  display: grid;
  gap: 1.5rem;
}

.macro-block {
  background: var(--bg-tertiary);
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  animation: fadeInDust 0.8s ease-out forwards;
  transition: all 0.3s ease;
  overflow: hidden;
}

.macro-block::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-gradient);
}

.macro-block:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-primary);
}

.macro-label {
  background: var(--accent-gradient);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: inline-block;
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.025em;
}

.macro-text {
  font-family: 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
  font-size: 0.95rem;
  white-space: pre-wrap;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.6;
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-secondary);
  margin-bottom: 1rem;
}

.copy-btn {
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: 0.025em;
}

.copy-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.copy-btn:active {
  transform: translateY(0);
}

.copy-btn.copied {
  background: var(--success);
  transform: scale(1.05);
}

.copy-btn::before {
  content: '\f0c5';
  font-family: 'Font Awesome 6 Free';
  font-weight: 400;
}

.copy-btn.copied::before {
  content: '\f00c';
  font-weight: 900;
}

.video-toggle {
  margin-top: 2rem;
}

.video-toggle .copy-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 2px solid var(--border-primary);
}

.video-toggle .copy-btn:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.video-wrapper {
  margin-top: 1.5rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.video-player video {
  width: 100%;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
}

.video-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  align-items: center;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
}

.video-controls label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.video-controls select,
.video-controls input[type="range"] {
  background: var(--surface);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  color: var(--text-primary);
  font-family: inherit;
}

.video-controls button {
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

.video-controls button:hover {
  background: var(--accent-secondary);
  transform: translateY(-1px);
}

/* Адаптивный дизайн */
@media (max-width: 1024px) {
  main {
    padding: 2rem 1.5rem 3rem;
  }
  
  .post {
    padding: 2rem;
  }
}

@media (max-width: 768px) {
  header {
    padding: 0 1rem;
    flex-wrap: wrap;
    min-height: auto;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  
  .header-controls {
    gap: 1rem;
    order: 2;
    flex: 1;
    justify-content: space-between;
    margin-top: 1rem;
  }
  
  .logo {
    font-size: 1.25rem;
    order: 1;
  }
  
  nav {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
  }
  
  nav button {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }
  
  main {
    padding: 1.5rem 1rem 2rem;
  }
  
  .post {
    padding: 1.5rem;
    margin-bottom: 2rem;
  }
  
  .post h2 {
    font-size: 1.5rem;
  }
  
  .macros {
    gap: 1rem;
  }
  
  .macro-block {
    padding: 1rem;
  }
  
  .video-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .video-controls label {
    justify-content: space-between;
  }
}

@media (max-width: 480px) {
  .logo span {
    display: none;
  }
  
  .logo::after {
    content: 'ДБ Памятка';
  }
  
  .post {
    padding: 1rem;
  }
  
  .post h2 {
    font-size: 1.25rem;
  }
  
  .copy-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }
}

/* Скроллбар */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Анимация для nav при загрузке */
@keyframes navAnimation {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

nav {
  animation: navAnimation 0.6s ease-out 0.3s forwards;
}

/* Улучшенные фокус состояния */
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Плавные переходы для всех интерактивных элементов */
button, select, input, .macro-block, .post, .theme-toggle {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Группировка макросов */
.macros-group {
  background: var(--bg-tertiary);
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-lg);
  margin-top: 2rem;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.macros-group::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-gradient);
}

.macros-group .expandable-header {
  padding: 1.5rem 2rem;
  border-bottom: none;
}

.macros-group .expandable-header .macros-group-title {
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
}

.macros-group .expandable-header .macros-group-title i {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.macros-group .expandable-content {
  padding: 0;
}

.macros-group.expanded .expandable-content {
  padding: 0 2rem 2rem 2rem;
}

.macros-group .macros {
  margin-top: 0;
  gap: 1rem;
}

.macros-group .macro-block {
  background: var(--surface);
  border: 1px solid var(--border-secondary);
  margin-bottom: 0;
}

.macros-group .macro-block::before {
  background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
  width: 3px;
}

/* Раскрывающиеся блоки */
.expandable-block {
  background: var(--bg-tertiary);
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

.expandable-header {
  background: var(--surface);
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--text-primary);
  transition: all 0.3s ease;
  border-bottom: 1px solid var(--border-primary);
}

.expandable-header:hover {
  background: var(--surface-hover);
  color: var(--accent-primary);
}

.expandable-header i {
  transition: transform 0.3s ease;
  color: var(--accent-primary);
}

.expandable-block.expanded .expandable-header i {
  transform: rotate(180deg);
}

.expandable-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
  padding: 0 1.5rem;
}

.expandable-block.expanded .expandable-content {
  max-height: 2000px;
  padding: 1.5rem;
}

.expandable-content .text-content {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 1rem;
}

.expandable-content .text-content h3 {
  color: var(--accent-primary);
  font-size: 1.1rem;
  margin: 1rem 0 0.5rem 0;
  font-weight: 600;
}

.expandable-content .text-content ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.expandable-content .text-content li {
  margin: 0.25rem 0;
}

/* Улучшенные макро-блоки в группах */
.question-item {
  background: var(--surface);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
}

.question-item:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.question-header {
  padding: 1rem 1.25rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-secondary);
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.question-header i {
  color: var(--accent-primary);
  font-size: 0.9rem;
}

.question-content {
  padding: 1rem 1.25rem;
  position: relative;
}

.question-text {
  font-family: 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  margin-bottom: 1rem;
  background: var(--bg-primary);
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-primary);
}

.question-copy-btn {
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: absolute;
  top: 1rem;
  right: 1.25rem;
}

.question-copy-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.question-copy-btn.copied {
  background: var(--success);
  transform: scale(1.05);
}

/* Индикатор количества элементов */
.count-badge {
  background: var(--accent-gradient);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  margin-left: auto;
}

/* Анимации для новых элементов */
@keyframes slideDown {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.question-item {
  animation: slideDown 0.5s ease-out forwards;
  opacity: 0;
}

.macros-group {
  animation: fadeInDust 0.8s ease-out forwards;
}

.expandable-block {
  animation: slideDown 0.6s ease-out forwards;
  opacity: 0;
}

/* Улучшенные hover эффекты */
.macros-group:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--accent-primary);
}

.expandable-block:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

/* Красивые скроллбары для раскрывающегося контента */
.expandable-content::-webkit-scrollbar {
  width: 6px;
}

.expandable-content::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.expandable-content::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 3px;
}

/* Улучшенные состояния focus */
.expandable-header:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Дополнительные стили для длинного текста */
.text-content {
  max-height: 400px;
  overflow-y: auto;
}

.text-content p {
  margin-bottom: 1rem;
}

.text-content strong {
  color: var(--accent-primary);
  font-weight: 600;
}

.text-content em {
  color: var(--accent-secondary);
  font-style: italic;
}

.text-content a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 500;
  position: relative;
  transition: all 0.3s ease;
}

.text-content a:hover {
  color: var(--accent-secondary);
  text-decoration: underline;
}

.text-content a::before {
  content: '\f35d';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-right: 0.25rem;
  font-size: 0.8rem;
}

/* Обычные параграфы постов */
.post > p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.post > p a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
}

.post > p a:hover {
  color: var(--accent-secondary);
  text-decoration: underline;
}

.post > p a::before {
  content: '\f35d';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-right: 0.25rem;
  font-size: 0.8rem;
}

/* Анимация для счетчика */
.count-badge {
  animation: pulse 2s infinite;
}

.macros-group:hover .count-badge {
  animation: none;
  transform: scale(1.1);
}

/* Дополнительные эффекты для интерактивности */
.question-item:nth-child(even) {
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-tertiary) 100%);
}

.question-item:nth-child(odd) {
  background: var(--surface);
}

/* Эффект для кнопок при нажатии */
.copy-btn:active,
.question-copy-btn:active {
  transform: scale(0.95);
}

/* Улучшенная анимация для expandable блоков */
.expandable-block.expanded {
  border-color: var(--accent-primary);
}

.expandable-header {
  user-select: none;
}

.expandable-header:active {
  transform: scale(0.98);
}
