/* 360パノラマ撮影 専用スタイル */

/* =========================
   パノラマ専用ミニヘッダー
   ========================= */
.panorama-body {
    background: var(--bg-gradient);
    min-height: 100vh;
    min-height: 100dvh;
    /* iOS対応 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panorama-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--card-border);
    z-index: 100;
}

.panorama-header .back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.panorama-header .back-link:hover {
    color: var(--text-primary);
}

.panorama-header .header-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* 撮影中はヘッダー非表示 */
.panorama-body.capturing .panorama-header {
    display: none;
}

.panorama-body.capturing .panorama-main {
    height: 100vh;
    height: 100dvh;
}

/* メインレイアウト */
.panorama-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* フェーズ共通 */
.phase {
    display: none;
    flex: 1;
    width: 100%;
    animation: fadeIn 0.4s ease-out;
}

.phase.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* =========================
   ターゲットサークル（照準）
   ========================= */
.target-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.target-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(52, 211, 153, 0.8);
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.3);
}

.target-crosshair-h,
.target-crosshair-v {
    position: absolute;
    background: rgba(52, 211, 153, 0.6);
}

.target-crosshair-h {
    width: 100%;
    height: 2px;
}

.target-crosshair-v {
    width: 2px;
    height: 100%;
}

.target-indicator {
    font-size: 0.8rem;
    color: rgba(52, 211, 153, 0.8);
    position: absolute;
    bottom: -25px;
    white-space: nowrap;
}

/* ターゲットが合った時のアニメーション */
.target-circle.aligned .target-ring {
    border-color: #34d399;
    box-shadow: 0 0 30px rgba(52, 211, 153, 0.6);
    animation: targetPulse 0.5s ease-out;
}

@keyframes targetPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* キャプチャ時のフラッシュ */
.target-circle.captured .target-ring {
    border-color: #fff;
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.8);
}

/* 次の撮影位置ガイド */
.next-position-guide {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.next-position-guide.visible {
    opacity: 1;
}

.guide-arrow {
    font-size: 1.5rem;
    color: var(--accent-color);
    animation: arrowBounce 1s infinite;
}

@keyframes arrowBounce {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(5px);
    }
}

.guide-text {
    font-size: 0.85rem;
    color: white;
}

/* =========================
   フェーズ1: 開始画面
   ========================= */
.start-container {
    text-align: center;
    padding: 2rem;
    max-width: 500px;
}

.feature-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.start-container h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #818cf8, #34d399);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.start-container .description {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.feature-list {
    list-style: none;
    text-align: left;
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 1rem;
    border: 1px solid var(--card-border);
}

.feature-list li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

.feature-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--accent-color);
    font-weight: bold;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin: 1rem 0;
}

.btn-icon {
    font-size: 1.2rem;
}

.note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* =========================
   フェーズ2: 撮影画面
   ========================= */
.camera-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 70vh;
    background: #000;
    overflow: hidden;
}

#camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.capture-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem;
}

/* =========================
   ARガイド・UI要素 (v2)
   ========================= */

/* ARコンテナ: ここに3D的にマーカーを配置する想定だが、
   まずは簡易的に画面全体を使う */
.ar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    perspective: 1000px;
    /* 3D効果用 */
    pointer-events: none;
}

/* 中央カーソル（自分） */
.center-cursor {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: white;
    border: 3px solid rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

/* 回転する矢印ガイド */
.cursor-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    transform-origin: center center;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid white;
    /* JSで回転制御 */
    will-change: transform;
    opacity: 0;
    /* 初期非表示 */
    transition: opacity 0.3s;
}

/* ターゲットマーカー */
.target-marker {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    /* 円形 */
    background: rgba(255, 255, 255, 0.3);
    border: 3px solid white;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s, width 0.2s, height 0.2s;
    z-index: 5;
}

/* アクティブ（近い）ターゲット */
.target-marker.active {
    background: rgba(52, 211, 153, 0.4);
    border-color: #34d399;
    width: 80px;
    height: 80px;
}

/* ロックオン（静止検知中） */
.target-marker.locking {
    background: rgba(52, 211, 153, 0.8);
    animation: lockPulse 1s infinite;
}

/* 撮影済み */
.target-marker.captured {
    background: rgba(16, 185, 129, 0.9);
    border-color: transparent;
    width: 40px;
    height: 40px;
    opacity: 0.6;
}

@keyframes lockPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 矢印ガイド (画面外のターゲットを指す) */
.guide-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
    opacity: 0.8;
    z-index: 8;
}

/* 進捗エリア (画面下部) */
.progress-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.progress-grid {
    display: flex;
    flex-direction: column;
    /* 行を縦に積む */
    align-items: center;
    gap: 4px;
    max-width: 300px;
    margin-bottom: 0.5rem;
}

.progress-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.progress-dot {
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transition: all 0.3s;
}

.progress-dot.active {
    background: #fbbf24;
    transform: scale(1.2);
}

.progress-dot.captured {
    background: #34d399;
}

.progress-text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
}

/* 撮影フィードバック */
.capture-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    z-index: 20;
}

.capture-feedback.flash {
    animation: flashAnim 0.5s ease-out;
}

@keyframes flashAnim {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2);
    }
}

.feedback-icon {
    font-size: 5rem;
}

/* 情報表示 */
.info-overlay {
    position: absolute;
    top: 60px;
    left: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    font-family: monospace;
    pointer-events: none;
}

/* 撮影ステータス (中央下部) */
.capture-status {
    position: absolute;
    bottom: 120px;
    /* コントロールの上 */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    color: white;
    font-size: 0.9rem;
    pointer-events: none;
    transition: opacity 0.3s;
}

.capture-status.recording {
    background: rgba(239, 68, 68, 0.8);
    animation: statusPulse 1s infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* 撮影コントロール */
.capture-controls {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    pointer-events: auto;
}

.btn-capture {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: 4px solid white;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

.btn-capture:hover {
    transform: scale(1.05);
}

.btn-capture.recording {
    animation: recordPulse 1s infinite;
}

@keyframes recordPulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 4px 40px rgba(239, 68, 68, 0.8);
    }
}

/* =========================
   フェーズ3: 処理中画面
   ========================= */
.processing-container {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 2rem;
}

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

.processing-container h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

#processing-status {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.progress-bar {
    width: 100%;
    max-width: 300px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #818cf8, #34d399);
    width: 0%;
    transition: width 0.3s ease-out;
}

/* =========================
   フェーズ4: プレビュー画面
   ========================= */
.preview-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#viewer-container {
    flex: 1;
    min-height: 60vh;
    background: #000;
    position: relative;
}

#viewer-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.preview-controls {
    padding: 1.5rem;
    text-align: center;
    background: var(--card-bg);
    border-top: 1px solid var(--card-border);
}

.preview-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.preview-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.preview-buttons .btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
}

/* =========================
   エラー表示
   ========================= */
.error-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.error-content {
    text-align: center;
    padding: 2rem;
    background: var(--card-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 1rem;
    max-width: 400px;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-content h3 {
    color: #fca5a5;
    margin-bottom: 0.5rem;
}

.error-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* =========================
   ボタン共通
   ========================= */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* =========================
   レスポンシブ
   ========================= */
@media (max-width: 768px) {
    .start-container {
        padding: 1rem;
    }

    .start-container h2 {
        font-size: 1.5rem;
    }

    .feature-icon {
        font-size: 3rem;
    }

    .angle-indicator {
        min-width: 150px;
        padding: 0.5rem 1rem;
    }

    .angle-value {
        font-size: 1.5rem;
    }

    .btn-capture {
        width: 70px;
        height: 70px;
    }
}

/* ランドスケープモード対応 */
@media (orientation: landscape) and (max-height: 500px) {
    .camera-container {
        min-height: 100vh;
    }

    .capture-overlay {
        padding: 0.5rem;
    }

    .angle-indicator {
        top: 0.5rem;
    }

    .capture-status {
        bottom: 70px;
    }

    .capture-controls {
        bottom: 0.5rem;
    }

    .btn-capture {
        width: 60px;
        height: 60px;
        font-size: 0.75rem;
    }
}