/* ============================================================
 * EMOJI UNIVERSE - APP-LEVEL OVERRIDES, UTILITIES, FINISH
 * Loaded last so it can override any prior rule.
 * ============================================================ */

/* -------------------- BODY / APP -------------------- */
.app-body {
  position: relative;
  min-height: 100vh;
  font-family: var(--font-body);
}

.app-body.is-locked {
  overflow: hidden;
}

/* -------------------- SECTION TRANSITIONS -------------------- */
.section[data-section] {
  animation: fadeUp 0.4s var(--ease-out-quart) backwards;
}

.section[hidden] {
  display: none;
}

/* -------------------- UTILITY -------------------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }

.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-md { font-size: 15px; }
.text-lg { font-size: 17px; }
.text-xl { font-size: 22px; }
.text-2xl { font-size: 28px; }
.text-3xl { font-size: 36px; }

.text-mute { color: var(--color-fg-mute); }
.text-dim  { color: var(--color-fg-dim); }
.text-accent { color: var(--color-accent); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }

.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.surface    { background: var(--color-surface); }
.surface-2  { background: var(--color-surface-2); }
.surface-3  { background: var(--color-surface-3); }

.bordered { border: 1px solid var(--color-border); }
.bordered-strong { border: 1px solid var(--color-border-strong); }

/* -------------------- COPY ACTION INLINE FEEDBACK -------------------- */
.copy-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 22px;
  border-radius: var(--radius-full);
  background: var(--grad-accent);
  color: #000;
  font-weight: 700;
  font-size: 14px;
  pointer-events: none;
  z-index: var(--layer-toast);
  opacity: 0;
  animation: copyToastIn 1.4s ease forwards;
}

@keyframes copyToastIn {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); }
}

/* -------------------- FLY-COPY GLYPH -------------------- */
.fly-copy {
  position: fixed;
  font-size: 28px;
  pointer-events: none;
  z-index: var(--layer-toast);
  animation: flyToCorner 720ms cubic-bezier(0.55, 0, 0.1, 1) forwards;
}

@keyframes flyToCorner {
  0%   { transform: scale(1) translate(0, 0); opacity: 1; }
  100% { transform: scale(0.4) translate(40vw, -40vh); opacity: 0; }
}

/* -------------------- NEW BADGE -------------------- */
.tag-new {
  display: inline-block;
  padding: 2px 8px;
  background: var(--grad-accent);
  color: #000;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: var(--radius-full);
}

/* -------------------- COUNT-UP NUMBERS -------------------- */
.stat__num {
  display: inline-block;
}

.stat__num.is-counting {
  animation: counterRoll 0.4s ease;
}

/* -------------------- CARD CONTEXT MENU -------------------- */
.card-menu {
  position: absolute;
  z-index: var(--layer-modal);
  background: var(--color-bg-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  min-width: 180px;
}

.card-menu.is-open {
  display: block;
  animation: fadeUp var(--t-base) var(--ease-out-back);
}

.card-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--color-fg);
  transition: background var(--t-fast) ease;
}

.card-menu__item:hover {
  background: var(--color-surface-2);
}

.card-menu__item-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

/* -------------------- VISIBILITY -------------------- */
.is-hidden { display: none !important; }
.is-invisible { visibility: hidden !important; }
.is-fade-out { animation: fadeOut var(--t-base) forwards; }
.is-fade-in  { animation: fadeIn var(--t-base) forwards; }

/* -------------------- FOCUS RING (for keyboard users) -------------------- */
.card:focus-visible,
.sticker:focus-visible,
.kao:focus-visible,
.gif-card:focus-visible,
.symbol:focus-visible,
.reaction-pack__item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* -------------------- BODY THEME EFFECTS -------------------- */
[data-theme="retro"] body {
  text-shadow: 0 0 6px rgba(126, 255, 126, 0.4);
}

[data-theme="retro"] .section__title {
  font-family: var(--font-display);
  font-size: clamp(20px, 3vw, 28px);
  text-shadow: 2px 2px 0 rgba(255, 184, 77, 0.6);
}

[data-theme="vapor"] .hero__title {
  text-shadow: 4px 4px 0 var(--color-accent-2);
}

[data-theme="solar"] .hero__title {
  text-shadow: 6px 6px 0 #000;
}

[data-theme="mono"] .card:hover {
  filter: invert(1);
}

[data-theme="paper"] .card {
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.04),
    0 2px 8px rgba(0, 0, 0, 0.06);
}

/* -------------------- PRINTABLE EMOJI SHEET -------------------- */
@media print {
  .cards-grid {
    grid-template-columns: repeat(10, 1fr) !important;
  }
  .card__glyph {
    font-size: 30px !important;
  }
  .card__label {
    opacity: 1 !important;
    font-size: 9px !important;
  }
}

/* -------------------- FINAL POLISH -------------------- */
::selection {
  background: var(--color-accent);
  color: var(--color-bg);
}

/* Smooth out interactive items */
button,
.card,
.sticker,
.kao,
.gif-card,
.symbol,
.reaction-pack__item,
.chip,
.cat,
.seg__btn {
  user-select: none;
  -webkit-user-select: none;
}

/* Selection text shouldn't break on emoji */
.card__glyph,
.sticker__glyph,
.modal__hero,
.symbol {
  -webkit-user-select: text;
  user-select: text;
}

/* -------------------- HEADER COMPACT ON SCROLL -------------------- */
.app-header.is-scrolled {
  border-bottom-color: var(--color-border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* -------------------- TOOLBAR COMPACT ON SCROLL -------------------- */
.sticky-toolbar.is-scrolled {
  border-bottom-color: var(--color-border-strong);
}

/* -------------------- LOADING-DOTS INLINE -------------------- */
.inline-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-fg-mute);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* -------------------- ANIMATED PLACEHOLDERS WHEN EMPTY -------------------- */
.placeholder-card {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg,
    var(--color-surface) 0%,
    var(--color-surface-2) 50%,
    var(--color-surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}

/* -------------------- DEBUG / DEV (toggle with key) -------------------- */
[data-debug="1"] *:not(:focus-visible) {
  outline: 1px dashed rgba(255, 0, 255, 0.18);
}

/* -------------------- TINY HAPPY DETAILS -------------------- */
.brand:hover .brand__icon-emoji {
  animation: tada 0.8s;
}

.icon-btn:hover {
  animation: bobSmall 0.6s ease;
}

.app-nav__link.is-active span {
  animation: pop 0.4s var(--ease-out-back);
}

/* Settle gradient cards smoothly */
.card {
  transition-property: transform, background, border-color, box-shadow, opacity;
}

/* -------------------- HEADER SHRINK -------------------- */
.app-header.is-shrunk {
  height: 56px;
}

.app-header.is-shrunk .brand__icon {
  width: 36px;
  height: 36px;
}

.app-header.is-shrunk .brand__icon-emoji {
  font-size: 20px;
}

.app-header.is-shrunk .brand__sub {
  display: none;
}

/* -------------------- ATOMIC HELPERS -------------------- */
.w-full { width: 100%; }
.h-full { height: 100%; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.block { display: block; }
.inline-block { display: inline-block; }
.grid { display: grid; }
.hidden { display: none; }
.cursor-pointer { cursor: pointer; }
.pointer-events-none { pointer-events: none; }

/* -------------------- SHIFT NUMBERS WHEN COUNTING -------------------- */
.stat__num {
  font-variant-numeric: tabular-nums;
}

/* -------------------- LIVE INDICATOR -------------------- */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  margin-right: 6px;
  box-shadow: 0 0 0 0 var(--color-success);
  animation: livePulse 1.6s infinite;
}

@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 var(--color-success); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* -------------------- BIG-EMOJI MODE -------------------- */
.bigmoji-mode .card {
  aspect-ratio: 3 / 4;
}

.bigmoji-mode .card__glyph {
  font-size: 4em;
}

/* -------------------- TOOLTIP -------------------- */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--color-bg-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xs);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) ease;
}

.tooltip:hover::after {
  opacity: 1;
}

/* -------------------- VARIANT SIZES FOR CARDS GRID -------------------- */
.cards-grid[data-size="xs"] .card {
  padding: 6px;
}

.cards-grid[data-size="xl"] .card {
  padding: var(--space-5);
}

/* -------------------- STAGGER ANIM-OUT WHEN FILTERING -------------------- */
.cards-grid.is-filtering .card {
  animation: fadeOut 200ms ease forwards;
}

/* -------------------- FOOTER POLISH -------------------- */
.app-footer__brand .brand__icon-emoji {
  animation: pulse 2.2s ease-in-out infinite;
}

/* -------------------- END -------------------- */
