/* 스티커 위젯 스타일 */

/* 기본 컨테이너 스타일 */
.sticker-container {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* 화면 고정 (fixed) 컨테이너 - 스크롤해도 화면에 고정 */
.sticker-container-fixed {
    position: fixed;
}

/* 페이지 콘텐츠 (absolute) 컨테이너 - 페이지와 함께 스크롤 */
.sticker-container-absolute {
    position: absolute;
    /* 전체 문서 높이만큼 확장 */
    height: auto;
    min-height: 100%;
}

/* mainskin 레이아웃 편집 패널은 별도 stacking context이므로 편집 중 스티커를 감춘다. */
body.main-reup-admin-open .sticker-container {
    visibility: hidden !important;
    pointer-events: none !important;
}

.sticker-item {
    position: absolute;
    isolation: isolate;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    transition: transform 0.2s ease;
}

.sticker-graffiti-bg {
    position: absolute;
    top: -25%;
    right: -25%;
    bottom: -25%;
    left: -25%;
    z-index: 0;
    pointer-events: none;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    clip-path: inset(0 100% 0 0);
    opacity: 0;
    transition: clip-path 0.28s ease-out, opacity 0.2s ease-out;
}

.sticker-item > img {
    position: relative;
    z-index: 1;
}

.sticker-item .rotate-handle {
    z-index: 10;
}

body:not(.sticker-edit-mode) .sticker-item.has-graffiti-hover:hover .sticker-graffiti-bg {
    clip-path: inset(0 0 0 0);
    opacity: 1;
}

.sticker-item.hover-reveal-outward .sticker-graffiti-bg {
    clip-path: ellipse(0% 0% at 50% 50%);
    transform: scale(0.88, 1.12);
    transition: clip-path 0.3s ease-out, transform 0.3s ease-out, opacity 0.18s ease-out;
}

body:not(.sticker-edit-mode) .sticker-item.has-graffiti-hover.hover-reveal-outward:hover .sticker-graffiti-bg {
    clip-path: ellipse(78% 72% at 50% 50%);
    transform: scale(1, 1.35);
    opacity: 1;
}

body.sticker-edit-mode .sticker-graffiti-bg {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .sticker-graffiti-bg {
        transition: none;
    }
}

/* 터치 화면에는 호버 전용 물결/스프레이 그래피티를 표시하지 않는다. */
@media (hover: none), (pointer: coarse) {
    .sticker-item .sticker-graffiti-bg,
    [data-sticker-mobile-widget="true"] .sticker-mobile-graffiti-bg {
        display: none !important;
    }

    [data-sticker-mobile-widget="true"] .sticker-mobile-rail {
        align-items: flex-start;
    }

    [data-sticker-mobile-widget="true"] .sticker-mobile-link,
    [data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced .sticker-mobile-link,
    [data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced.is-open .sticker-mobile-link,
    [data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced .sticker-mobile-link:nth-child(even),
    [data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced.is-open .sticker-mobile-link:nth-child(even) {
        justify-content: flex-start;
        margin-left: 0;
        transform: none;
        transition: opacity 160ms ease-out;
    }
}

body:not(.sticker-edit-mode) .sticker-item.has-link {
    cursor: pointer !important;
}

/* 편집 모드 컨트롤 패널 기본 스타일 */
.sticker-control-top,
.sticker-control-right,
.sticker-control-bottom {
    position: absolute;
    border-radius: 6px;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.sticker-control-top {
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 6px;
    display: flex;
    gap: 3px;
    white-space: nowrap;
}

.sticker-control-right {
    right: -45px;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sticker-control-bottom {
    bottom: -70px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* 편집 모드일 때만 컨트롤 패널 표시 */
body.sticker-edit-mode .sticker-item:hover .sticker-control-top,
body.sticker-edit-mode .sticker-item:hover .sticker-control-right,
body.sticker-edit-mode .sticker-item:hover .sticker-control-bottom,
body.sticker-edit-mode .sticker-item.selected .sticker-control-top,
body.sticker-edit-mode .sticker-item.selected .sticker-control-right,
body.sticker-edit-mode .sticker-item.selected .sticker-control-bottom {
    opacity: 1;
    pointer-events: auto;
}

/* 컨트롤 버튼 */
.control-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    background: rgba(23, 25, 29, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.control-btn:hover {
    background: rgba(23, 25, 29, 0.3);
    transform: scale(1.1);
}

.control-btn.danger {
    background: rgba(244, 67, 54, 0.8);
    border-color: rgba(244, 67, 54, 1);
}

.control-btn.danger:hover {
    background: rgba(244, 67, 54, 1);
}

/* 아이콘 버튼 (필터/애니메이션) */
.control-icon-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    background: rgba(23, 25, 29, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.control-icon-btn:hover {
    background: rgba(23, 25, 29, 0.3);
    color: white;
}

.control-icon-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.control-row {
    display: flex;
    gap: 2px;
}

/* 수직 슬라이더 */
.vertical-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 6px;
    height: 70px;
    cursor: pointer;
}

/* 리사이즈 핸들 */
.resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border: 2px solid var(--info-color);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

body.sticker-edit-mode .sticker-item:hover .resize-handle,
body.sticker-edit-mode .sticker-item.selected .resize-handle {
    opacity: 1;
}

.resize-se {
    bottom: -7px;
    right: -7px;
    cursor: se-resize;
}

.sticker-item.draggable {
    cursor: move;
    cursor: grab;
}

.sticker-item.dragging {
    cursor: grabbing;
    opacity: 0.8;
    transform: scale(1.05);
    z-index: 10000;
}

.sticker-item img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    pointer-events: none;
}

/* 관리자 모드: 삭제 버튼 - 기본은 숨김 (편집 모드에서만 표시) */
.sticker-item .delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #f44336;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.2s;
    display: none; /* 기본 숨김 */
}

/* 편집 모드에서만 삭제 버튼 표시 */
body.sticker-edit-mode .sticker-item .delete-btn {
    display: block;
}

body.sticker-edit-mode .sticker-item:hover .delete-btn {
    opacity: 1;
}

.sticker-item .delete-btn:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

/* 반응형 */
@media (max-width: 768px) {
    /* 모바일에서는 자유 배치 스티커를 숨기고 전용 메뉴 레일만 사용한다. */
    .sticker-container {
        display: none !important;
        pointer-events: none !important;
    }

    /* paper_profile 신문 화면에서는 absolute 스티커를 지면 구성 요소로 유지한다. */
    .sticker-container.sticker-paper-mobile-canvas {
        display: block !important;
        z-index: 899 !important;
        pointer-events: none !important;
    }

    .sticker-container.sticker-paper-mobile-canvas .sticker-item {
        max-width: none !important;
        max-height: none !important;
    }

    .sticker-item {
        max-width: 80px !important;
        max-height: 80px !important;
    }

    .sticker-item .delete-btn {
        width: 20px;
        height: 20px;
        font-size: 12px;
        line-height: 16px;
    }
}

/* Rendered only by the server's mobile branch, including wide mobile landscape. */
[data-sticker-mobile-widget="true"] .sticker-mobile-menu-btn {
        position: fixed;
        left: var(--sticker-mobile-left, 15px);
        top: var(--sticker-mobile-top, 70px);
        z-index: 999;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 45px;
        height: 45px;
        padding: 0;
        border: 1px solid var(--container-border-color);
        border-radius: var(--container-border-radius);
        background: var(--container-bg-color);
        color: var(--content-font-color);
        font: inherit;
        font-family: Arial, sans-serif;
        font-size: 24px;
        font-weight: 900;
        line-height: 1;
        cursor: pointer;
        box-sizing: border-box;
        box-shadow: 0 2px 8px rgb(from var(--black) r g b / 20%);
        list-style: none;
}

[data-sticker-mobile-widget="true"] .sticker-mobile-menu-icon {
    display: block;
    color: inherit;
    transform: translateY(1px);
}

[data-sticker-mobile-widget="true"] .sticker-mobile-menu-btn::-webkit-details-marker {
    display: none;
}

[data-sticker-mobile-widget="true"] .sticker-mobile-menu-btn::marker {
    content: '';
    font-size: 0;
}

[data-sticker-mobile-widget="true"] .sticker-mobile-rail {
        position: fixed;
        left: var(--sticker-mobile-left, 15px);
        top: calc(var(--sticker-mobile-top, 70px) + 49px);
        z-index: 998;
        display: flex;
        width: min(42vw, 180px);
        max-height: var(--sticker-mobile-max-height, 240px);
        flex-direction: column;
        gap: 8px;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 2px 4px 4px 2px;
        background: transparent;
        scrollbar-width: none;
}

[data-sticker-mobile-widget="true"].sticker-mobile-disclosure:not([open]) > .sticker-mobile-rail {
    display: none;
}

.sticker-mobile-disclosure.is-site-menu-open {
    visibility: hidden !important;
    pointer-events: none !important;
}

[data-sticker-mobile-widget="true"] .sticker-mobile-rail::-webkit-scrollbar {
    display: none;
}

[data-sticker-mobile-widget="true"] .sticker-mobile-link {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        overflow: visible;
        color: var(--content-font-color, #222);
        text-decoration: none;
}

[data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced .sticker-mobile-link {
        opacity: 0;
        transform: translateX(-10px) rotate(-2deg);
        transition: opacity 160ms ease-out, transform 180ms ease-out;
        transition-delay: calc(var(--sticker-rail-index, 0) * 45ms);
}

[data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced .sticker-mobile-link:nth-child(even) {
    transform: translateX(-10px) rotate(2deg);
}

[data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced.is-open .sticker-mobile-link {
    opacity: 1;
    transform: translateX(0) rotate(-2deg);
}

[data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced.is-open .sticker-mobile-link:nth-child(even) {
    transform: translateX(0) rotate(2deg);
}

[data-sticker-mobile-widget="true"] .sticker-mobile-link > img {
        position: relative;
        z-index: 1;
        display: block;
        width: auto;
        max-width: 100%;
        max-height: 76px;
        object-fit: contain;
}

[data-sticker-mobile-widget="true"] .sticker-mobile-graffiti-bg {
        position: absolute;
        inset: -12%;
        z-index: 0;
        pointer-events: none;
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
        opacity: 0.8;
    }

[data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced .sticker-mobile-graffiti-bg {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 220ms ease-out;
    transition-delay: calc(var(--sticker-rail-index, 0) * 45ms);
}

[data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced.is-open .sticker-mobile-graffiti-bg {
    clip-path: inset(0 0 0 0);
}

[data-sticker-mobile-widget="true"] .sticker-mobile-label-fallback {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    background: var(--container-bg-color, #fff);
    box-shadow: 0 1px 4px rgb(from var(--black, #000) r g b / 15%);
    text-align: center;
    overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
    [data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced .sticker-mobile-link,
    [data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced .sticker-mobile-graffiti-bg {
        transition: none;
    }

    [data-sticker-mobile-widget="true"] .sticker-mobile-rail.is-enhanced .sticker-mobile-graffiti-bg {
        clip-path: inset(0 0 0 0);
    }
}


/* ===== 스티커 애니메이션 (저장된 애니메이션 표시용) ===== */
/* 통!... 통!... 느낌 - 동작 후 쉬는 시간 포함 */

/* 바운스 - 일반 (1.5초 주기, 0.3초 동작 + 1.2초 대기) */
.sticker-item img.sticker-bounce {
    animation: stickerBounce 1.5s ease-out infinite;
}

/* 바운스 - 좌우반전 */
.sticker-item img.sticker-bounce[data-flip-h="1"] {
    animation: stickerBounceFlip 1.5s ease-out infinite;
}

@keyframes stickerBounce {
    0% { transform: translateY(0) scaleY(1); }
    6% { transform: translateY(-15px) scaleX(0.95) scaleY(1.1); }
    12% { transform: translateY(0) scaleX(1.05) scaleY(0.9); }
    15% { transform: translateY(-5px) scaleY(1.02); }
    20% { transform: translateY(0) scaleY(1); }
    100% { transform: translateY(0) scaleY(1); }
}

@keyframes stickerBounceFlip {
    0% { transform: translateY(0) scaleY(1) scaleX(-1); }
    6% { transform: translateY(-15px) scaleY(1.1) scaleX(-0.95); }
    12% { transform: translateY(0) scaleY(0.9) scaleX(-1.05); }
    15% { transform: translateY(-5px) scaleY(1.02) scaleX(-1); }
    20% { transform: translateY(0) scaleY(1) scaleX(-1); }
    100% { transform: translateY(0) scaleY(1) scaleX(-1); }
}

/* 흔들림 - 일반 (1.2초 주기, 0.25초 동작 + 대기) */
.sticker-item img.sticker-shake {
    animation: stickerShake 1.2s ease-in-out infinite;
}

/* 흔들림 - 좌우반전 */
.sticker-item img.sticker-shake[data-flip-h="1"] {
    animation: stickerShakeFlip 1.2s ease-in-out infinite;
}

@keyframes stickerShake {
    0% { transform: translateX(0) rotate(0deg); }
    4% { transform: translateX(-5px) rotate(-5deg); }
    8% { transform: translateX(5px) rotate(5deg); }
    12% { transform: translateX(-3px) rotate(-3deg); }
    16% { transform: translateX(3px) rotate(3deg); }
    20% { transform: translateX(0) rotate(0deg); }
    100% { transform: translateX(0) rotate(0deg); }
}

@keyframes stickerShakeFlip {
    0% { transform: translateX(0) rotate(0deg) scaleX(-1); }
    4% { transform: translateX(-5px) rotate(-5deg) scaleX(-1); }
    8% { transform: translateX(5px) rotate(5deg) scaleX(-1); }
    12% { transform: translateX(-3px) rotate(-3deg) scaleX(-1); }
    16% { transform: translateX(3px) rotate(3deg) scaleX(-1); }
    20% { transform: translateX(0) rotate(0deg) scaleX(-1); }
    100% { transform: translateX(0) rotate(0deg) scaleX(-1); }
}

/* 펄스 - 일반 (1.5초 주기) */
.sticker-item img.sticker-pulse {
    animation: stickerPulse 1.5s ease-in-out infinite;
}

/* 펄스 - 좌우반전 */
.sticker-item img.sticker-pulse[data-flip-h="1"] {
    animation: stickerPulseFlip 1.5s ease-in-out infinite;
}

@keyframes stickerPulse {
    0% { transform: scale(1); }
    10% { transform: scale(1.12); }
    20% { transform: scale(1); }
    100% { transform: scale(1); }
}

@keyframes stickerPulseFlip {
    0% { transform: scale(1) scaleX(-1); }
    10% { transform: scale(1.12) scaleX(-1); }
    20% { transform: scale(1) scaleX(-1); }
    100% { transform: scale(1) scaleX(-1); }
}

/* 회전 - 일반 (2초 주기, 빠른 회전 후 대기) */
.sticker-item img.sticker-rotate {
    animation: stickerRotate 2s ease-out infinite;
}

/* 회전 - 좌우반전 */
.sticker-item img.sticker-rotate[data-flip-h="1"] {
    animation: stickerRotateFlip 2s ease-out infinite;
}

@keyframes stickerRotate {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(360deg); }
    100% { transform: rotate(360deg); }
}

@keyframes stickerRotateFlip {
    0% { transform: rotate(0deg) scaleX(-1); }
    25% { transform: rotate(360deg) scaleX(-1); }
    100% { transform: rotate(360deg) scaleX(-1); }
}
