/* ============================================================
   FLASH — Front-camera Live Auto Shutter by palm Hand
   スタイルシート
   ============================================================ */

/* ============================================================
   1. リセット・ベース
   ============================================================ */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
                 "Noto Sans JP", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #ffffff;
    background-color: #000000;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* 縦向き固定（JSでも制御するがCSSでも対応） */
@media screen and (orientation: landscape) {
    body::after {
        content: "端末を縦向きにしてください";
        position: fixed;
        inset: 0;
        z-index: 10000;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #000000;
        color: #ffffff;
        font-size: 1.25rem;
        text-align: center;
        padding: 2rem;
    }
}

/* ============================================================
   2. スクリーンリーダー専用
   ============================================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   3. 画面共通
   ============================================================ */

.screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background-color: #000000;
}

.screen[hidden] {
    display: none;
}

.screen-inner {
    width: 100%;
    max-width: 400px;
    padding: 2rem 1.5rem;
    text-align: center;
}

.screen-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #ffffff;
}

.screen-description {
    font-size: 0.95rem;
    color: #cccccc;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* ============================================================
   4. ボタン共通
   ============================================================ */

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.btn:active {
    opacity: 0.7;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #2563eb;
    color: #ffffff;
}

.btn-primary:active {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: #374151;
    color: #ffffff;
}

.btn-secondary:active {
    background-color: #1f2937;
}

.btn-danger {
    background-color: #dc2626;
    color: #ffffff;
}

.btn-danger:active {
    background-color: #b91c1c;
}

.btn-full {
    display: block;
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
}

/* ============================================================
   5. PIN入力
   ============================================================ */

.pin-input-group {
    margin-bottom: 1rem;
}

.pin-input {
    width: 160px;
    padding: 0.75rem 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.5em;
    color: #ffffff;
    background-color: #1f2937;
    border: 2px solid #374151;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.pin-input:focus {
    border-color: #2563eb;
}

.pin-input::placeholder {
    color: #6b7280;
    letter-spacing: 0.3em;
}

/* ============================================================
   6. エラー・ロックアウトメッセージ
   ============================================================ */

.error-message {
    color: #f87171;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.error-message[hidden] {
    display: none;
}

.lockout-message {
    color: #fbbf24;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.lockout-message[hidden] {
    display: none;
}

/* ============================================================
   7. 設定画面
   ============================================================ */

.settings-panel {
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 3rem;
}

.setting-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 1rem 0;
    border-bottom: 1px solid #1f2937;
}

.setting-item-bordered {
    border: 1px solid #374151;
    border-radius: 8px;
    padding: 1rem;
    margin: 0.5rem 0;
}

.setting-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #d1d5db;
    text-align: left;
}

.setting-select,
.setting-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 1rem;
    color: #ffffff;
    background-color: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.setting-select:focus,
.setting-input:focus {
    border-color: #2563eb;
}

.setting-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='%239ca3af'%3E%3Cpath d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.setting-input::placeholder {
    color: #6b7280;
}

/* 接続テスト結果 / PIN変更結果 */
.test-result {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    text-align: left;
}

.test-result[hidden] {
    display: none;
}

.test-result.success {
    color: #4ade80;
}

.test-result.error {
    color: #f87171;
}

/* 設定画面 注意書き */
.setting-note {
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: #1c1917;
    border-left: 3px solid #fbbf24;
    border-radius: 4px;
    text-align: left;
}

.setting-note p {
    font-size: 0.8rem;
    color: #a8a29e;
    line-height: 1.6;
}

/* ============================================================
   8. カメラ画面
   ============================================================ */

#screen-camera {
    background-color: #000000;
    z-index: 50;
}

/* カメラプレビュー映像 */
#camera-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* フロントカメラの鏡像表示 */
}

/* ============================================================
   9. カメラ画面オーバーレイ要素
   ============================================================ */

/* セミナー名（上部） */
.overlay-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 1rem 1rem 0.75rem;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
    z-index: 60;
}

.overlay-top[hidden] {
    display: none;
}

/* ガイドメッセージ */
.overlay-guide {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    background-color: rgba(0, 0, 0, 0.55);
    border-radius: 24px;
    white-space: nowrap;
    z-index: 60;
}

/* 警告メッセージ */
.overlay-warning {
    position: absolute;
    top: 4rem;
    left: 1rem;
    right: 1rem;
    padding: 0.625rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fbbf24;
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid #fbbf24;
    border-radius: 8px;
    text-align: center;
    z-index: 60;
}

.overlay-warning[hidden] {
    display: none;
}

/* 手のひら検出アイコン */
.palm-indicator {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 60;
}

.palm-indicator[hidden] {
    display: none;
}

.palm-icon {
    font-size: 1.5rem;
    opacity: 0.7;
}

/* ============================================================
   10. 歯車アイコン・撮影カウント
   ============================================================ */

.settings-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 70;
    touch-action: manipulation;
}

.gear-icon {
    font-size: 1.4rem;
    color: #ffffff;
    opacity: 0.8;
}

.shot-count {
    position: absolute;
    top: 3.5rem;
    right: 0.75rem;
    min-width: 44px;
    padding: 0.2rem 0.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #ffffff;
    text-align: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    z-index: 70;
}

/* ============================================================
   11. カウントダウン
   ============================================================ */

.countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 80;
    pointer-events: none;
}

.countdown-overlay[hidden] {
    display: none;
}

.countdown-number {
    font-size: 8rem;
    font-weight: 900;
    color: #ffffff;
    text-shadow:
        0 0 20px rgba(255, 255, 255, 0.8),
        0 0 60px rgba(255, 255, 255, 0.4);
    animation: countdown-pulse 1s ease-in-out infinite;
}

@keyframes countdown-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.85;
    }
}

/* 画面縁点滅 */
.border-flash {
    position: absolute;
    inset: 0;
    border: 6px solid #ffffff;
    border-radius: 0;
    z-index: 75;
    pointer-events: none;
    animation: border-blink 0.5s ease-in-out infinite;
}

.border-flash[hidden] {
    display: none;
}

@keyframes border-blink {
    0%, 100% {
        border-color: rgba(255, 255, 255, 0.8);
    }
    50% {
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* ============================================================
   12. フラッシュ演出
   ============================================================ */

.screen-flash {
    position: absolute;
    inset: 0;
    background-color: #ffffff;
    z-index: 90;
    pointer-events: none;
    animation: flash-effect 0.4s ease-out forwards;
}

.screen-flash[hidden] {
    display: none;
}

@keyframes flash-effect {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* ============================================================
   13. プレビュー表示
   ============================================================ */

.preview-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000000;
    z-index: 85;
}

.preview-overlay[hidden] {
    display: none;
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* カメラプレビューと同じ鏡像 */
}

/* ============================================================
   14. アップロード状態
   ============================================================ */

.upload-status-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 88;
}

.upload-status-overlay[hidden] {
    display: none;
}

.upload-status-message {
    font-size: 1rem;
    color: #ffffff;
}

/* ============================================================
   15. クールダウン
   ============================================================ */

.cooldown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 80;
    pointer-events: none;
}

.cooldown-overlay[hidden] {
    display: none;
}

.cooldown-overlay p {
    font-size: 1.1rem;
    color: #ffffff;
    opacity: 0.8;
}

/* ============================================================
   16. 手動シャッターボタン
   ============================================================ */

.manual-shutter-btn {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 72px;
    height: 72px;
    border: 4px solid #ffffff;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    z-index: 70;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.manual-shutter-btn[hidden] {
    display: none;
}

.manual-shutter-btn:active {
    background-color: rgba(255, 255, 255, 0.3);
}

.shutter-icon {
    display: block;
    width: 56px;
    height: 56px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: background-color 0.15s;
}

.manual-shutter-btn:active .shutter-icon {
    background-color: #d1d5db;
}

/* ============================================================
   17. スピナー（ローディング）
   ============================================================ */

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

/* ============================================================
   18. ユーティリティ
   ============================================================ */

/* hidden属性が効かない場合のフォールバック */
[hidden] {
    display: none !important;
}
