/* smiles — noční messenger companion. Záměrně jediné (tmavé) téma. */

:root {
  --bg: #17141f;
  --surface: #211d2c;
  --surface-2: #2a2538;
  --line: #37304a;
  --text: #f4efe6;
  --muted: #a99bc9;
  --accent: #ffcf3f;
  --accent-ink: #241b00;
  --radius: 18px;
  --grid-cell: 56px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

button {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html { scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* atmosféra: měkká záře za hlavičkou + jemný grain */
.glow {
  position: fixed;
  inset: -20% -20% auto -20%;
  height: 60vh;
  background:
    radial-gradient(ellipse 60% 80% at 50% 0%, rgba(255, 207, 63, 0.13), transparent 65%),
    radial-gradient(ellipse 40% 60% at 80% 10%, rgba(169, 155, 201, 0.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

.top, main, .foot { position: relative; z-index: 2; }

/* ── hlavička ─────────────────────────────── */
.top {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(28px, 6vh, 64px) 20px 8px;
  text-align: center;
}
.wordmark {
  margin: 0;
  font-size: clamp(44px, 9vw, 72px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  animation: drop-in 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.wordmark-emoji {
  display: inline-block;
  font-size: 0.82em;
  margin-left: 0.08em;
  transition: transform 0.35s cubic-bezier(0.2, 1.8, 0.4, 1);
}
.wordmark:hover .wordmark-emoji { transform: rotate(18deg) scale(1.15); }
.tagline {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  animation: drop-in 0.6s 0.08s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes drop-in {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: none; }
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px 140px;
}

/* ── vyhledávání ──────────────────────────── */
.searchbar {
  position: sticky;
  top: max(10px, env(safe-area-inset-top));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 8px 8px 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s, box-shadow 0.2s;
  animation: drop-in 0.6s 0.16s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.searchbar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(255, 207, 63, 0.15);
}
.searchbar-icon { font-size: 18px; filter: grayscale(0.4); }
#q {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 600 clamp(17px, 4vw, 21px) 'Bricolage Grotesque', system-ui, sans-serif;
  padding: 12px 0;
  outline: none;
}
#q::placeholder { color: #8d7fae; font-weight: 400; }
#q::-webkit-search-cancel-button { display: none; }

.ai-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 14px 'Bricolage Grotesque', system-ui, sans-serif;
  padding: 12px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, filter 0.15s;
}
.ai-btn:hover { filter: brightness(1.08); transform: scale(1.04); }
.ai-btn:active { transform: scale(0.96); }
.ai-btn[disabled] { cursor: wait; }
.ai-btn[disabled] .ai-btn-spark { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 480px) {
  .ai-btn-label { display: none; }
  .ai-btn { padding: 12px 14px; font-size: 16px; }
}

/* ── kategorie ────────────────────────────── */
.chips {
  display: flex;
  gap: 8px;
  padding: 16px 2px 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 600 13px 'Bricolage Grotesque', system-ui, sans-serif;
  padding: 11px 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--muted); color: var(--text); }
.chip.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* ── sekce ────────────────────────────────── */
.section-label {
  margin: 22px 4px 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── grid ─────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-cell), 1fr));
  gap: 4px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font-size: clamp(28px, 7vw, 34px);
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s, transform 0.12s cubic-bezier(0.2, 1.6, 0.4, 1);
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.cell:hover { background: var(--surface); transform: scale(1.16) rotate(-4deg); z-index: 3; }
.cell:active { transform: scale(0.88); }
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cell.has-skins::after {
  content: '';
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.7;
}
.cell.copied { animation: pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.45) rotate(6deg); }
  100% { transform: scale(1); }
}

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-emoji { font-size: 56px; margin-bottom: 8px; }
.empty-ai-btn {
  margin-top: 14px;
  border: 1.5px dashed var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: 600 15px 'Bricolage Grotesque', system-ui, sans-serif;
  padding: 12px 22px;
  cursor: pointer;
  transition: all 0.15s;
}
.empty-ai-btn:hover { background: rgba(255, 207, 63, 0.1); }

/* ── AI výsledky ──────────────────────────── */
.ai-section {
  margin-top: 20px;
  border: 1.5px dashed rgba(255, 207, 63, 0.5);
  border-radius: var(--radius);
  background: rgba(255, 207, 63, 0.04);
  padding: 14px 16px 16px;
  animation: ai-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes ai-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.ai-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.ai-section-title { font-weight: 600; font-size: 14px; color: var(--accent); }
.ai-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 10px 14px;
  margin: -6px -8px -6px 0;
  border-radius: 10px;
}
.ai-close:hover { background: var(--surface-2); color: var(--text); }
.ai-results { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px 8px 8px;
  cursor: pointer;
  font: 500 13px 'Bricolage Grotesque', system-ui, sans-serif;
  transition: transform 0.12s cubic-bezier(0.2, 1.6, 0.4, 1), border-color 0.12s;
  animation: ai-in 0.3s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.ai-chip:hover { transform: scale(1.05); border-color: var(--accent); }
.ai-chip:active { transform: scale(0.94); }
.ai-chip .e {
  font-size: 26px;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.ai-chip .why { color: var(--muted); }
.ai-error { color: var(--muted); font-size: 14px; }

/* ── skládanka (tray) ─────────────────────── */
.tray {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(680px, calc(100vw - 24px));
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 8px 8px 16px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
  animation: tray-in 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes tray-in {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to { opacity: 1; transform: translateX(-50%); }
}
.tray-text {
  font-size: 24px;
  letter-spacing: 2px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  max-width: 50vw;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.tray-text::-webkit-scrollbar { display: none; }
.tray-copy {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 14px 'Bricolage Grotesque', system-ui, sans-serif;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, filter 0.15s;
}
.tray-copy:hover { filter: brightness(1.08); }
.tray-copy:active { transform: scale(0.95); }
.tray-clear {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 12px 14px;
  border-radius: 999px;
}
.tray-clear:hover { color: var(--text); background: var(--surface); }

/* ── toast ────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  z-index: 30;
  background: var(--text);
  color: var(--bg);
  font: 600 15px 'Bricolage Grotesque', system-ui, sans-serif;
  border-radius: 999px;
  padding: 10px 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ── výběr odstínu pleti ──────────────────── */
.tone-picker {
  position: fixed;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: min(330px, calc(100vw - 16px));
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  animation: ai-in 0.15s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.tone-picker button {
  border: 0;
  background: transparent;
  font-size: 26px;
  padding: 9px;
  border-radius: 10px;
  cursor: pointer;
  line-height: 1;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.tone-picker button:hover { background: var(--surface); transform: scale(1.1); }

/* ── patička ──────────────────────────────── */
.foot {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 20px 100px;
  text-align: center;
  color: #8d7fae;
  font-size: 12px;
}

.load-error {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  font-size: 16px;
  line-height: 2.4;
}
.load-error button {
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 600 14px 'Bricolage Grotesque', system-ui, sans-serif;
  padding: 10px 20px;
  cursor: pointer;
}
.foot a { color: inherit; }

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