/* --- Styles globaux et rail --- */
:root {
    --rail-height: 160px;
    --thumb-gap: 12px;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial;
    background: #000;
    color: #fff;
}

.rail-wrap {
    position: absolute; /* FIX pour iframe WebKit */
    top: 0;
    left: 0;
    right: 0;
    height: var(--rail-height);
    background: #000;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #222;
}

.progress-fill {
    height: 100%;
    background: limegreen;
    width: 0%;
    transition: width 0.4s ease;
}

.rail-container {
    flex: 1;
    display: flex;
    align-items: center;
    width: 100%;
    position: relative;
    padding-top: 40px; /* espace pour le timer */
}

.rail {
    display: flex;
    gap: var(--thumb-gap);
    align-items: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    cursor: grab;
    flex: 1;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.rail:active {
    cursor: grabbing;
}

.rail::-webkit-scrollbar {
    display: none;
}

.rail {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.thumb {
    flex: 0 0 auto;
    width: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.thumb-img {
    width: 100%;
    height: 90px;
    border-radius: 6px;
    overflow: hidden;
    background: #222;
    position: relative;
}

.thumb-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.thumb-title {
    margin-top: 6px;
    font-size: 0.85rem;
    text-align: center;
    color: #eee;
}

.btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}

.btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

@media (max-width: 520px) {
    :root { --rail-height: 140px; }
    .thumb { width: 120px; }
    .thumb-img { height: 70px; }
    .thumb-title { font-size: 0.75rem; }
    .btn { width: 60px; height: 60px; font-size: 2rem; }
}

@keyframes haloPulse {
    0% { box-shadow: 0 0 0 0 rgba(0,255,100,0.8); }
    50% { box-shadow: 0 0 20px 6px rgba(0,255,100,0.6); }
    100% { box-shadow: 0 0 0 0 rgba(0,255,100,0.8); }
}

.thumb.active .thumb-img {
    animation: haloPulse 1.5s infinite ease-in-out;
}

.thumb-img.visited {
    border-radius: 6px;
    box-shadow: 0 0 15px 6px rgba(30, 144, 255, 0.7),
                0 0 30px 12px rgba(30, 144, 255, 0.4);
    transition: box-shadow 0.3s ease-in-out;
}

main {
    padding-top: calc(var(--rail-height) + 40px); /* rail + timer */
    position: relative;
}

.frame-container {
    height: calc(100vh - var(--rail-height) - 40px - 60px); /* rail + timer + description */
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #001f3f 0%, #003366 30%, #004080 60%, #002244 100%);
}

iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.description {
    padding: 10px;
    background: #111;
    font-size: 0.9rem;
    min-height: 50px;
    border-top: 1px solid #333;
}

.empty {
    padding: 32px;
    text-align: center;
    color: #ccc;
}

#loader {
    position: absolute;
    top: calc(var(--rail-height) + 40px);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--rail-height) - 40px - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 1.2rem;
    z-index: 500;
    visibility: hidden;
}

#loader::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 4px solid #0f0;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#particlesCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1; /* derrière l'iframe */
}

iframe#viewer {
    position: relative;
    z-index: 2;
}

#timer {
    position: absolute;
    top: 10px;
    right: 20px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    text-shadow: 
        0 0 5px #33ccff,
        0 0 10px #33ccff,
        0 0 20px #0099cc;
    background: rgba(0, 0, 51, 0.2);
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
    animation: floatTimer 2s infinite ease-in-out;
    z-index: 1001;
}

@keyframes floatTimer {
    0% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
    100% { transform: translateY(0); }
}