﻿/* =========================================================
   KOTORI CAPTCHA
   LAGONG EDITION
========================================================= */

/* -----------------------------
    Widget
------------------------------ */

.cpw-widget {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    width: 320px;
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,.65);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0,0,0,.18);
    overflow: hidden;
    z-index: 25000;
    user-select: none;
}

/* -----------------------------
    Header
------------------------------ */

.cpw-header {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    cursor: move;
    transition: .25s;
}

    .cpw-header.stage1 {
        background: #EDBABE;
    }

    .cpw-header.stage2 {
        background: #6B8165;
    }

    .cpw-header.dragging {
        opacity: .9;
    }

/* -----------------------------
    Title
------------------------------ */

.cpw-title {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .5px;
}

/* -----------------------------
    Close
------------------------------ */

.cpw-close {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    transition: .2s;
}

    .cpw-close:hover {
        background: rgba(255,255,255,.35);
        transform: rotate(90deg);
    }

/* -----------------------------
    Body
------------------------------ */

.cpw-body {
    padding: 12px;
}

/* -----------------------------
    Open Button
------------------------------ */

.cpw-open {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    width: 160px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,.18);
    cursor: pointer;
    transition: .25s;
    z-index: 19999;
}

    .cpw-open:hover {
        transform: translateY(calc(-50% - 2px));
        box-shadow: 0 16px 32px rgba(0,0,0,.24);
    }

.cpw-open-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #444;
}

.cpw-open-sub {
    margin-left: 26px;
    font-size: 11px;
    color: #999;
    letter-spacing: .6px;
    text-transform: uppercase;
}

.cpw-lock {
    width: 18px;
    height: 18px;
    color: #EDBABE;
    flex: none;
    transition: .25s;
}

.cpw-open:hover .cpw-lock {
    color: #6B8165;
    transform: scale(1.1);
}

.cpw-open-mobile {
    display: none;
}

/* =========================================================
   START
========================================================= */

.cpw-start {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18px 10px;
}

/* -----------------------------
    Checkbox
------------------------------ */

.cpw-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: .2s;
}

    .cpw-checkbox:hover {
        background: #f5f8ff;
    }

    .cpw-checkbox input {
        display: none;
    }

/* -----------------------------
    Box
------------------------------ */

.cpw-box {
    width: 22px;
    height: 22px;
    border: 2px solid #b8b8b8;
    border-radius: 3px;
    background: #fff;
    position: relative;
    transition: .2s;
}

    .cpw-box::after {
        content: "✓";
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%,-50%) scale(.6);
        color: #EDBABE;
        font-size: 14px;
        opacity: 0;
        transition: .2s;
    }

.cpw-checkbox input:checked + .cpw-box {
    border-color: #EDBABE;
}

    .cpw-checkbox input:checked + .cpw-box::after {
        opacity: 1;
        transform: translate(-50%,-50%) scale(1);
    }

/* -----------------------------
    Text
------------------------------ */

.cpw-text {
    font-size: 14px;
    font-weight: 600;
    color: #444;
}

/* =========================================================
   Loading
========================================================= */

#cpw-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    gap: 16px;
    text-align: center;
}

.cpw-loading-title {
    font-size: 15px;
    font-weight: 700;
    color: #555;
    letter-spacing: .3px;
}

.cpw-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0,0,0,.12);
    border-top-color: #EDBABE;
    border-radius: 50%;
    animation: cpwSpinner .8s linear infinite;
}


/* =========================================================
   GAME
========================================================= */

.cpw-game {
    animation: cpwFade .25s;
}

.cpw-progress {
    text-align: center;
    font-size: 11px;
    color: #888;
    margin-bottom: 6px;
}

.cpw-message {
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: #444;
    line-height: 1.5;
    margin-bottom: 12px;
}

/* =========================================================
   GRID
========================================================= */

.cpw-grid {
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 6px;
    margin-bottom: 14px;
}

/* =========================================================
   CELL
========================================================= */

.cpw-cell {
    position: relative;
    aspect-ratio: 1/1;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    background: #f6f6f6;
    transition: transform .15s, border-color .15s, box-shadow .15s;
}

    .cpw-cell img {
        width: 100%;
        height: 100%;
        display: block;
        object-fit: cover;
        pointer-events: none;
        transition: transform .18s, filter .18s;
    }

    .cpw-cell:hover img {
        transform: scale(1.05);
    }

    .cpw-cell:active {
        transform: scale(.96);
    }

    /* =========================================================
   SELECTED
========================================================= */

.cpw-widget.stage1 .cpw-cell.selected {
    border-color: #EDBABE;
    box-shadow: 0 0 0 2px rgba(237,186,190,.25);
    background: rgba(237,186,190,.05);
}

    .cpw-widget.stage1 .cpw-cell.selected::after {
        content: "✓";
        position: absolute;
        top: 4px;
        right: 4px;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #EDBABE;
        color: #fff;
        font-size: 13px;
        font-weight: 700;
        box-shadow: 0 2px 8px rgba(0,0,0,.20);
        animation: cpwCheck .22s cubic-bezier(.2,1.4,.5,1);
        z-index: 20;
    }

.cpw-widget.stage2 .cpw-cell.selected {
    border-color: #6B8165;
    box-shadow: 0 0 0 2px rgba(107,129,101,.25);
    background: rgba(107,129,101,.05);
}

    .cpw-widget.stage2 .cpw-cell.selected::after {
        content: "✓";
        position: absolute;
        top: 4px;
        right: 4px;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #6B8165;
        color: #fff;
        font-size: 13px;
        font-weight: 700;
        box-shadow: 0 2px 8px rgba(0,0,0,.20);
        animation: cpwCheck .22s cubic-bezier(.2,1.4,.5,1);
        z-index: 20;
    }

        .cpw-cell.selected img {
            filter: saturate(1.15);
            transform: scale(1.03);
        }

        .cpw-cell.selected:hover {
            transform: none;
        }

    /* =========================================================
   WRONG
========================================================= */

    .cpw-cell.wrong {
        border-color: #EB5A5A;
        box-shadow: 0 0 0 2px rgba(235,90,90,.18);
    }

        .cpw-cell.wrong img {
            filter: grayscale(.2);
        }

/* =========================================================
   FOOTER
========================================================= */

.cpw-footer {
    display: flex;
    justify-content: center;
}

/* =========================================================
   CONFIRM
========================================================= */

.cpw-confirm {
    min-width: 110px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: #5D6F92;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: .18s;
}

/* =========================================================
   Stage Button Color
========================================================= */

.cpw-widget.stage1 .cpw-confirm {
    background: linear-gradient( 180deg, #F4C6C9, #EDBABE );
}

    .cpw-widget.stage1 .cpw-confirm:hover {
        background: linear-gradient( 180deg, #F4C6C9, #EDBABE );
    }

.cpw-widget.stage2 .cpw-confirm {
    background: linear-gradient( 180deg, #7A9274, #6B8165 );
}

    .cpw-widget.stage2 .cpw-confirm:hover {
        background: linear-gradient( 180deg, #7A9274, #6B8165 );
    }

    .cpw-confirm:hover {
        transform: translateY(-2px);
        filter: brightness(1.04);
    }

    .cpw-confirm:active {
        transform: scale(.97);
    }

    .cpw-confirm.loading {
        pointer-events: none;
        opacity: .75;
    }

/* =========================================================
   SUCCESS / FAIL
========================================================= */

.cpw-success,
.cpw-fail {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px 16px;
    animation: cpwFade .25s;
}

.cpw-success-icon,
.cpw-fail-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 14px;
}

.cpw-success-icon {
    background: #58B46C;
    box-shadow: 0 8px 18px rgba(88,180,108,.28);
}

.cpw-fail-icon {
    background: #EB5A5A;
    box-shadow: 0 8px 18px rgba(235,90,90,.28);
}

.cpw-success-text,
.cpw-fail-text {
    font-size: 14px;
    font-weight: 700;
    color: #444;
    text-align: center;
    line-height: 1.5;
    margin-bottom: 16px;
}

/* =========================================================
   RESTART
========================================================= */

.cpw-restart {
    min-width: 110px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: #5D6F92;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: .18s;
}

    .cpw-restart:hover {
        transform: translateY(-2px);
        filter: brightness(1.05);
    }

    .cpw-restart:active {
        transform: scale(.97);
    }

/* =========================================================
   DRAG
========================================================= */

.cpw-widget.dragging {
    opacity: .95;
    cursor: grabbing;
    transition: none;
    box-shadow: 0 20px 40px rgba(0,0,0,.22);
}

.cpw-header.dragging {
    cursor: grabbing;
}

/* =========================================================
   EFFECT
========================================================= */

.cpw-cell {
    -webkit-user-select: none;
    user-select: none;
}

    .cpw-cell img {
        -webkit-user-drag: none;
        user-select: none;
    }

.cpw-pop {
    animation: cpwPop .18s ease;
}

.cpw-shake {
    animation: cpwShake .45s ease;
}

/* =========================================================
   ANIMATION
========================================================= */

@keyframes cpwFade {

    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cpwPop {

    0% {
        transform: scale(.90);
    }

    60% {
        transform: scale(1.04);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes cpwShake {

    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-5px);
    }

    40% {
        transform: translateX(5px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes cpwSpinner {

    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes cpwFadeOut {

    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width:800px) {

    /* PC용 버튼 숨김 */

    .cpw-open {
        display: none !important;
    }

    /* 모바일 버튼 */

    .cpw-open-mobile {
        display: flex;
        position: fixed;
        right: 15px;
        top: 124px;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        border: 1px solid #eeeeee;
        background: #ffffff;
        color: #8D8C8C;
        align-items: center;
        justify-content: center;
        box-shadow: 0 8px 20px rgba(0,0,0,.15);
        cursor: pointer;
        z-index: 20000;
    }

        .cpw-open-mobile .cpw-lock {
            width: 18px;
            height: 18px;
        }

    /* 캡챠 창 */

    .cpw-widget {
        width: min(300px,calc(100vw - 22px));
        left: 50%;
        right: auto;
        top: 43%;
        transform: translate(-50%,-50%);
        z-index: 25000;
    }
}

/* =========================================================
   SMALL SCREEN
========================================================= */

@media (max-height:680px) {

    .cpw-widget {
        transform: translateY(-50%) scale(.92);
        transform-origin: right center;
    }
}

/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion:reduce) {

    * {
        animation: none !important;
        transition: none !important;
    }
}