/* ============================================================
   Brechó Papalotl 🦋 — estética aconchegante
   Terracota suave, creme, serifa e mariposas.
   ============================================================ */
:root {
  --terra: #c4704f;
  --terra-dark: #a4543a;
  --cream: #fff8f1;
  --paper: #fdf3e7;
  --ink: #5b3a29;
  --muted: #a08775;
  --line: #eadbc8;
  --ok: #6f8f5a;
  --warn: #d9a441;
  --bad: #b3543f;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(91, 58, 41, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.55;
}

/* ---------- Header limpo: logo + busca + sacola ---------- */
header.shop {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px clamp(14px, 4vw, 40px);
  background: rgba(255, 248, 241, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { font-size: 1.35rem; font-weight: bold; letter-spacing: .5px; white-space: nowrap; }
.logo .moth { display: inline-block; animation: flutter 3s ease-in-out infinite; }
@keyframes flutter { 0%,100% { transform: translateY(0) rotate(-4deg);} 50% { transform: translateY(-4px) rotate(4deg);} }

.search {
  flex: 1; max-width: 480px; margin-inline: auto;
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px;
}
.search input { flex: 1; border: 0; outline: 0; font: inherit; background: transparent; color: var(--ink); }

.cart-btn {
  position: relative; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 8px 14px; cursor: pointer; font: inherit; color: var(--ink);
}
.cart-btn .count {
  position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px;
  border-radius: 999px; background: var(--terra); color: #fff;
  font-size: .72rem; display: grid; place-items: center; padding: 0 4px;
}

/* ---------- Filtros por tipo + ordenação ---------- */
.filters { max-width: 1200px; margin: 0 auto; padding: 6px clamp(14px, 4vw, 40px) 4px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; background: #fff; cursor: pointer; font: inherit; color: var(--ink); }
.chip.active { background: var(--terra); color: #fff; border-color: var(--terra); }
#sort-select { font: inherit; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
#filter-toggle { display: inline-flex; align-items: center; gap: 6px; }
.chips { display: none; width: 100%; }
.chips.show { display: flex; }
.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); max-height: 260px; overflow: auto; z-index: 50; display: none; }
.suggest:has(> *) { display: block; }
.suggest .sg { padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest .sg:hover { background: var(--paper); }
.suggest .sg .meta { font-size: .8rem; color: var(--muted); }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 44px 18px 26px; }
.hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 560px; }

/* ---------- Grid da vitrine ---------- */
.grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  padding: 10px clamp(14px, 4vw, 40px) 60px;
  max-width: 1200px; margin: 0 auto;
}
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .18s ease;
}
.card:hover { transform: translateY(-3px); }
.card .photo { aspect-ratio: 3/4; width: 100%; object-fit: cover; background: var(--paper); display:block; }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .code { font-size: .72rem; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.card .title { font-weight: bold; }
.card .meta { font-size: .85rem; color: var(--muted); }
.price { font-size: 1.05rem; font-weight: bold; }
.price s { color: var(--muted); font-weight: normal; font-size: .85rem; margin-right: 6px; }

.badge {
  align-self: flex-start; font-size: .72rem; padding: 3px 10px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink);
}
.badge.promo { background: #fbeede; border-color: #eccfa8; color: var(--terra-dark); }

.btn {
  border: 0; border-radius: 999px; padding: 11px 16px; font: inherit; cursor: pointer;
  background: var(--terra); color: #fff; transition: filter .15s;
}
.btn:hover { filter: brightness(.94); }
.btn.ghost { background: transparent; color: var(--terra-dark); border: 1px solid var(--terra); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Peça reservada por outra pessoa */
.card.reserved { filter: saturate(.55); }
.reserved-tag {
  background: #fdf0dd; border: 1px dashed var(--warn); color: #7a5a1e;
  font-size: .8rem; padding: 8px 10px; border-radius: 12px; text-align: center;
}

/* ---------- Responsivo: cabeçalho empilha no celular ---------- */
@media (max-width: 640px) {
  header.shop { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  header.shop .search { order: 3; flex: 1 1 100%; max-width: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; padding: 10px 14px 60px; }
  .hero { padding: 30px 14px 18px; }
}

/* ---------- Banner Clube Papalotl (seção aconchegante, sem pop-up) ---------- */
.club-banner {
  max-width: 900px; margin: 20px auto 70px; padding: clamp(22px, 5vw, 44px);
  background: linear-gradient(135deg, #d98a66, #c4704f 60%, #b4603f);
  color: #fff6ec; border-radius: 26px; box-shadow: var(--shadow);
  display: block; text-align: center;
}
.club-banner h2 { margin: 0 0 8px; font-size: clamp(1.3rem, 3vw, 1.8rem); }
.club-banner p { margin: 0 0 16px; color: #fbe6d6; }
.club-banner .art { text-align: center; font-size: 64px; line-height: 1.1; user-select: none; }
.club-banner .art small { display: block; font-size: .8rem; color: #fbe6d6; }
@media (max-width: 640px) { .club-banner { grid-template-columns: 1fr; } .club-banner .art { order: -1; } }

/* ---------- Modal genérico ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 22px; padding: 0; max-width: 460px; width: calc(100% - 32px);
  color: var(--ink); background: var(--cream); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(91, 58, 41, .35); backdrop-filter: blur(3px); }
#detail-dialog { max-width: 900px; width: calc(100% - 24px); }
.detail-wrap { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 20px; }
@media (max-width: 640px) { .detail-wrap { grid-template-columns: 1fr; } }
#detail-main { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 14px; background: var(--paper); }
#detail-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
#detail-thumbs img { width: 56px; height: 74px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
#detail-thumbs img.active { border-color: var(--terra); }
.similar { display: flex; gap: 10px; flex-wrap: wrap; }
.similar .sim { width: 90px; cursor: pointer; }
.similar .sim img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; }
.similar .sim div { font-size: .78rem; }
.modal-body { padding: 22px 24px 24px; }
.modal-body h3 { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: .82rem; color: var(--muted); }
.field input {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); outline: none;
}
.field input:focus { border-color: var(--terra); }

/* ---------- Carrinho (drawer lateral) ---------- */
#cart-drawer {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(420px, 100%);
  background: var(--cream); border-left: 1px solid var(--line); z-index: 60;
  transform: translateX(105%); transition: transform .25s ease; display: flex; flex-direction: column;
  box-shadow: -12px 0 30px rgba(91,58,41,.12);
}
#cart-drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-items { flex: 1; overflow: auto; padding: 12px 20px; display: flex; flex-direction: column; gap: 10px; }
.cart-line { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; background: #fff; }
.cart-line img { width: 52px; height: 66px; object-fit: cover; border-radius: 8px; }
.cart-line .grow { flex: 1; min-width: 0; }
.cart-line .rm { border: 0; background: none; color: var(--bad); cursor: pointer; font-size: 1rem; }
.drawer-foot { border-top: 1px solid var(--line); padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 10px; }
.totals { display: flex; flex-direction: column; gap: 3px; font-size: .95rem; }
.totals .row { display: flex; justify-content: space-between; }
.totals .grand { font-weight: bold; font-size: 1.15rem; }
.coupon-row { display: flex; gap: 8px; }
.coupon-row input { flex: 1; font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; text-transform: uppercase; }
.coupon-msg { font-size: .82rem; min-height: 1.1em; }
.coupon-msg.ok { color: var(--ok); }
.coupon-msg.err { color: var(--bad); }

/* ---------- Splash de transição "Levando suas peças..." ---------- */
#splash {
  position: fixed; inset: 0; z-index: 90; display: none; place-items: center;
  background: radial-gradient(circle at 50% 35%, #ffe9d6, #c4704f);
  color: #fff8f1; text-align: center;
}
#splash.show { display: grid; }
#splash .flyer { font-size: 72px; display: inline-block; animation: fly 1s ease-in-out forwards; }
@keyframes fly {
  0% { transform: translate(-40vw, 30vh) scale(.6) rotate(-10deg); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translate(30vw, -35vh) scale(1.15) rotate(8deg); opacity: .9; }
}
#splash p { font-size: 1.25rem; margin-top: 10px; }

/* ---------- Mariposa Guia (mascote canto inferior direito) ---------- */
#moth-guide {
  position: fixed; bottom: 18px; right: 18px; z-index: 70;
  width: 64px; height: 64px; border-radius: 50%;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
  cursor: pointer; display: grid; place-items: center; font-size: 30px;
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-6px);} }
#moth-pop {
  position: fixed; bottom: 92px; right: 18px; z-index: 71; width: min(300px, calc(100% - 36px));
  background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 16px; display: none;
}
#moth-pop.open { display: block; }
#moth-pop h4 { margin: 0 0 6px; }
#moth-pop p { margin: 0 0 12px; font-size: .88rem; color: var(--muted); }

footer.shop { text-align: center; color: var(--muted); font-size: .85rem; padding: 26px 16px 90px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--cream); padding: 10px 18px; border-radius: 999px;
  opacity: 0; transition: all .25s; z-index: 95; font-size: .9rem; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
