/* ========================================
   Step 4: 주제 선택 - RELLA 테마 디자인
   기존 색상 팔레트 사용 (보라/노랑/크림)
   ======================================== */

/* 접근성을 위한 스크린 리더 전용 클래스 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ========================================
   카테고리 Pill 버튼
   ======================================== */
.category-pills-section {
  width: 100%;
  margin-bottom: 24px;
}

/* 나이 입력 섹션 */
.age-input-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

#childAge {
  width: 60px;
  height: 36px;
  padding: 4px 8px;
  font-size: 1.1em;
  font-weight: 600;
  color: var(--dark-purple);
  text-align: center;
  background: white;
  border: 2px solid rgba(185, 126, 245, 0.3);
  border-radius: 8px;
  transition: all 0.2s ease;
}

#childAge:hover {
  border-color: var(--purple);
}

#childAge:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(185, 126, 245, 0.2);
}

.age-unit {
  font-family: "Inter", sans-serif;
  font-size: 1em;
  font-weight: 600;
  color: var(--brown);
}

.category-pills-container {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 20px;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: white;
  border: 2px solid rgba(185, 126, 245, 0.3);
  border-radius: 50px;
  font-family: "Inter", sans-serif;
  font-size: 1em;
  font-weight: 600;
  color: var(--dark-purple);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  min-height: 48px;
}

.category-pill-icon {
  font-size: 1.3em;
  line-height: 1;
}

.category-pill:hover {
  transform: translateY(-2px);
  border-color: var(--purple);
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.3);
}

.category-pill:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(185, 126, 245, 0.2);
}

.category-pill.active {
  background: var(--button-gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 16px rgba(185, 126, 245, 0.4);
}

.category-pill.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(185, 126, 245, 0.5);
}

/* ========================================
   테마 콘텐츠 섹션
   ======================================== */
.theme-content-section {
  width: 100%;
  padding: 0 20px;
  position: relative;
}

/* 로딩 상태 */
.theme-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
}

.theme-loading.hidden {
  display: none;
}

.spinner-ring {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(185, 126, 245, 0.2);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.theme-loading p {
  font-family: "Inter", sans-serif;
  font-size: 1em;
  color: var(--brown);
  margin: 0;
}

/* 빈 상태 */
.theme-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
}

.theme-empty-state.hidden {
  display: none;
}

.empty-state-icon {
  font-size: 3em;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.empty-state-title {
  font-family: "Inter", sans-serif;
  font-size: 1.3em;
  font-weight: 700;
  color: var(--dark-purple);
  margin: 0;
}

.empty-state-desc {
  font-family: "Inter", sans-serif;
  font-size: 1em;
  color: var(--brown);
  text-align: center;
  line-height: 1.6;
  margin: 0;
}

/* ========================================
   테마 카드 그리드
   ======================================== */
.theme-cards-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.theme-card {
  background: white;
  border: 2px solid rgba(185, 126, 245, 0.2);
  border-radius: 30px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 2px 8px var(--shadow-yellow);
  width: 100%;
}

.theme-card:hover {
  transform: translateY(-4px);
  border-color: var(--purple);
  box-shadow:
    0 8px 24px rgba(185, 126, 245, 0.3),
    0 0 0 1px rgba(185, 126, 245, 0.1) inset;
}

.theme-card:hover .theme-card-icon {
  background: rgba(237, 222, 252, 0.8);
  transform: scale(1.05);
}

.theme-card:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(185, 126, 245, 0.2);
}

.theme-card.selected {
  border-color: var(--purple);
  box-shadow: 0 8px 24px rgba(185, 126, 245, 0.4);
}

/* 하단 액션 버튼 영역 */
.theme-card-actions {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 2;
}

/* 편집 버튼 */
.theme-edit-btn {
  width: 32px;
  height: 32px;
  background: white;
  border: 2px solid rgba(185, 126, 245, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #666;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.theme-edit-btn:hover {
  background: rgba(237, 222, 252, 0.5);
  border-color: var(--purple);
  color: var(--purple);
  transform: scale(1.05);
}

/* 선택 체크마크 */
.theme-card-check-mark {
  width: 32px;
  height: 32px;
  background: white;
  border: 2px solid #ddd;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ddd;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.theme-card.selected .theme-card-check-mark {
  background: var(--button-gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 8px rgba(185, 126, 245, 0.4);
}

/* 테마 카드 이미지 영역 */
.theme-card-image {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 80%, rgba(255, 250, 230, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(237, 222, 252, 0.3) 0%, transparent 50%);
}

.theme-card-image::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(185, 126, 245, 0.2) 50%,
    transparent 100%
  );
}

.theme-card-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(237, 222, 252, 0.6);
  border-radius: 50%;
  font-size: 2.5em;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.05));
  z-index: 1;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 테마 카드 콘텐츠 */
.theme-card-content {
  padding: 20px 20px 60px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-card-title {
  font-family: "Inter", sans-serif;
  font-size: 1.2em;
  font-weight: 700;
  color: var(--dark-purple);
  margin: 0;
  line-height: 1.3;
  text-align: center;
}

.theme-lesson {
  padding: 10px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
}

.theme-lesson-label {
  font-family: "Inter", sans-serif;
  font-size: 0.85em;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 4px;
}

.theme-lesson-text {
  font-family: "Inter", sans-serif;
  font-size: 0.9em;
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
}

.theme-growth {
  padding-left: 10px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
}

.theme-growth-icon {
  display: none;
}

.theme-growth-content {
  width: 100%;
}

.theme-growth-label {
  font-family: "Inter", sans-serif;
  font-size: 0.85em;
  font-weight: 700;
  color: var(--brown);
  margin-bottom: 4px;
}

.theme-growth-text {
  font-family: "Inter", sans-serif;
  font-size: 0.9em;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* ========================================
   반응형 디자인
   ======================================== */

/* 태블릿 (768px ~ 1024px) */
@media (max-width: 1024px) {
  .theme-cards-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

/* 모바일 (< 768px) */
@media (max-width: 768px) {
  .category-pills-container {
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }

  .category-pills-container::-webkit-scrollbar {
    height: 4px;
  }

  .category-pills-container::-webkit-scrollbar-thumb {
    background: var(--purple);
    border-radius: 2px;
  }

  .theme-cards-container {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* 테마 편집 모달 */
.theme-edit-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-edit-modal.hidden {
  display: none;
}

.theme-edit-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.theme-edit-modal-content {
  position: relative;
  background: white;
  border-radius: 24px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 3px solid var(--purple);
}

.theme-edit-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  background: var(--button-gradient);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(185, 126, 245, 0.4);
}

.theme-edit-modal-close:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.6);
}

.theme-edit-modal-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.theme-edit-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 나이 섹션과 등장인물 섹션 사이 여백 확대 */
.theme-edit-field + .theme-edit-field {
  margin-top: 20px;
}

.theme-edit-label {
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-dark);
  margin-bottom: 12px;
  display: block;
}

/* 인라인 힌트 텍스트 (라벨 옆) */
.theme-edit-hint-inline {
  font-family: "Inter", sans-serif;
  font-weight: 400;
  font-size: 13px;
  color: #999;
  margin-left: 4px;
}

.theme-edit-input,
.theme-edit-textarea {
  font-family: "Inter", sans-serif;
  font-size: 14px;
  padding: 12px 16px;
  border: 2px solid rgba(185, 126, 245, 0.3);
  border-radius: 12px;
  background: white;
  transition: all 0.3s ease;
}

.theme-edit-input:focus,
.theme-edit-textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(185, 126, 245, 0.1);
}

.theme-edit-input::placeholder,
.theme-edit-textarea::placeholder {
  color: #aaa;
}

.theme-edit-textarea {
  resize: vertical;
  min-height: 80px;
}

/* 모달 안의 나이 입력 */
.theme-edit-modal .age-input-section {
  justify-content: flex-start;
}

/* 힌트 텍스트 */
.theme-edit-hint {
  font-family: "Inter", sans-serif;
  font-size: 12px;
  color: #999;
  margin: 4px 0 0 0;
}

/* 저장 버튼 */
.theme-edit-save-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--button-gradient);
  border: none;
  border-radius: 12px;
  color: white;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.3);
  margin-top: 8px;
}

.theme-edit-save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(185, 126, 245, 0.4);
}

.theme-edit-save-btn:active {
  transform: translateY(0);
}

/* 등장인물 선택 - 모달 전용 (우선순위 높임) */
.theme-edit-modal .character-selection {
  display: flex !important;
  flex-direction: column;
  gap: 16px;
  opacity: 1 !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  transform: none !important;
  border-radius: 0 !important;
}

/* ::before 제거 */
.theme-edit-modal .character-selection::before {
  display: none !important;
}

.theme-edit-modal .character-category {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  overflow: visible;
  margin-bottom: 12px;
}

.theme-edit-modal .character-category-title {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--purple);
  width: 100%;
  overflow: visible;
  white-space: normal;
  padding-left: 2px;
}

.theme-edit-modal .character-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-edit-modal .character-option {
  font-family: "Inter", sans-serif;
  font-size: 13px;
  padding: 8px 16px;
  border: 2px solid rgba(185, 126, 245, 0.3);
  border-radius: 20px;
  background: white;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.3s ease;
}

.theme-edit-modal .character-option:hover {
  border-color: var(--purple);
  background: rgba(237, 222, 252, 0.2);
}

.theme-edit-modal .character-option.selected {
  background: var(--button-gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 8px rgba(185, 126, 245, 0.3);
}

.theme-edit-modal .character-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f5f5f5;
}

/* 작은 모바일 (< 480px) */
@media (max-width: 480px) {
  .category-pills-section,
  .theme-content-section {
    padding: 0 10px;
  }

  .category-pill {
    padding: 10px 20px;
    font-size: 0.95em;
  }

  .theme-card-content {
    padding: 16px;
  }

  .theme-card-title {
    font-size: 1.1em;
  }

  .theme-edit-modal-content {
    padding: 24px;
    width: 95%;
  }
}
