/* ============================================================
   webgl-common.css  — WebGL 페이지 공통 스타일
   ============================================================ */

:root {
    --webgl-primary:          #9333ea;
    --webgl-secondary:        #ec4899;
    --webgl-accent:           #a855f7;
    --webgl-light:            #f472b6;

    --webgl-bg-dark:          rgba(30, 30, 40, 0.95);
    --webgl-bg-semi:          rgba(30, 30, 40, 0.80);
    --webgl-bg-light:         rgba(30, 30, 40, 0.70);

    --webgl-text-primary:     rgba(255, 255, 255, 0.90);
    --webgl-text-secondary:   rgba(255, 255, 255, 0.85);
    --webgl-text-muted:       rgba(255, 255, 255, 0.70);

    --webgl-border-primary:   rgba(147, 51, 234, 0.60);
    --webgl-border-secondary: rgba(255, 255, 255, 0.30);
    --webgl-border-light:     rgba(255, 255, 255, 0.20);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', 'Noto Sans KR', sans-serif;
    background: #0d0d0d;
    color: #eee;
    min-height: 100vh;
    overflow: hidden;
}

canvas {
    display: block;
}

/* ---------- Static Loading Spinner (#static-loading) ---------- */
#static-loading {
    position: fixed;
    inset: 0;
    background: var(--webgl-static-bg, #0d0d0d);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    color: white;
    font-family: 'Segoe UI', sans-serif;
    transition: opacity 0.4s;
}

#static-loading .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.15);
    border-top-color: var(--webgl-spinner-color, var(--webgl-accent, #a855f7));
    border-radius: 50%;
    animation: webgl-spin 0.9s linear infinite;
    margin-bottom: 16px;
}

@keyframes webgl-spin { to { transform: rotate(360deg); } }

/* ---------- Loading Progress Screen (#loading) ---------- */
#loading {
    position: fixed;
    inset: 0;
    background: var(--webgl-loading-bg, linear-gradient(135deg, #0a0a1a 0%, #111128 50%, #0d0d1f 100%));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 0.8s ease;
}

#loading.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ---------- Legacy Loading Screen (#loading-screen) ---------- */
#loading-screen {
    position: fixed;
    inset: 0;
    background: #0d0d0d;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9997;
    gap: 16px;
}

.loading-bar-track {
    width: 280px;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 3px;
    transition: width 0.3s;
}

.loading-text {
    font-size: 0.85em;
    color: rgba(255,255,255,0.5);
}

/* ---------- 공통 푸터 ---------- */
.common-footer {
    font-family: 'Noto Sans KR', sans-serif;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(51, 51, 51, 0.9);
    color: white;
    padding: 3px;
    text-align: center;
    font-size: 14px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    z-index: 9999;
    pointer-events: auto;
}

.common-footer a {
    color: #FFD700;
    text-decoration: none;
    margin-left: 10px;
    font-weight: bold;
    transition: color 0.3s;
}

.common-footer a:hover {
    color: #FFA500;
    text-decoration: underline;
}

/* ---------- 환영 팝업 ---------- */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.welcome-popup {
    background: #1a1a2e;
    border: 2px solid #667eea;
    border-radius: 20px;
    padding: 40px;
    max-width: 700px;
    width: 90%;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    animation: popupSlideIn 0.4s ease-out;
    text-align: center;
}

@keyframes popupSlideIn {
    from { opacity: 0; transform: scale(0.8) translateY(-20px); }
    to   { opacity: 1; transform: scale(1)   translateY(0);    }
}

.welcome-popup h2 {
    margin: 0 0 25px;
    font-size: 32px;
    font-weight: bold;
    color: #a78bfa;
}

.welcome-content {
    margin-bottom: 25px;
    padding: 20px 0;
}

.welcome-content p {
    margin: 12px 0;
    color: #eee;
    font-size: 16px;
    line-height: 1.6;
}

.welcome-credits p {
    margin: 8px 0;
    color: #aaa;
    font-size: 15px;
}

.welcome-credits strong {
    color: #a78bfa;
    font-weight: 600;
}

.welcome-close {
    padding: 14px 32px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.welcome-close:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.welcome-close:active {
    transform: translateY(-1px);
}

/* ---------- 모바일 가로화면 대응 ---------- */
@media (max-height: 500px) and (orientation: landscape) {
    .welcome-popup {
        max-height: 85vh;
        padding: 20px 28px;
        border-radius: 14px;
        display: flex;
        flex-direction: column;
    }

    .welcome-popup h2 {
        font-size: 22px;
        margin: 0 0 10px;
    }

    .welcome-content {
        margin-bottom: 12px;
        padding: 8px 0;
        overflow-y: auto;
        flex: 1;
        min-height: 0; /* flex 자식 overflow 허용 */
    }

    .welcome-content p {
        font-size: 13px;
        margin: 6px 0;
        line-height: 1.5;
    }

    .welcome-content h3 {
        font-size: 14px;
        margin-top: 10px !important;
    }

    .welcome-credits p {
        font-size: 12px;
        margin: 4px 0;
    }

    .welcome-close {
        padding: 10px 24px;
        font-size: 15px;
        border-radius: 10px;
        flex-shrink: 0;
    }
}

/* ---------- 숏컷 버튼 & 패널 ---------- */
.shortcut-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 24px;
    background: rgba(147, 51, 234, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    border: 2px solid var(--webgl-border-secondary);
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.shortcut-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(147, 51, 234, 0.4);
    background: rgba(147, 51, 234, 0.9);
}

.shortcut-toggle.active {
    background: rgba(236, 72, 153, 0.8);
    border-color: rgba(255, 255, 255, 0.5);
}

.shortcut-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 300px;
    max-height: 500px;
    background: var(--webgl-bg-semi);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 2px solid var(--webgl-border-light);
    border-radius: 12px;
    padding: 20px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0);    }
}

.shortcut-panel h3 {
    margin: 0 0 15px;
    color: white;
    font-size: 20px;
    font-weight: bold;
}

.artwork-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.artwork-button {
    padding: 12px;
    background: rgba(147, 51, 234, 0.6);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid var(--webgl-border-light);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.artwork-button:hover {
    transform: translateX(5px);
    background: rgba(147, 51, 234, 0.9);
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
}

/* ---------- 주목 모드 패널 ---------- */
.focus-panel {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--webgl-bg-semi);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 3px solid var(--webgl-border-secondary);
    border-radius: 16px;
    padding: 30px;
    min-width: min(400px, 90vw);
    max-width: 700px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.5s ease;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(50px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0);    }
}

.artwork-info h2 {
    margin: 0 0 10px;
    color: var(--webgl-secondary);
    font-size: 28px;
}

.artwork-info p {
    margin: 0 0 20px;
    color: var(--webgl-text-primary);
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-line;
}

.back-button {
    padding: 12px 24px;
    background: rgba(147, 51, 234, 0.8);
    backdrop-filter: blur(10px);
    border: 2px solid var(--webgl-border-secondary);
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.back-button:hover {
    transform: translateY(-2px);
    background: rgba(147, 51, 234, 1);
    box-shadow: 0 6px 16px rgba(147, 51, 234, 0.4);
}

@media (max-width: 768px) {
    .welcome-popup {
        padding: 30px 20px;
        max-width: 90%;
    }
    .welcome-popup h2 {
        font-size: 24px;
        margin-bottom: 20px;
    }
    .welcome-content p {
        font-size: 14px;
    }
    .welcome-credits p {
        font-size: 13px;
    }
    .welcome-close {
        padding: 12px 24px;
        font-size: 16px;
    }
    .focus-panel {
        min-width: auto;
        width: 90%;
        padding: 20px;
        bottom: 60px;
    }
    .shortcut-panel {
        width: 90%;
        right: 5%;
    }
    .shortcut-toggle {
        padding: 10px 16px;
        font-size: 14px;
    }
    .artwork-info h2 {
        font-size: 22px;
    }
    .artwork-info p {
        font-size: 14px;
    }
}

/* ---------- 모바일 세로 모드 — 팝업 세로 스크롤 ---------- */
@media (max-width: 768px) and (orientation: portrait) {
    .welcome-popup {
        max-height: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .focus-panel {
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* ---------- 인터랙션 힌트 (하단 조작 안내) ---------- */
.interaction-hint {
    position: fixed;
    bottom: 36px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 100;
    pointer-events: none;
}

.interaction-hint p {
    display: inline-block;
    padding: 6px 20px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    letter-spacing: 0.5px;
    margin: 0;
}
