/* BranchStream Web Frontend Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #000;
    color: #fff;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Skeleton Loading Animation */
@keyframes skeleton-pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        opacity: 0.6;
    }
}

.skeleton-item {
    background: linear-gradient(90deg, #222 0%, #333 50%, #222 100%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
    height: 1em;
}

.story-card.skeleton .story-thumbnail.skeleton-item {
    height: 200px;
    width: 100%;
}

.story-card.skeleton .story-title.skeleton-item {
    height: 1.2em;
    margin-bottom: 8px;
}

.story-card.skeleton .story-meta .skeleton-item {
    height: 0.9em;
    margin-right: 10px;
    display: inline-block;
}

/* Story Menu (YouTube-like) */
.story-menu {
    min-height: 100vh;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Video Player Back Button */
.player-back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.player-back-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.audio-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.audio-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.audio-btn.muted {
    opacity: 0.5;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px 0;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: #fff;
}

.header p {
    font-size: 1.2rem;
    color: #ccc;
}

.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.story-card {
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 8px;
    overflow: hidden;
    background-color: #111;
}

.story-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 255, 255, 0.3);
}

.story-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.story-info {
    padding: 15px;
}

.story-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #fff;
}

.story-meta {
    display: flex;
    gap: 15px;
    color: #999;
    font-size: 0.9rem;
}

/* Story Details Page */
.story-detail {
    min-height: 100vh;
    padding: 20px;
    padding-top: 140px; /* move content further down */
    display: flex;
    flex-direction: column;
    align-items: center; /* center block horizontally */
}

.back-btn {
    background: none;
    border: none;
    color: #ccc;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 10px 0;
    margin-bottom: 20px;
    transition: color 0.3s ease;
    position: fixed;       /* keep at top-left of the page */
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.back-btn:hover {
    color: #fff;
}

.detail-content {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 40px;
    max-width: 1100px;
    margin: 40px auto 0; /* add more top margin to sit lower */
    align-items: start; /* top-align text with thumbnail */
    justify-content: center; /* center grid within container */
}

/* Ensure the right column starts at the top of the row */
.detail-right {
    align-self: start;
}

.detail-thumbnail {
    width: 100%;
    height: 300px;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    margin-bottom: 20px;
}

.play-btn {
    width: auto;
    min-width: 200px;
    max-width: 320px;
    background: linear-gradient(135deg, #fff, #eaeaea);
    color: #000;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s ease;
    min-height: 60px;
    margin: 20px 0 0 0;
}

.play-btn:hover {
    transform: scale(1.05);
}

/* Button loading state removed - progress bar is now independent */

.play-icon {
    font-size: 1.3rem;
}

/* Progress Bar Styles */
.loading-progress {
    position: static; /* inline under thumbnail */
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 0;
    background: none;
}

.loading-progress .progress-bar {
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, rgba(255,255,255,0.25), rgba(255,255,255,0.15));
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.loading-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffffff, #e9e9e9);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.loading-progress .progress-fill.complete {
    background: linear-gradient(90deg, #ffffff, #e9e9e9);
    width: 100% !important;
}

.loading-progress .progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: progress-shimmer 1.5s infinite;
}

.progress-text {
    font-size: 0.85rem;
    color: #fff;
    text-align: center;
    margin: 0;
    font-weight: 500;
}

@keyframes progress-shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    font-size: 0.75rem;
    color: #fff;
    text-align: center;
    font-weight: 500;
    opacity: 0.9;
    line-height: 1.1;
    margin: 0;
}

.detail-right h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #fff;
}

.meta-info {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    color: #ccc;
    font-size: 0.9rem;
}

.meta-info span {
    background: #333;
    padding: 4px 12px;
    border-radius: 4px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.tag {
    background: #fff;
    color: black;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
}

/* Story Player */
.story-player {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 1000;
}

.player-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-element {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Dark overlay for choice moments */
.dark-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10;
}

/* Choice overlay */
.choice-overlay {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

.choice-container {
    text-align: center;
}

.choices {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.choice-btn {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: 2px solid #333;
    padding: 15px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    min-width: 200px;
    transition: all 0.3s ease;
}

.choice-btn:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

.choice-btn.selected {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.4);
}

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

.choice-timer {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.timer-bar {
    width: 200px;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.timer-bar::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: #fff;
    width: var(--progress, 0%);
    transition: width 0.1s linear;
}

#timer-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    min-width: 30px;
    text-align: center;
}

/* End story overlay */
.end-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.end-content {
    text-align: center;
    padding: 40px;
}

.end-content h3 {
    font-size: 2rem;
    margin-bottom: 30px;
    color: #fff;
}

.end-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.end-btn {
    background: #000;
    color: white;
    border: 2px solid #333;
    padding: 15px 25px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.end-btn:hover {
    background: #333;
    border-color: #555;
    transform: translateY(-2px);
}

/* Video controls */
.video-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 8px;
    z-index: 5;
}

.control-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

.progress-container {
    flex: 1;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}

.progress-bar {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.1s linear;
}

/* Error message */
.error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
    padding: 20px;
}

.error h3 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.retry-btn {
    background: #fff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .story-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .detail-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .choices {
        flex-direction: column;
        gap: 10px;
    }

    .choice-btn {
        min-width: 250px;
    }

    .end-buttons {
        flex-direction: column;
    }
}
