/* Guestbook Section */
.guestbook-section {
    background-color: var(--color-bg);
}

.guestbook-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Guestbook Form Area (Post-it Style) */
.guestbook-form-area {
    background: #fdfadd;
    /* Yellow Post-it */
    max-height: 0;
    opacity: 0;
    padding: 0 35px;
    margin: 0 auto;
    overflow: hidden;
    transform: translateY(-20px);
    border-radius: 2px 2px 15px 5px / 2px 2px 5px 15px;
    /* Curl */
    border: none;
    box-shadow: 2px 10px 40px rgba(0, 0, 0, 0.1);
    max-width: 450px;
    width: 100%;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: none;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* No tape on the form itself - it appears only when 'stuck' */
.guestbook-section .guestbook-form-area::before,
.guestbook-section .guestbook-form-area.is-open::before,
.guestbook-section .guestbook-form-area[class*="color-"]::before {
    display: none !important;
    content: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

.guestbook-form-area.is-open {
    max-height: 900px !important;
    opacity: 1 !important;
    padding: 50px 22px 22px !important;
    margin-top: 25px !important;
    transform: translateY(0) rotate(0deg) !important;
    pointer-events: auto !important;
    border-radius: 4px !important;
    position: relative;
}

/* New X Close Button */
.gb-close-form-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 38px;
    font-weight: 200;
    color: rgba(0,0,0,0.3);
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s;
    user-select: none;
    z-index: 10;
}

.gb-close-form-btn:hover {
    color: rgba(0,0,0,0.6);
}

/* Toggle Button - Clean Pill Shape */
#gb-toggle-form-btn {
    background: #fdfadd;
    border-radius: 2px 2px 10px 5px / 2px 2px 5px 10px;
    border: none;
    box-shadow: 2px 4px 15px rgba(0, 0, 0, 0.08);
    font-family: 'Gowun Dodum', var(--font-body);
    font-size: 1.15rem;
    font-weight: 600;
    color: #444;
    padding: 15px 30px;
    position: relative;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    margin: 20px auto 10px;
    display: block;
    max-height: 80px;
    opacity: 1;
    overflow: visible;
    /* to show tape */
    transform: rotate(-1.5deg);
}

/* Tape on the button */
#gb-toggle-form-btn::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(-3deg);
    width: 35px;
    height: 15px;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#gb-toggle-form-btn:hover {
    transform: translateY(-3px) scale(1.02) rotate(0deg);
    box-shadow: 2px 10px 25px rgba(0, 0, 0, 0.12);
}

#gb-toggle-form-btn.is-hidden {
    max-height: 0;
    opacity: 0;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0;
    padding-bottom: 0;
    border: none;
    pointer-events: none;
    box-shadow: none;
    overflow: hidden;
    /* Hide cleanly */
}

/* Post-it Input Styling */
.guestbook-form-area input,
.guestbook-form-area textarea:not(.gb-text-overlay) {
    background: transparent !important;
    border: none;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.15) !important;
    border-radius: 0 !important;
    padding: 8px 5px;
    margin-bottom: 20px;
    font-family: 'Gowun Dodum', 'Noto Sans KR', sans-serif;
    font-size: 1.05rem;
    color: #444;
    resize: none;
    box-shadow: none !important;
    width: 100%;
    transition: border-bottom-color 0.3s;
}

.guestbook-form-area input:focus,
.guestbook-form-area textarea:not(.gb-text-overlay):focus {
    outline: none;
    border-bottom: 1px solid var(--color-accent) !important;
}

#gb-name {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Rubber Stamp Buttons - Handwritten & Pressed look */
#gb-submit {
    display: block !important;
    width: 100% !important; /* Fill the bottom */
    margin-top: 10px;
    border-radius: 3px !important;
    padding: 12px 25px !important;
    font-family: 'Gowun Dodum', var(--font-body) !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    background-color: rgba(188, 143, 143, 0.8) !important;
    color: #fff !important;
    border: 2.5px solid rgba(188, 143, 143, 1) !important;
    box-shadow: 1px 2px 4px rgba(0,0,0,0.1) !important;
    transform: rotate(1deg) !important;
    mix-blend-mode: multiply !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    text-transform: none !important;
}

#gb-submit:hover {
    transform: rotate(0deg) scale(1.02) !important;
}

/* Old cancel button removed */


/* Scroll wrapper with bottom fade */
.gb-scroll-wrapper {
    position: relative;
}

.gb-scroll-wrapper.has-more::after {
    content: '';
    position: absolute;
    top: var(--gb-fade-top, 80%);
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 0%, #fcfbf9 30%);
    pointer-events: none;
    z-index: 1;
}

/* Guestbook Grid for Post-Its */
.guestbook-scroll-area {
    width: 100%;
    padding: 30px 10px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    align-items: start;
}

.empty-state {
    grid-column: 1 / -1;
    margin: 60px auto;
    color: #bbb;
    text-align: center;
    font-family: 'Gowun Dodum', var(--font-body);
    font-size: 1.05rem;
    line-height: 1.8;
}

@media (min-width: 768px) {
    .guestbook-scroll-area {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        padding: 40px 20px;
    }
}

@media (min-width: 1024px) {
    .guestbook-scroll-area {
        grid-template-columns: repeat(4, 1fr);
        gap: 25px;
    }
}

/* Post-It Cards */
.bubble {
    width: 100%;
    background: #fdfadd;
    border-radius: 2px 2px 15px 5px / 2px 2px 5px 15px;
    /* Subtle paper curl */
    padding: 25px 15px 15px;
    box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, z-index 0s;
    position: relative;
    border: none;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* Tape effect */
.bubble::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    width: 35px;
    height: 15px;
    z-index: 2;
}

.bubble:hover {
    transform: scale(1.05) rotate(0deg) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* Color classes derived from backend color_idx (1 to 4) */
.color-1 {
    background: #fdfadd;
    transform: rotate(-2.5deg);
}

.color-1::before {
    transform: translateX(-50%) rotate(3deg);
    background: rgba(255, 200, 200, 0.5);
}

.color-2 {
    background: #eef7f8;
    transform: rotate(1.5deg);
}

.color-2::before {
    transform: translateX(-50%) rotate(-4deg);
    background: rgba(200, 255, 200, 0.5);
}

.color-3 {
    background: #fdf0f4;
    transform: rotate(-1.5deg);
}

.color-3::before {
    transform: translateX(-50%) rotate(2deg);
    background: rgba(200, 200, 255, 0.5);
}

.color-4 {
    background: #f2f8ed;
    transform: rotate(3deg);
}

.color-4::before {
    transform: translateX(-50%) rotate(-2deg);
    background: rgba(255, 255, 200, 0.5);
}

/* Prevent the form from rotating when it gets a color class */
.guestbook-form-area.is-open {
    transform: translateY(0) rotate(0deg) !important;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Fly-in Animation for new bubbles */
@keyframes flyInFly {
    0% {
        opacity: 0;
        transform: translate(0, 150px) scale(1.4) rotate(15deg);
        box-shadow: 10px 40px 60px rgba(0, 0, 0, 0.3);
        z-index: 100;
    }

    100% {
        opacity: 1;
        transform: translate(0, 0) scale(1) rotate(0deg);
        box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.08);
        z-index: 1;
    }
}

.bubble.fly-in {
    animation: flyInFly 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.bubble .b-name {
    font-family: 'Gowun Dodum', var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 10px;
    padding-bottom: 8px;
    text-align: left;
    letter-spacing: 0;
}

.bubble .b-name::before {
    display: none;
}

.bubble .b-text {
    font-family: 'Gowun Dodum', 'Noto Sans KR', sans-serif;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: break-word;
    text-align: left;
    flex-grow: 1;
}

.empty-state {
    font-family: 'Noto Sans KR', sans-serif;
    color: #999;
    text-align: center;
    padding: 60px 20px;
    width: 100%;
    font-size: 1.05rem;
    line-height: 1.8;
}

.bubble .b-name {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-accent);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.bubble .b-name::before {
    content: '';
    display: block;
    width: 4px;
    height: 4px;
    background-color: var(--color-accent);
    border-radius: 50%;
}


/* Post-It Modal Reuse */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    touch-action: none;
    transition: opacity 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--modal-bg, #fdfadd);
    padding: 45px 35px 35px;
    border-radius: 2px 2px 20px 5px / 2px 2px 5px 20px;
    max-width: 450px;
    width: 90%;
    position: relative;
    text-align: center;
    box-shadow: 2px 10px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain; /* 내부 스크롤이 배경으로 체이닝되지 않도록 */
}

.modal-content::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: var(--modal-tape-transform, translateX(-50%) rotate(0deg));
    width: 60px;
    height: 25px;
    background: var(--modal-tape-bg, rgba(255, 255, 255, 0.5));
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    z-index: 2;
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0) scale(1) rotate(0deg);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: rgba(0, 0, 0, 0.2);
    transition: color 0.2s;
    line-height: 1;
    z-index: 10;
}

.close-modal:hover {
    color: rgba(0, 0, 0, 0.6);
}

#modal-name {
    font-family: 'Gowun Dodum', var(--font-body);
    font-size: 1.4rem;
    color: #444;
    margin-bottom: 20px;
    padding-bottom: 15px;
    font-weight: 600;
}

/* ── 통합 캔버스 (글씨 + 그림) ── */
.gb-canvas-wrap {
    position: relative;
    overflow: hidden;
    border-radius: 4px 4px 0 0;
    cursor: text;
    /* 포스트잇 색상은 color-N 클래스에서 override */
    background: #fdfadd;
}


.guestbook-form-area.color-1 .gb-canvas-wrap { background: #fdfadd; }
.guestbook-form-area.color-2 .gb-canvas-wrap { background: #eef7f8; }
.guestbook-form-area.color-3 .gb-canvas-wrap { background: #fdf0f4; }
.guestbook-form-area.color-4 .gb-canvas-wrap { background: #f2f8ed; }

#gb-draw-canvas {
    display: block;
    width: 100%;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none; /* iOS 롱프레스 시스템 메뉴 방지 */
}

/* 텍스트 오버레이 입력창 */
.gb-text-overlay {
    position: absolute !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    padding: 0 2px !important;
    margin: 0 !important;
    font-family: 'Gowun Dodum', sans-serif !important;
    line-height: 1.4 !important;
    box-shadow: none !important;
    display: none;
    z-index: 5;
    resize: none !important;
    overflow: hidden !important;
    word-break: break-all !important;
    caret-color: currentColor !important;
}

/* 툴바 */
.gb-draw-toolbar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 0 0 4px 4px;
    margin-bottom: 12px;
}

.gb-toolbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* 모드 탭 */
.gb-mode-tabs {
    display: flex;
    gap: 2px;
    background: rgba(0,0,0,0.08);
    border-radius: 6px;
    padding: 2px;
}

.gb-mode-tab {
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: 'Gowun Dodum', var(--font-body);
    color: #666;
    transition: all 0.15s;
    white-space: nowrap;
}

.gb-mode-tab b {
    font-weight: 700;
    margin-right: 2px;
}

.gb-mode-tab.active {
    background: #fff;
    color: #222;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* 색상 스와치 */
.gb-color-swatches {
    display: flex;
    gap: 6px;
    align-items: center;
    width: 100%;
    justify-content: flex-start;
}

.gb-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: all 0.15s;
    padding: 0;
    flex-shrink: 0;
}

.gb-swatch.active {
    border-color: rgba(255,255,255,0.9);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.2);
    transform: scale(1.15);
}

/* 지우개 버튼 */
.gb-eraser-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    cursor: pointer;
    padding: 0;
    background: rgba(0,0,0,0.07);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    margin-left: 2px;
    visibility: hidden; /* 공간은 유지하면서 숨김 */
}

.gb-eraser-btn.active {
    border-color: rgba(255,255,255,0.9);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.2);
    transform: scale(1.15);
    background: rgba(0,0,0,0.12);
}

/* 그림 모드일 때만 지우개 노출 */
.gb-draw-toolbar.draw-mode .gb-eraser-btn {
    visibility: visible;
}

/* 지우기 버튼 */
.gb-clear-btn {
    padding: 4px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
    font-family: 'Gowun Dodum', var(--font-body);
    color: var(--color-accent, #b22);
    transition: opacity 0.15s;
    white-space: nowrap;
}

.gb-clear-btn:hover { opacity: 0.7; }

/* 포스트잇 카드 내 그림 */
.b-drawing {
    width: 100%;
    border-radius: 3px;
    display: block;
}

/* 모달 내 그림 */
.modal-drawing {
    width: 100%;
    border-radius: 4px;
    margin-bottom: 14px;
    display: block;
}

/* ── 소형 폰 (iPhone SE 등, max-width: 390px) ── */
@media (max-width: 390px) {
    .modal-content {
        padding: 36px 20px 24px;
        width: 94%;
    }
}

#modal-message {
    font-family: 'Gowun Dodum', 'Noto Sans KR', sans-serif;
    font-size: 1.15rem;
    line-height: 1.8;
    color: #555;
    margin-bottom: 30px;
    white-space: pre-wrap;
    text-align: left;
}

#modal-date {
    font-family: 'Gowun Dodum', var(--font-body);
    font-size: 0.9rem;
    color: #888;
    text-align: right;
    display: block;
}