/* ============================================
   ДИЗАЙН-ТОКЕНЫ — «Игрушки из 3D-принтера»
   Идея: мотив слоёв FDM-печати (горизонтальные
   линии наплавления) как фирменный узор.
   Палитра — цвета пластика/филамента.
   ============================================ */
:root {
  --bg: #f4f5f8;            /* белый пластик */
  --surface: #ffffff;       /* карточка / "деталь" */
  --ink: #23262b;           /* тёмно-серый пластик, не чёрный */
  --ink-soft: #6b7078;      /* приглушённый текст */
  --coral: #ff6b5b;         /* филамент — основной акцент */
  --teal: #2ec4b6;          /* филамент — вторичный */
  --yellow: #ffc145;        /* филамент — третичный, для меток */
  --line: #e3e5ea;          /* тонкая линия / бортик стола печати */
  --radius: 18px;
  --shadow: 0 12px 28px -14px rgba(35,38,43,0.18);
  --font-display: "Baloo 2", system-ui, sans-serif;
  --font-body: "Quicksand", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #15171b;
  --surface: #1e2126;
  --ink: #f1f2f5;
  --ink-soft: #9aa0aa;
  --line: #2b2f36;
  --shadow: 0 12px 28px -14px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  line-height: 1.5;
  transition: background .35s ease, color .35s ease;
}

img { max-width: 100%; display: block; }

a { color: inherit; }

/* Фирменный узор — линии печати */
.layer-lines {
  height: 14px;
  width: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--coral) 0 26px,
    var(--yellow) 26px 52px,
    var(--teal) 52px 78px
  );
  opacity: 0.9;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Шапка ---------- */
header.site-head {
  padding: 20px 0 10px;
}
.site-head .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
}
.brand-name small {
  display: block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: .04em;
}
.admin-link {
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
}
.admin-link:hover { border-color: var(--coral); color: var(--coral); }

/* ---------- Hero ---------- */
.hero {
  padding: 56px 0 40px;
  text-align: center;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1.05;
  margin: 0 0 14px;
  font-weight: 800;
}
.hero h1 span {
  color: var(--coral);
  position: relative;
}
.hero p {
  max-width: 520px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: 17px;
}
.hero-plate {
  margin: 34px auto 0;
  max-width: 640px;
  height: 6px;
  border-radius: 999px;
  background: repeating-linear-gradient(
    90deg, var(--coral) 0 18px, transparent 18px 22px
  );
  opacity: .5;
}

/* ---------- Каталог ---------- */
.catalog {
  padding: 10px 0 70px;
}
.catalog h2 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 22px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 34px -16px rgba(35,38,43,0.26);
}
.card-photo {
  aspect-ratio: 4 / 3;
  background: linear-gradient(160deg, #eef0f4, #e4e7ee);
  position: relative;
  overflow: hidden;
}
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-photo .placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #b7bcc6;
}
.card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.card-body h3 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0;
}
.card-body p {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0;
  flex: 1;
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.price-tag {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--coral);
}
.buy-btn {
  font-size: 13px;
  font-weight: 700;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
}
.buy-btn:hover { background: var(--coral); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- Футер ---------- */
footer {
  padding: 26px 0 40px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
}

/* ============================================
   Админка
   ============================================ */
.admin-shell {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px 80px;
}
.admin-box {
  width: 100%;
  max-width: 560px;
}
.gate {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px;
  text-align: center;
  border: 1px solid var(--line);
}
.gate h1 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 6px 0 6px;
}
.gate p { color: var(--ink-soft); font-size: 14px; margin-bottom: 20px; }
.gate input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 2px solid var(--line);
  font-size: 16px;
  font-family: var(--font-body);
  text-align: center;
  letter-spacing: .1em;
  margin-bottom: 12px;
}
.gate input:focus { outline: none; border-color: var(--coral); }
.gate button, .primary-btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: none;
  background: var(--coral);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.gate button:hover, .primary-btn:hover { background: #ff5645; }
.gate .err { color: #d1453a; font-size: 13px; min-height: 18px; margin-top: 8px; }

.panel {
  display: none;
}
.panel.active { display: block; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.panel-head h1 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0;
}
.logout-link {
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  cursor: pointer;
}

.form-card, .list-card, .export-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.form-card h2, .list-card h2, .export-card h2 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0 0 16px;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink-soft);
}
.field input, .field textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 2px solid var(--line);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--teal); }
.field textarea { resize: vertical; min-height: 70px; }
.field small { display: block; color: var(--ink-soft); font-size: 12px; margin-top: 5px; }

.preview-row { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.preview-thumb {
  width: 76px; height: 76px; border-radius: 12px;
  background: var(--bg); border: 1px dashed var(--line);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; }

.btn-row { display: flex; gap: 10px; margin-top: 6px; }
.secondary-btn {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: #fff;
  font-family: var(--font-body);
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}
.secondary-btn:hover { border-color: var(--ink); }

.toy-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.toy-row:last-child { border-bottom: none; }
.toy-row img, .toy-row .ph {
  width: 54px; height: 54px; border-radius: 10px; object-fit: cover;
  background: var(--bg); flex-shrink: 0;
}
.toy-row .info { flex: 1; min-width: 0; }
.toy-row .info b { display: block; font-size: 14px; }
.toy-row .info span { display: block; font-size: 12px; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: flex; gap: 6px; }
.row-actions button {
  border: none; background: var(--bg); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; cursor: pointer; font-weight: 700;
}
.row-actions button:hover { background: var(--line); }
.row-actions .del:hover { background: #ffe1de; color: #d1453a; }

.export-card p { color: var(--ink-soft); font-size: 14px; margin: 0 0 14px; }
.export-card ol { margin: 0 0 16px; padding-left: 20px; color: var(--ink-soft); font-size: 14px; }
.export-card li { margin-bottom: 6px; }

.hint-banner {
  background: #fff7e6;
  border: 1px solid #ffe2a8;
  color: #8a6412;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 20px;
}

@media (max-width: 480px) {
  .site-head .wrap { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* ============================================
   Тёмная тема — точечные поправки
   ============================================ */
[data-theme="dark"] .card-photo {
  background: linear-gradient(160deg, #23262c, #1a1c21);
}
[data-theme="dark"] .gate,
[data-theme="dark"] .form-card,
[data-theme="dark"] .list-card,
[data-theme="dark"] .export-card {
  background: var(--surface);
}
[data-theme="dark"] .hint-banner {
  background: #2a2410;
  border-color: #4a3d12;
  color: #ffd989;
}
[data-theme="dark"] .buy-btn { color: #fff; }
[data-theme="dark"] .secondary-btn { background: transparent; color: var(--ink); }

/* ============================================
   Переключатели темы / языка
   ============================================ */
.switchers {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.switch-group {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.theme-btn, .lang-btn {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, transform .15s ease;
}
.theme-btn:hover, .lang-btn:hover { color: var(--ink); }
.theme-btn.active, .lang-btn.active {
  background: var(--coral);
  color: #fff;
  transform: scale(1.04);
}

/* ============================================
   Корзина — плавающая кнопка
   ============================================ */
.cart-fab {
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  transition: transform .15s ease, border-color .2s ease;
}
.cart-fab:hover { border-color: var(--coral); }
.cart-fab.bump { animation: cartBump .4s ease; }
.cart-count {
  background: var(--coral);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ============================================
   Оверлей / модалки (корзина, чекаут)
   ============================================ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(15,16,19,0.5);
  backdrop-filter: blur(2px);
  display: none;
  align-items: flex-start;
  justify-content: flex-end;
  z-index: 100;
  animation: fadeIn .2s ease;
}
.overlay.active { display: flex; }
.overlay.center { align-items: center; justify-content: center; }

.drawer {
  width: min(380px, 92vw);
  height: 100%;
  background: var(--bg);
  padding: 22px;
  overflow-y: auto;
  animation: slideIn .28s cubic-bezier(.22,.9,.32,1);
  box-shadow: -20px 0 40px -20px rgba(0,0,0,.3);
}
.modal-card {
  width: min(440px, 92vw);
  background: var(--bg);
  border-radius: 20px;
  padding: 26px;
  animation: popIn .25s cubic-bezier(.22,.9,.32,1);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h2 {
  font-family: var(--font-display);
  font-size: 20px; margin: 0;
}
.icon-btn {
  border: none; background: var(--surface); border-radius: 10px;
  width: 34px; height: 34px; cursor: pointer; font-size: 16px;
  color: var(--ink-soft);
}
.icon-btn:hover { color: var(--coral); }

.cart-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.cart-item img, .cart-item .ph {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover;
  background: var(--surface); flex-shrink: 0;
}
.cart-item .ci-info { flex: 1; min-width: 0; }
.cart-item .ci-info b { display: block; font-size: 14px; }
.cart-item .ci-info span { font-size: 12px; color: var(--ink-soft); }
.qty-stepper {
  display: flex; align-items: center; gap: 6px;
}
.qty-stepper button {
  width: 24px; height: 24px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; color: var(--ink); font-weight: 700;
}
.cart-total-row {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-display); font-size: 17px; margin: 18px 0;
}
.phone-row { display: flex; gap: 8px; }
.phone-prefix {
  padding: 11px 12px; border-radius: 10px; border: 2px solid var(--line);
  color: var(--ink-soft); font-weight: 700; background: var(--surface);
}
.field-error { color: #ff6b5b; font-size: 12px; margin-top: 4px; min-height: 16px; }

/* ============================================
   Тост-уведомления
   ============================================ */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg);
  padding: 12px 20px; border-radius: 999px;
  font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================
   Анимации
   ============================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(.92) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes cartBump { 0% { transform: scale(1); } 35% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes heroIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shimmerLines {
  0% { background-position: 0 0; }
  100% { background-position: 300px 0; }
}

.card { animation: cardIn .5s cubic-bezier(.22,.9,.32,1) both; }
.hero h1, .hero p, .hero-plate { animation: heroIn .6s ease both; }
.hero p { animation-delay: .08s; }
.hero-plate { animation-delay: .16s; }

.layer-lines {
  background-size: 300px 100%;
  animation: shimmerLines 6s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

@media (max-width: 480px) {
  .overlay:not(.center) { justify-content: stretch; }
  .drawer { width: 100vw; }
}
