/* ===================================================
   공통 리셋 & 기본값
=================================================== */
:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-bg: #f6f7fb;
    --color-surface: #ffffff;
    --color-text: #111827;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple SD Gothic Neo', sans-serif;
    color-scheme: light;
}

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

/* 전역 hidden 유틸리티 */
.hidden { display: none !important; }

body {
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

/* ===================================================
   화면 1 : 소개 페이지
=================================================== */
.landing-wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 48px 24px 80px;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* 로고 */
.landing-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-badge { font-size: 2rem; }
.logo-text {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--color-primary);
}

/* 히어로 */
.hero { display: flex; flex-direction: column; gap: 16px; }
.hero-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.5px;
}
.hero-desc {
    font-size: 1rem;
    line-height: 1.75;
    color: var(--color-muted);
}

/* 기능 카드 */
.feature-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.feature-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.feature-icon { font-size: 1.6rem; }
.feature-card h3 { font-size: 1rem; font-weight: 700; }
.feature-card p { font-size: 0.875rem; color: var(--color-muted); line-height: 1.6; }

/* CTA */
.cta-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}
.btn-primary {
    padding: 14px 28px;
    background: var(--color-primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.cta-hint { font-size: 0.8rem; color: var(--color-muted); }

/* ===================================================
   화면 2 : 캘리브레이션 페이지
=================================================== */
.calibration-wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 48px 24px 80px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 헤더 */
.calibration-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.back-link {
    font-size: 0.875rem;
    color: var(--color-muted);
    text-decoration: none;
}
.back-link:hover { color: var(--color-text); }
.calibration-title { font-size: 1.6rem; font-weight: 800; }
.calibration-desc { font-size: 0.9rem; color: var(--color-muted); line-height: 1.6; margin-top: 4px; }

/* 웹캠 컨테이너 */
.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #0f172a;
    border-radius: var(--radius);
    overflow: hidden;
}
.camera-container video,
.camera-container canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.camera-container canvas { pointer-events: none; }

/* 웹캠 로딩 플레이스홀더 */
.camera-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #94a3b8;
    font-size: 0.9rem;
    pointer-events: none;
}
.camera-placeholder-icon { font-size: 2.5rem; }
.camera-placeholder.hidden { display: none; }

/* 랜드마크 상태 */
.landmark-status {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--color-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 4px 12px;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-border);
    transition: background 0.2s;
}
.status-item.detected .status-dot { background: #22c55e; }
.status-item.detected { color: var(--color-text); }

/* 등록 버튼 영역 */
.calibration-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}
.btn-primary:disabled {
    background: var(--color-border);
    color: var(--color-muted);
    cursor: not-allowed;
}
.btn-redo {
    padding: 14px 20px;
    background: transparent;
    color: var(--color-muted);
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}
.btn-redo:hover { background: var(--color-border); }

/* ===================================================
   모니터링 플로팅 위젯
=================================================== */
.monitor-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 240px;
    background: #0e1a21;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.45);
    z-index: 9999;
}
.monitor-widget.hidden { display: none; }

.widget-lottie,
.widget-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
/* Lottie가 생성하는 SVG를 위젯 크기에 맞춤 */
.widget-lottie svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
}
.widget-lottie.hidden { display: none; }

.widget-warning {
    position: absolute;
    inset: 0;
    background: rgba(239, 68, 68, 0.35);
    pointer-events: none;
    border-radius: 16px;
}
.widget-warning.hidden { display: none; }

.widget-reset {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 12px;
    background: rgba(255,255,255,0.12);
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    z-index: 1;
}
.widget-reset:hover { background: rgba(255,255,255,0.22); }
.popup-body {
    margin: 0;
    width: 100vw;
    height: 100vh;
    background: #0e1a21;
    overflow: hidden;
    position: relative;
}

#monitorCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* Lottie 컨테이너 */
.lottie-container {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lottie-container.hidden { display: none; }

/* 경고 오버레이 (깜빡임) */
.warning-overlay {
    position: fixed;
    inset: 0;
    background: rgba(239, 68, 68, 0.35);
    pointer-events: none;
    z-index: 10;
}
.warning-overlay.hidden { display: none; }

/* 하단 컨트롤 */
.popup-controls {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}
.btn-reset {
    padding: 5px 14px;
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    white-space: nowrap;
    transition: background 0.15s;
}
.btn-reset:hover { background: rgba(255, 255, 255, 0.2); }
