/* М'який куб Cube Market — стилі 3D-в'ювера. Усі класи з префіксом .bf-, глобальних стилів немає.
   Шрифт задається змінною --bf-font (за замовчуванням Onest). */
.bf-cube {
  --bf-ink: #1d1f22;
  --bf-muted: #8e9399;
  --bf-soft: #b8bcc1;
  --bf-line: #e1e3e6;
  --bf-accent: #e4202a;
  --bf-surface: #ffffff;
  position: relative;
  width: 100%;
  max-width: 1200px;
  height: min(80vh, 780px);
  min-height: 460px;
  font-family: var(--bf-font, "Onest", "Helvetica Neue", Arial, sans-serif);
  color: var(--bf-ink);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.bf-cube *, .bf-cube *::before, .bf-cube *::after { box-sizing: border-box; }
.bf-cube__canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; outline: none; }
.bf-cube__canvas.is-dragging { cursor: grabbing; }
.bf-cube__fallback { display: block; width: 100%; height: 100%; object-fit: contain; }
.bf-cube__fallback-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; padding: 24px; text-align: center; font-size: 15px; color: var(--bf-muted); }
.bf-cube__canvas:focus-visible { outline: 2px solid var(--bf-ink); outline-offset: -2px; }

.bf-badge {
  position: absolute; top: 20px; left: 20px;
  display: inline-flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 18px;
  background: var(--bf-surface);
  border: 1px solid var(--bf-line);
  border-radius: 12px;
  font-size: 17px; color: #5f646a;
}
.bf-badge svg { width: 18px; height: 18px; flex: none; }

.bf-cube__hint {
  position: absolute; top: 34px; right: 22px; margin: 0;
  font-size: 13px; line-height: 1.4; color: var(--bf-muted);
  transition: opacity .6s ease; pointer-events: none;
}
.bf-cube__hint.is-hidden { opacity: 0; }
.bf-cube__hint.is-message { opacity: 1; color: var(--bf-ink); font-weight: 500; }

/* Підписи: крапка, пунктир, текст */
.bf-cube__labels { position: absolute; inset: 0; pointer-events: none; }
.bf-label { position: absolute; left: 0; top: 0; opacity: 0; will-change: transform, opacity; --len: 64px; }
.bf-label__dot {
  position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--bf-ink); box-shadow: 0 0 0 3px rgba(255,255,255,.92);
}
.bf-label__line {
  position: absolute; top: -1px; left: 10px; width: var(--len); height: 0;
  border-top: 1.5px dashed #7d838a;
}
.bf-label__text {
  position: absolute; top: -15px; left: calc(var(--len) + 14px);
  white-space: nowrap; font-size: 14px; font-weight: 500; line-height: 20px; color: var(--bf-ink);
  padding: 4px 10px; background: rgba(255,255,255,.96);
  border: 1px solid var(--bf-line); border-radius: 8px;
}
.bf-label.is-left .bf-label__line { left: auto; right: 10px; }
.bf-label.is-left .bf-label__text { left: auto; right: calc(var(--len) + 14px); }

/* Панель керування */
.bf-cube__bar {
  position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(660px, calc(100% - 24px));
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  background: rgba(255,255,255,.96);
  border: 1px solid var(--bf-line);
  border-radius: 14px;
}
.bf-btn {
  flex: none; font: inherit; font-size: 14px; font-weight: 600; line-height: 1;
  height: 40px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.bf-btn:focus-visible, .bf-range:focus-visible, .bf-slot:focus-visible { outline: 2px solid var(--bf-ink); outline-offset: 2px; }
.bf-btn--primary { background: var(--bf-accent); color: #fff; min-width: 108px; }
.bf-btn--primary:hover { background: #c81a23; }
.bf-btn--ghost {
  background: transparent; color: var(--bf-ink); border-color: var(--bf-line);
  display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; font-weight: 500;
}
.bf-btn--ghost:hover { border-color: #bdbdbd; }
.bf-btn--ghost[aria-expanded="true"] { border-color: var(--bf-ink); }
.bf-btn svg { width: 16px; height: 16px; flex: none; }

.bf-track { position: relative; flex: 1 1 auto; min-width: 0; padding-bottom: 18px; }
.bf-range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; --fill: 0%; }
.bf-range::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--bf-accent) var(--fill), var(--bf-line) var(--fill)); }
.bf-range::-moz-range-track { height: 3px; border-radius: 2px; background: var(--bf-line); }
.bf-range::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--bf-accent); }
.bf-range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6.5px; border-radius: 50%; background: #fff; border: 2px solid var(--bf-accent); }
.bf-range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--bf-accent); }
.bf-stages { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; font-size: 12px; color: var(--bf-muted); }
.bf-stages span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; transition: color .2s ease; }
.bf-stages span.is-active { color: var(--bf-ink); }

/* Панель власного дизайну: сама розгортка куба є полем завантаження */
.bf-design {
  position: absolute; right: 16px; top: 16px;
  width: min(300px, calc(100% - 24px));
  max-height: calc(100% - 110px);
  overflow: auto;
  padding: 14px;
  background: var(--bf-surface);
  border: 1px solid var(--bf-line);
  border-radius: 14px;
}
.bf-design[hidden] { display: none; }
.bf-design__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.bf-design__title { margin: 0; font-size: 16px; font-weight: 600; }
.bf-design__close { width: 32px; height: 32px; padding: 0; border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--bf-muted); cursor: pointer; border-radius: 8px; }
.bf-design__close:hover { color: var(--bf-ink); }
.bf-net { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(3, auto); gap: 3px; margin-bottom: 12px; }
.bf-slot {
  position: relative; aspect-ratio: 1; padding: 0;
  border: 1px dashed #c9ccd0; border-radius: 6px;
  background: #f7f8f9 center / cover no-repeat;
  font: inherit; font-size: 11px; color: var(--bf-muted);
  cursor: pointer; display: flex; align-items: flex-end; justify-content: center;
}
.bf-slot:hover, .bf-slot.is-drop { border-color: var(--bf-ink); color: var(--bf-ink); }
.bf-slot.is-drop { border-style: solid; background-color: #eceef0; }
.bf-slot span { padding: 0 4px 5px; background: none; }
.bf-slot.has-image { border-style: solid; border-color: var(--bf-line); color: transparent; }
.bf-slot.has-image:hover { color: #fff; }
.bf-slot.has-image:hover span { text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.bf-slot[data-face="top"] { grid-column: 2; grid-row: 1; }
.bf-slot[data-face="left"] { grid-column: 1; grid-row: 2; }
.bf-slot[data-face="front"] { grid-column: 2; grid-row: 2; }
.bf-slot[data-face="right"] { grid-column: 3; grid-row: 2; }
.bf-slot[data-face="back"] { grid-column: 4; grid-row: 2; }
.bf-slot[data-face="bottom"] { grid-column: 2; grid-row: 3; }
.bf-design__actions { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.bf-design__actions .bf-btn { height: 36px; font-size: 13px; justify-content: center; display: inline-flex; align-items: center; }
.bf-design__note { margin: 10px 0 0; font-size: 12px; line-height: 1.45; color: var(--bf-muted); }

@media (max-width: 560px) {
  .bf-cube { height: min(86vh, 680px); }
  .bf-cube__bar { gap: 8px; padding: 8px; }
  .bf-btn--primary { min-width: 0; padding: 0 14px; }
  .bf-btn--ghost { padding: 0 11px; }
  .bf-btn--ghost .bf-btn-label { display: none; }
  .bf-label { --len: 14px; }
  .bf-label__text { font-size: 12px; line-height: 18px; top: -13px; padding: 3px 8px; border-radius: 7px; }
  .bf-track { padding-bottom: 0; }
  .bf-stages { display: none; }
  .bf-badge { top: 12px; left: 12px; height: 40px; font-size: 15px; padding: 0 14px; }
  .bf-cube__hint { display: none; }
  .bf-design { top: auto; bottom: 76px; right: 12px; max-height: calc(100% - 150px); }
}
@media (prefers-reduced-motion: reduce) {
  .bf-cube__hint, .bf-btn, .bf-stages span { transition: none; }
}
