/* ═══════════════════════════════════════════════════════════
   EmojiCraft — styles.css
   Default: light mode  |  [data-theme="dark"]: dark mode
═══════════════════════════════════════════════════════════ */

/* ── Custom properties ── */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface2: #f9f9fb;
  --border: #e8e8ec;
  --text: #1a1a1a;
  --text2: #6b6b7a;
  --text3: #adadbc;
  --accent: #F5C518;
  --accent-h: #D4A800;
  --accent-bg: rgba(245, 197, 24, 0.10);
  --accent-glow: rgba(245, 197, 24, 0.30);
  --accent-text: #1a1a1a;
  --cell-hover: #f0f0f5;
  --cell-select: #ede9fe;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 30px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 50px rgba(0, 0, 0, 0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #0d0d0f;
  --surface: #18181c;
  --surface2: #1f1f25;
  --border: #2a2a35;
  --text: #f0f0f5;
  --text2: #8888a0;
  --text3: #555568;
  --accent: #FDE047;
  --accent-h: #FEF08A;
  --accent-bg: rgba(253, 224, 71, 0.10);
  --accent-glow: rgba(253, 224, 71, 0.20);
  --accent-text: #1a1a1a;
  --cell-hover: #252530;
  --cell-select: #2d2b50;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 50px rgba(0, 0, 0, 0.6);
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition:
    background 0.25s,
    color 0.25s;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: var(--font);
}
input {
  font-family: var(--font);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text3);
}

/* ── Top nav ── */
.style-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: stretch;
  justify-content: center;
  transition: background 0.25s, border-color 0.25s;
}

.style-nav-inner {
  display: flex;
  align-items: stretch;
  flex: 1;
  justify-content: center;
}

/* ── Theme toggle — bare image, peeks from under the nav ── */
.theme-btn {
  position: fixed;
  top: 2rem;
  right: -.5rem;
  z-index: 9999;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 100px;
  height: 100px;
}
.theme-btn .btn-moon,
.theme-btn .btn-sun {
  position: absolute;
  top: 0;
  left: 0;
  height: 100px;
  width: auto;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  transform: scale(0.9);
  pointer-events: none;
}
[data-theme="light"] .theme-btn .btn-moon {
  opacity: 1;
  transform: scale(1);
}
[data-theme="dark"] .theme-btn .btn-sun {
  opacity: 1;
  transform: scale(1);
}
/* ═══════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════ */

.app {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 56px;
  flex: 1;
  overflow: hidden;
  padding: 32px 24px;
  position: relative;
  z-index: 1;
}

/* ── LEFT: preview section ── */
.preview-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  width: 280px;
}

/* Emoji display */
.emoji-display {
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.emoji-display img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.18));
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.emoji-display .emoji-char {
  font-size: 160px;
  line-height: 1;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.15));
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.82);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.emoji-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0.25;
}
.emoji-placeholder span {
  font-size: 80px;
  line-height: 1;
}
.emoji-placeholder p {
  font-size: 0.85rem;
  color: var(--text2);
  font-weight: 500;
}

/* Export controls */
.export-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

/* Download button */
.dl-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 32px;
  border-radius: 50px;
  background: var(--accent);
  color: var(--accent-text, #1a1a1a);
  font-weight: 600;
  font-size: 0.9375rem;
  border: none;
  cursor: pointer;
  transition:
    background 0.18s,
    transform 0.15s,
    box-shadow 0.18s;
  box-shadow: 0 4px 18px var(--accent-glow);
  white-space: nowrap;
}
.dl-btn:hover {
  background: var(--accent-h);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow);
}
.dl-btn:active {
  transform: translateY(0);
}
.dl-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.dl-btn svg {
  flex-shrink: 0;
}

/* Segment groups */
.options-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seg-group {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 3px;
  gap: 2px;
}

.seg {
  padding: 5px 13px;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.14s;
  white-space: nowrap;
}
.seg:hover:not(.seg-active) {
  color: var(--text);
  background: var(--border);
}
.seg.seg-active {
  background: var(--accent);
  color: var(--accent-text, #1a1a1a);
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Custom size input */
.custom-sz {
  width: 72px;
  padding: 5px 10px;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.8rem;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}
.custom-sz:focus {
  border-color: var(--accent);
}
.custom-sz.hidden {
  display: none;
}

/* ZIP options */
.zip-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-left: 7em; 
}

.zip-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text2);
  user-select: none;
}

.zip-label-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}

.zip-label-text small {
  font-size: 0.68rem;
  color: var(--text3);
}

/* Toggle */
.toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle.on {
  background: var(--accent);
}
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.toggle.on .toggle-knob {
  transform: translateX(16px);
}


/* Hint text */
.hint {
  font-size: 0.8rem;
  color: var(--text3);
  text-align: center;
  line-height: 1.4;
}

/* Style nav buttons */
.style-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text2);
  padding: 14px 22px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  position: relative;
  bottom: -1px;
  white-space: nowrap;
}
.style-btn:hover {
  color: var(--text);
  background: var(--surface2);
}
.style-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── RIGHT: picker card ── */
.picker-section {
  flex-shrink: 0;
}

.picker-card {
  width: 342px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    background 0.25s,
    border-color 0.25s;
}

/* Category tabs */
.cat-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  flex: 1;
  min-width: 36px;
  padding: 8px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  position: relative;
  bottom: -1px;
  color: var(--text3);
}
.cat-tab svg {
  width: 18px;
  height: 18px;
  display: block;
}
.cat-tab:hover {
  background: var(--surface2);
  color: var(--text);
}
.cat-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

/* Search row */
.search-row {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  transition: border-color 0.15s;
}
.search-wrap:focus-within {
  border-color: var(--accent);
}

/* Skin tone picker */
.skin-tones {
  display: flex;
  gap: 6px;
  align-items: center;
}
.skin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  padding: 0;
  outline: none;
}
.skin-dot:hover {
  transform: scale(1.2);
  border-color: var(--text2);
}
.skin-dot.active {
  border-color: var(--text);
  transform: scale(1.15);
}
.search-icon {
  color: var(--text3);
  flex-shrink: 0;
}
.search-input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  padding: 8px 0;
  font-size: 0.875rem;
  color: var(--text);
}
.search-input::placeholder {
  color: var(--text3);
}
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* Grid header */
.grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 4px;
}
.grid-header span {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text2);
}
.grid-count {
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  color: var(--text3);
}

/* Skeleton */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px;
  padding: 4px;
  max-height: 360px;
  overflow: hidden;
}
.skel-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--surface2) 25%,
    var(--border) 50%,
    var(--surface2) 75%
  );
  background-size: 300% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0% {
    background-position: -300% 0;
  }
  100% {
    background-position: 300% 0;
  }
}

/* Emoji grid */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 1px;
  padding: 4px;
  max-height: 370px;
  overflow-y: auto;
}
.emoji-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition:
    background 0.1s,
    transform 0.1s;
  font-size: 1.45rem;
  line-height: 1;
}
.emoji-cell:hover {
  background: var(--cell-hover);
  transform: scale(1.1);
}
.emoji-cell.sel {
  background: var(--cell-select);
  transform: scale(1.05);
  box-shadow: 0 0 0 1.5px var(--accent);
}
.emoji-cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  gap: 8px;
  font-size: 2rem;
}
.empty-state p {
  font-size: 0.82rem;
  color: var(--text3);
  text-align: center;
}
.empty-state.hidden {
  display: none;
}
.hidden {
  display: none !important;
}

/* ── Footer ── */
.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 20px;
  font-size: 0.76rem;
  color: var(--text3);
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.footer a {
  color: var(--text2);
  text-decoration: none;
}
.footer a:hover {
  color: var(--accent);
}

.footer-source {
  font-size: 0.72rem;
  color: var(--text3);
}
.footer-source a {
  color: var(--accent);
}

.footer-credit {
  color: var(--text3);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.25s,
    transform 0.25s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Animations ── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.fade-up {
  animation: fadeUp 0.2s ease;
}

/* ═══════════════════════════════════════
   RESPONSIVE — mobile
═══════════════════════════════════════ */

@media (max-width: 780px) {
  /* Nav: horizontal scroll so all styles are reachable */
  .style-nav {
    justify-content: flex-start;
  }
  .style-nav-inner {
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .style-nav-inner::-webkit-scrollbar {
    display: none;
  }

  /* Controls on top, grid below */
  .app {
    flex-direction: column;
    gap: 16px;
    padding: 16px 12px;
    align-items: stretch;
    overflow-y: auto;
  }

  .preview-section {
    width: 100%;
    align-items: center;
    gap: 12px;
  }

  /* Smaller preview on mobile */
  .emoji-display {
    width: 100px;
    height: 100px;
  }
  .emoji-display .emoji-char {
    font-size: 72px;
  }
  .emoji-placeholder {
    display: none;
  }

  .picker-section {
    flex-shrink: unset;
  }

  .picker-card {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 400px) {
  .seg-group {
    flex-wrap: wrap;
    border-radius: 12px;
  }
}
