/* First-run onboarding. */

/* Backdrop */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tutorial-overlay.tutorial-visible {
  opacity: 1;
}

/* Tutorial card */
.tutorial-card {
  position: fixed;
  z-index: 10002;
  width: min(560px, 94vw);
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;


  background: linear-gradient(
    135deg,
    rgba(16, 20, 26, 0.95) 0%,
    rgba(24, 30, 38, 0.92) 100%
  );
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);


  border: 1px solid rgba(209, 191, 150, 0.2);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(209, 191, 150, 0.1) inset,
    0 1px 2px rgba(209, 191, 150, 0.15) inset;

  opacity: 0;
  transform: translateY(-20px) scale(0.96);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tutorial-card.tutorial-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tutorial-card-center {
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) scale(0.96) !important;
}

.tutorial-card-center.tutorial-visible {
  transform: translate(-50%, -50%) scale(1) !important;
}

/* Sheet layout */
.tutorial-sheet {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Header */
.tutorial-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.75rem 2rem 1.5rem;
  background: linear-gradient(
    180deg,
    rgba(209, 191, 150, 0.12) 0%,
    rgba(209, 191, 150, 0.04) 100%
  );
  border-bottom: 1px solid rgba(209, 191, 150, 0.15);
  position: relative;
}

.tutorial-sheet-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(209, 191, 150, 0.3) 50%,
    transparent
  );
}

.tutorial-header-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.tutorial-title {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  margin: 0;
  background: linear-gradient(
    135deg,
    #ffffff 0%,
    rgba(209, 191, 150, 1) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tutorial-step-counter {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

/* Close button */
.tutorial-close {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(209, 191, 150, 0.2);
  background: rgba(209, 191, 150, 0.08);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.tutorial-close:hover {
  transform: scale(1.05);
  background: rgba(209, 191, 150, 0.15);
  border-color: rgba(209, 191, 150, 0.35);
  box-shadow: 0 4px 12px rgba(209, 191, 150, 0.2);
}

.tutorial-close:active {
  transform: scale(0.98);
}

/* Scrollable content */
.tutorial-sheet-body {
  padding: 2rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.tutorial-description {
  color: var(--color-text-secondary);
  font-size: 1rem;
  line-height: 1.7;
  margin: 0 0 2rem 0;
  letter-spacing: 0.01em;
}

/* Progress indicator */
.tutorial-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tutorial-progress-fill {
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(209, 191, 150, 0.8) 0%,
    rgba(209, 191, 150, 1) 50%,
    rgba(173, 150, 93, 1) 100%
  );
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow:
    0 0 12px rgba(209, 191, 150, 0.5),
    0 1px 2px rgba(209, 191, 150, 0.3);
}

.tutorial-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3) 50%,
    transparent
  );
  animation: shimmer 2s infinite;
}

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

/* Actions */
.tutorial-sheet-actions {
  margin-top: auto;
  padding: 1.5rem 2rem;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(209, 191, 150, 0.15);
  background: linear-gradient(
    180deg,
    rgba(209, 191, 150, 0.04) 0%,
    rgba(0, 0, 0, 0.2) 100%
  );
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.875rem;
}

/* Tutorial actions */
.tutorial-btn {
  flex: 1;
  padding: 0.875rem 1.5rem;
  border-radius: 12px;
  border: none;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.tutorial-btn-primary {
  background: linear-gradient(
    135deg,
    rgba(209, 191, 150, 1) 0%,
    rgba(173, 150, 93, 1) 100%
  );
  color: #0f1419;
  box-shadow:
    0 4px 16px rgba(209, 191, 150, 0.35),
    0 1px 2px rgba(209, 191, 150, 0.2) inset;
  position: relative;
  overflow: hidden;
}

.tutorial-btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s;
}

.tutorial-btn-primary:hover::before {
  left: 100%;
}

.tutorial-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 24px rgba(209, 191, 150, 0.45),
    0 1px 2px rgba(209, 191, 150, 0.3) inset;
}

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

.tutorial-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(209, 191, 150, 0.2);
  color: var(--color-text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tutorial-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(209, 191, 150, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

/* Guided-control highlight */
.tutorial-highlight {
  border: 3px solid var(--color-accent-primary);
  border-radius: 12px;
  box-shadow:
    0 0 0 4px rgba(209, 191, 150, 0.2),
    0 0 24px rgba(209, 191, 150, 0.4);
  z-index: 10001;
  position: relative;
  animation: tutorialPulse 2.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.tutorial-highlight::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    rgba(209, 191, 150, 0.3),
    rgba(173, 150, 93, 0.3)
  );
  filter: blur(8px);
  z-index: -1;
  animation: tutorialGlow 2.5s ease-in-out infinite;
}

@keyframes tutorialPulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px rgba(209, 191, 150, 0.2),
      0 0 24px rgba(209, 191, 150, 0.4);
  }
  50% {
    box-shadow:
      0 0 0 8px rgba(209, 191, 150, 0.3),
      0 0 36px rgba(209, 191, 150, 0.6);
  }
}

@keyframes tutorialGlow {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Mobile */
@media (max-width: 768px) {
  .tutorial-card {
    width: calc(100vw - 1.5rem);
    max-height: calc(100vh - 1.5rem);
    border-radius: 18px;
  }

  .tutorial-sheet-header {
    padding: 1.5rem 1.25rem 1.25rem;
  }

  .tutorial-title {
    font-size: 1.25rem;
  }

  .tutorial-sheet-body {
    padding: 1.5rem 1.25rem;
  }

  .tutorial-description {
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
  }

  .tutorial-sheet-actions {
    padding: 1.25rem;
    flex-direction: column;
  }

  .tutorial-btn {
    width: 100%;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tutorial-overlay,
  .tutorial-card,
  .tutorial-highlight,
  .tutorial-progress-fill::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Print */
@media print {
  .tutorial-overlay,
  .tutorial-card,
  .tutorial-highlight {
    display: none !important;
  }
}

@media (prefers-color-scheme: dark) {
  .tutorial-card {
    background: linear-gradient(
      135deg,
      rgba(12, 16, 22, 0.96) 0%,
      rgba(20, 26, 34, 0.94) 100%
    );
  }
}

.tutorial-target-active {
  position: relative !important;
  z-index: 10001 !important;
}
