/* ============================================================
   StockClaw 강의 사이트 — 공통 스타일
   Pretendard + Font Awesome 6.4.0
   ============================================================ */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

/* ── CSS 변수 ── */
:root {
  --primary:       #3498db;
  --primary-dark:  #2980b9;
  --primary-light: #ebf5fb;
  --text:          #1f2937;
  --text-muted:    #64748b;
  --bg:            #ffffff;
  --bg-gray:       #f8fafc;
  --border:        #e2e8f0;
  --success:       #10b981;
  --error:         #ef4444;
  --warning:       #f59e0b;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 15px rgba(0,0,0,.07), 0 4px 6px rgba(0,0,0,.05);
  --transition:    150ms ease;
  --header-h:      64px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

ul, ol { list-style: none; }

img { max-width: 100%; display: block; }

button { cursor: pointer; border: none; background: none; font-family: inherit; }

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* ── Layout ── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* ── 헤더 ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.site-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.header-logo img { height: 32px; width: auto; }
.header-logo .logo-text { color: var(--primary); }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.header-nav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.header-nav a:hover,
.header-nav a.active {
  background: var(--bg-gray);
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.header-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.header-profile:hover { background: var(--bg-gray); }

.header-profile .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
}

.header-profile .profile-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

/* 모바일 햄버거 */
.header-menu-toggle {
  display: none;
  padding: 8px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 1.25rem;
}

/* mobile-auth는 PC에서 항상 숨김 (모바일 햄버거 내부에서만 표시) */
.header-nav .mobile-auth { display: none; }

/* ── 푸터 (컴팩트) ── */
.site-footer {
  background: var(--bg-gray);
  border-top: 1px solid var(--border);
  padding: 20px 0 16px;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.footer-brand .footer-logo {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.footer-brand p {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-links-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-links-group h4 {
  display: none;
}

.footer-links-group a {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: color var(--transition);
}

.footer-links-group a:hover { color: var(--primary); }

.footer-bottom {
  display: flex;
  justify-content: center;
  align-items: center;
}

.footer-bottom p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.footer-bottom-links { display: none; }

/* ── 버튼 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              transform var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgba(52,152,219,.35);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-gray);
  color: var(--text);
}

.btn-danger {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 1.0625rem;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.btn-block { width: 100%; }

.btn-loading { pointer-events: none; }
.btn-loading .btn-text { opacity: 0; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── 강의 카드 ── */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.course-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
}

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

.course-card-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bg-gray);
  overflow: hidden;
}

.course-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease;
}

.course-card:hover .course-card-thumb img { transform: scale(1.03); }

.course-card-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.course-card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.course-card-category {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.course-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 12px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.course-card-meta i { font-size: 0.875rem; }

.course-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.course-card-price {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.course-card-price.free { color: var(--success); }

.course-card-price .original-price {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-right: 4px;
}

/* ── 폼 ── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--error);
  margin-left: 2px;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.8125rem;
  color: var(--error);
  margin-top: 4px;
  display: none;
}

.form-group.has-error .form-error { display: block; }
.form-group.has-error .form-input { border-color: var(--error); }

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input::placeholder { color: #b0bec5; }

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(52,152,219,.18);
}

.form-input:disabled {
  background: var(--bg-gray);
  color: var(--text-muted);
  cursor: not-allowed;
}

textarea.form-input {
  resize: vertical;
  min-height: 100px;
}

.input-with-icon {
  position: relative;
}

.input-with-icon .form-input { padding-left: 40px; }
.input-with-icon .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ── 모달 ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  backdrop-filter: blur(2px);
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0,0,0,.15);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(8px);
  transition: transform 200ms ease;
}

.modal-overlay.is-open .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.125rem;
  transition: background var(--transition), color var(--transition);
}

.modal-close:hover {
  background: var(--bg-gray);
  color: var(--text);
}

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── 배지 ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.badge-primary {
  background: var(--primary);
  color: #fff;
}

.badge-free {
  background: var(--success);
  color: #fff;
}

.badge-preview {
  background: rgba(0,0,0,.55);
  color: #fff;
  backdrop-filter: blur(4px);
}

.badge-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}

.badge-new {
  background: #fee2e2;
  color: #dc2626;
}

.badge-hot {
  background: #fef3c7;
  color: #92400e;
}

/* ── 섹션 공통 ── */
.section { padding: 64px 0; }
.section-sm { padding: 40px 0; }

.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-header h2 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
}

.section-header p {
  font-size: 1.0625rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
}

/* ── 빈 상태 ── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
}

.empty-state i {
  font-size: 3rem;
  color: var(--border);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ── 구분선 ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 20px 0;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

/* ── 로딩 스피너 ── */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.8);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.spinner-overlay p {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

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

/* ── 토스트 알림 ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 250ms ease;
  position: relative;
  overflow: hidden;
}

.toast.toast-success { background: #065f46; }
.toast.toast-error   { background: #991b1b; }
.toast.toast-warning { background: #92400e; }
.toast.toast-info    { background: #1e40af; }

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; font-size: 0.9375rem; line-height: 1.5; }
.toast-close {
  flex-shrink: 0;
  opacity: .7;
  padding: 2px;
  transition: opacity var(--transition);
  color: #fff;
}
.toast-close:hover { opacity: 1; }

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255,255,255,.4);
  animation: toastProgress 3s linear forwards;
}

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

@keyframes slideOutRight {
  to { transform: translateX(110%); opacity: 0; }
}

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0; }
}

/* ── 유틸 ── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.text-primary { color: var(--primary); }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* ── 반응형: 768px ── */
@media (max-width: 768px) {
  :root { --header-h: 56px; }

  .container { padding: 0 16px; }
  .section    { padding: 48px 0; }

  /* 헤더 */
  .header-nav { display: none; }

  .header-nav.is-open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px 16px;
    gap: 2px;
    box-shadow: var(--shadow-md);
  }

  .header-menu-toggle { display: flex; }

  /* 모바일: 햄버거 외 헤더 액션 숨김 */
  .header-actions > a.btn-outline,
  .header-actions > a.btn-primary,
  .header-actions > a.btn-ghost,
  .header-actions .header-profile,
  .header-actions .profile-dropdown {
    display: none !important;
  }
  /* 햄버거 메뉴 토글은 항상 보이게 */
  .header-actions .header-menu-toggle { display: flex !important; }

  /* 모바일 햄버거 메뉴 안에 로그인/가입 표시 */
  .header-nav.is-open .mobile-auth {
    display: flex !important;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
  }
  .header-nav .mobile-auth a {
    padding: 10px 12px;
    text-align: center;
    border-radius: var(--radius);
    font-weight: 600;
  }
  .header-nav .mobile-auth .btn-outline {
    border: 1px solid var(--primary);
    color: var(--primary);
  }
  .header-nav .mobile-auth .btn-primary {
    background: var(--primary);
    color: #fff !important;
  }

  /* 강의 그리드 */
  .course-grid { grid-template-columns: 1fr; gap: 16px; }

  /* 섹션 헤더 */
  .section-header h2 { font-size: 1.625rem; }

  /* 모달 */
  .modal-content { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  /* 토스트 */
  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }

  /* 푸터 */
  .footer-inner { flex-direction: column; gap: 24px; }
  .footer-links { flex-direction: column; gap: 20px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* 버튼 */
  .btn-lg { padding: 11px 22px; font-size: 1rem; }
}

@media (max-width: 480px) {
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
}
