/* apps/web-html/css/base.css
 * 공용 컴포넌트 스타일 (DESIGN-01). 값은 tokens.css 변수만 쓴다.
 * 순서: 기본 → 버튼·칩 → 카드·스켈레톤 → 배너 → 카테고리 탭 → 토스트 → 모바일
 */

/* ---------- 기본 ---------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--c-accent-text); }
/* hidden 속성이 .hero 같은 display 지정에 덮이지 않게 */
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.wrap { max-width: var(--w-page); margin: 0 auto; padding: 28px 32px 64px; }

/* 상단 내비게이션은 nav.css (모든 화면 공통) */

.page-title { margin: 0; font-size: 22px; font-weight: 700; }

/* ---------- 검색바 ---------- */
.search-bar { display: flex; gap: var(--sp-2); }
.search-field {
  flex: 1; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px;
  border-radius: var(--r-md); background: var(--c-surface); border: 1px solid var(--c-line);
  color: var(--c-text-muted);
}
.search-field:focus-within { border-color: var(--c-accent); }
.search-field input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  color: var(--c-text); font: inherit; font-size: 15px;
}

/* ---------- 버튼·칩 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 22px; border-radius: var(--r-md); border: 0;
  font: inherit; font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--c-accent); color: #FFFFFF; }
.btn-primary:hover { background: var(--c-accent-hover); color: #FFFFFF; }
.btn-ghost { background: rgba(255, 255, 255, 0.1); color: var(--c-text); border: 1px solid rgba(255, 255, 255, 0.14); }
.btn-gold { background: rgba(230, 194, 122, 0.14); color: var(--c-gold); border: 1px solid rgba(230, 194, 122, 0.3); }

.chips { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.chip {
  padding: 2px 8px; border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.12); color: #E9E6F2; font-size: 11px; line-height: 1.6;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .chips { flex-wrap: nowrap; overflow: hidden; }
.card .chip { flex: 0 1 auto; min-width: 0; max-width: 60%; }
.eyebrow {
  align-self: flex-start; padding: 5px 10px; border-radius: 999px;
  background: rgba(13, 12, 18, 0.6); border: 1px solid rgba(230, 194, 122, 0.4); color: var(--c-gold);
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
}

/* ---------- 카드 (세로 3:4, 이미지 위 정보) ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--sp-4); }
.card {
  position: relative; display: block; aspect-ratio: 3 / 4; overflow: hidden;
  border-radius: 18px; background: var(--c-surface);
  color: var(--c-text); text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45); }
.card:focus-visible { outline: 2px solid var(--c-accent-text); outline-offset: 2px; }
.card .thumb {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; background: var(--c-surface);
}
.card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(13, 12, 18, 0) 45%, rgba(13, 12, 18, 0.92) 100%);
}
.card .body {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  padding: 14px; display: flex; flex-direction: column; gap: 6px;
}
.card .name { font-size: 17px; font-weight: 700; line-height: 1.3; }
.card .meta {
  font-size: 13px; line-height: 1.45; color: var(--c-text-sub);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.skeleton-card {
  aspect-ratio: 3 / 4; border-radius: 18px; overflow: hidden; position: relative;
  background: var(--c-surface); animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-thumb { display: none; }
.skeleton-body { position: absolute; left: 14px; right: 14px; bottom: 14px; }
.skeleton-name { width: 55%; height: 18px; background: var(--c-surface-2); border-radius: 4px; margin-bottom: 8px; }
.skeleton-meta { width: 85%; height: 14px; background: var(--c-surface-2); border-radius: 4px; }
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ---------- 홈 배너 ---------- */
.hero {
  position: relative; min-height: 340px; border-radius: var(--r-xl); overflow: hidden;
  display: flex; align-items: flex-end; background: var(--c-surface);
}
/* 배너 전용 이미지가 없어 카드 이미지(캐릭터 3:4 등)를 쓴다. 잘라 채우지 않고 통째로 보이고,
   남는 공간은 같은 이미지를 흐리게 깔아 채운다 (BUG-013) */
.hero-bg {
  position: absolute; inset: -32px; width: calc(100% + 64px); height: calc(100% + 64px);
  object-fit: cover; filter: blur(28px) brightness(0.5); transition: opacity .35s ease;
}
.hero-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; object-position: right center; transition: opacity .35s ease;
}
.hero-img.is-fading, .hero-bg.is-fading { opacity: 0; }
.hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(13, 12, 18, 0.94) 0%, rgba(13, 12, 18, 0.72) 38%, rgba(13, 12, 18, 0.05) 75%);
}
.hero-body {
  position: relative; z-index: 1; padding: 40px 44px; max-width: 540px;
  display: flex; flex-direction: column; gap: 14px;
}
.hero-title { margin: 0; font-size: 40px; line-height: 1.15; font-weight: 700; }
.hero-desc {
  margin: 0; font-size: 16px; line-height: 1.6; color: var(--c-text-sub);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero .chip { padding: 4px 10px; border-radius: 8px; font-size: 12px; background: rgba(255, 255, 255, 0.08); color: var(--c-text-sub); }
.hero-dots { position: absolute; right: 24px; bottom: 22px; z-index: 1; display: flex; gap: 6px; }
.hero-dots span { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.3); transition: width .2s ease; }
.hero-dots span.on { width: 18px; background: var(--c-text); }

/* ---------- 카테고리 탭 (세그먼트) ---------- */
.category-tabs {
  display: inline-flex; align-self: flex-start; padding: 4px; gap: 2px; border-radius: 14px;
  background: var(--c-surface); border: 1px solid var(--c-line-soft);
}
.category-tab {
  height: 40px; padding: 0 20px; border: 0; border-radius: 10px;
  background: transparent; color: var(--c-text-muted);
  font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; transition: background .15s ease, color .15s ease;
}
.category-tab:hover { color: var(--c-text); }
.category-tab.active { background: var(--c-text); color: var(--c-bg); font-weight: 600; }

/* ---------- 스크롤 시 상단 메뉴 아래에 고정 (UX-004) ---------- */
:root { --h-nav: 67px; }
.sticky-controls {
  position: sticky; top: var(--h-nav); z-index: 20;
  margin: -10px 0; padding: 10px 0; background: var(--c-bg);
}

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity .18s ease;
}
.toast.show { opacity: 1; }
.toast .box {
  pointer-events: auto; min-width: 200px; max-width: 80vw; padding: 14px 18px; text-align: center;
  background: var(--c-surface); border: 1px solid var(--c-line); color: var(--c-text);
  border-radius: var(--r-md); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* ---------- 모바일 ---------- */
@media (max-width: 720px) {
  .wrap { padding: 12px 16px 32px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { border-radius: var(--r-lg); }
  .card .body { padding: 10px; gap: 3px; }
  .card .name { font-size: 15px; }
  .card .meta { font-size: 12px; -webkit-line-clamp: 1; }
  .card .chips { display: none; }

  .hero { min-height: 220px; border-radius: 20px; }
  .hero-img { object-position: center top; }
  .hero::after { background: linear-gradient(180deg, rgba(13, 12, 18, 0) 25%, rgba(13, 12, 18, 0.92) 100%); }
  .hero-body { padding: 16px; gap: 6px; }
  .hero-title { font-size: 22px; }
  .hero-desc { font-size: 13px; -webkit-line-clamp: 1; }
  .hero .chips { display: none; }
  .hero .btn { height: 38px; padding: 0 14px; font-size: 14px; margin-top: 4px; }
  .hero-dots { right: 16px; bottom: 16px; }

  .category-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .category-tab { padding: 0; font-size: 14px; }
}
@media (min-width: 520px) and (max-width: 720px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
