/**
 * SMPain Clinic - 모바일 퍼스트 스타일시트
 *
 * 설계 원칙:
 * 1. 모바일 기본 → 태블릿/PC 확장 (min-width 미디어 쿼리)
 * 2. 인라인 스타일 최소화, 클래스 기반
 * 3. 터치 타겟 최소 44px
 * 4. 가독성: 본문 16px, 줄간격 1.6
 *
 * 버전: 2.0.0
 * 최종 수정: 2025-12-06
 */

/* ============================================
   1. CSS 변수
   ============================================ */
:root {
  /* 색상 */
  --color-ivory: #e8e8da;
  --color-ivory-light: #f2f2e8;
  --color-white: #ffffff;
  --color-deep-green: #4a5742;
  --color-deep-green-dark: #3d4a37;
  --color-terracotta: #b86a51;
  --color-gold: #ffd700;
  --color-deep-blue: #4A85A4;
  --color-heading: #3d3a38;
  --color-text: #5d5753;
  --color-text-light: #9d9793;

  /* 간격 - 모바일 기준 */
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* 폰트 크기 - 모바일 기준 */
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;
  --text-3xl: 36px;

  /* 레이아웃 */
  --container-padding: 16px;
  --container-max: 1200px;

  /* 효과 */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
}

/* 태블릿 이상에서 간격/폰트 확대 */
@media (min-width: 768px) {
  :root {
    --space-lg: 32px;
    --space-xl: 48px;
    --space-2xl: 64px;
    --text-xl: 26px;
    --text-2xl: 32px;
    --text-3xl: 42px;
    --container-padding: 24px;
  }
}

@media (min-width: 1024px) {
  :root {
    --space-xl: 60px;
    --space-2xl: 80px;
    --text-2xl: 36px;
    --text-3xl: 48px;
    --container-padding: 32px;
  }
}

/* ============================================
   2. 기본 리셋 및 타이포그래피
   ============================================ */
body {
  background-color: var(--color-ivory) !important;
}

.sm-page {
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, sans-serif;
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

.sm-page * {
  box-sizing: border-box;
}

.sm-page h1,
.sm-page h2,
.sm-page h3,
.sm-page h4 {
  font-family: 'Noto Sans KR', sans-serif;
  color: var(--color-heading);
  margin: 0 0 var(--space-md) 0;
  line-height: 1.3;
  word-break: keep-all;
}

.sm-page h1 { font-size: var(--text-2xl); font-weight: 700; }
.sm-page h2 { font-size: var(--text-xl); font-weight: 700; }
.sm-page h3 { font-size: var(--text-lg); font-weight: 600; }
.sm-page h4 { font-size: var(--text-base); font-weight: 600; }

.sm-page p {
  margin: 0 0 var(--space-md) 0;
  word-break: keep-all;
}

.sm-page a {
  color: var(--color-deep-green);
  text-decoration: none;
  transition: var(--transition);
}

.sm-page a:hover {
  color: var(--color-terracotta);
}

/* ============================================
   3. 컨테이너
   ============================================ */
.sm-container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.sm-container--narrow {
  max-width: 800px;
}

.sm-container--wide {
  max-width: 1400px;
}

/* ============================================
   4. 섹션
   ============================================ */
.sm-section {
  padding: var(--space-xl) 0;
}

.sm-section--sm {
  padding: var(--space-lg) 0;
}

.sm-section--lg {
  padding: var(--space-2xl) 0;
}

/* 배경색 (BEM: sm-bg--color) */
.sm-bg--ivory { background-color: var(--color-ivory); }
.sm-bg--ivory-light { background-color: var(--color-ivory-light); }
.sm-bg--white { background-color: var(--color-white); }
.sm-bg--green {
  background-color: var(--color-deep-green);
  color: var(--color-white);
}
.sm-bg--green h1, .sm-bg--green h2, .sm-bg--green h3,
.sm-bg--green p, .sm-bg--green li { color: var(--color-white); }

.sm-bg--terracotta {
  background-color: var(--color-terracotta);
  color: var(--color-white);
}
.sm-bg--terracotta h1, .sm-bg--terracotta h2, .sm-bg--terracotta h3,
.sm-bg--terracotta p, .sm-bg--terracotta li { color: var(--color-white); }

/* 그라데이션 */
.sm-bg--green-gradient {
  background: linear-gradient(135deg, var(--color-deep-green) 0%, var(--color-deep-green-dark) 100%);
  color: var(--color-white);
}
.sm-bg--green-gradient h1, .sm-bg--green-gradient h2, .sm-bg--green-gradient h3,
.sm-bg--green-gradient p { color: var(--color-white); }

/* ============================================
   5. 그리드 시스템 (모바일 퍼스트)
   ============================================ */
.sm-grid {
  display: grid;
  gap: var(--space-md);
}

/* 모바일: 1열 */
.sm-grid--2,
.sm-grid--3,
.sm-grid--4 {
  grid-template-columns: 1fr;
}

/* 태블릿: 2열 */
@media (min-width: 600px) {
  .sm-grid--2 { grid-template-columns: repeat(2, 1fr); }
  .sm-grid--3 { grid-template-columns: repeat(2, 1fr); }
  .sm-grid--4 { grid-template-columns: repeat(2, 1fr); }
}

/* PC: 3-4열 */
@media (min-width: 900px) {
  .sm-grid--3 { grid-template-columns: repeat(3, 1fr); }
  .sm-grid--4 { grid-template-columns: repeat(4, 1fr); }
}

/* 간격 변형 */
.sm-grid--gap-sm { gap: var(--space-sm); }
.sm-grid--gap-lg { gap: var(--space-lg); }

/* ============================================
   6. Hero 섹션 (모바일 퍼스트)
   ============================================ */
.sm-hero {
  padding: var(--space-xl) 0;
  text-align: center;
}

.sm-hero__subtitle {
  font-size: var(--text-base);
  opacity: 0.85;
  margin-bottom: var(--space-sm);
}

.sm-hero__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-md);
  line-height: 1.3;
}

.sm-hero__desc {
  font-size: var(--text-base);
  opacity: 0.9;
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.sm-hero__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
}

/* 태블릿 이상: 버튼 가로 배치 */
@media (min-width: 480px) {
  .sm-hero__actions {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
  }
}

@media (min-width: 768px) {
  .sm-hero {
    padding: var(--space-2xl) 0;
  }

  .sm-hero__title {
    font-size: var(--text-3xl);
  }

  .sm-hero__desc {
    font-size: var(--text-lg);
  }
}

/* ============================================
   7. 버튼 (터치 친화적)
   ============================================ */
.sm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 14px 24px;
  font-size: var(--text-base);
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

/* 모바일: 전체 너비 */
.sm-btn--full {
  width: 100%;
}

@media (min-width: 480px) {
  .sm-btn--full {
    width: auto;
  }
}

/* Primary: 딥그린 */
.sm-btn--primary {
  background-color: var(--color-deep-green) !important;
  color: #ffffff !important;
  border-color: var(--color-deep-green) !important;
}

.sm-btn--primary:hover {
  background-color: var(--color-deep-green-dark) !important;
  color: #ffffff !important;
}

/* Secondary: 흰색 배경 + 테라코타 텍스트 (어두운 배경용) */
.sm-btn--secondary {
  background-color: #ffffff !important;
  color: #b86a51 !important;
  border-color: #ffffff !important;
}

.sm-btn--secondary:hover {
  background-color: #e8e8da !important;
  color: #b86a51 !important;
}

/* Outline: 딥그린 테두리 */
.sm-btn--outline {
  background-color: transparent !important;
  color: #4a5742 !important;
  border-color: #4a5742 !important;
}

.sm-btn--outline:hover {
  background-color: #4a5742 !important;
  color: #ffffff !important;
}

/* Outline White: 흰색 테두리 (어두운 배경용) */
.sm-btn--outline-white {
  background-color: transparent !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

.sm-btn--outline-white:hover {
  background-color: #ffffff !important;
  color: #4a5742 !important;
}

/* 큰 버튼 */
.sm-btn--lg {
  min-height: 56px;
  padding: 16px 32px;
  font-size: var(--text-lg);
}

/* ============================================
   8. 카드
   ============================================ */
.sm-card {
  background-color: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.sm-card:hover {
  box-shadow: var(--shadow-md);
}

.sm-card--link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.sm-card--link:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.sm-card--link:hover .sm-card__title {
  color: var(--color-terracotta);
}

.sm-card__icon {
  font-size: 40px;
  margin-bottom: var(--space-md);
  text-align: center;
}

.sm-card__title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-sm);
  transition: var(--transition);
}

.sm-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  margin: 0;
}

/* 카드 상단 악센트 */
.sm-card--accent-green {
  border-top: 4px solid var(--color-deep-green);
}

.sm-card--accent-terracotta {
  border-top: 4px solid var(--color-terracotta);
}

/* 카드 가운데 정렬 */
.sm-card--center {
  text-align: center;
}

/* ============================================
   9. 3단계 순환 다이어그램
   ============================================ */
.sm-stages {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  align-items: center;
}

.sm-stage {
  width: 100%;
  max-width: 300px;
  text-align: center;
  padding: var(--space-lg);
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.sm-stage__number {
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-white);
  margin-bottom: var(--space-sm);
}

.sm-stage--1 .sm-stage__number { background-color: var(--color-terracotta); }
.sm-stage--2 .sm-stage__number { background-color: var(--color-deep-green); }
.sm-stage--3 .sm-stage__number { background-color: var(--color-gold); color: var(--color-heading); }

.sm-stage__title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.sm-stage--1 .sm-stage__title { color: var(--color-terracotta); }
.sm-stage--2 .sm-stage__title { color: var(--color-deep-green); }
.sm-stage--3 .sm-stage__title { color: #b8860b; }

.sm-stage__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.sm-stage__desc {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  margin: 0;
  line-height: 1.5;
}

/* 화살표 (모바일: 숨김) */
.sm-stages__arrow {
  display: none;
  font-size: 24px;
  color: var(--color-text-light);
}

/* 활성 단계 스타일 */
.sm-stage--active {
  background: var(--color-deep-green) !important;
  color: white !important;
}

/* 하이라이트 단계 (테라코타) */
.sm-stage--highlight {
  background: var(--color-terracotta) !important;
  color: white !important;
}

/* ============================================
   Flow Diagram (재발 악순환 등)
   ============================================ */
.sm-flow-diagram {
  text-align: center;
  padding: 32px;
  background: white;
  border-radius: 8px;
  margin-top: 24px;
}

.sm-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.sm-flow__item {
  padding: 16px 24px;
  border-radius: 8px;
  width: 100%;
  max-width: 280px;
}

.sm-flow__item--warning { background: #fee; color: var(--color-terracotta); }
.sm-flow__item--neutral { background: #ffe; color: #886; }
.sm-flow__item--success { background: #efe; color: var(--color-deep-green); }
.sm-flow__item--info { background: #eef; color: #446; }

.sm-flow__arrow {
  display: none;
  font-size: 24px;
  color: #ccc;
}

.sm-flow__caption {
  margin-top: 24px;
  color: #666;
}

@media (min-width: 768px) {
  .sm-flow {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
  }

  .sm-flow__item {
    width: auto;
    max-width: none;
  }

  .sm-flow__arrow {
    display: block;
  }
}

/* 태블릿 이상: 가로 배치 */
@media (min-width: 768px) {
  .sm-stages {
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
  }

  .sm-stage {
    flex: 1;
    max-width: 280px;
  }

  .sm-stages__arrow {
    display: block;
    align-self: center;
  }
}

/* ============================================
   10. FAQ 아코디언
   ============================================ */
.sm-faq {
  border-top: 1px solid #e0e0e0;
}

.sm-faq__item {
  border-bottom: 1px solid #e0e0e0;
}

.sm-faq__item summary {
  display: block;
  padding: var(--space-md) 0;
  padding-right: 30px;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-heading);
  cursor: pointer;
  list-style: none;
  position: relative;
}

.sm-faq__item summary::-webkit-details-marker { display: none; }

.sm-faq__item summary::after {
  content: '+';
  position: absolute;
  right: 0;
  top: var(--space-md);
  font-size: 20px;
  font-weight: 300;
  color: var(--color-text-light);
}

.sm-faq__item[open] summary::after { content: '−'; }

.sm-faq__item summary:hover { color: var(--color-terracotta); }

.sm-faq__item p {
  padding: 0 0 var(--space-md) 0;
  margin: 0;
  color: var(--color-text);
}

.sm-faq__item a {
  display: inline-block;
  margin-bottom: var(--space-md);
  font-size: var(--text-sm);
}

/* ============================================
   11. 리스트
   ============================================ */
.sm-list,
.sm-list--check,
.sm-list--numbered {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sm-list li,
.sm-list--check li,
.sm-list--numbered li {
  padding: var(--space-sm) 0;
  padding-left: 28px;
  position: relative;
  border-bottom: 1px solid #f0f0f0;
}

.sm-list li:last-child,
.sm-list--check li:last-child,
.sm-list--numbered li:last-child {
  border-bottom: none;
}

/* 체크 리스트 */
.sm-list--check li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--color-deep-green);
  font-weight: 700;
}

/* 넘버드 리스트 */
.sm-list--numbered {
  counter-reset: list-counter;
}

.sm-list--numbered li::before {
  counter-increment: list-counter;
  content: counter(list-counter) ".";
  position: absolute;
  left: 0;
  color: var(--color-deep-green);
  font-weight: 600;
}

/* 링크 리스트 */
.sm-list--links a,
.sm-related-links a {
  display: block;
  padding: var(--space-sm) 0;
  color: var(--color-text);
}

.sm-list--links a:hover,
.sm-related-links a:hover {
  color: var(--color-terracotta);
}

/* 관련 링크 리스트 */
.sm-related-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sm-related-links li {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid #f0f0f0;
}

.sm-related-links li:last-child {
  border-bottom: none;
}

/* ============================================
   12. CTA 섹션
   ============================================ */
.sm-cta {
  text-align: center;
  padding: var(--space-xl) var(--container-padding);
}

.sm-cta__title {
  margin-bottom: var(--space-sm);
}

.sm-cta__desc {
  margin-bottom: var(--space-lg);
  opacity: 0.9;
}

.sm-cta__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
}

@media (min-width: 480px) {
  .sm-cta__actions {
    flex-direction: row;
    justify-content: center;
  }
}

/* ============================================
   13. 알림/정보 박스
   ============================================ */
.sm-notice {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.sm-notice--info {
  background-color: var(--color-ivory-light);
  border-left: 4px solid var(--color-deep-blue);
}

.sm-notice--warning {
  background-color: #fff8e6;
  border-left: 4px solid var(--color-terracotta);
}

.sm-notice p {
  margin: 0;
  font-size: var(--text-sm);
}

/* ============================================
   14. 태그/라벨
   ============================================ */
.sm-tag {
  display: inline-block;
  padding: 4px 12px;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: 20px;
}

.sm-tag--green { background-color: var(--color-deep-green); color: var(--color-white); }
.sm-tag--terracotta { background-color: var(--color-terracotta); color: var(--color-white); }
.sm-tag--gold { background-color: var(--color-gold); color: var(--color-heading); }

/* ============================================
   15. 유틸리티 클래스
   ============================================ */
.sm-text-center, .sm-text--center { text-align: center; }
.sm-text-left, .sm-text--left { text-align: left; }

/* 버튼 그룹 */
.sm-btn-group {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* 컨테이너 크기 변형 */
.sm-container--narrow { max-width: 800px; }
.sm-container--medium { max-width: 900px; }
.sm-container--tight { max-width: 600px; }

/* 마진 유틸리티 */
.sm-mt--md { margin-top: var(--space-md); }
.sm-mt--lg { margin-top: var(--space-lg); }

.sm-mt-0 { margin-top: 0; }
.sm-mt-sm { margin-top: var(--space-sm); }
.sm-mt-md { margin-top: var(--space-md); }
.sm-mt-lg { margin-top: var(--space-lg); }
.sm-mt-xl { margin-top: var(--space-xl); }

.sm-mb-0 { margin-bottom: 0; }
.sm-mb-sm { margin-bottom: var(--space-sm); }
.sm-mb-md { margin-bottom: var(--space-md); }
.sm-mb-lg { margin-bottom: var(--space-lg); }
.sm-mb-xl { margin-bottom: var(--space-xl); }

/* 모바일 전용 */
@media (max-width: 767px) {
  .sm-mobile-hide { display: none !important; }
  .sm-mobile-full { width: 100% !important; }
  .sm-mobile-center { text-align: center !important; }
}

/* 태블릿 이상 전용 */
@media (min-width: 768px) {
  .sm-tablet-hide { display: none !important; }
}

/* ============================================
   16. WordPress 호환
   ============================================ */
/* 페이지 제목 숨기기 */
.sm-page ~ .entry-title,
body.page .entry-title,
body.page .entry-header,
article.page > .entry-header {
  display: none !important;
}

/* WordPress wpautop 문제 해결 */
/* p 태그가 그리드 레이아웃을 깨지 않도록 */
.sm-grid > p {
  display: contents;
}

/* 빈 p 태그 숨기기 */
.sm-grid > p:empty,
.sm-grid > br,
.sm-card > p:empty,
.sm-card__body > p:empty,
a.sm-card > p:empty {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* p 태그 안의 빈 a 태그 숨기기 */
.sm-grid > p > a.sm-card:empty,
.sm-grid > p > a:empty,
a.sm-card:empty {
  display: none !important;
}

/* ============================================
   17. 접근성
   ============================================ */
/* 포커스 표시 */
.sm-btn:focus,
.sm-card--link:focus,
a:focus {
  outline: 2px solid var(--color-deep-blue);
  outline-offset: 2px;
}

/* 고대비 모드 지원 */
@media (prefers-contrast: high) {
  .sm-btn {
    border-width: 3px;
  }
}

/* 모션 감소 선호 */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
