/* style.css */

/* 全体設定 */
body {
    margin: 0;
    font-family: "Yu Mincho", "YuMincho", serif;
    /* 明朝体 */
    background-color: #f4f4f4;
    color: #333;

    /* 保存防止対策: 選択不可、ドラッグ不可、長押しメニュー不可 */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    /* iOS長押しメニュー無効化 */
}

/* 画像個別の保護強化 */
img {
    pointer-events: none;
    /* 画像へのクリック・タッチイベント自体を透過させる（保存メニュー封じ） */
}

/* --- メニュー画面 --- */
.menu-body {
    background-color: #fff;
    padding: 40px 20px;
}

.menu-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

h1 {
    font-size: 2rem;
    letter-spacing: 0.5em;
    margin-bottom: 0;
}

.subtitle {
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    color: #888;
    margin-bottom: 40px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 20px;
}

.song-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 10px;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: #333;
    transition: background 0.3s;
}

.song-item:active {
    background-color: #f9f9f9;
}

.song-page {
    font-size: 0.8rem;
    color: #999;
    font-family: sans-serif;
}

.song-title {
    font-size: 1.1rem;
}

.song-artist {
    font-size: 0.75rem;
    color: #666;
    margin-left: 10px;
    font-family: sans-serif;
}

/* --- AR画面 & プレイヤー --- */
#player-overlay {
    display: none;
    /* 初期は非表示 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease;
}

.player-inner {
    text-align: center;
    width: 80%;
}

.jacket {
    width: 200px;
    height: 200px;
    background: #eee;
    border: 1px solid #ccc;
    margin: 20px auto;
}

audio {
    width: 100%;
    margin: 20px 0;
}

#back-btn {
    background: transparent;
    border: 1px solid #333;
    padding: 10px 30px;
    cursor: pointer;
    font-family: serif;
    margin-top: 20px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* --- 専用プレイヤーページ (Player.html) --- */

body.player-body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* height: 100vh;  <-- Causing issues on iOS */
    min-height: 100vh;
    /* Fallback */
    min-height: 100dvh;
    /* iOS Dynamic Viewport Unit */
    margin: 0;
    font-family: 'Inter', sans-serif;
    /* overflow: hidden; <-- Prevent scrolling */
    overflow-y: auto;
    /* Allow vertical scroll */
    padding-bottom: 20px;
    /* Add padding for safe area */
}

.player-container {
    width: 90%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.album-art {
    width: 250px;
    height: 250px;
    border-radius: 15px;
    object-fit: cover;
    margin-bottom: 25px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.album-art.playing {
    transform: scale(1.05);
}

.player-container h2 {
    margin: 0 0 5px;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.player-container p.artist {
    margin: 0 0 25px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.btn {
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn:active {
    transform: scale(0.95);
}

.btn-play {
    width: 60px;
    height: 60px;
    background: white;
    color: #1a1a2e;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

.btn-play svg {
    width: 24px;
    height: 24px;
    fill: #1a1a2e;
    transform: translateX(2px);
}

.btn-play.paused svg {
    transform: translateX(0);
}

.progress-container {
    width: 100%;
    margin-bottom: 25px;
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    height: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.5);
}

.time-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 8px;
}

.back-link {
    display: inline-block;
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.3s;
}

.back-link:hover {
    color: white;
}

/* --- Serial Code Form --- */
.serial-form {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    margin: 40px auto;
    /* 自然な中央配置 */
    text-align: center;
}

.serial-form h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.serial-form p {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 20px;
}

#serial-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box;
}

#serial-submit {
    width: 100%;
    padding: 12px;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

#serial-submit:hover {
    background-color: #555;
}

#error-message {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 15px;
    display: none;
}

/* --- Loading & Buffering States --- */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 15px;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.buffering-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.7rem;
    z-index: 11;
    display: none;
}

.buffering-indicator.active {
    display: block;
}

/* --- Smooth Video Transitions --- */
#media-container video {
    transition: opacity 0.3s ease;
}

#media-container video.fading-in {
    opacity: 0;
    animation: fadeInVideo 0.3s ease forwards;
}

#media-container video.fading-out {
    animation: fadeOutVideo 0.3s ease forwards;
}

@keyframes fadeInVideo {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOutVideo {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* --- Ready State Indicator --- */
.ready-indicator {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    z-index: 11;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ready-indicator.show {
    opacity: 1;
}