/* ==========================================================================
   1. 외부 폰트 및 전역 설정
   ========================================================================== */
@import url('https://fonts.googleapis.com/gh/orioncactus/pretendard/dist/web/static/pretendard.css');
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@1,600&display=swap');

:root { 
    --cursor-x: 50%; 
    --cursor-y: 50%; 
    --nav-height: 90px; 
    /* ✅ 티스토리 포인트 컬러 (오렌지) */
    --primary-orange: #f97316; 
}

html { scroll-behavior: smooth; }
body { 
    font-family: 'Pretendard', sans-serif; 
    background: #fafaf9; /* 티스토리에 어울리는 따뜻한 스톤 배경 */
    color: #1c1917; 
    overflow-x: hidden; 
    letter-spacing: -0.02em; 
    padding-top: var(--nav-height); 
    overscroll-behavior-y: auto; 
}

/* ==========================================================================
   2. 통합 내비게이션 바 및 사이드바
   ========================================================================== */
#navbar {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#navbar.scrolled {
    background-color: rgba(255, 255, 255, 0.95) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    height: 80px;
}

.nav-link-item {
    position: relative;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #a8a29e;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 0.5rem 0.5rem;
    white-space: nowrap;
}

.nav-link-item.nav-yt:hover { color: #ef4444; } 
.nav-link-item.nav-ig:hover { color: #ec4899; }
.nav-link-item.nav-tk:hover { color: #06b6d4; } 
.nav-link-item.nav-nb:hover { color: #22c55e; }
.nav-link-item.nav-ts:hover, .nav-link-item.nav-ts.active { color: var(--primary-orange); }

.nav-link-item::after {
    content: '';
    position: absolute;
    bottom: 0; left: 50%; width: 0; height: 2px;
    background: currentColor;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}
.nav-link-item:hover::after, .nav-link-item.active::after { width: 100%; }

/* ✅ 사이드메뉴 활성화 상태 강제 적용 */
#sideMenu.active { transform: translateX(0) !important; }

/* ==========================================================================
   3. T-Story Studio 고유 컴포넌트 스타일
   ========================================================================== */

/* 배경 효과 (오렌지/웜톤 믹스) */
.fluid-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; background: radial-gradient(circle at var(--cursor-x) var(--cursor-y), rgba(249, 115, 22, 0.08) 0%, transparent 40%), radial-gradient(circle at 80% 20%, rgba(251, 146, 60, 0.05) 0%, transparent 50%), radial-gradient(circle at 20% 80%, rgba(253, 186, 116, 0.04) 0%, transparent 50%); transition: background 0.2s ease-out; }
.aurora-blur { position: fixed; width: 140vw; height: 140vh; top: -20vh; left: -25vw; z-index: -2; background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 25%, #fafaf9 50%, #fff7ed 100%); filter: blur(120px); animation: auroraRotate 25s linear infinite; }
@keyframes auroraRotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* 카드 및 컨테이너 */
.mag-card { background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(40px) saturate(150%); border: 1px solid rgba(255, 255, 255, 0.8); border-radius: 2.5rem; padding: 2rem; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1); height: fit-content; position: relative; z-index: 10; }

.canvas-container {
    aspect-ratio: 4 / 3; width: 100%; max-width: 900px; margin: 0 auto; position: relative; border-radius: 28px; overflow: hidden; background: #fff; box-shadow: 0 25px 60px rgba(0,0,0,0.06); touch-action: none;
}
#blogCanvas { width: 100% !important; height: auto !important; display: block; cursor: crosshair; }

/* 배경/프레임 선택 버튼 (오렌지 포인트) */
.bg-selector-btn { border: 2px solid transparent; transition: all 0.2s; position: relative; overflow: hidden; border-radius: 0.75rem; }
.bg-selector-btn.active { border-color: var(--primary-orange); transform: scale(1.05); }
.bg-selector-btn.active::after { content: '✓'; position: absolute; top: -5px; right: -5px; background: var(--primary-orange); color: white; width: 18px; height: 18px; border-radius: 50%; font-size: 10px; display: flex; align-items: center; justify-content: center; font-weight: 900; z-index: 5; }

.frame-color-btn { width: 100%; aspect-ratio: 1; border-radius: 50%; cursor: pointer; transition: all 0.2s; border: 1px solid rgba(0,0,0,0.1); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.frame-color-btn:hover { transform: scale(1.1); }
.frame-color-btn.active { transform: scale(1.15); box-shadow: 0 0 0 2px white, 0 0 0 4px var(--primary-orange); }

/* 매트 설정 슬라이더 */
#matteSliderArea { background: #fafaf9; padding: 15px 20px; border-radius: 1rem; border: 1px solid #e7e5e4; margin-top: 10px; }
input[type="range"] { accent-color: var(--primary-orange); cursor: pointer; -webkit-appearance: none; width: 100%; height: 8px; background: #e7e5e4; border-radius: 4px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; background: var(--primary-orange); border-radius: 50%; border: 3px solid white; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }

/* 갤러리 아이템 */
.gallery-item { position: relative; aspect-ratio: 1/1; border-radius: 1rem; overflow: hidden; border: 2px solid #fff; box-shadow: 0 4px 6px rgba(0,0,0,0.1); cursor: grab; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.btn-delete-img { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; background: rgba(255, 0, 0, 0.8); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; opacity: 0; transition: opacity 0.2s; }
.gallery-item:hover .btn-delete-img { opacity: 1; }

/* ==========================================================================
   4. 애니메이션 및 유틸리티 (오렌지 효과)
   ========================================================================== */
@keyframes modal-up { from { opacity: 0; transform: scale(0.95) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.animate-modal-up { animation: modal-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes guide-pulse { 0% { box-shadow: 0 0 0 0px rgba(249, 115, 22, 0.7); border-color: #f97316; } 70% { box-shadow: 0 0 0 15px rgba(249, 115, 22, 0); border-color: #f97316; } 100% { box-shadow: 0 0 0 0px rgba(249, 115, 22, 0); } }
.guide-highlight { animation: guide-pulse 1.5s infinite !important; border: 3px solid #f97316 !important; border-radius: 1.5rem; }

.pulse-highlight { animation: pulse-border-glow 2.5s infinite !important; border-color: rgba(249, 115, 22, 0.8) !important; }
@keyframes pulse-border-glow { 0% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.6); } 70% { box-shadow: 0 0 0 25px rgba(249, 115, 22, 0); } 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); } }

/* 🔥 [추가] 5. PC 버전 전시공간 탭 버튼 크기 확대 및 모바일 스크롤바 숨기기 */
.category-tab-btn {
    padding: 0.8rem 1.8rem !important; /* PC: 버튼 상하좌우 여백 확대 */
    font-size: 14px !important;        /* PC: 글씨 크기 확대 */
}
.category-tab-btn i {
    font-size: 18px !important;        /* PC: 아이콘 크기 확대 */
    margin-right: 8px !important;
}

/* 스크롤바 완전 숨기기 (모바일/PC 스와이프 기능 유지) */
.custom-scroll::-webkit-scrollbar,
#bgGalleryContainer .grid.grid-cols-4::-webkit-scrollbar {
    display: none !important;
}
.custom-scroll,
#bgGalleryContainer .grid.grid-cols-4 {
    -ms-overflow-style: none !important; /* IE and Edge */
    scrollbar-width: none !important;    /* Firefox */
}

.credit-serif { font-family: 'Cormorant Garamond', serif; }
.break-keep { word-break: keep-all; }

/* ==========================================================================
   6. 🔥 반응형 (모바일) 스타일 - 티스토리 초정밀 최적화
   ========================================================================== */
@media (max-width: 1024px) {
    #navbar { padding: 0 1rem !important; }
}

@media (max-width: 768px) {
    body { padding-top: 70px; }
    #navbar { height: 75px !important; }
    main.container { padding-left: 1rem !important; padding-right: 1rem !important; }
    
    header h2 { 
        font-size: 1.4rem !important; 
        line-height: 1.3 !important; 
        margin-bottom: 0.5rem !important;
        letter-spacing: -0.02em !important;
        font-weight: 900 !important;
    }

    header p { 
        font-size: 0.9rem !important; 
        line-height: 1.5 !important;
        padding: 0 1rem !important;
    }

    /* 레이아웃 가로폭 중앙 정렬 일치화 */
    .lg\:col-span-8, .lg\:col-span-4, .canvas-container, .bg-white.rounded-\[40px\] {
        width: 100% !important; 
        max-width: 450px !important; 
        margin-left: auto !important; 
        margin-right: auto !important;
    }

    /* 패딩 및 마진 밸런스 */
    .mag-card, .bg-white.rounded-\[32px\], .bg-white.rounded-\[40px\] { 
        padding: 1.5rem 1.1rem !important; 
        border-radius: 1.5rem !important; 
    }
    #dropZone { padding: 2.5rem 1rem !important; }

    /* 01. 전시 공간 썸네일 모바일 최적화 (가로 스크롤 및 크기 고정) */
    #bgGalleryContainer .grid.grid-cols-4 {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        gap: 8px !important;
        padding-bottom: 4px !important; /* 스크롤바 숨김으로 하단 여백 축소 */
        -webkit-overflow-scrolling: touch; 
    }

    #bgGalleryContainer .bg-thumb,
    #bgGalleryContainer label.cursor-pointer {
        flex: 0 0 auto !important; 
        width: 100px !important; 
        height: 60px !important;
        aspect-ratio: auto !important; 
    }

    /* 🔥 [수정] 모바일에서는 전시 공간 탭 버튼을 작게 복구 */
    .category-tab-btn {
        padding: 0.5rem 1rem !important;
        font-size: 11px !important;
        white-space: nowrap !important;
    }
    .category-tab-btn i {
        font-size: 13px !important;
        margin-right: 5px !important;
    }

    /* 06. 카테고리 칩(라디오 버튼) 사이즈 축소 */
    .category-radio + label {
        padding: 6px 12px !important;
        font-size: 10px !important;
        letter-spacing: -0.02em !important;
    }
    
    .category-group-title {
        font-size: 10px !important;
        margin-bottom: 10px !important;
    }

    .ai-write-btn {
        font-size: 9.5px !important;
        padding: 12px 4px !important;
        letter-spacing: -0.02em;
    }

    .grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; gap: 6px !important; }
    #aiBlogResult { padding: 1.5rem !important; font-size: 14px !important; }
}

/* =========================================
   🔥 카테고리 태그(라디오 버튼) 커스텀 스타일 (티스토리 전용 오렌지 테마)
   ========================================= */
.category-radio:checked + label {
    background-color: var(--primary-orange) !important; 
    color: white !important;
    border-color: var(--primary-orange) !important;
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.3);
    font-weight: 900 !important;
}

.category-group-title {
    position: relative;
}
.category-group-title::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 30px;
    height: 3px;
    background-color: var(--primary-orange); 
    border-radius: 2px;
}

/* ==========================================================================
   7. AI T-Blog Result Content (티스토리 감성 초밀착 제어)
   ========================================================================== */
#aiBlogResult {
    word-break: keep-all;    
    line-height: 1.35;        
    letter-spacing: -0.03em; 
    color: #44403c; /* 웜그레이 톤으로 티스토리 느낌 강조 */
}

#aiBlogResult h1 {
    margin-top: 0 !important;
    margin-bottom: 6px !important; 
    line-height: 1.15 !important;   
    font-size: 1.8rem !important;
    font-weight: 900 !important;
    letter-spacing: -0.05em !important;
    color: #1c1917 !important;
}

#aiBlogResult div.relative p {
    margin-bottom: 8px !important;
    line-height: 1.4 !important;
    font-size: 1.05rem !important;
}

#aiBlogResult h3 {
    display: flex !important;
    align-items: center !important;
    margin-top: 16px !important;    
    margin-bottom: 4px !important;  
    line-height: 1.2 !important;    
    font-size: 1.3rem !important;  
    font-weight: 900 !important;
    color: #292524 !important;
}

#aiBlogResult p {
    margin-top: 0 !important;
    margin-bottom: 10px !important;  
    line-height: 1.55 !important;   
    font-size: 1.05rem !important;  
    color: #57534e !important;      
    text-align: justify;            
}

#aiBlogResult h3 i {
    font-size: 0.9rem !important;
    margin-right: 8px !important;
    color: var(--primary-orange) !important; 
}

#aiBlogResult p:empty, 
#aiBlogResult br {
    display: none !important;      
}

#aiBlogResult .mt-4, 
#aiBlogResult .mt-10 {
    margin-top: 14px !important;   
    padding-top: 14px !important;
}

/* ==========================================================================
   8. 갤러리 아코디언 애니메이션 
   ========================================================================== */
.hidden-accordion {
    height: 0 !important;
    opacity: 0;
    margin-top: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border: none !important;
    pointer-events: none;
}