/* ==============================
   common.css — 공통 레이아웃 & 타이포
   ============================== */

/* ── 기본 body ── */
body {
  font-family: var(--font-base);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  color: var(--text-primary);
  background-color: var(--bg-base);
  line-height: var(--lh-normal);
}

/* ── PWA 앱 래퍼 ── */
#app {
  max-width: var(--max-width);
  min-height: 100vh;
  margin: 0 auto;
  /* background: var(--bg-base); */
  position: relative;
  overflow-x: hidden;
  padding-bottom: 64px;
}

/* ── 페이지 컨테이너 ── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  padding: var(--space-4);
  padding-top: calc(var(--header-height) + var(--space-4));
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4));
}

.page-content--no-nav {
  padding-bottom: var(--space-8);
}

/* ── 헤더 ── */
.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 var(--space-4);
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-xs);
}

.app-header__title {
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  color: var(--sage-dark);
  letter-spacing: -0.02em;
  margin-right: auto;
}

.app-header__logo {
  font-size: var(--text-xl);
  font-weight: var(--fw-extrabold);
  color: var(--sage-dark);
  letter-spacing: -0.03em;
  margin-right: auto;
}

.app-header__logo .highlight {
  color: var(--sage);
}

.app-header__back {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-full);
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.app-header__back:active {
  background: var(--gray-100);
}

.app-header__action {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── 하단 네비게이션 ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: stretch;
  z-index: var(--z-sticky);
  box-shadow: 0 -2px 12px rgba(31, 51, 40, 0.06);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item.active {
  color: var(--sage);
}

.bottom-nav__icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── 타이포그래피 ── */
.heading-xl  { font-size: var(--text-3xl); font-weight: var(--fw-extrabold); line-height: var(--lh-tight);  letter-spacing: -0.03em; }
.heading-lg  { font-size: var(--text-2xl); font-weight: var(--fw-bold);      line-height: var(--lh-tight);  letter-spacing: -0.02em; }
.heading-md  { font-size: var(--text-xl);  font-weight: var(--fw-bold);      line-height: var(--lh-snug);   letter-spacing: -0.02em; }
.heading-sm  { font-size: var(--text-lg);  font-weight: var(--fw-semibold);  line-height: var(--lh-snug); }
.body-lg     { font-size: var(--text-base); font-weight: var(--fw-regular);  line-height: var(--lh-relaxed); }
.body-sm     { font-size: var(--text-sm);   font-weight: var(--fw-regular);  line-height: var(--lh-normal); }
.caption     { font-size: var(--text-xs);   font-weight: var(--fw-regular);  line-height: var(--lh-normal); color: var(--text-secondary); }
.label       { font-size: var(--text-sm);   font-weight: var(--fw-semibold); }

/* ── 섹션 헤더 ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.section-title {
  font-size: var(--text-base);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-more {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--sage);
}

/* ── 구분선 ── */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-4) 0;
}

.divider--thick {
  height: 8px;
  background: var(--gray-100);
  margin: var(--space-4) calc(-1 * var(--space-4));
}

/* ── 뱃지 ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px var(--space-2);
  border-radius: var(--border-radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.4;
}

.badge--sage    { background: var(--sage-light);   color: var(--sage-dark); }
.badge--point   { background: #FDE8D5;              color: var(--point-dark); }
.badge--success { background: #D4F0E3;              color: #2A7A50; }
.badge--warning { background: #FEF5D8;              color: #9A7A10; }
.badge--error   { background: #FCE0E0;              color: #B03030; }
.badge--gray    { background: var(--gray-100);      color: var(--gray-600); }

/* ── 급수 뱃지 ── */
.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--border-radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
}

.grade-S  { background: #FFF1E0; color: #C87A30; border: 1px solid #FBCF9A; }
.grade-A  { background: #EDE8FF; color: #6B46C1; border: 1px solid #C4B5FD; }
.grade-B  { background: #E0F0FF; color: #1E6FB5; border: 1px solid #93C5FD; }
.grade-C  { background: var(--sage-light); color: var(--sage-dark); border: 1px solid var(--sage); }
.grade-D  { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-300); }
.grade-초심 { background: #F0FFF4; color: #276749; border: 1px solid #9AE6B4; }

/* ── 경기 타입 뱃지 ── */
.match-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px var(--space-2);
  border-radius: var(--border-radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
}

.match-type--남자복식  { background: #EFF6FF; color: #1D4ED8; }
.match-type--여자복식  { background: #FDF2F8; color: #9D174D; }
.match-type--남녀혼복  { background: #F5F0FF; color: #6D28D9; }

/* ── 빈 상태 ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-16) var(--space-6);
  text-align: center;
}

.empty-state__icon {
  font-size: 3rem;
  opacity: 0.4;
}

.empty-state__text {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  line-height: var(--lh-relaxed);
}

/* ── 로딩 스피너 ── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--sage-light);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
}

/* ── 풀스크린 로딩 ── */
.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  min-height: 100vh;
}

/* ── 스크롤바 숨기기 (모바일) ── */
.scroll-hidden {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scroll-hidden::-webkit-scrollbar { display: none; }

/* ── 가로 스크롤 컨테이너 ── */
.scroll-x {
  display: flex;
  overflow-x: auto;
  gap: var(--space-3);
  padding-bottom: var(--space-2);
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar { display: none; }

/* ── 유틸리티 ── */
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-sage     { color: var(--sage); }
.text-point    { color: var(--point-dark); }
.text-muted    { color: var(--text-secondary); }
.text-danger   { color: var(--color-error); }
.text-success  { color: var(--color-success); }
.fw-bold       { font-weight: var(--fw-bold); }
.fw-semibold   { font-weight: var(--fw-semibold); }
.mt-2  { margin-top: var(--space-2); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mb-2  { margin-bottom: var(--space-2); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.hidden { display: none !important; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
