/**
 * Article Thumbnail Rail - Sleek iPhone-style Carousel
 * Mobile-only fixed bottom navigation with center-focused halo glow effect
 */

/* CSS Custom Properties */
:root {
    --atr-thumbnail-width: 72px;
    --atr-thumbnail-height: 72px;
    --atr-active-scale: 1.25;
    --atr-glow-color: rgba(255, 255, 255, 0.6);
    --atr-glow-spread: 12px;
    --atr-border-radius: 8px;
    --atr-transition-speed: 0.3s;
    --atr-gap: 6px;
}

/* Hide on desktop/tablet - mobile only */
@media screen and (min-width: 769px) {
    .atr-rail {
        display: none !important;
    }
}

/* Main Rail Container - Fixed at bottom like menu bar */
.atr-rail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.6) 50%, transparent 100%);
    padding: 10px 0 4px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.atr-rail.atr-visible {
    transform: translateY(0);
}

/* Inner container */
.atr-rail-container {
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
}

/* Carousel wrapper for touch scrolling */
.atr-carousel-wrapper {
    overflow: hidden;
    position: relative;
    padding: 5px 0 3px;
}

/* Carousel track */
.atr-carousel {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--atr-gap);
    will-change: transform;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
}

/* Individual thumbnail items */
.atr-thumbnail-item {
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
    transition: all var(--atr-transition-speed) cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center center;
    -webkit-tap-highlight-color: transparent;
}

/* Thumbnail image container */
.atr-thumbnail {
    width: var(--atr-thumbnail-width);
    height: var(--atr-thumbnail-height);
    border-radius: var(--atr-border-radius);
    overflow: hidden;
    position: relative;
    background: rgba(255, 255, 255, 0.1);
}

.atr-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Active/Center thumbnail with halo glow */
.atr-thumbnail-item.atr-active {
    transform: scale(1.4) translateY(-12px);
    z-index: 10;
    margin: 0 -8px;
}

.atr-thumbnail-item.atr-active .atr-thumbnail {
    box-shadow:
        0 0 var(--atr-glow-spread) var(--atr-glow-color),
        0 0 calc(var(--atr-glow-spread) * 2) rgba(255, 255, 255, 0.3),
        0 0 calc(var(--atr-glow-spread) * 3) rgba(255, 255, 255, 0.1),
        0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Subtle halo ring effect */
.atr-thumbnail-item.atr-active::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: calc(var(--atr-border-radius) + 4px);
    background: radial-gradient(
        ellipse at center,
        rgba(255, 255, 255, 0.15) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        transparent 70%
    );
    pointer-events: none;
    animation: atr-pulse 2s ease-in-out infinite;
}

@keyframes atr-pulse {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Title display area */
.atr-title-display {
    text-align: center;
    padding: 4px 16px 2px;
    min-height: 18px;
}

.atr-current-title {
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.3;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.25s ease;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.atr-current-title.atr-title-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Loading state */
.atr-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60px;
}

.atr-loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: atr-spin 0.8s linear infinite;
}

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

/* Small mobile adjustments */
@media screen and (max-width: 360px) {
    :root {
        --atr-thumbnail-width: 60px;
        --atr-thumbnail-height: 60px;
        --atr-gap: 5px;
    }

    .atr-current-title {
        font-size: 11px;
    }
}

/* Larger mobile phones */
@media screen and (min-width: 481px) and (max-width: 768px) {
    :root {
        --atr-thumbnail-width: 80px;
        --atr-thumbnail-height: 80px;
        --atr-gap: 8px;
    }

    .atr-current-title {
        font-size: 12px;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .atr-rail,
    .atr-carousel,
    .atr-thumbnail-item,
    .atr-current-title {
        transition: none;
    }

    .atr-thumbnail-item.atr-active::before {
        animation: none;
    }

    .atr-loading-spinner {
        animation: none;
    }
}

/* Safe area insets for notched devices (iPhone X+) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .atr-rail {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}
