/* ==========================================================================
   Emoji Search & Copy — style.css
   Accent colors come from the shared theme (cdn.yusufaw.me/theme.css):
   --accent, --accent-hover, --accent-soft, --accent-2, --accent-rgb, --accent-border
   ========================================================================== */

:root {
  /* Warm, paper-like neutral base tuned to sit under a teal accent */
  --bg: #f4f6f6;
  --bg-2: #eef1f2;
  --surface: #ffffff;
  --surface-2: #fbfcfc;
  --text: #182226;
  --text-soft: #55636a;
  --text-faint: #84949a;
  --border: #e4e8e9;
  --border-strong: #d1d8da;

  --shadow-sm: 0 1px 2px rgba(24, 34, 38, 0.05);
  --shadow: 0 1px 2px rgba(24, 34, 38, 0.04), 0 10px 30px rgba(24, 34, 38, 0.07);
  --shadow-lg: 0 2px 4px rgba(24, 34, 38, 0.05), 0 24px 60px rgba(24, 34, 38, 0.12);

  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 13px;
  --maxw: 1120px;

  --ease: cubic-bezier(0.34, 1.56, 0.64, 1); /* gentle overshoot */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Fallbacks in case theme.css fails to load */
:root {
  --accent: var(--accent, #2a737e);
  --accent-hover: var(--accent-hover, #235f69);
  --accent-soft: var(--accent-soft, #e2eef0);
  --accent-2: var(--accent-2, #4f9aa6);
  --accent-border: var(--accent-border, #c2dbdf);
  --accent-rgb: var(--accent-rgb, 42, 115, 126);
}

/* Dark palette. Applied when the OS prefers dark (unless the user forced
   light), or when the user explicitly picks dark via the header toggle.
   Keep these two blocks in sync. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1417;
    --bg-2: #101a1e;
    --surface: #161f23;
    --surface-2: #1a2529;
    --text: #ecf1f2;
    --text-soft: #9db0b6;
    --text-faint: #6a7d84;
    --border: #24322f;
    --border-strong: #33454b;

    /* Re-tint the accent soft/border tokens so hovers read on dark surfaces */
    --accent-soft: color-mix(in srgb, var(--accent) 22%, var(--surface));
    --accent-border: color-mix(in srgb, var(--accent) 42%, var(--border));

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 34px rgba(0, 0, 0, 0.42);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.4), 0 28px 64px rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme="dark"] {
  --bg: #0d1417;
  --bg-2: #101a1e;
  --surface: #161f23;
  --surface-2: #1a2529;
  --text: #ecf1f2;
  --text-soft: #9db0b6;
  --text-faint: #6a7d84;
  --border: #24322f;
  --border-strong: #33454b;

  --accent-soft: color-mix(in srgb, var(--accent) 22%, var(--surface));
  --accent-border: color-mix(in srgb, var(--accent) 42%, var(--border));

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 34px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.4), 0 28px 64px rgba(0, 0, 0, 0.55);
}

/* Keep native form controls / scrollbars aligned to the active theme */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Ambient accent glow behind the hero — adds depth to the flat neutral base */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1000px 560px at 82% -10%, color-mix(in srgb, var(--accent-2) 24%, transparent), transparent 60%),
    radial-gradient(1200px 680px at 8% -14%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 58%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
a:hover { color: var(--accent-hover); }

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.25rem);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.85rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 11px;
  background: linear-gradient(150deg, var(--accent-2), var(--accent));
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  box-shadow: 0 5px 14px rgba(var(--accent-rgb), 0.35),
              inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.25s var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.28rem;
  letter-spacing: -0.015em;
}
.brand-tag {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

/* Right-side header cluster */
.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--text-soft);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease,
              transform 0.16s var(--ease), box-shadow 0.16s ease;
}
.theme-toggle:hover {
  color: var(--accent-hover);
  background: var(--accent-soft);
  border-color: var(--accent-border);
  transform: translateY(-1px);
}
.theme-toggle:active { transform: translateY(0) scale(0.94); }
.theme-toggle:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}
.theme-toggle svg {
  width: 19px;
  height: 19px;
}
/* Show the icon matching what a click will switch *to* */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
}
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }

/* ---------- Intro ---------- */
.intro {
  padding-block: clamp(2.75rem, 7vw, 5rem) 1.75rem;
  max-width: 48rem;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1.25rem;
  padding: 0.35rem 0.85rem 0.35rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 70%, transparent);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
}
.eyebrow::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.intro h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.35rem, 6.2vw, 3.9rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  margin: 0 0 1rem;
  text-wrap: balance;
}
.intro h1 em {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.lede {
  margin: 0;
  font-size: clamp(1.02rem, 2vw, 1.18rem);
  color: var(--text-soft);
  max-width: 40rem;
}

/* ---------- Controls (sticky) ---------- */
.controls {
  position: sticky;
  top: 3.6rem;
  z-index: 20;
  padding: 1rem;
  margin-bottom: 1.5rem;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: saturate(1.5) blur(14px);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 1.05rem;
  width: 20px; height: 20px;
  color: var(--text-soft);
  pointer-events: none;
  transition: color 0.18s ease, transform 0.25s var(--ease);
}
#search {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  color: var(--text);
  padding: 1rem 3.1rem 1rem 3rem;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
#search::placeholder { color: var(--text-faint); }
#search:focus-visible,
#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent),
              var(--shadow);
}
.search:focus-within .search-icon {
  color: var(--accent);
  transform: scale(1.05);
}

/* Keyboard hint badge */
.kbd-hint {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 7px;
  min-width: 1.5rem;
  padding: 0.15rem 0.4rem;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.search:focus-within .kbd-hint { opacity: 0; }

/* ---------- Category chips ---------- */
.categories { margin-top: 0.9rem; }
#category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.chip {
  position: relative;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.48rem 1.05rem;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease,
              transform 0.16s var(--ease), box-shadow 0.16s ease;
}
.chip:hover {
  color: var(--accent-hover);
  border-color: var(--accent-border);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.chip:active { transform: translateY(0) scale(0.97); }

/* Active category — solid saturated fill + selection ring so it is unmistakable */
.chip.is-active {
  color: #fff;
  font-weight: 700;
  background: var(--accent, #2a737e);
  border-color: var(--accent, #2a737e);
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #2a737e) 32%, transparent),
              0 9px 20px rgba(var(--accent-rgb), 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.chip.is-active:hover {
  color: #fff;
  background: var(--accent-hover, #235f69);
  border-color: var(--accent-hover, #235f69);
  transform: translateY(-2px);
}
/* Leading dot marker so the selected chip reads clearly, even without color */
.chip.is-active::before {
  content: "";
  display: inline-block;
  width: 0.42rem;
  height: 0.42rem;
  margin-right: 0.45rem;
  vertical-align: 0.06em;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
}
.chip:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Result count ---------- */
.result-count {
  margin: 0 0 1.1rem;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-soft);
}

/* ---------- Grid ---------- */
.grid {
  list-style: none;
  margin: 0 0 3.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.7rem;
}
.grid > li {
  min-width: 0; /* allow grid item to shrink so labels can ellipsis-clip */
  display: flex;
}

.card {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  padding: 1.15rem 0.5rem 0.9rem;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-soft);
  text-align: center;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), border-color 0.2s ease,
              box-shadow 0.2s var(--ease-out), background 0.2s ease;
  overflow: hidden;
}
.card:hover {
  border-color: var(--accent-border);
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--accent-soft) 45%, var(--surface)));
  box-shadow: 0 12px 26px rgba(var(--accent-rgb), 0.16);
  transform: translateY(-4px);
}
.card:active { transform: translateY(-1px) scale(0.97); }
.card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent);
}
.card-emoji {
  display: block;
  font-size: 2.05rem;
  line-height: 1.15;
  margin-bottom: 0.55rem;
  transition: transform 0.24s var(--ease);
  /* Keep native color emoji rendering */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.card:hover .card-emoji { transform: scale(1.24) rotate(-4deg); }
.card-name {
  display: block;
  min-width: 0;
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.16s ease;
}
.card:hover .card-name { color: var(--accent-hover); }

/* Per-card copied flash — accent fill with a check */
.card.copied {
  border-color: var(--accent);
}
.card.copied::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-radius: inherit;
  animation: cardCopied 0.9s var(--ease-out) forwards;
}
@keyframes cardCopied {
  0%   { opacity: 0; transform: scale(0.4); }
  20%  { opacity: 1; transform: scale(1); }
  70%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

.empty {
  text-align: center;
  color: var(--text-soft);
  padding: 3.5rem 1rem;
  font-size: 1rem;
}

/* ---------- Toast ----------
   High-contrast, theme-adaptive pill: dark on light mode, light on dark mode,
   so the "Copied" confirmation is always clearly legible. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 2.25rem;
  transform: translateX(-50%) translateY(1.5rem) scale(0.96);
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.5rem 0.85rem 0.9rem;
  background: var(--text);
  color: var(--surface);
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--surface) 16%, transparent);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.32),
              0 4px 14px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.28s var(--ease);
  z-index: 40;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}
.toast-emoji {
  font-size: 1.35rem;
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 16%, transparent);
}
/* Green-lit check so the confirmation reads instantly in both themes */
.toast-text::before {
  content: "✓";
  margin-right: 0.4rem;
  font-weight: 800;
  color: #34c98a;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: color-mix(in srgb, var(--surface) 45%, transparent);
}
.site-footer .wrap {
  padding-block: 1.75rem 2.75rem;
}
.site-footer p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .kbd-hint { display: none; }
  #search { padding-right: 1.1rem; }
  .controls { top: 3.3rem; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); }
  .card-emoji { font-size: 1.7rem; }
  .brand-tag { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover,
  .card:active,
  .chip:hover,
  .chip.is-active { transform: none; }
  .card:hover .card-emoji { transform: none; }
  .card.copied::after { animation: none; opacity: 1; }
}
