/* motoquiz Custom Styles (Bootstrap 5対応) */

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* 画面切り替え */
.screen {
    display: none;
    padding: 2rem 0;
    min-height: 100vh;
}

.screen.active {
    display: block !important;
}

/* スタート画面 */
#start-screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* クイズ画面 */
#quiz-screen {
    background: #f8f9fa;
}

/* バイク画像カード - スクロール追従 */
#bike-card {
    position: sticky;
    top: 20px;
    z-index: 10;
}

/* バイク画像 */
#bike-image {
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 2;
}

#image-placeholder {
    display: none;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 1;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

#image-placeholder i {
    color: #adb5bd;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

#bike-image[src=""],
#bike-image:not([src]) {
    display: none !important;
    z-index: 0;
}

#bike-image[src=""] ~ #image-placeholder,
#bike-image:not([src]) ~ #image-placeholder {
    display: flex !important;
    z-index: 1;
}

/* 選択ステップ */
.selection-step {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    transition: all 0.3s;
}

.selection-step.active {
    border-color: #0d6efd;
    background: #e7f1ff;
}

.selection-step.completed {
    border-color: #198754;
    background: #d1e7dd;
}

.selection-step.correct {
    border-color: #198754;
    background: #d1e7dd;
}

.selection-step.incorrect {
    border-color: #dc3545;
    background: #f8d7da;
}

.step-number {
    font-size: 0.75rem;
    font-weight: bold;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.selection-step.active .step-number {
    color: #0d6efd;
}

.selection-step.completed .step-number {
    color: #198754;
}

.step-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
}

.step-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: #212529;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 選択肢ボタン */
.option-btn {
    transition: all 0.2s ease;
    font-weight: 500;
}

.option-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.option-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.option-btn.selected {
    background-color: #0d6efd !important;
    color: white !important;
    border-color: #0d6efd !important;
    font-weight: 600;
}

/* 検索ボックス */
#search-input {
    font-size: 1rem;
    border: 2px solid #dee2e6;
    transition: border-color 0.2s ease;
}

#search-input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* 結果画面 */
#result-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#result-screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-item {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item.correct {
    background-color: #d1e7dd;
}

.result-item.incorrect {
    background-color: #f8d7da;
}

/* フィードバックモーダル */
.feedback-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* インラインフィードバックアイコン */
.selection-step .feedback-icon {
    font-size: 1rem;
    margin-bottom: 0;
    display: inline-block;
}

/* ステップメッセージ */
#step-message {
    animation: fadeIn 0.3s ease-out;
}

/* レスポンシブ調整 */
@media (max-width: 768px) {
    .selection-step {
        padding: 0.5rem;
    }

    .step-number {
        font-size: 0.625rem;
    }

    .step-label,
    .step-value {
        font-size: 0.75rem;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.5s ease-out;
}

/* ローディングスピナー */
#loading-spinner {
    padding: 2rem;
}

/* フルスクリーンローディング */
#fullscreen-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

#fullscreen-loading.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    position: relative;
    text-align: center;
    color: white;
    max-width: 600px;
    margin: 0 auto;
}

.loading-spinner {
    width: 120px;
    height: 120px;
    position: relative;
    margin: 0 auto 2rem;
}

.loading-spinner::before,
.loading-spinner::after {
    content: '';
    position: absolute;
    border-radius: 50%;
}

.loading-spinner::before {
    width: 100%;
    height: 100%;
    border: 8px solid transparent;
    border-top-color: #fff;
    border-right-color: #fff;
    animation: spinComplex 3s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.loading-spinner::after {
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
    border: 6px solid transparent;
    border-bottom-color: rgba(255, 255, 255, 0.7);
    border-left-color: rgba(255, 255, 255, 0.7);
    animation: spinComplexReverse 2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

@keyframes spinComplex {
    0% {
        transform: rotate(0deg) scale(1);
        opacity: 1;
    }
    25% {
        transform: rotate(180deg) scale(1.1);
        opacity: 0.8;
    }
    50% {
        transform: rotate(360deg) scale(1);
        opacity: 1;
    }
    75% {
        transform: rotate(540deg) scale(0.9);
        opacity: 0.8;
    }
    100% {
        transform: rotate(720deg) scale(1);
        opacity: 1;
    }
}

@keyframes spinComplexReverse {
    0% {
        transform: rotate(0deg) scale(1);
        opacity: 0.7;
    }
    30% {
        transform: rotate(-120deg) scale(1.15);
        opacity: 1;
    }
    60% {
        transform: rotate(-240deg) scale(0.85);
        opacity: 0.7;
    }
    100% {
        transform: rotate(-360deg) scale(1);
        opacity: 0.7;
    }
}

/* バイクアイコンの追加アニメーション */
.loading-content::before {
    content: '🏍️';
    position: absolute;
    top: 50%;
    right: -100px;
    font-size: 3rem;
    animation: bikeRide 4s ease-in-out infinite;
    transform: translateY(-50%);
}

@keyframes bikeRide {
    0% {
        right: -100px;
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    50% {
        right: 50%;
        transform: translateX(50%) translateY(-50%) scale(1.2);
    }
    90% {
        opacity: 1;
    }
    100% {
        right: calc(100% + 100px);
        opacity: 0;
    }
}

.loading-text {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.loading-progress {
    width: 300px;
    max-width: 80vw;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin: 1rem auto;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.8) 0%,
        rgba(255, 255, 255, 1) 50%,
        rgba(255, 255, 255, 0.8) 100%);
    background-size: 200% 100%;
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.loading-tips {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 1.5rem;
    max-width: 400px;
    animation: fadeIn 0.5s ease-out;
}

/* 画面遷移アニメーション */
.screen {
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ボタンアニメーション強化 */
.btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

/* カードアニメーション */
.card {
    animation: cardIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.3s ease;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* プログレスバーアニメーション */
.progress-bar {
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* オプションボタンのスタガーアニメーション */
.option-btn {
    animation: optionIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

@keyframes optionIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* スタガー効果 */
.option-btn:nth-child(1) { animation-delay: 0.05s; }
.option-btn:nth-child(2) { animation-delay: 0.1s; }
.option-btn:nth-child(3) { animation-delay: 0.15s; }
.option-btn:nth-child(4) { animation-delay: 0.2s; }
.option-btn:nth-child(5) { animation-delay: 0.25s; }
.option-btn:nth-child(6) { animation-delay: 0.3s; }

/* 正解・不正解のアニメーション */
.selection-step.correct {
    animation: correctBounce 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.selection-step.incorrect {
    animation: incorrectShake 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes correctBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* バイク画像フェードイン */
#bike-image {
    animation: imageIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes imageIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
