/* ── Load-in animations ── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Theme transition fade ── */
@keyframes themeFadeIn {
  from {
    opacity: 0.92;
  }
  to {
    opacity: 1;
  }
}

/* ── Smooth Rotation ── */
@keyframes smoothRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Navigation */
nav {
  opacity: 1;
}

.nav-tabs {
  opacity: 1;
}

.nav-tab {
  transition: color 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.nav-tab:hover {
  transform: none;
  color: var(--text);
}

/* Preview Area */
.preview-area {
  opacity: 1;
}

.preview-wrap {
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.preview-wrap:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.preview-label {
  letter-spacing: 0.05em;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

canvas {
  transition: opacity 0.3s ease;
}

.control-group {
  opacity: 1;
}

.control-label {
  transition: color 0.2s ease;
  letter-spacing: 1.5px;
}

/* Style Grid (Patterns) */
.style-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.style-btn {
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.style-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.style-btn.active {
  transform: scale(1.03);
  box-shadow: 0 8px 20px rgba(240, 240, 240, 0.1);
}

/* Palette Swatches */
.palette-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.palette-swatch {
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.palette-swatch:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.palette-swatch.active {
  transform: scale(1.1);
  box-shadow: 0 8px 20px rgba(240, 240, 240, 0.2);
}

/* Mode Toggle */
.mode-toggle {
  opacity: 1;
}

.mode-btn {
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.mode-btn:hover {
  transform: none;
}

.mode-btn.active {
  box-shadow: 0 4px 12px rgba(240, 240, 240, 0.15);
}

/* Shuffle Button */
.btn-shuffle {
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.btn-shuffle:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.btn-shuffle:active {
  transform: translateY(0);
}

.btn-shuffle svg {
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-shuffle:hover svg {
  transform: rotate(-180deg);
}

.btn-shuffle svg.rotating {
  animation: smoothRotate 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Export Buttons */
.export-group {
  opacity: 1;
}

.btn-export {
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.btn-export:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.btn-export:active {
  transform: translateY(0);
}

.btn-desktop {
  opacity: 1;
}

.btn-mobile {
  opacity: 1;
}

.size-hint {
  font-size: 0.85rem;
}

/* Language Selector */
.language-selector-container {
  opacity: 1;
}

.language-btn {
  transition: all 0.2s ease;
}

.language-menu {
  animation: fadeInUp 0.25s ease-out;
}

.language-option {
  transition: all 0.2s ease;
}

.language-option:hover {
  transform: translateX(3px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.language-option-flag {
  transition: transform 0.2s ease;
  display: inline-block;
}

/* ── Micro-interactions ── */

/* Focus visible on buttons */
button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* Text transitions */
span, label {
  transition: color 0.2s ease;
}

/* Button cursor */
button {
  cursor: pointer;
}

/* ── Theme transition ── */
:root {
  transition: background-color 0.3s ease,
              color 0.3s ease;
}

main, .controls-panel {
  transition: background-color 0.3s ease;
}

/* ── Performance & Accessibility ── */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Mobile Optimizations ── */
@media (max-width: 768px) {
  .preview-wrap:hover {
    transform: translateY(-2px);
  }

  .style-btn:hover {
    transform: scale(1.02);
  }

  .palette-swatch:hover {
    transform: scale(1.08);
  }

  button {
    transition: all 0.2s ease;
  }
}