/* 이모지 검색 도구 전용 스타일
   테마: emojipedia.org를 참고한 블랙 배경 + 오렌지 포인트 컬러.
   검은 배경 위에서 이모지 원본 색이 또렷하게 도드라지도록 카드 테두리는 없애고,
   호버 시에만 은은한 밝은 배경으로 반응하는 방식(emojipedia 그리드 스타일)을 씁니다. */

:root {
  --emoji-primary: #fb923c;
  --emoji-primary-dark: #f97316;
  --emoji-bg: #0c0c10;
  --emoji-surface: #18181d;
  --emoji-surface-hover: #232329;
  --emoji-card-bg: #18181d;
  --emoji-border: #2a2a32;
  --emoji-text: #f4f4f5;
  --emoji-text-muted: #9ca3af;
  --emoji-radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--emoji-bg);
  color: var(--emoji-text);
  line-height: 1.6;
}

/* back-link을 position:fixed로 화면에 띄우면, 스크롤 중인 본문 텍스트가 그 아래를
   지나가는 순간마다 겹쳐 보이는 문제가 있었습니다(실사용 스크린샷으로 발견). 그래서
   버튼만 따로 띄우는 대신, 폭 전체를 덮는 불투명한 배경의 sticky 바(.top-bar) 안에
   버튼을 넣는 방식으로 바꿨습니다 — 그 바 아래로 지나가는 내용은 불투명 배경에
   완전히 가려지므로 어떤 화면 크기에서도 겹쳐 보이지 않습니다. */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 16px;
  background: var(--emoji-bg);
}

/* PC처럼 넓은 화면에서는 스크롤을 올렸을 때 상단바 전체가 화면을 가리지 않도록,
   막대(.top-bar) 자체를 폭 전체가 아니라 버튼 크기만큼만 남기고 배경도 지웁니다.
   .back-link 자체가 이미 불투명한 배경(pill 버튼)을 갖고 있어서 겹침 문제 없이
   버튼만 떠 있는 것처럼 보입니다. */
@media (min-width: 768px) {
  .top-bar {
    width: fit-content;
    height: auto;
    padding: 12px 16px 0;
    background: transparent;
  }
}

.back-link {
  display: inline-block;
  padding: 6px 14px;
  background: var(--emoji-surface);
  border: 1px solid var(--emoji-border);
  border-radius: 999px;
  color: var(--emoji-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
}

.back-link:hover {
  color: var(--emoji-primary);
}

.page-header {
  text-align: center;
  padding: 10px 16px 16px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-family: "Encode Sans Expanded", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 800;
  font-size: 2.2rem;
  letter-spacing: -0.01em;
  color: var(--emoji-primary-dark);
}

.subtitle {
  margin: 0;
  color: var(--emoji-text-muted);
  font-size: 1.1rem;
}

.tagline-extra {
  margin: 6px 0 0;
  color: var(--emoji-text-muted);
  font-size: 0.9rem;
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.recent-section {
  margin-top: 24px;
}

.recent-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.recent-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--emoji-text);
}

.recent-clear {
  border: none;
  background: none;
  color: var(--emoji-text-muted);
  font-size: 0.83rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.recent-clear:hover {
  color: var(--emoji-primary);
}

.recent-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.recent-card {
  flex: 0 0 auto;
  cursor: pointer;
}

.recent-card-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--emoji-surface);
  transition: background 0.12s ease, transform 0.08s ease;
}

.recent-card:hover .recent-card-visual,
.recent-card:focus-visible .recent-card-visual {
  background: var(--emoji-surface-hover);
  transform: scale(1.08);
}

.recent-card-visual img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
}

.recent-card-fallback {
  font-size: 1.8rem;
  line-height: 1;
}


@keyframes emoji-card-flash {
  0%,
  100% {
    box-shadow: none;
  }
  25%,
  75% {
    box-shadow: 0 0 0 4px rgba(251, 146, 60, 0.45);
  }
}

.emoji-card.is-flashing .emoji-visual {
  animation: emoji-card-flash 0.75s ease-in-out 3;
}

.search-section {
  position: sticky;
  top: 56px;
  background: var(--emoji-bg);
  padding: 16px 0;
  z-index: 10;
}

.search-input-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--emoji-text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 14px 18px 14px 44px;
  font-size: 1.2rem;
  border: 2px solid var(--emoji-border);
  border-radius: var(--emoji-radius);
  outline: none;
  background: var(--emoji-surface);
  color: var(--emoji-text);
  transition: border-color 0.15s ease;
}

#search-input::placeholder {
  color: var(--emoji-text-muted);
}

#search-input:focus {
  border-color: var(--emoji-primary);
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.category-tab {
  flex: 0 0 auto;
  padding: 7px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--emoji-border);
  border-radius: 999px;
  background: var(--emoji-card-bg);
  color: var(--emoji-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.category-tab:hover {
  border-color: var(--emoji-primary);
  color: var(--emoji-primary-dark);
}

.category-tab.is-active {
  background: var(--emoji-primary);
  border-color: var(--emoji-primary);
  color: #17110a;
}

.result-count {
  margin: 8px 2px 0;
  font-size: 0.9rem;
  color: var(--emoji-text-muted);
}

.emoji-sections {
  margin-top: 8px;
}

.emoji-subgroup {
  margin-bottom: 28px;
}

.emoji-subgroup-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--emoji-text);
  margin: 0 0 14px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  justify-items: center;
  gap: 4px;
}

.emoji-card {
  text-align: center;
}

.emoji-card .emoji-visual {
  cursor: pointer;
  border: none;
  background: transparent;
  /* 퍼센트(%) 크기 대신 고정 px로 지정합니다. 그리드 셀 폭은 화면마다 소수점 값이라
     %로 계산하면 아이콘마다 반올림 오차가 미세하게 달라질 수 있는데, 고정 px는
     항상 정확히 정사각형으로 렌더링됩니다. */
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  transition: background 0.12s ease, transform 0.08s ease;
}

.emoji-card .emoji-visual:hover,
.emoji-card .emoji-visual:focus-visible {
  background: var(--emoji-surface-hover);
  transform: scale(1.12);
}

.emoji-card img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
}

.emoji-card .emoji-fallback {
  font-size: 2.5rem;
  line-height: 1;
}

.download-btn-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.emoji-card .download-btn {
  flex: 1;
  padding: 5px 0;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: var(--emoji-primary);
  color: #fff;
  cursor: pointer;
}

.emoji-card .download-btn:hover {
  background: var(--emoji-primary-dark);
}

.emoji-card .download-btn-svg {
  background: #78716c;
}

.emoji-card .download-btn-svg:hover {
  background: #57534e;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--emoji-text-muted);
  padding: 40px 0;
}

.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: var(--emoji-primary);
  color: #17110a;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
}

.copy-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.ads-container {
  margin: 40px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--emoji-surface);
  border: 1px solid var(--emoji-border);
  border-radius: var(--emoji-radius);
  color: var(--emoji-text-muted);
  font-size: 0.9rem;
}

/* 좌우 여백에 붙어 스크롤을 따라다니는 세로형(스카이스크래퍼) 광고.
   본문(max-width: 1000px)과 최대 10px까지는 겹쳐도 노출합니다(flag-master와 동일 규칙). */
.ads-rail {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 160px;
  margin: 0;
  display: none;
  z-index: 5;
}

.ads-rail-left {
  left: 16px;
}

.ads-rail-right {
  right: 16px;
}

@media (min-width: 1332px) {
  .ads-rail {
    display: flex;
  }
}

.info-section {
  margin-top: 24px;
}

.info-section h2 {
  color: var(--emoji-primary-dark);
  font-size: 1.35rem;
  margin-top: 32px;
}

.faq-list .faq-item {
  margin-bottom: 16px;
}

.faq-list dt {
  font-weight: 600;
  color: var(--emoji-text);
  margin-bottom: 4px;
}

.faq-list dd {
  margin: 0;
  color: var(--emoji-text-muted);
}

.page-footer {
  text-align: center;
  padding: 24px 16px 40px;
  color: var(--emoji-text-muted);
  font-size: 0.85rem;
}

.footer-links {
  margin: 8px 0 0;
}

.footer-links a {
  color: var(--emoji-text-muted);
  text-decoration: underline;
}

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

@media (max-width: 480px) {
  .emoji-grid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 6px;
  }

  .emoji-card .emoji-visual {
    width: 64px;
    height: 64px;
  }

  .emoji-card img {
    width: 50px;
    height: 50px;
  }

  .emoji-card .emoji-fallback {
    font-size: 2.8rem;
  }

  .page-header h1 {
    font-size: 1.7rem;
  }
}

.scroll-top-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--emoji-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  transition: background 0.12s ease, transform 0.12s ease;
}

.scroll-top-btn:hover {
  background: var(--emoji-primary-dark);
  transform: translateY(-2px);
}

/* [hidden] 속성과 .scroll-top-btn { display:flex }는 상세도(specificity)가 같아서
   나중에 선언된 쪽이 이겨 hidden이 무시되는 문제가 있었습니다(카테고리 폼에서 이미
   겪은 버그와 동일한 원인). 그래서 [hidden]을 명시적으로 다시 덮어씁니다. */
.scroll-top-btn[hidden] {
  display: none;
}
