/* app.css — токены темы и продуктовые компоненты (дизайн-контракт) */

:root {
  --bg: #FFF7F2;
  --surface: #FFFFFF;
  --ink: #2A2320;
  --muted: #7A6E67;
  --border: #F0E2DA;
  --brand: #FF7A59;
  --brand-dark: #E8623F;
  --craft: #4CAF6D;
  --craft-dark: #3D9459;
  --warn: #E8A33D;
}

* { -webkit-tap-highlight-color: transparent; }

/* ── Тематический фон страницы ─────────────────────────────────── */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  opacity: .16;
  filter: saturate(1.05);
  pointer-events: none;
}
.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,247,242,.55) 0%, rgba(255,247,242,.92) 55%, var(--bg) 100%);
}
@media (min-width: 768px) {
  .page-bg { opacity: .22; }
}

/* ── Декоративные иконки на карточках ──────────────────────────── */
.card-decor { position: relative; overflow: hidden; }
.card-decor-img {
  position: absolute;
  width: 64px;
  height: 64px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 6px 12px rgba(42, 35, 32, .12));
  animation: decor-float 5s ease-in-out infinite;
}
.card-decor-img--craft { top: -14px; right: -10px; }
.card-decor-img--chest { top: -14px; right: -10px; animation-delay: .6s; }
@keyframes decor-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@media (max-width: 639px) {
  .card-decor-img { width: 48px; height: 48px; }
}

body { line-height: 1.55; }
h1, h2, h3 { font-weight: 800; }
h2 { font-size: 22px; }
@media (min-width: 640px) { h2 { font-size: 24px; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 1px 2px rgba(42, 35, 32, .04), 0 8px 24px -8px rgba(42, 35, 32, .08);
}

/* ── Кнопки ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 48px;
  padding: 0 1.25rem;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1rem;
  transition: transform 150ms ease, background-color 180ms ease, box-shadow 180ms ease, opacity 150ms ease;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none !important; }
.btn:active:not(:disabled) { transform: scale(.98); }

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 16px -4px rgba(255, 122, 89, .5);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }

.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) { background: var(--bg); border-color: var(--brand); }

.btn-download {
  background: var(--craft);
  color: #fff;
  box-shadow: 0 6px 16px -4px rgba(76, 175, 109, .5);
}
.btn-download:hover { background: var(--craft-dark); }

@media (max-width: 767px) {
  .btn-primary, .btn-download { width: 100%; }
}

/* ── Плитки-примеры ─────────────────────────────────────────────── */
.chips-row {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
}
.chips-row::-webkit-scrollbar { height: 6px; }
.chips-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

@media (min-width: 768px) {
  .chips-row { flex-wrap: wrap; overflow-x: visible; }
}

.chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  max-width: 220px;
  text-align: left;
  padding: .6rem .9rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: .875rem;
  color: var(--ink);
  transition: border-color 160ms ease, background-color 160ms ease, transform 150ms ease;
  cursor: pointer;
  white-space: normal;
}
.chip:hover { border-color: var(--brand); background: #FFF0EA; transform: translateY(-1px); }

@media (min-width: 768px) { .chip { max-width: 240px; } }

/* ── Превью текстуры ────────────────────────────────────────────── */
.pixelated {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.flat-preview { flex-shrink: 0; }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast-root {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--ink);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.35);
  animation: toast-in 200ms ease;
}
.toast .toast-msg { flex: 1; font-size: .9rem; }
.toast button {
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: .8rem;
  min-height: 32px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Появление карточки результата ─────────────────────────────── */
.result-appear { animation: result-in 320ms ease; }
@keyframes result-in { from { opacity: 0; transform: translateY(6px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ── Логотип-кубик ──────────────────────────────────────────────── */
.logo-cube {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--brand), var(--craft));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transform: perspective(200px) rotateX(8deg) rotateY(-12deg);
  transition: transform 200ms ease;
  flex-shrink: 0;
}
header:hover .logo-cube { transform: perspective(200px) rotateX(0deg) rotateY(0deg); }

/* ── 3D-сцена ───────────────────────────────────────────────────── */
.stage-wrapper { display: flex; flex-direction: column; align-items: center; }
.stage {
  width: 100%;
  max-width: 300px;
  height: 260px;
  perspective: 700px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: grab;
}
.stage:active { cursor: grabbing; }
.figure {
  position: relative;
  transform-style: preserve-3d;
  width: 1px;
  height: 1px;
}
.cube {
  position: absolute;
  top: 0;
  left: 0;
  transform-style: preserve-3d;
}
.face {
  position: absolute;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  backface-visibility: hidden;
}

/* ── Загрузка ───────────────────────────────────────────────────── */
.loading-dots { display: inline-flex; gap: 4px; }
.loading-dots span {
  width: 6px; height: 6px; border-radius: 2px;
  background: currentColor;
  animation: dot-bounce 900ms ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 120ms; }
.loading-dots span:nth-child(3) { animation-delay: 240ms; }
@keyframes dot-bounce { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

@media (prefers-reduced-motion: reduce) {
  *, .figure, .toast, .result-appear, .loading-dots span, .logo-cube, .card-decor-img {
    animation: none !important;
    transition: none !important;
  }
}
