/* Player CSS - Cinematic Story Player */

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

body {
    overflow: hidden;
    background: #000;
    font-family: 'Georgia', 'Times New Roman', serif;
}

.player-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
}

/* Close Button */
.close-btn {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    text-decoration: none;
}

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

.close-btn svg {
    width: 24px;
    height: 24px;
}

/* Image Layer with Ken Burns Effect */
.image-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.ken-burns-container {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
}

.story-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    animation: kenBurns 60s ease-in-out infinite;
}

/* Ken Burns Animations - Multiple variations */
@keyframes kenBurns {
    0% {
        transform: scale(1) translate(0, 0);
    }
    25% {
        transform: scale(1.1) translate(-2%, -1%);
    }
    50% {
        transform: scale(1.05) translate(1%, 2%);
    }
    75% {
        transform: scale(1.15) translate(-1%, 1%);
    }
    100% {
        transform: scale(1) translate(0, 0);
    }
}

/* Alternative Ken Burns patterns */
.ken-burns-1 {
    animation: kenBurns1 45s ease-in-out infinite;
}

@keyframes kenBurns1 {
    0%, 100% {
        transform: scale(1.0) translateX(0) translateY(0);
    }
    50% {
        transform: scale(1.2) translateX(-3%) translateY(-2%);
    }
}

.ken-burns-2 {
    animation: kenBurns2 50s ease-in-out infinite;
}

@keyframes kenBurns2 {
    0%, 100% {
        transform: scale(1.1) translateX(-2%) translateY(0);
    }
    50% {
        transform: scale(1.0) translateX(2%) translateY(-3%);
    }
}

.ken-burns-3 {
    animation: kenBurns3 55s ease-in-out infinite;
}

@keyframes kenBurns3 {
    0% {
        transform: scale(1.0) translateX(0) translateY(0);
    }
    33% {
        transform: scale(1.15) translateX(2%) translateY(-2%);
    }
    66% {
        transform: scale(1.1) translateX(-2%) translateY(1%);
    }
    100% {
        transform: scale(1.0) translateX(0) translateY(0);
    }
}

/* Overlay Layer */
.overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.gradient-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 30%;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.7) 0%,
        rgba(0, 0, 0, 0.3) 50%,
        transparent 100%
    );
}

.gradient-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.9) 0%,
        rgba(0, 0, 0, 0.6) 30%,
        rgba(0, 0, 0, 0.2) 60%,
        transparent 100%
    );
}

.gradient-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(0, 0, 0, 0.4) 100%
    );
}

/* Animated gradient overlay */
.animated-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        45deg,
        transparent 0%,
        rgba(99, 102, 241, 0.03) 25%,
        transparent 50%,
        rgba(168, 85, 247, 0.03) 75%,
        transparent 100%
    );
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Text Layer */
.text-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    display: flex;
    flex-direction: column;
    padding: 6rem 2rem 10rem;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.text-layer.visible {
    opacity: 1;
}

.story-title-display {
    color: #fff;
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-left: 5%;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    max-width: 80%;
    line-height: 1.3;
}

.story-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-left: 5%;
}

.story-kind {
    background: rgba(99, 102, 241, 0.8);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 500;
    text-transform: capitalize;
    backdrop-filter: blur(10px);
}

.story-for {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    font-style: italic;
}

.story-text-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 10%,
        black 85%,
        transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 10%,
        black 85%,
        transparent 100%
    );
}

.story-text {
    color: white;
    font-size: 1.5rem;
    line-height: 2;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 0, 0, 0.5);
    padding: 2rem 5%;
    transform: translateY(0);
    transition: transform 0.1s linear;
}

/* Auto-scroll animation */
.story-text.scrolling {
    animation: textScroll var(--scroll-duration, 60s) linear forwards;
}

@keyframes textScroll {
    0% {
        transform: translateY(20%);
    }
    100% {
        transform: translateY(var(--scroll-end, -100%));
    }
}

/* Controls Layer */
.controls-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 30;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

/* Progress Bar */
.progress-container {
    width: 100%;
    max-width: 600px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    overflow: hidden;
    transition: height 0.2s ease;
}

.progress-container:hover {
    height: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    width: 0%;
    border-radius: 2px;
    transition: width 0.1s linear;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.progress-container:hover .progress-bar::after {
    transform: translateY(-50%) scale(1);
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

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

.control-btn svg {
    pointer-events: none;
}

.rewind-btn,
.forward-btn {
    width: 48px;
    height: 48px;
}

.rewind-btn svg,
.forward-btn svg {
    width: 24px;
    height: 24px;
}

.play-btn {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    box-shadow: 0 4px 30px rgba(99, 102, 241, 0.4);
}

.play-btn:hover {
    background: linear-gradient(135deg, #4f46e5, #9333ea);
    transform: scale(1.1);
    box-shadow: 0 6px 40px rgba(99, 102, 241, 0.6);
}

.play-btn svg {
    width: 32px;
    height: 32px;
}

.play-btn .play-icon {
    margin-left: 4px;
}

.hidden {
    display: none !important;
}

/* Time Display */
.time-display {
    color: rgba(255, 255, 255, 0.7);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.time-separator {
    margin: 0 0.25rem;
    opacity: 0.5;
}

/* Loading State */
.player-container.loading .story-image {
    filter: blur(20px);
    animation: none;
}

.player-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 100;
}

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

/* Paused State */
.player-container.paused .story-image {
    animation-play-state: paused;
}

.player-container.paused .animated-gradient {
    animation-play-state: paused;
}

.player-container.paused .story-text.scrolling {
    animation-play-state: paused;
}

/* Idle State - Hide controls */
.player-container.idle .close-btn,
.player-container.idle .controls-layer,
.player-container.idle .story-meta {
    opacity: 0;
    pointer-events: none;
}

.close-btn,
.controls-layer,
.story-meta {
    transition: opacity 0.5s ease;
}

/* Responsive */
@media (max-width: 768px) {
    .story-text {
        font-size: 1.2rem;
        line-height: 1.8;
    }

    .text-layer {
        padding: 5rem 1rem 9rem;
    }

    .play-btn {
        width: 64px;
        height: 64px;
    }

    .play-btn svg {
        width: 28px;
        height: 28px;
    }

    .rewind-btn,
    .forward-btn {
        width: 40px;
        height: 40px;
    }

    .rewind-btn svg,
    .forward-btn svg {
        width: 20px;
        height: 20px;
    }

    .story-meta {
        padding-left: 1rem;
    }

    .story-title-display {
        font-size: 1.25rem;
        padding-left: 1rem;
    }

    .initial-story-title {
        font-size: 1.5rem;
        max-width: 90%;
    }

    .close-btn {
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }

    .close-btn svg {
        width: 20px;
        height: 20px;
    }
}

/* Fullscreen */
.player-container:fullscreen {
    width: 100vw;
    height: 100vh;
}

/* High contrast mode for better readability */
@media (prefers-contrast: high) {
    .story-text {
        text-shadow: 0 2px 4px black, 0 0 20px black;
    }

    .gradient-bottom {
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.95) 0%,
            rgba(0, 0, 0, 0.7) 40%,
            transparent 100%
        );
    }
}

/* Play Prompt Overlay (for autoplay blocked) */
.play-prompt {
    position: fixed;
    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: 200;
    cursor: pointer;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.play-prompt-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    transform: scale(1);
    transition: transform 0.2s ease;
}

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

.play-prompt-icon {
    width: 100px;
    height: 100px;
    background: rgba(99, 102, 241, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    padding-left: 8px;
    box-shadow: 0 0 60px rgba(99, 102, 241, 0.5);
}

.play-prompt-text {
    color: white;
    font-size: 1.25rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.9;
}

/* End Overlay (story complete) */
.end-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    cursor: pointer;
    animation: fadeIn 0.5s ease;
}

.end-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
    transform: scale(1);
    transition: transform 0.2s ease;
}

.end-overlay:hover .end-overlay-content {
    transform: scale(1.02);
}

.end-icon {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    box-shadow: 0 0 60px rgba(16, 185, 129, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 60px rgba(16, 185, 129, 0.5);
    }
    50% {
        box-shadow: 0 0 80px rgba(16, 185, 129, 0.7);
    }
}

.end-text {
    color: white;
    font-size: 2rem;
    font-family: 'Georgia', 'Times New Roman', serif;
    letter-spacing: 0.05em;
}

.end-countdown {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.end-countdown span {
    color: white;
    font-weight: bold;
}

/* ==================== INITIAL PLAY OVERLAY ==================== */

.initial-play-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.initial-play-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.initial-play-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    text-align: center;
    padding: 2rem;
}

.initial-story-title {
    color: #fff;
    font-size: 2rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1.5rem;
    text-shadow: 0 2px 20px rgba(0,0,0,0.5);
    max-width: 600px;
    line-height: 1.3;
}

.initial-play-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.initial-story-kind {
    background: rgba(99, 102, 241, 0.9);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 500;
    text-transform: capitalize;
    letter-spacing: 0.05em;
}

.initial-story-for {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    font-style: italic;
    font-family: 'Georgia', 'Times New Roman', serif;
}

.initial-play-btn {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.9), rgba(168, 85, 247, 0.9));
    border: 4px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s ease;
    box-shadow:
        0 0 60px rgba(99, 102, 241, 0.4),
        0 20px 50px rgba(0, 0, 0, 0.5);
    animation: initialPlayPulse 2s ease-in-out infinite;
}

@keyframes initialPlayPulse {
    0%, 100% {
        box-shadow:
            0 0 60px rgba(99, 102, 241, 0.4),
            0 20px 50px rgba(0, 0, 0, 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow:
            0 0 80px rgba(99, 102, 241, 0.6),
            0 25px 60px rgba(0, 0, 0, 0.6);
        transform: scale(1.05);
    }
}

.initial-play-btn:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow:
        0 0 100px rgba(99, 102, 241, 0.6),
        0 30px 70px rgba(0, 0, 0, 0.6);
    animation: none;
}

.initial-play-icon {
    font-size: 3.5rem;
    color: white;
    margin-left: 10px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.initial-play-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 0;
}

/* Initial State - Hide text and controls */
.player-container[data-state="initial"] .text-layer {
    opacity: 0;
    pointer-events: none;
}

.player-container[data-state="initial"] .controls-layer {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.player-container[data-state="initial"] .close-btn {
    opacity: 0.5;
}

/* Playing State - Show all elements */
.player-container[data-state="playing"] .text-layer,
.player-container[data-state="playing"] .controls-layer {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    transition: opacity 0.6s ease 0.3s, transform 0.6s ease 0.3s;
}

.player-container[data-state="playing"] .close-btn {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Mobile adjustments for initial play overlay */
@media (max-width: 768px) {
    .initial-play-btn {
        width: 120px;
        height: 120px;
    }

    .initial-play-icon {
        font-size: 3rem;
        margin-left: 8px;
    }

    .initial-play-text {
        font-size: 0.85rem;
    }

    .initial-story-for {
        font-size: 1rem;
    }
}

@media (max-width: 400px) {
    .initial-play-btn {
        width: 100px;
        height: 100px;
    }

    .initial-play-icon {
        font-size: 2.5rem;
        margin-left: 6px;
    }

    .initial-play-text {
        font-size: 0.75rem;
    }
}
