/* キャプチャーボタン */
.capture-btn-wrapper {
    position: fixed;
    display: none; /* 初期は非表示 */
    width: 100%;
    bottom: 5%;
    justify-content: center;
    z-index: 200;
    -webkit-touch-callout: none;
    user-select: none;
    pointer-events: none; /* wrapperはタップを通過させる */
}

.capture-btn-wrapper.active {
    display: flex; /* AR START後に表示 */
}

.capture-btn-wrapper.preview {
    display: none;
}

#capture-btn,
#stop-btn {
    border: none;
    background: linear-gradient(145deg, #4a4a4a 0%, #2a2a2a 50%, #1a1a1a 100%);
    border-radius: 100%;
    width: 150px;
    height: 150px;
    cursor: pointer;
    padding: 0;
    display: block;
    position: relative;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    pointer-events: auto;
    box-shadow: 
        0 10px 25px rgba(0, 0, 0, 0.7),
        0 5px 10px rgba(0, 0, 0, 0.5),
        inset 0 -3px 10px rgba(0, 0, 0, 0.8),
        inset 0 3px 10px rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

/* ボタン押下時のアニメーション */
#capture-btn.btn-pressed,
#stop-btn.btn-pressed {
    animation: btnPressScale 0.3s ease-out;
}

@keyframes btnPressScale {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.25);
    }
    100% {
        transform: scale(1);
    }
}

#stop-btn {
    display: none;
}

#stop-btn.now-recording {
    display: block;
    opacity: 0;
    position: absolute;
    z-index: 2;
    border: 5px solid rgba(255, 255, 255, 0.5);
    pointer-events: none; /* 透明時はタップを通過させる */
}


#capture-btn.now-recording {
    width: 220px;
    height: 220px;
    transition: 1s;
    background: linear-gradient(145deg, #5a5a5a 0%, #3a3a3a 50%, #2a2a2a 100%);
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.8),
        0 8px 15px rgba(0, 0, 0, 0.6),
        inset 0 -4px 12px rgba(0, 0, 0, 0.9),
        inset 0 4px 12px rgba(255, 255, 255, 0.25);
}

#capture-btn.now-capture {
    transition: 1s;
    background: linear-gradient(145deg, #5a5a5a 0%, #3a3a3a 50%, #2a2a2a 100%);
    box-shadow: 
        0 12px 30px rgba(0, 0, 0, 0.75),
        0 6px 12px rgba(0, 0, 0, 0.55),
        inset 0 -3px 10px rgba(0, 0, 0, 0.85),
        inset 0 3px 10px rgba(255, 255, 255, 0.22);
}


.capture-btn-inner-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.capture-btn-inner {
    bottom: 8%;
    left: 50%;
    display: block;
    width: 80%;
    height: 80%;
    border-radius: 100%;
    transition: 0.3s;
    background: linear-gradient(145deg, #ffffff 0%, #e8e8e8 50%, #d0d0d0 100%);
    box-shadow: 
        0 6px 18px rgba(0, 0, 0, 0.5),
        0 3px 8px rgba(0, 0, 0, 0.4),
        inset 0 -3px 8px rgba(0, 0, 0, 0.25),
        inset 0 3px 8px rgba(255, 255, 255, 0.9);
}

.capture-btn-inner.preview {
    width: 50%;
    height: 50%;
}

.capture-btn-inner.now-capture {
    width: 70%;
    height: 70%;
}


.capture-btn-inner.rec-start {
    width: 70%;
    height: 70%;
    background: linear-gradient(145deg, #ff5555 0%, #ff0000 50%, #cc0000 100%);
    box-shadow: 
        0 6px 18px rgba(255, 0, 0, 0.7),
        0 3px 8px rgba(255, 0, 0, 0.5),
        inset 0 -3px 8px rgba(0, 0, 0, 0.6),
        inset 0 3px 8px rgba(255, 150, 150, 0.7);
}

.capture-btn-inner.now-recording {
    width: 30%;
    height: 30%;
    border-radius: 10px;
    background: #ff0000; /* シンプルな赤 */
    box-shadow: none; /* 影を削除してくっきり表示 */
}

/* プレビュー時ボタン */
.pic-preview-btn-wrapper,
.movie-preview-btn-wrapper {
    display: none;
}

.pic-preview-btn-wrapper.preview,
.movie-preview-btn-wrapper.preview {
    display: flex;
    position: fixed;
    bottom: 5%;
    width: 100%;
    justify-content: center; /* 中央揃え */
    z-index: 4;
    pointer-events: none; /* wrapperはタップを通過させる */
}

/* バツボタン共通スタイル */
#pic-preview-back-btn,
#movie-preview-back-btn {
    position: fixed;
    transform: none;
    background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0a0a0a 100%);
    width: 100px;
    height: 100px;
    border-radius: 50%; /* 円形 */
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto !important;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.6),
        0 2px 4px rgba(0, 0, 0, 0.4),
        inset 0 -2px 6px rgba(0, 0, 0, 0.8),
        inset 0 2px 6px rgba(255, 255, 255, 0.15);
    z-index: 999 !important; /* プレビューより前面に */
    padding: 0;
}

/* 縦向き - 静止画用バツボタン位置 */
#pic-preview-back-btn {
    right: calc(12vw + 22px) !important; /* 数値を大きくすると左に移動 */
    bottom: calc(14.5vh + 14px) !important; /* 数値を大きくすると上に移動 */
}

/* 縦向き - 動画用バツボタン位置 */
#movie-preview-back-btn {
    right: calc(13vw + 15px) !important; /* 数値を大きくすると左に移動 */
    bottom: calc(13vh + 15px) !important; /* 数値を大きくすると上に移動 */
}

#pic-preview-back-btn:hover,
#movie-preview-back-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(145deg, #3a3a3a 0%, #2a2a2a 50%, #1a1a1a 100%);
    box-shadow: 
        0 12px 30px rgba(0, 0, 0, 0.7),
        0 4px 8px rgba(0, 0, 0, 0.5),
        inset 0 -3px 8px rgba(0, 0, 0, 0.9),
        inset 0 3px 8px rgba(255, 255, 255, 0.2);
}

#pic-preview-back-btn:active,
#movie-preview-back-btn:active {
    transform: translateY(0px);
    background: linear-gradient(145deg, #1a1a1a 0%, #0a0a0a 50%, #000000 100%);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.6),
        0 2px 4px rgba(0, 0, 0, 0.4),
        inset 0 2px 8px rgba(0, 0, 0, 0.95),
        inset 0 -1px 4px rgba(255, 255, 255, 0.1);
}

/* 横向き時のボタン調整 */
@media (orientation: landscape) {
  /* キャプチャボタン */
  .capture-btn-wrapper {
    bottom: 3%;
  }
  
  /* プレビューボタン */
  .pic-preview-btn-wrapper.preview,
  .movie-preview-btn-wrapper.preview {
    bottom: 5%;
  }
  
  #capture-btn,
  #stop-btn {
    width: 100px;
    height: 100px;
  }
  
  #capture-btn.now-recording {
    width: 150px;
    height: 150px;
  }
  
  /* カメラ切り替えボタン */
  .camera-switcher-btn-wrapper {
    bottom: 4%;
    transform: scale(1);
  }
  
  #camera-switcher {
    margin-right: 30px;
  }
  
  .camera-switcher-inner {
    width: 70px;
    height: 70px;
  }
  
  .camera-switcher-inner::before {
    width: 60%;
    height: 60%;
  }
  
  #pic-preview-share-btn,
  #movie-preview-share-btn {
    padding: 6px 15px;
    font-size: 16px;
    letter-spacing: 1px;
  }
}

/* Xマークを作成 */
#pic-preview-back-btn::before,
#movie-preview-back-btn::before {
    content: "";
    position: absolute;
    width: 50px;
    height: 5px;
    background: #FFF;
    transform: rotate(45deg);
    border-radius: 2px;
}

#pic-preview-back-btn::after,
#movie-preview-back-btn::after {
    content: "";
    position: absolute;
    width: 50px;
    height: 5px;
    background: #FFF;
    transform: rotate(-45deg);
    border-radius: 2px;
}

/* 横向き時の調整 */
@media (orientation: landscape) {
  #pic-preview-back-btn,
  #movie-preview-back-btn {
    width: 54px; /* 90%のサイズ */
    height: 54px;
  }
  
  /* 横向き - 静止画用バツボタン位置 */
  #pic-preview-back-btn {
    right: calc(26.5vw + 15px) !important; /* 数値を大きくすると左に移動 */
    bottom: calc(24vh + 15px) !important; /* 数値を大きくすると上に移動 */
  }
  
  /* 横向き - 動画用バツボタン位置 */
  #movie-preview-back-btn {
    right: calc(27vw + 15px) !important; /* 数値を大きくすると左に移動 */
    bottom: calc(22.5vh + 15px) !important; /* 数値を大きくすると上に移動 */
  }
  
  #pic-preview-back-btn::before,
  #movie-preview-back-btn::before,
  #pic-preview-back-btn::after,
  #movie-preview-back-btn::after {
    width: 27px; /* Xマークも90%に */
    height: 3px;
  }
}

#pic-preview-share-btn,
#movie-preview-share-btn {
    background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0a0a0a 100%);
    border: none;
    color: #FFF;
    border-radius: 100px;
    padding: 25px 65px;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.6),
        0 2px 4px rgba(0, 0, 0, 0.4),
        inset 0 -2px 6px rgba(0, 0, 0, 0.8),
        inset 0 2px 6px rgba(255, 255, 255, 0.15);
    pointer-events: auto; /* ボタン自体はタップ可能にする */
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

#pic-preview-share-btn::before,
#movie-preview-share-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

#pic-preview-share-btn:hover,
#movie-preview-share-btn:hover {
    transform: translateY(-4px);
    background: linear-gradient(145deg, #3a3a3a 0%, #2a2a2a 50%, #1a1a1a 100%);
    box-shadow: 
        0 12px 30px rgba(0, 0, 0, 0.7),
        0 4px 8px rgba(0, 0, 0, 0.5),
        inset 0 -3px 8px rgba(0, 0, 0, 0.9),
        inset 0 3px 8px rgba(255, 255, 255, 0.2);
}

#pic-preview-share-btn:hover::before,
#movie-preview-share-btn:hover::before {
    left: 100%;
}

#pic-preview-share-btn:active,
#movie-preview-share-btn:active {
    transform: translateY(-1px);
    background: linear-gradient(145deg, #1a1a1a 0%, #0a0a0a 50%, #000000 100%);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.6),
        0 2px 4px rgba(0, 0, 0, 0.4),
        inset 0 2px 8px rgba(0, 0, 0, 0.95),
        inset 0 -1px 4px rgba(255, 255, 255, 0.1);
}


/* カメラ切り替えボタン */
.camera-switcher-btn-wrapper {
    position: fixed;
    display: none; /* 初期は非表示 */
    bottom: 6.5%;
    right: 0;
    justify-content: end;
    z-index: 201;
    transform: scale(1.25);
    transform-origin: center;
    pointer-events: none; /* wrapperはタップを通過させる */
}

.camera-switcher-btn-wrapper.active {
    display: flex; /* AR START後に表示 */
    pointer-events: auto; /* ボタンをクリック可能にする */
}

.camera-switcher-btn-wrapper.preview {
    display: none;
}

#camera-switcher {
    border: none;
    background: transparent;
    margin-right: 50px;
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

#camera-switcher:active .camera-switcher-inner {
    transform: scale(0.95);
    box-shadow: 
        0 6px 15px rgba(0, 0, 0, 0.7),
        0 2px 6px rgba(0, 0, 0, 0.5),
        inset 0 -2px 8px rgba(0, 0, 0, 0.9),
        inset 0 2px 8px rgba(255, 255, 255, 0.15);
}

.camera-switcher-inner {
    display: inline-block;
    vertical-align: middle;
    color: #FFF;
    line-height: 1;
    position: relative;
    width: 100px;
    height: 100px;
    background: linear-gradient(145deg, #3a3a3a 0%, #2a2a2a 50%, #1a1a1a 100%);
    border-radius: 50%;
    box-shadow: 
        0 10px 25px rgba(0, 0, 0, 0.7),
        0 5px 10px rgba(0, 0, 0, 0.5),
        inset 0 -3px 10px rgba(0, 0, 0, 0.8),
        inset 0 3px 10px rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

/* カメラ切り替えアイコン画像 */
.camera-switcher-inner::before {
    content: "";
    position: absolute;
    width: 60%;
    height: 60%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: url("./assets/camera-switch.png") center/contain no-repeat;
}

/* スペアボタン */
#spare-btn {
    visibility: hidden;
}