/*
 * Application CSS
 * Tailwind CSS handles most styling.
 */

/* ===== CSS Custom Properties (Design Tokens) ===== */
:root {
  --color-brand: #0d9488;       /* teal-600 (primary) */
  --color-brand-dark: #0f766e;  /* teal-700 */
  --color-brand-light: #ccfbf1; /* teal-100 */
  --color-brand-50: #f0fdfa;    /* teal-50 */
  --color-accent: #f97316;      /* carrot orange (secondary) */
  --radius-sm: 0.375rem;   /* 6px */
  --radius-md: 0.5rem;     /* 8px */
  --radius-lg: 0.75rem;    /* 12px */
  --radius-xl: 1rem;       /* 16px */
  --radius-2xl: 1.5rem;    /* 24px - 당근마켓 스타일 큰 라운드 */
  --shadow-card: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-card-hover: 0 2px 4px 0 rgb(0 0 0 / 0.08);
  --border-card: 1px solid #f3f4f6; /* gray-100 border 당근마켓 스타일 */
}

/* ===== Turbo Progress Bar ===== */
.turbo-progress-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--color-brand), #2dd4bf);
}

/* ===== Turbo Frame Loading Dots (차분한 로딩) ===== */
turbo-frame[busy]::before {
  content: "";
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin: 2rem auto;
  height: 2rem;
}

turbo-frame[busy]::after {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  background-color: var(--color-brand);
  border-radius: 50%;
  animation: dotPulse 1.4s infinite ease-in-out;
}

/* ===== Custom styles for star rating ===== */
.star-rating input[type="radio"] {
  display: none;
}

.star-rating label {
  cursor: pointer;
  transition: color 0.2s;
}

/* ===== Status badge animations ===== */
.status-badge {
  transition: all 0.2s ease-in-out;
}

/* ===== Flash message animation ===== */
.flash-message {
  animation: slideDown 0.3s ease-out;
}

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

/* ===== Toast animations ===== */
.toast-enter {
  animation: toastIn 0.3s ease-out forwards;
}

.toast-exit {
  animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(1rem);
  }
}

/* ===== Mobile menu animation ===== */
.mobile-menu-enter {
  animation: menuSlideDown 0.2s ease-out forwards;
}

.mobile-menu-exit {
  animation: menuSlideUp 0.15s ease-in forwards;
}

@keyframes menuSlideDown {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes menuSlideUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
}

/* ===== Form validation states ===== */
.field-error input,
.field-error select,
.field-error textarea {
  border-color: #ef4444 !important;
}

.field-error input:focus,
.field-error select:focus,
.field-error textarea:focus {
  --tw-ring-color: #fca5a5;
  border-color: #ef4444 !important;
}

.field-success input,
.field-success select,
.field-success textarea {
  border-color: #22c55e !important;
}

/* ===== Toast progress bar ===== */
.toast-progress {
  transition: width linear;
}

.toast-progress[data-paused] {
  transition: none;
}

/* ===== Loading Progress Bar ===== */
.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, #0d9488, #2dd4bf);
  transition: width 0.3s ease-out;
  z-index: 9999;
  box-shadow: 0 0 10px rgba(13, 148, 136, 0.5);
}

/* ===== Button Loading Dots (차분한 로딩 표시) ===== */
.btn-spinner {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-spinner::before,
.btn-spinner::after {
  content: "";
  display: inline-block;
  width: 0.375rem;
  height: 0.375rem;
  background-color: currentColor;
  border-radius: 50%;
  animation: dotPulse 1.4s infinite ease-in-out;
}

.btn-spinner::before {
  animation-delay: 0s;
}

.btn-spinner::after {
  animation-delay: 0.7s;
}

@keyframes dotPulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== Fade In Animation ===== */
.fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Card Hover Effect ===== */
.card-hover {
  transition: all 0.2s ease-out;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

/* ===== Smooth Transitions ===== */
.transition-smooth {
  transition: all 0.2s ease-out;
}

/* ===== Focus Visible (접근성) ===== */
*:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
  border-radius: var(--radius-md);
}

/* ===== Shake Animation (입력 오류) ===== */
.shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }
  30%, 50%, 70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%, 60% {
    transform: translate3d(4px, 0, 0);
  }
}

/* ===== Slide In Animation (단계 전환) ===== */
.slide-in-right {
  animation: slideInRight 0.3s ease-out forwards;
}

.slide-in-left {
  animation: slideInLeft 0.3s ease-out forwards;
}

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

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

/* ===== Progress Bar Animation ===== */
.progress-bar-animate {
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Pulse Animation (저장 중) ===== */
.pulse-once {
  animation: pulseOnce 1s ease-in-out;
}

@keyframes pulseOnce {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ===== Stagger Animation Delays (스크롤 리빌 순차) ===== */
.fade-in:nth-child(2) { animation-delay: 0.08s; }
.fade-in:nth-child(3) { animation-delay: 0.16s; }
.fade-in:nth-child(4) { animation-delay: 0.24s; }
.fade-in:nth-child(5) { animation-delay: 0.32s; }

/* ===== 당근마켓 스타일 컴포넌트 ===== */

/* 리스트 아이템 터치 피드백 */
.list-item-touch {
  transition: background-color 0.15s ease;
}

.list-item-touch:active {
  background-color: #f9fafb; /* gray-50 */
}

/* 바텀시트 */
.bottom-sheet-overlay {
  background-color: rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s ease;
}

.bottom-sheet-content {
  border-radius: 1.5rem 1.5rem 0 0;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes bottomSheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes bottomSheetDown {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}

/* 스켈레톤 로딩 */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
  border-radius: 0.5rem;
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 세그먼트 탭 (당근마켓 스타일) */
.segment-tab {
  position: relative;
  padding: 0.625rem 1rem;
  font-weight: 600;
  font-size: 0.9375rem;
  color: #9ca3af;
  transition: color 0.2s ease;
}

.segment-tab.active {
  color: #111827;
}

.segment-tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: #111827;
}

/* 하단 탭바 */
.bottom-tab-bar {
  background-color: white;
  border-top: 1px solid #f3f4f6;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  padding: 0.375rem 0;
  font-size: 0.625rem;
  font-weight: 500;
  color: #9ca3af;
  transition: color 0.2s ease;
}

.bottom-tab-item.active {
  color: #111827;
}

/* 당근마켓 스타일 카드 (border 기반, shadow 최소) */
.karrot-card {
  background-color: white;
  border: 1px solid #f3f4f6;
  border-radius: 1rem;
  transition: background-color 0.15s ease;
}

.karrot-card:hover {
  background-color: #f9fafb;
}

/* Safe area 패딩 */
.pb-safe {
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== Native App 전용 스타일 ===== */
.native-app {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

.native-app main {
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(env(safe-area-inset-bottom) + 0.5rem);
}

.native-app img,
.native-app a {
  -webkit-touch-callout: none;
}

/* ===== UI Design System 애니메이션 (Toss/당근마켓 스타일) ===== */

/* Fade-in 애니메이션 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* Card Hover 애니메이션 */
.card-hover {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* Shake 애니메이션 (에러 시) */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.4s ease;
}

/* Bounce 애니메이션 (강조) */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-8px);
  }
  60% {
    transform: translateY(-4px);
  }
}

.bounce {
  animation: bounce 0.6s ease;
}

/* Pulse 애니메이션 (알림) */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(13, 148, 136, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(13, 148, 136, 0);
  }
}

.pulse {
  animation: pulse 2s infinite;
}

/* Slide-up 애니메이션 (모달 등) */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

/* Scale 애니메이션 (버튼 클릭 등) */
@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.scale-in {
  animation: scaleIn 0.2s ease-out;
}

/* Progress Bar 애니메이션 */
@keyframes progress {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(0);
  }
}

.progress-animate {
  animation: progress 0.5s ease-out;
}

/* Skeleton Loading 애니메이션 */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    #f3f4f6 25%,
    #e5e7eb 50%,
    #f3f4f6 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Smooth Transitions (전역 기본값) */
.transition-smooth {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Button Press 효과 */
.btn-press:active {
  transform: scale(0.98);
}

/* ===== 토스 스타일 UI 컴포넌트 ===== */

/* 한글 최적화 커닝 (당근마켓 스타일) */
body {
  letter-spacing: -0.3px;
}

/* 진행 바 그라디언트 + 펄스 (시인성 강화) */
@keyframes progressPulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.6),
                0 0 35px rgba(168, 85, 247, 0.4),
                0 2px 8px rgba(59, 130, 246, 0.3);
  }
  50% {
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.8),
                0 0 50px rgba(59, 130, 246, 0.6),
                0 4px 12px rgba(168, 85, 247, 0.4);
  }
}

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

.progress-bar-pulse {
  animation: progressPulse 1.5s ease-in-out infinite;
}

.animate-shimmer {
  animation: shimmer 2s infinite;
}

/* 토스 스타일 버튼 애니메이션 */
.option-btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.option-btn:hover {
  transform: translateY(-6px) scale(1.02); /* 당근마켓 + 토스 스타일 */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.option-btn:active {
  transform: scale(0.98);
}

/* 선택된 버튼 강조 (시인성 개선) */
.option-btn.selected,
.select-button.selected {
  transform: scale(1.05) !important;
  box-shadow: 0 15px 50px -10px currentColor, 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
  border-width: 3px !important;
}

.select-button {
  cursor: pointer;
  user-select: none;
}

/* 아이콘 서클 호버 효과 */
.icon-circle {
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.option-btn:hover .icon-circle {
  transform: scale(1.1) rotate(5deg);
}

.option-btn.selected .icon-circle {
  animation: iconBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes iconBounce {
  0% { transform: scale(1) rotate(0deg); }
  30% { transform: scale(1.2) rotate(-10deg); }
  60% { transform: scale(0.95) rotate(5deg); }
  100% { transform: scale(1.1) rotate(0deg); }
}

/* 체크 아이콘 등장 애니메이션 (select-check 클래스도 포함) */
.check-icon,
.select-check {
  animation: checkAppear 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* 선택된 상태의 체크 표시 */
.select-button.selected .select-check {
  display: block !important;
}

@keyframes checkAppear {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(10deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* Ripple 효과 */
@keyframes rippleEffect {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

/* 영상 업로드 박스 펄스 (토스 스타일 그라디언트) */
.video-upload-box {
  animation: videoPulseGradient 3s ease-in-out infinite;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

@keyframes videoPulseGradient {
  0%, 100% {
    border-color: rgb(59, 130, 246);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
  }
  33% {
    border-color: rgb(168, 85, 247);
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.4);
  }
  66% {
    border-color: rgb(99, 102, 241);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
  }
}

.video-upload-box:hover {
  animation: none;
  transform: scale(1.02);
  box-shadow: 0 10px 40px -10px rgba(59, 130, 246, 0.5);
}

/* 드래그 시 확대 효과 */
.video-upload-box.scale-105 {
  transform: scale(1.05);
  animation: none;
}

/* 모바일 하단 고정 버튼 */
@media (max-width: 767px) {
  .mobile-fixed-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: white;
    border-top: 1px solid #e5e7eb;
    z-index: 20;
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
  }

  .step-content {
    padding-bottom: 6rem;
  }
}

/* 다크 모드 대응 (선택적) */
@media (prefers-color-scheme: dark) {
  .mobile-fixed-bottom {
    background: #1f2937;
    border-top-color: #374151;
  }
}

/* 로딩 애니메이션 강화 */
.btn-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 페이드인 애니메이션 (단계 전환) */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-content {
  animation: fadeInUp 0.5s ease-out;
}

/* ===== 버튼 시인성 개선 (최소한의 전역 스타일) ===== */
/* 접근성: 최소 터치 영역 보장 */
button,
a[role="button"],
input[type="submit"],
input[type="button"] {
  min-height: 44px; /* WCAG 터치 최소 크기 */
}

/* 그라디언트 배경 버튼만 흰 텍스트 보장 (다른 스타일은 Tailwind에 맡김) */
button[class*="bg-gradient-"],
a[class*="bg-gradient-"] {
  color: white;
}

/* Focus 상태 (접근성) - 키보드 사용자를 위한 최소 스타일 */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #0d9488;
  outline-offset: 2px;
}

