/* ---------------------------------------------------------------------------
   Emojis — a quiet search surface
   --------------------------------------------------------------------------- */
:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-muted: #f2f3f7;
  --border: #e7e8ee;
  --border-strong: #d6d8e2;
  --fg: #17181c;
  --fg-muted: #5e6170;
  --fg-subtle: #6e7180;
  --accent: #5e6ad2;
  --accent-soft: rgba(94, 106, 210, 0.1);
  --toast-bg: #ffffff;
  --toast-fg: #17181c;
  --shadow-pop: 0 12px 32px rgba(20, 22, 30, 0.14);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Helvetica Neue", Arial,
    sans-serif;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla",
    sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --surface: #151519;
    --surface-muted: #1c1c22;
    --border: #27272e;
    --border-strong: #3a3a44;
    --fg: #f2f2f5;
    --fg-muted: #b1b2bc;
    --fg-subtle: #858692;
    --accent: #9098f3;
    --accent-soft: rgba(144, 152, 243, 0.15);
    --toast-bg: #26262e;
    --toast-fg: #f2f2f5;
    --shadow-pop: 0 14px 40px rgba(0, 0, 0, 0.45);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent-soft);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.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;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 100;
  transform: translate(-50%, -160%);
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--fg);
  color: var(--bg);
  font-size: 12px;
  text-decoration: none;
  transition: transform 0.15s ease;
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------------------
   Layout
   --------------------------------------------------------------------------- */
.shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 24px;
}

.topbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  height: 56px;
}

.wordmark {
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.main {
  flex: 1 0 auto;
  padding: max(48px, calc(50vh - 115px)) 0 48px;
  transition: padding-top 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.main.is-searching {
  padding-top: 28px;
}

.search {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 8px 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--fg-subtle);
  stroke-width: 1.7;
  stroke-linecap: round;
  transition: stroke 0.15s ease;
}

.search-bar:focus-within .search-icon {
  stroke: var(--fg-muted);
}

.search-bar input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  letter-spacing: -0.01em;
  outline: none;
  appearance: none;
}

.search-bar input::placeholder {
  color: var(--fg-subtle);
  opacity: 1;
}

.search-bar input::-webkit-search-cancel-button,
.search-bar input::-webkit-search-decoration {
  display: none;
}

.clear-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--fg-subtle);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.clear-button:hover {
  background: var(--surface-muted);
  color: var(--fg);
}

.clear-button svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.key-hint {
  flex: 0 0 auto;
  min-width: 20px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--fg-subtle);
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.5;
  text-align: center;
  transition: opacity 0.15s ease;
}

.search-bar:focus-within .key-hint {
  opacity: 0;
}

.hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  margin: 10px 0 0;
  color: var(--fg-subtle);
  font-size: 10.5px;
}

.hint span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hint kbd {
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.5;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 14px;
  margin-top: 32px;
}

.suggestions-label {
  color: var(--fg-subtle);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.suggestion {
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--fg-muted);
  font-size: 11.5px;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.12s ease, text-decoration-color 0.12s ease;
}

.suggestion:hover {
  color: var(--fg);
  text-decoration-color: var(--border-strong);
}

/* ---------------------------------------------------------------------------
   Results
   --------------------------------------------------------------------------- */
.results {
  margin-top: 30px;
}

.results-meta {
  margin: 0 0 6px;
  color: var(--fg-subtle);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
  gap: 4px;
}

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 90px;
  padding: 14px 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.result:hover {
  background: var(--surface-muted);
}

.result[aria-selected="true"],
.result.copied {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.result.copied {
  transition-duration: 0.06s;
}

.result-emoji {
  font-family: var(--font-emoji);
  font-size: 26px;
  line-height: 1;
}

.result-name {
  display: -webkit-box;
  max-width: 100%;
  min-height: 2.6em;
  overflow: hidden;
  color: var(--fg-muted);
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.result:hover .result-name,
.result[aria-selected="true"] .result-name,
.result.copied .result-name {
  color: var(--fg);
}

/* Loading tiles */
.result.skeleton {
  cursor: default;
  pointer-events: none;
}

.result.skeleton:hover {
  background: transparent;
}

.sk-emoji,
.sk-name {
  background: var(--surface-muted);
  animation: pulse 1.4s ease-in-out infinite;
}

.sk-emoji {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.sk-name {
  width: 46px;
  height: 7px;
  border-radius: 4px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

/* Empty + error */
.state {
  padding: 40px 16px;
  text-align: center;
  color: var(--fg-muted);
  font-size: 12.5px;
}

.state p {
  margin: 0;
}

.state p + p {
  margin-top: 4px;
}

.state-detail {
  color: var(--fg-subtle);
  font-size: 11.5px;
}

.text-button {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.noscript-state {
  max-width: 480px;
  margin: 48px auto;
}

/* ---------------------------------------------------------------------------
   Toast
   --------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--toast-bg);
  color: var(--toast-fg);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

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

.toast-emoji {
  font-family: var(--font-emoji);
  font-size: 17px;
  line-height: 1;
}

.toast-text {
  overflow: hidden;
  font-size: 11.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-area {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .shell {
    padding: 0 16px;
  }

  .topbar {
    height: 52px;
  }

  .main {
    padding-top: max(40px, calc(50vh - 96px));
  }

  .main.is-searching {
    padding-top: 20px;
  }

  .search-bar {
    height: 44px;
  }

  .clear-button {
    width: 26px;
    height: 26px;
  }

  .suggestions {
    gap: 4px 12px;
    margin-top: 24px;
  }

  .suggestion {
    padding: 4px 0;
  }

  .results {
    margin-top: 24px;
  }

  .result {
    min-height: 84px;
    padding: 12px 6px 9px;
  }

  .result-emoji {
    font-size: 24px;
  }

  .result-name {
    font-size: 10.5px;
  }

  .hint {
    display: none;
  }

  .toast {
    bottom: 16px;
  }
}

@media (max-width: 460px) {
  .suggestion:last-child {
    display: none;
  }
}

@media (hover: none) {
  .hint,
  .key-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
