/* Bundle builder page. Colors climb with the tier: purple → pink → orange → gold → rainbow. */

.bundle { max-width: 960px; margin: 0 auto; padding: 0 16px 64px; }
.bundle-hero { padding: 40px 0 24px; }
.bundle-hero h1 { font-size: clamp(2.5rem, 7vw, 4.5rem); text-transform: uppercase; letter-spacing: -.02em; margin: 0 0 .3em; }
.bundle-hero em { font-style: normal; background: linear-gradient(90deg, var(--purple), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Tier colors ---------- */
.bin { --c1: #7c3aed; --c2: #a855f7; --glow: rgba(168, 85, 247, .25); }
.bin[data-tier="1"] { --c1: #a855f7; --c2: #ff4fa3; --glow: rgba(255, 79, 163, .35); }
.bin[data-tier="2"] { --c1: #ff4fa3; --c2: #ff8a3d; --glow: rgba(255, 138, 61, .4); }
.bin[data-tier="3"] { --c1: #ff8a3d; --c2: #ffd23f; --glow: rgba(255, 210, 63, .45); }
.bin[data-tier="4"] { --c1: #ff4fa3; --c2: #38bdf8; --glow: rgba(255, 255, 255, .45); }

/* ---------- Bin ---------- */
.bin {
  position: relative;
  background: var(--surface); border: 1.5px solid var(--c2); border-radius: 20px;
  padding: 28px 24px 24px;
  box-shadow: 0 0 0 4px var(--glow), 0 20px 60px -20px var(--glow);
  transition: border-color .4s, box-shadow .4s, transform .2s;
}
.bin.hover { transform: scale(1.015); box-shadow: 0 0 0 8px var(--glow), 0 20px 80px -10px var(--glow); }

/* ---------- Meter ---------- */
.meter { position: relative; margin: 0 10px 64px; }
.meter-track {
  height: 26px; border-radius: 999px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--line);
}
.meter-fill {
  position: relative; height: 100%;
  width: calc(var(--fill, 0) * 100%);
  min-width: 0;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  border-radius: 999px;
  transition: width .6s cubic-bezier(.34, 1.56, .64, 1), background .4s;
  box-shadow: 0 0 24px var(--glow);
}
/* Moving candy stripes */
.meter-fill::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .22) 0 10px, transparent 10px 20px);
  background-size: 28.28px 28.28px;
  animation: stripes .8s linear infinite;
}
/* Hot leading edge */
.meter-fill::before {
  content: ''; position: absolute; right: 0; top: 50%; width: 18px; height: 18px; translate: 40% -50%;
  border-radius: 50%; background: #fff; filter: blur(6px); opacity: .7;
}
.bin.empty .meter-fill::before { display: none; }
.bin[data-tier="4"] .meter-fill {
  background: linear-gradient(90deg, #a855f7, #ff4fa3, #ff8a3d, #ffd23f, #4ade80, #38bdf8, #a855f7);
  background-size: 300% 100%;
  animation: rainbow 2.5s linear infinite;
}
@keyframes stripes { to { background-position: 28.28px 0; } }
@keyframes rainbow { to { background-position: 300% 0; } }

.meter-marks { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; pointer-events: none; }
.meter-marks li { position: absolute; left: var(--at); top: 0; height: 26px; }
.mark-dot {
  position: absolute; top: 50%; left: 0; translate: -50% -50%;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--line);
  transition: background .3s, border-color .3s, box-shadow .3s, scale .3s;
}
.reached .mark-dot { background: #fff; border-color: #fff; box-shadow: 0 0 12px var(--c2); scale: 1.15; }
.mark-label {
  position: absolute; top: 34px; left: 0; translate: -50% 0; white-space: nowrap;
  font-size: .8rem; color: var(--muted); text-align: center; line-height: 1.2;
}
.mark-label strong { display: block; font-family: var(--display); font-weight: 800; font-size: 1rem; color: var(--text); opacity: .55; }
.reached .mark-label { color: var(--text); }
.reached .mark-label strong { opacity: 1; color: var(--c2); }
.meter-marks li:last-child .mark-label { translate: -100% 0; text-align: right; }

/* ---------- Stats ---------- */
.bin-stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 24px; margin-bottom: 16px; }
.bin-stats p { margin: 0; }
.bin-count { font-family: var(--display); font-weight: 800; font-size: 1.1rem; }
.bin-count [data-count] {
  display: inline-block; font-size: 3rem; line-height: 1;
  background: linear-gradient(90deg, var(--c1), var(--c2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.bin-count.bump [data-count] { animation: bump .45s cubic-bezier(.34, 1.56, .64, 1); }
.bin-each { font-size: 1.1rem; color: var(--muted); }
.bin-each span { font-family: var(--display); font-weight: 800; font-size: 1.6rem; color: var(--text); }
.bin-save { font-weight: 600; color: var(--c2); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.45) rotate(-6deg); } 100% { transform: scale(1); } }

/* ---------- Drop area ---------- */
.bin-drop {
  min-height: 132px; border: 2px dashed var(--line); border-radius: 14px; padding: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .2s, background .2s;
}
.bin.hover .bin-drop, .is-dragging .bin-drop { border-color: var(--c2); }
.bin.hover .bin-drop { background: var(--glow); }
.bin-empty { margin: 0; color: var(--muted); font-weight: 600; }
.bin-items { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.bin-items:empty { display: none; }
.bin-items li { position: relative; width: 96px; }
.bin-items img { display: block; width: 100%; border-radius: 4px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .14), 0 4px 12px rgba(0, 0, 0, .5); }
.bin-tag {
  position: absolute; left: 50%; bottom: -8px; translate: -50% 0;
  background: var(--text); color: var(--bg); font: 700 .65rem/1 var(--body); text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 6px; border-radius: 999px;
}
.bin-items li.pop { animation: pop .5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes pop { 0% { transform: scale(0) rotate(-20deg); } 100% { transform: scale(1) rotate(0); } }
.bin-remove {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: var(--text); color: var(--bg); font-size: 16px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.bin-items li:hover .bin-remove, .bin-remove:focus-visible { opacity: 1; }
@media (hover: none) { .bin-remove { opacity: .85; } }

.bin-next { margin: 16px 0 4px; font-size: 1.05rem; }
.bin-next strong { color: var(--c2); }
.bin-body { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; align-items: stretch; }
.bin-main { display: flex; flex-direction: column; min-width: 0; }
.bin-main .bin-drop { flex: 1; }
.bin-checkout {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 20px;
  align-self: start; position: sticky; top: 16px;
}
.bin-checkout p { margin: 0; }
.bin-total-label { font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
.bin-total { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.bin-was { color: var(--muted); font-size: 1.15rem; }
.bin-total-amount {
  font-family: var(--display); font-weight: 800; font-size: 3.25rem; line-height: 1;
  background: linear-gradient(90deg, var(--c1), var(--c2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.bin-checkout .button--primary { margin-top: 10px; padding: 14px 20px; font-size: 1.1rem; }
.bin-checkout .button--primary:disabled { opacity: .45; cursor: not-allowed; }
.bin-clear {
  align-self: center; margin-top: 4px; background: none; border: 0; padding: 6px;
  font: 600 .875rem var(--body); color: var(--muted); text-decoration: underline; cursor: pointer;
}
.bin-clear:hover { color: var(--text); }

/* ---------- Tray ---------- */
.tray { margin-top: 40px; }
.tray h2 { margin-bottom: .2em; }
.tray-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.tray-head p { margin: 0; }
.tray-kind { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--muted); }
.tray-kind select {
  appearance: none; font: 600 1rem var(--body); color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a69cb8' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1.5px solid var(--line); border-radius: 999px; padding: 10px 40px 10px 16px; cursor: pointer;
}
.tray-kind select:hover, .tray-kind select:focus-visible { border-color: var(--purple); outline: none; }
.tray-kind-note { margin: 12px 0 0; color: var(--pink-soft); }
.tray-grid { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.tray-item {
  width: 100%; display: flex; flex-direction: column; gap: 8px; align-items: stretch;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px;
  color: var(--text); font: 600 .9rem/1.25 var(--body); text-align: left;
  cursor: grab; touch-action: none; user-select: none;
  transition: border-color .15s, transform .15s;
}
.tray-item:hover { border-color: var(--purple); transform: translateY(-2px) rotate(-1deg); }
.tray-item:active { cursor: grabbing; }
.tray-item img { display: block; width: 100%; border-radius: 3px; pointer-events: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }
.tray-item span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }

/* ---------- Drag ghost, effects ---------- */
.drag-ghost {
  position: fixed; z-index: 1000; pointer-events: none; border-radius: 4px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .6);
}
.drag-ghost.dragging { scale: 1.1; transition: rotate .1s; }
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; }

.fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 999; }

.bin.shake { animation: shake .5s; }
@keyframes shake {
  10%, 90% { transform: translate(-2px, 1px) rotate(-.3deg); }
  20%, 80% { transform: translate(4px, -2px) rotate(.4deg); }
  30%, 50%, 70% { transform: translate(-6px, 2px) rotate(-.5deg); }
  40%, 60% { transform: translate(6px, -1px) rotate(.5deg); }
}

html.flash body::after {
  content: ''; position: fixed; inset: 0; z-index: 998; pointer-events: none;
  background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, .5), transparent 60%);
  animation: flash .7s ease-out forwards;
}
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.tier-toast {
  position: fixed; left: 50%; top: 84px; z-index: 1001; translate: -50% -20px;
  background: var(--text); color: var(--bg); font-family: var(--display); font-weight: 800; font-size: 1.15rem;
  padding: 10px 20px; border-radius: 999px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .25s, translate .35s cubic-bezier(.34, 1.56, .64, 1);
}
.tier-toast.show { opacity: 1; translate: -50% 0; }
.tier-toast.max {
  color: #fff; font-size: 1.35rem;
  background: linear-gradient(90deg, #a855f7, #ff4fa3, #ff8a3d, #ffd23f, #a855f7); background-size: 300% 100%;
  animation: rainbow 2s linear infinite;
}
.tier-toast.warn { background: var(--pink); }

@media (max-width: 760px) {
  .bin-body { grid-template-columns: 1fr; gap: 16px; }
  .bin-checkout { position: static; padding: 16px; }
}

@media (max-width: 560px) {
  .bin { padding: 22px 14px 16px; }
  .meter { margin: 0 8px 60px; }
  .mark-label { font-size: .7rem; }
  .mark-label strong { font-size: .85rem; }
  .bin-items li { width: 72px; }
  .tray-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tray-item { padding: 8px; font-size: .8rem; }
  .bin-total-amount { font-size: 2.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .meter-fill, .meter-fill::after, .bin[data-tier="4"] .meter-fill, .tier-toast.max { animation: none; transition: none; }
  .bin.shake, .bin-items li.pop, .bin-count.bump [data-count] { animation: none; }
}
.bin-checkout .error:empty { display: none; }
