/* =============================================
   대동여지도 탐구 - Camera Page Styles
   ============================================= */

/* Camera Page Layout */
.camera-page {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background-color: #000;
}

/* Video Container */
.camera-video-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Loading indicator */
.camera-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 55;
}

.camera-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--color-white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.camera-loading-text {
    color: var(--color-white);
    font-size: 0.875rem;
    margin-top: var(--spacing-md);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Captured Photo Preview */
.camera-preview {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: #F5E6D3;
}

.camera-preview.active {
    display: flex;
}

.camera-preview-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* GPU Wakeup Indicator (촬영 버튼 위 배지) */
.wakeup-indicator {
    position: absolute;
    left: 50%;
    bottom: calc(120px + var(--safe-area-bottom));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: rgba(0, 0, 0, 0.65);
    color: #fff;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 60;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.wakeup-indicator.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
    visibility: hidden;
}

.wakeup-indicator.active {
    background-color: rgba(199, 62, 58, 0.95); /* dancheong-red */
    box-shadow: 0 4px 16px rgba(199, 62, 58, 0.4);
    animation: wakeupPulse 1.5s ease-in-out infinite;
}

.wakeup-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #C9A227; /* gold-primary */
    animation: wakeupBlink 1s ease-in-out infinite;
}

@keyframes wakeupBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes wakeupPulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.04); }
}

/* Camera Controls */
.camera-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xl);
    padding: var(--spacing-xl);
    padding-bottom: calc(var(--spacing-xxl) + var(--safe-area-bottom));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
}

/* Capture Button */
.camera-capture-btn {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-full);
    background-color: var(--color-white);
    border: 4px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-capture-btn:hover,
.camera-capture-btn:focus {
    transform: scale(1.05);
}

.camera-capture-btn:active {
    transform: scale(0.95);
    background-color: #f0f0f0;
}

.camera-capture-btn svg {
    width: 32px;
    height: 32px;
    stroke: var(--color-text);
}

/* 카메라 사이드 버튼 - 프로스트 글라스 */
.camera-side-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all var(--transition-fast);
}

.camera-side-btn svg {
    width: 22px;
    height: 22px;
    color: #fff;
    stroke: #fff;
}

/* Top Controls */
.camera-top-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    padding-top: calc(var(--spacing-md) + var(--safe-area-top));
    z-index: 50;
}

.camera-back-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-back-btn svg {
    width: 24px;
    height: 24px;
    stroke: var(--color-white);
}

/* Permission Screen */
.camera-permission {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    background-color: var(--color-background);
    padding: var(--spacing-xl);
    text-align: center;
    z-index: 90;
}

.camera-permission.hidden {
    display: none;
}

.camera-permission-icon {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.camera-permission-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
}

.camera-permission-subtitle {
    font-size: 1.05rem;
    color: var(--color-text);
    max-width: 360px;
    font-weight: 500;
    line-height: 1.5;
}

.camera-permission-text {
    font-size: 1rem;
    color: var(--color-text-light);
    max-width: 280px;
}

.camera-permission-btn {
    padding: var(--spacing-md) var(--spacing-xl);
    background-color: var(--color-primary);
    color: var(--color-white);
    font-weight: 600;
    border-radius: var(--radius-md);
}

/* Edit Page Styles */
.camera-edit-page {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background-color: var(--color-background);
    overflow: hidden;
}

.camera-edit-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-top: calc(56px + var(--safe-area-top));
    padding-bottom: 0;
    min-height: 0;
}

.camera-edit-preview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    background-color: #f0f0f0;
    position: relative;
    min-height: 0;
}

.camera-edit-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    touch-action: none;
}

/* Delete Zone */
.sticker-delete-zone {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    background-color: rgba(220, 38, 38, 0.85);
    color: white;
    font-size: 0.8rem;
    font-weight: 800;
    font-family: var(--font-primary);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    opacity: 0;
    transform: translateY(-100%);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    z-index: 10;
}

.sticker-delete-zone.active {
    opacity: 1;
    transform: translateY(0);
}

.sticker-delete-zone svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

/* Overlay Toolbox Bottom Sheet */
.edit-toolbox-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background-color: var(--hanji-cream);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(0);
    transition: transform 0.3s ease;
    touch-action: none;
}

.edit-toolbox-panel.collapsed {
    transform: translateY(calc(100% - 28px));
}

/* Toolbox Handle */
.edit-toolbox-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 8px;
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.edit-toolbox-handle:active {
    cursor: grabbing;
}

.handle-bar {
    width: 40px;
    height: 4px;
    background-color: var(--color-text-light);
    border-radius: 2px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.edit-toolbox-panel.collapsed .handle-bar {
    opacity: 0.8;
}

/* Toolbox Body */
.edit-toolbox-body {
    overflow: hidden;
}

/* Background Selector */
.bg-selector {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--hanji-cream);
    max-height: 160px;
    overflow-y: auto;
}

.bg-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    background: none;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.bg-option.active {
    border-color: var(--gold-primary);
}

.bg-option img {
    width: 100%;
    aspect-ratio: 1;
    height: auto;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.bg-swatch {
    width: 100%;
    aspect-ratio: 1;
    height: auto;
    border-radius: var(--radius-sm);
    border: 1px solid #ccc;
}

.bg-label {
    font-size: 0.8rem;
    font-family: var(--font-primary);
    color: var(--color-text);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: keep-all;
    overflow-wrap: break-word;
}

/* Stickers Panel */
.stickers-panel {
    background-color: var(--hanji-cream);
    padding: var(--spacing-sm) var(--spacing-md);
    border-top: 1px solid rgba(201, 162, 39, 0.3);
}

/* Sticker Tabs */
.stickers-tabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--color-secondary);
}

.stickers-tab {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-light);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.stickers-tab.active {
    color: var(--gold-primary);
    border-bottom-color: var(--gold-primary);
}

/* Stickers Grid */
.stickers-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--spacing-sm);
    max-height: 140px;
    overflow-y: auto;
    padding-bottom: var(--spacing-xs);
    -webkit-overflow-scrolling: touch;
}

.sticker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px;
    background-color: var(--color-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.sticker-item:active {
    transform: scale(0.92);
}

.sticker-item img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.sticker-label {
    font-size: 0.7rem;
    font-family: var(--font-primary);
    color: var(--color-text);
    text-align: center;
    line-height: 1.1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: keep-all;
    overflow-wrap: break-word;
    max-width: 100%;
    padding: 0 2px;
}

.sticker-preview-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--color-text);
}

/* Action Buttons (inside toolbox drawer) */
.camera-edit-actions {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    padding-bottom: calc(var(--spacing-sm) + var(--safe-area-bottom));
    border-top: 1px solid rgba(201, 162, 39, 0.3);
}

/* 카메라 편집 버튼 - 컴팩트 스타일 */
.camera-edit-btn {
    flex: 1;
    padding: 2px 20px;
    font-size: 1.25rem;
    font-weight: normal;
    font-family: var(--font-primary);
    border-radius: var(--radius-md);
    text-align: center;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.camera-edit-btn.secondary {
    background: var(--hanji-aged);
    border: 1px solid #ccc;
    color: #333;
}

.camera-edit-btn.primary {
    background: #666;
    border: 1px solid #666;
    color: #fff;
}

/* After Capture Controls - Text Button Bar */
.camera-after-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    padding-bottom: calc(var(--spacing-md) + var(--safe-area-bottom));
    background: rgba(245, 230, 211, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.camera-action-btn {
    flex: 1;
    padding: 2px 20px;
    font-family: var(--font-primary);
    font-size: 1.25rem;
    font-weight: normal;
    border-radius: var(--radius-md);
    text-align: center;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.camera-action-btn.secondary {
    background: var(--hanji-aged);
    border: 1px solid #ccc;
    color: #333;
}

.camera-action-btn.primary {
    background: #666;
    border: 1px solid #666;
    color: #fff;
}

/* Flash Animation */
.camera-flash {
    position: absolute;
    inset: 0;
    background-color: var(--color-white);
    opacity: 0;
    pointer-events: none;
    z-index: 60;
}

.camera-flash.flash {
    animation: cameraFlash 0.3s ease-out;
}

@keyframes cameraFlash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Responsive */
@media (min-width: 768px) {
    .camera-capture-btn {
        width: 80px;
        height: 80px;
    }

    .camera-capture-btn svg {
        width: 40px;
        height: 40px;
    }
}

/* Landscape */
@media (max-height: 500px) and (orientation: landscape) {
    .camera-controls {
        flex-direction: row;
        justify-content: center;
        padding: var(--spacing-md);
    }

    .camera-capture-btn {
        width: 56px;
        height: 56px;
    }
}

/* =============================================
   Ink Splash Effect
   ============================================= */
#ink-splash {
    position: absolute;
    inset: 0;
    display: none;
    pointer-events: none;
    z-index: 61;
}

.ink-drop {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    background: radial-gradient(circle, #1a1a1a 0%, #333 60%, transparent 100%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    will-change: transform, opacity;
}

/* =============================================
   Brush Stroke Loading
   ============================================= */
.brush-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 55;
}

.brush-strokes {
    display: flex;
    gap: 12px;
    margin-bottom: var(--spacing-lg);
}

.brush-stroke {
    width: 6px;
    height: 40px;
    background: linear-gradient(to bottom, #1a1a1a, #555);
    border-radius: 3px;
    opacity: 0;
    animation: brushPaint 1.2s ease-in-out infinite;
}

@keyframes brushPaint {
    0% { opacity: 0; transform: scaleY(0.3) translateY(10px); }
    30% { opacity: 1; transform: scaleY(1) translateY(0); }
    60% { opacity: 1; transform: scaleY(1) translateY(0); }
    100% { opacity: 0; transform: scaleY(0.3) translateY(-10px); }
}

.brush-loading-text {
    color: var(--color-white);
    font-size: 0.9rem;
    font-family: var(--font-primary);
}

/* =============================================
   Save Celebration
   ============================================= */
.save-celebration-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 200;
}

.save-celebration-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl) var(--spacing-xxl);
    background: linear-gradient(135deg, var(--hanji-cream) 0%, var(--hanji-aged) 100%);
    border: 3px solid var(--gold-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 0 30px rgba(201, 162, 39, 0.4);
}

.save-celebration-check {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--gold-primary);
    border-radius: 50%;
    color: white;
}

.save-celebration-text {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-primary);
    color: var(--color-text);
}

.save-celebration-particle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background-color: var(--gold-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    will-change: transform, opacity;
}

/* =============================================
   Accessibility: Reduced Motion
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    .ink-drop,
    .brush-stroke,
    .save-celebration-card,
    .save-celebration-particle {
        animation: none !important;
        transition: none !important;
    }

    .brush-stroke {
        opacity: 1;
        transform: none;
    }
}

/* ==================== Edit Panel - Always Visible ==================== */
.edit-bottom-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(245, 230, 211, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 0 calc(env(safe-area-inset-bottom, 0px) + 8px);
    z-index: 100;
    border-top: 1px solid rgba(139, 69, 19, 0.2);
}

.edit-panel-tabs {
    display: flex;
    gap: 8px;
    padding: 0 16px 8px;
}

.edit-tab {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--gold-primary, #C9A227);
    border-radius: 8px;
    background: transparent;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--color-primary, #8B4513);
    cursor: pointer;
}
.edit-tab.active {
    background: var(--gold-primary, #C9A227);
    color: #fff;
}

.edit-option-scroll {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.edit-option-scroll::-webkit-scrollbar {
    display: none;
}
