/* ============================================
   Стикеры - декоративные плавающие изображения
   ============================================ */

/* Якорные элементы для стикеров */
[data-sticker-anchor] {
    position: relative;
}

/* overflow:visible только для секций — не ломаем overflow:hidden на карточках */
section[data-sticker-anchor] {
    overflow: visible;
}

main {
    position: relative;
}

/* Глобальный контейнер для неприкреплённых стикеров */
#sticker-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    pointer-events: none;
    z-index: 100;
    overflow: visible;
}

.sticker {
    position: absolute;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.sticker img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

/* ── Режим редактирования ── */

/* Блокируем hover/click на ссылках/кнопках, к которым привязаны стикеры в edit mode */
a.sticker-edit-mode,
button.sticker-edit-mode {
    pointer-events: none;
}

#sticker-container.edit-mode .sticker,
.sticker-edit-mode .sticker {
    pointer-events: auto;
    cursor: grab;
}

#sticker-container.edit-mode .sticker.dragging,
.sticker-edit-mode .sticker.dragging {
    cursor: grabbing;
}

#sticker-container.edit-mode .sticker::after,
.sticker-edit-mode .sticker::after,
.sticker.sticker-selected::after {
    content: '';
    position: absolute;
    inset: -2px;
    border: 2px dashed rgba(107, 66, 38, .4);
    border-radius: 4px;
    pointer-events: none;
}

/* Подсветка якорных секций в edit-mode */
.sticker-edit-mode {
    outline: 2px dashed rgba(107, 66, 38, .2);
    outline-offset: -2px;
}

/* ── Хэндлы (видны только в edit-mode при hover) ── */

.sticker-handles {
    display: none;
}

#sticker-container.edit-mode .sticker-handles,
.sticker-edit-mode .sticker .sticker-handles {
    display: block;
}

.sticker-handle {
    position: absolute;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    pointer-events: auto;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
    color: #fff;
    transition: transform .15s;
    opacity: 0;
}

#sticker-container.edit-mode .sticker:hover .sticker-handle,
#sticker-container.edit-mode .sticker.dragging .sticker-handle,
#sticker-container.edit-mode .sticker.sticker-selected .sticker-handle,
.sticker-edit-mode .sticker:hover .sticker-handle,
.sticker-edit-mode .sticker.dragging .sticker-handle,
.sticker-edit-mode .sticker.sticker-selected .sticker-handle {
    opacity: 1;
}

.sticker-handle:hover {
    transform: scale(1.2);
}

.sticker-handle-rotate {
    top: -30px;
    left: 50%;
    margin-left: -13px;
    background: #17a2b8;
    cursor: grab;
}

.sticker-handle-resize {
    bottom: -13px;
    right: -13px;
    background: #28a745;
    cursor: nwse-resize;
}

.sticker-handle-delete {
    top: -13px;
    right: -13px;
    background: #dc3545;
}

.sticker-handle-layer-up {
    top: -13px;
    left: -13px;
    background: #6c757d;
}

.sticker-handle-layer-down {
    bottom: -13px;
    left: -13px;
    background: #6c757d;
}

.sticker-layer-num {
    display: none;
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
}

#sticker-container.edit-mode .sticker-layer-num,
.sticker-edit-mode .sticker .sticker-layer-num {
    display: block;
}

/* Кнопка привязки к якорю — справа по центру */
.sticker-handle-anchor {
    top: 50%;
    right: -30px;
    margin-top: -13px;
    background: #fd7e14;
}

/* Отразить по горизонтали — слева по центру */
.sticker-handle-flip-x {
    top: 50%;
    left: -30px;
    margin-top: -13px;
    background: #6f42c1;
}

/* Отразить по вертикали — сверху, левее rotate */
.sticker-handle-flip-y {
    top: -30px;
    left: 50%;
    margin-left: 16px;
    background: #e83e8c;
}

/* Лейбл текущей привязки */
.sticker-anchor-label {
    display: none;
    position: absolute;
    top: -48px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(253, 126, 20, .85);
    color: #fff;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 6px;
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
}

#sticker-container.edit-mode .sticker-anchor-label,
.sticker-edit-mode .sticker .sticker-anchor-label {
    display: block;
}

/* Оверлей при выборе якоря */
.sticker-anchor-overlay {
    z-index: 10000;
    background: rgba(253, 126, 20, .15);
    border: 2px solid rgba(253, 126, 20, .6);
    cursor: pointer;
    transition: background .15s;
    border-radius: 6px;
}

.sticker-anchor-overlay:hover {
    background: rgba(253, 126, 20, .35);
}

.sticker-anchor-overlay-label {
    display: block;
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(253, 126, 20, .9);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    pointer-events: none;
}

.sticker-anchor-unbind {
    background: rgba(220, 53, 69, .15);
    border-color: rgba(220, 53, 69, .6);
}

.sticker-anchor-unbind:hover {
    background: rgba(220, 53, 69, .35);
}

.sticker-anchor-unbind .sticker-anchor-overlay-label {
    position: static;
    background: rgba(220, 53, 69, .9);
}

/* ── Тулбар ── */

#sticker-toolbar {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1060;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 12px;
    padding: 10px 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,.15);
    gap: 10px;
    align-items: center;
    pointer-events: auto;
}

#sticker-toolbar.active {
    display: flex;
}

#stickerModeToggle.active {
    color: var(--color-primary, #6B4226) !important;
    background: var(--color-accent-soft, #F0D9C4);
    border-radius: 6px;
}
