/* Overall page styling */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: #000;
    color: white;
    font-family: 'Georgia', serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* Controls bar */
.controls {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 12vh; /* Set height to 8% of viewport height */
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    padding: 0; /* Remove padding to keep it tight */
}

.control-button {
    font-family: 'Georgia', serif;
    font-size: 1.5rem;
    color: white;
    background: rgba(68, 68, 68, 0.8);
    border: 2px solid white;
    padding: 10px 20px;
    margin: 0 15px;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    border-radius: 5px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.control-button:hover {
    background: rgba(102, 102, 102, 0.8);
}

.control-button.playing {
    opacity: 0.5; /* Fade the button when playing */
}

/* Overall Play Button Styling */
#play-pause-poem {
    position: relative;
    z-index: 10;
    background-color: rgba(68, 68, 68, 0.8); /* Matches other control buttons */
    color: white; /* Text remains bright */
    border: 2px solid white;
    border-radius: 5px;
    padding: 10px 20px;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Hover Effect */
#play-pause-poem:hover {
    background-color: rgba(102, 102, 102, 0.8); /* Brighter background on hover */
}

/* Ripple Effect (Subtle and Dynamic) */
#play-pause-poem.playing::after {
    content: '';
    position: absolute;
    top: 50%; /* Center the ripple source */
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px; /* Ripple starts as a small point */
    height: 10px;
    border-radius: 50%; /* Circular ripple */
    background: radial-gradient(circle, 
        rgba(0, 123, 255, 0.5) 20%, 
        rgba(0, 255, 255, 0.2) 60%, 
        transparent 100%);
    opacity: 0;
    z-index: -1; /* Ensure it stays behind the button */
    animation: rippleWaves 1.5s infinite ease-out;
}

/* Ripple Animation */
@keyframes rippleWaves {
    0% {
        width: 10px;
        height: 10px;
        opacity: 0.8;
    }
    50% {
        width: 150px;
        height: 150px;
        opacity: 0.3;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* Subtle ripples in the text area */
.line.rippled {
    position: relative;
    overflow: hidden;
}

.line.rippled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 123, 255, 0.4) 10%, rgba(0, 123, 255, 0) 70%);
    animation: subtleTextRipple 2s ease-out infinite;
}

@keyframes subtleTextRipple {
    0% {
        width: 0;
        height: 0;
        opacity: 0.8;
    }
    50% {
        width: 200px;
        height: 200px;
        opacity: 0.3;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* Hover effect for non-playing state */
#play-pause-poem:hover {
    background-color: #2c8ac9; /* Slightly brighter blue */
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.5);
}

/* Disabled hover for playing state */
#play-pause-poem.playing:hover {
    background-color: #3498db; /* Maintain consistent color */
    box-shadow: none; /* Disable hover shadow */
}

.split-animation {
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    margin: 0 10px;
}

/* Explosion effect */
.control-button {
    transition: transform 0.8s ease-out, opacity 0.8s ease;
    transform-origin: center;
}

.collision-swap {
    animation: explodeEffect 0.8s ease-out forwards;
}

@keyframes explodeEffect {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.5) translate(100px, 100px) rotate(360deg);
        opacity: 0;
    }
}

/* Centered button expansion */
.split-animation {
    animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    margin: 0 10px;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    50% {
        transform: scale(1.1) translateY(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.pixel-fade-out {
    animation: pixelDissolve 5s ease-in-out forwards;
    pointer-events: none; /* Prevent interaction during animation */
    position: relative;
}

@keyframes pixelDissolve {
    0% {
        opacity: 1;
        filter: none;
        mask-image: radial-gradient(circle, black 90%, transparent 100%);
        mask-size: 10px 10px;
        mask-repeat: repeat;
    }
    50% {
        mask-image: radial-gradient(circle, black 70%, transparent 100%);
        mask-size: 20px 20px;
        filter: blur(1px);
    }
    100% {
        opacity: 0;
        mask-image: radial-gradient(circle, transparent 100%, black 100%);
        mask-size: 50px 50px;
        filter: blur(2px);
    }
}

.quick-fade-in {
    animation: quickFade 0.3s ease-out forwards;
}

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

/* Poem container for wide screens */
.poem-container {
    position: relative;
    margin: 0 auto;
    width: 55%; /* At least 55% of screen width for wide screens */
    height: 40vh; /* 40% of viewport height */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-top: calc(50vh - 20vh); /* Center vertically by offsetting half of its height */
    padding-top: 80px; /* Adjust padding to account for the control bar */
    font-size: 1.3rem; /* Default font size */
}

/* For portrait screens */
@media screen and (max-width: 768px) {
    .poem-container {
        width: 90%; /* Takes up 90% of the width */
        height: 50vh; /* 50% of viewport height */
        margin-top: calc(50vh - 25vh); /* Center vertically by offsetting half of its height */
        padding-top: 60px; /* Adjust padding for mobile */
        font-size: 1.1rem; /* Smaller font size for mobile */
    }
}

.line {
    position: absolute;
    left: 50%;
    transform: translate(-50%, 0);
    width: 100%;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
}

.line.active {
    opacity: 1;
}

.line.fading {
    opacity: 0; /* Fully invisible */
}

.volume-slider {
    width: 100px;
    margin: 0 10px;
}

.sound-check {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%;
    font-size: 1.3rem; /* Default font size */
}

/* For portrait screens */
@media screen and (max-width: 768px) {
    .sound-check {
        font-size: 1.1rem; /* Smaller font size for mobile */
    }
}

.text-size-controls {
    margin-top: 10px;
}

.text-size-button {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    background: rgba(68, 68, 68, 0.8);
    border: 2px solid white;
    padding: 5px 10px;
    margin: 0 5px;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.3s ease;
}

.text-size-button:hover {
    background: rgba(102, 102, 102, 0.8);
}

.text-size-indicator {
    position: absolute;
    top: 50%; /* Center vertically */
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0; /* Initially hidden */
    transition: opacity 0.3s ease;
    font-size: 1.2rem;
    color: white;
    background: rgba(0, 0, 0, 0.8);
    padding: 5px 10px;
    border-radius: 5px;
    z-index: 101; /* Ensure it appears above other elements */
}

.control-button#text-button,
.control-button#restart-symbol {
    padding: 10px 15px;
    font-weight: bold;
}

/* Disabled button style */
.control-button:disabled {
    cursor: not-allowed;
    filter: grayscale(100%);
}
