/* ==========================================================================
   wordlist.css — 연령별 어휘 레퍼런스 페이지
   고객 문제: "이 아이한테 어떤 단어를 먼저 가르쳐야 하는지 모르겠다"
   이 화면의 역할: 전문가의 가이드 — 연령×우선순위 체계적 어휘 레퍼런스
   ========================================================================== */

/* ── 디자인 토큰 ── */
:root {
  --teal: #0891B2;
  --teal-dark: #155E75;
  --teal-mid: #0E7490;
  --teal-light: #CFFAFE;
  --emerald: #059669;
  --emerald-dark: #065F46;
  --emerald-light: #D1FAE5;
  --sand: #FBF9F6;
  --sand-dark: #F5F0E8;
  --warm-border: #E8E2D9;
  --text-dark: #1E293B;
  --text-mid: #64748B;
  --text-light: #94A3B8;
  --text-white: #FFFFFF;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Pretendard Variable', 'Pretendard', sans-serif;
  background: var(--sand);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   메인 레이아웃
   ========================================================================== */
.wl-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 60px;
  display: flex;
  gap: 24px;
}

/* ==========================================================================
   연령대 사이드바
   ========================================================================== */
.wl-sidebar-wrap {
  width: 180px;
  flex-shrink: 0;
  position: sticky;
  top: 76px;
  align-self: flex-start;
}
.wl-sidebar {
  width: 100%;
  background: #fff;
  border: 1px solid var(--warm-border);
  border-radius: var(--r-md);
  padding: 16px 10px;
  box-shadow: var(--shadow-sm);
}
.wl-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wl-sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  color: var(--text-mid);
}
.wl-sidebar-item:hover {
  background: #F8FAFB;
  color: var(--text-dark);
}
.wl-sidebar-item.active {
  background: var(--teal-light);
  color: var(--teal-dark);
  border-left-color: var(--teal);
}
.wl-sidebar-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.wl-sidebar-age {
  font-size: 14px;
  font-weight: 600;
}
.wl-sidebar-months {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-light);
}
.wl-sidebar-item.active .wl-sidebar-months {
  color: var(--teal-mid);
}
.wl-sidebar-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  background: #F1F5F9;
  padding: 2px 7px;
  border-radius: 10px;
}
.wl-sidebar-item.active .wl-sidebar-count {
  background: rgba(8,145,178,0.15);
  color: var(--teal-dark);
}

/* ==========================================================================
   사이드바 검색창 (연령대 아래)
   ========================================================================== */
.wl-sidebar-search {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--sand-dark);
  border: 1.5px solid #C9BFAD;
  border-radius: 10px;
  padding: 8px 12px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.wl-sidebar-search:hover {
  border-color: #B4A88E;
}
.wl-sidebar-search:focus-within {
  background: #fff;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}
.wl-sidebar-search .wl-search-icon {
  color: var(--text-mid);
  flex-shrink: 0;
}
.wl-sidebar-search .wl-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--text-dark);
  font-family: inherit;
  padding: 2px 0;
}
.wl-sidebar-search .wl-search-input::placeholder {
  color: var(--text-mid);
}
.wl-sidebar-search .wl-search-clear {
  width: 22px;
  height: 22px;
  border: none;
  background: rgba(0,0,0,0.06);
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  color: var(--text-mid);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wl-sidebar-search .wl-search-clear:hover { background: rgba(0,0,0,0.12); }

/* ==========================================================================
   우선순위 안내 (읽기 전용 표 — 클릭 불가, 텍스트처럼)
   ========================================================================== */
.wl-legend {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--warm-border);
  border-radius: 8px;
  overflow: hidden;
  cursor: default;
  background: transparent;
}
.wl-legend-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--warm-border);
  font-size: 13px;
  line-height: 1.45;
}
.wl-legend-row:last-child { border-bottom: none; }
.wl-legend-label {
  font-size: 13px;
  font-weight: 700;
}
.wl-legend-row.priority-1 .wl-legend-label { color: rgba(177, 54, 54, 0.65); }
.wl-legend-row.priority-2 .wl-legend-label { color: rgba(180, 113, 8, 0.65); }
.wl-legend-row.priority-3 .wl-legend-label { color: rgba(78, 138, 127, 0.75); }
.wl-legend-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
}

/* ==========================================================================
   단어장 콘텐츠
   ========================================================================== */
.wl-content {
  flex: 1;
  min-width: 0;
}

/* ==========================================================================
   순위 필터 바 (세그먼트 컨트롤 — 메인 상단)
   UX: 검색창은 사이드바로 이동했고, 메인 상단은 순위 필터가 차지
   ========================================================================== */
.wl-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.wl-filter-seg {
  display: inline-flex;
  background: #fff;
  border: 1.5px solid var(--warm-border);
  border-radius: 10px;
  padding: 4px;
  gap: 2px;
  box-shadow: var(--shadow-sm);
}
.wl-filter-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-mid);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 18px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 36px;
}
.wl-filter-btn:hover {
  background: #F8FAFB;
  color: var(--text-dark);
}
.wl-filter-btn.active {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 2px 6px rgba(8, 145, 178, 0.25);
}
.wl-filter-btn.active.priority-1 {
  background: #D84848;
  box-shadow: 0 2px 6px rgba(216, 72, 72, 0.25);
}
.wl-filter-btn.active.priority-2 {
  background: #E8A020;
  box-shadow: 0 2px 6px rgba(232, 160, 32, 0.25);
}
.wl-filter-btn.active.priority-3 {
  background: #7AB5A8;
  box-shadow: 0 2px 6px rgba(122, 181, 168, 0.3);
}
.wl-filter-meta {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-mid);
}

.wl-search-status {
  font-size: 13px;
  color: var(--text-mid);
  padding: 0 4px 8px;
  min-height: 0;
}
.wl-search-status:empty { display: none; }

/* 검색 결과 grid — 카드 그룹 없이 flat */
.wl-search-grid {
  background: #fff;
  border: 1.5px solid #E8EFF2;
  border-radius: var(--r-md);
  padding: 16px;
}

/* 카드 하단 meta 태그 (연령 · 카테고리) */
.wl-card-meta {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
  margin-top: 2px;
  line-height: 1.3;
}

/* 검색 결과 0개 empty state */
.wl-search-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.wl-search-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.wl-search-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-mid);
}

/* 카테고리 섹션 */
.wl-cat {
  background: #fff;
  border: 1.5px solid #E8EFF2;
  border-radius: var(--r-md);
  margin-bottom: 12px;
  overflow: hidden;
}
.wl-cat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
}
.wl-cat-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-dark);
}
.wl-cat-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
}

/* 카드 그리드 */
.wl-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 0 16px 16px;
}

/* ==========================================================================
   단어 카드 — 레퍼런스 모드 (버튼 없음, 클릭 가능)
   ========================================================================== */
.wl-card {
  position: relative;
  background: #fff;
  border: 1.5px solid #E8EFF2;
  border-radius: var(--r-sm);
  padding: 10px 8px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.wl-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* 우선순위 배지 */
.wl-card-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  z-index: 1;
  opacity: 0.80;
}
.wl-card-badge.priority-1 { background: #D84848; color: #fff; }
.wl-card-badge.priority-2 { background: #E8A020; color: #fff; }
.wl-card-badge.priority-3 { background: #7AB5A8; color: #fff; }

/* 카드 이미지 */
.wl-card-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin: 0 auto 6px;
  display: block;
}

/* 카드 단어명 */
.wl-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
}

/* ==========================================================================
   단어 상세 모달
   ========================================================================== */
.wl-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
}
.wl-modal-overlay.show {
  display: flex;
}

.wl-modal {
  position: relative;
  background: #fff;
  border-radius: 20px;
  width: 760px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  display: flex;
  align-items: stretch;
}

/* 이미지 영역 — 좌측 고정 */
.wl-modal-img-wrap {
  flex: 0 0 auto;
}
/* 텍스트 영역 — 우측 flex */
.wl-modal-body {
  flex: 1 1 auto;
  min-width: 0;
}

/* 이미지 영역 — 시선 고정점 */
.wl-modal-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 28px 28px;
  background: #fff;
  border-radius: 20px 0 0 20px;
}
.wl-modal-img {
  width: 240px;
  height: 240px;
  object-fit: contain;
}

/* 텍스트 영역 — 좌측 정렬 */
.wl-modal-body {
  padding: 28px 28px 24px 20px;
  display: flex;
  flex-direction: column;
}

.wl-modal-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 4px;
  text-align: center;
}

.wl-modal-age {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-mid);
  margin-bottom: 14px;
  text-align: center;
}

/* 순위 + 근거 — 색상 카드 프레이밍 */
.wl-modal-priority {
  padding: 12px 18px 14px;
  border-radius: var(--r-sm);
  border-left: 4px solid;
}
.wl-modal-priority.priority-1 {
  background: #FEF2F2;
  border-left-color: #D84848;
}
.wl-modal-priority.priority-2 {
  background: #FFFBEB;
  border-left-color: #E8A020;
}
.wl-modal-priority.priority-3 {
  background: #F0FDFA;
  border-left-color: #7AB5A8;
}

.wl-modal-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
}
.wl-modal-badge.priority-1 { background: #D84848; }
.wl-modal-badge.priority-2 { background: #E8A020; }
.wl-modal-badge.priority-3 { background: #7AB5A8; }

.wl-modal-reason {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-dark);
  line-height: 1.65;
}

/* 좁은 화면: 모달 세로 스택 복원 */
@media (max-width: 680px) {
  .wl-modal { flex-direction: column; }
  .wl-modal-img-wrap {
    padding: 24px 20px 12px;
    border-radius: 20px 20px 0 0;
  }
  .wl-modal-img { width: 200px; height: 200px; }
  .wl-modal-body { padding: 16px 24px 24px; }
  .wl-modal-name, .wl-modal-age { text-align: center; }
}


/* ==========================================================================
   반응형
   ========================================================================== */
@media (max-width: 768px) {
  .wl-main { flex-direction: column; gap: 16px; }
  .wl-sidebar-wrap { width: 100%; position: static; }
  .wl-sidebar { width: 100%; }
  .wl-sidebar-list { flex-direction: row; gap: 4px; overflow-x: auto; }
  .wl-sidebar-item {
    white-space: nowrap;
    padding: 8px 14px;
    border-left: none;
    border-bottom: 3px solid transparent;
  }
  .wl-sidebar-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--teal);
  }
  .wl-sidebar-search { margin-top: 10px; }
  .wl-legend { display: none; }
  .wl-filter-bar { flex-direction: column; align-items: flex-start; }
  .wl-filter-seg { width: 100%; justify-content: space-between; }
  .wl-filter-btn { flex: 1; padding: 8px 10px; }
  .wl-card-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .wl-card-img { width: 72px; height: 72px; }
}
