/* Import playful fonts */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Patrick+Hand&family=Bubblegum+Sans&display=swap');

/* General Body Styling */
body {
    font-family: 'Comic Sans MS', Arial, sans-serif;
    background: linear-gradient(135deg, #f9e1e1 0%, #e1f9e1 100%);
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    position: relative;
    overflow-x: hidden;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><path d="M20 5L25 15L35 15L27 22L30 32L20 27L10 32L13 22L5 15L15 15Z" fill="rgba(255, 255, 255, 0.1)"/></svg>') repeat;
    opacity: 0.3;
    z-index: -1;
}

/* Container Styling (for both form and story) */
.container {
    background: #fff;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 600px; /* Default for form */
    position: relative;
    border: 3px solid #e65c54;
    background: linear-gradient(145deg, #fff, #f9f9f9);
    will-change: border-color;
    transition: border-color 0.3s ease;
}

/* Hover effect instead of infinite animation */
.container:hover {
    border-color: #4caf50;
    animation: borderGlow 3s infinite;
}

/* Adjust container for story display */
#story-display .container {
    max-width: 800px;
    background: #fffcf5 url('https://www.transparenttextures.com/patterns/paper-fibers.png');
    border: 3px solid #ffd700;
    overflow: hidden;
}

/* Policy Page Styling */
.policy-container {
    max-width: 800px; /* Wider than form for readability */
    margin: 40px auto; /* Center with spacing */
    background: #fffcf5 url('https://www.transparenttextures.com/patterns/paper-fibers.png'); /* Parchment texture */
    border: 3px solid #e65c54;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    position: relative;
}

/* Story display transition */
#story-display {
    margin-top: 40px;
    transition: opacity 0.5s ease;
}

#story-display[style*="display: none"] {
    opacity: 0;
}

#story-display[style*="display: block"] {
    opacity: 1;
}

/* Header Styling */
h1 {
    text-align: center;
    color: #e65c54;
    font-family: 'Fredoka+One', cursive;
    font-size: 2.5rem;
    margin-top: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

h2 {
    color: #e65c54;
    font-family: 'Bubblegum Sans', cursive;
    font-size: 1.8rem;
    margin-top: 20px;
    margin-bottom: 10px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

.subtitle {
    text-align: center;
    color: #4caf50;
    font-size: 1.3rem;
    margin-bottom: 30px;
    font-style: italic;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.05);
}

/* Form Label Styling */
label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #e65c54;
    font-size: 1.1rem;
}

/* Input and Select Fields Styling */
input, select, textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 10px;
    border: 2px solid #ffcccb;
    box-sizing: border-box;
    font-family: 'Comic Sans MS', Arial, sans-serif;
    background: linear-gradient(145deg, #fff, #f0f8ff);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    font-size: 1rem;
}

input[type="text"], input[type="email"], textarea {
    background: linear-gradient(145deg, #fff, #f0f8ff);
}

textarea {
    height: 120px;
    resize: vertical;
}

/* Dropdown Menu Styling */
select {
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23e65c54" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
    width: 100%;
    max-width: 300px;
}

/* Specific styling for the style dropdown */
#style {
    max-width: 300px;
}

/    max-width: 300px;
}

/* Word Count Styling */
#word-count, #custom-style-count {
    font-size: 0.9rem;
    color: #4caf50;
    text-align: right;
    margin-top: -15px;
    margin-bottom: 20px;
    font-style: italic;
}

/* Button Styling */
button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(145deg, #e65c54, #ff8c7f);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.3rem;
    font-family: 'Fredoka One', cursive;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
    background: linear-gradient(145deg, #d14f48, #e65c54);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

button:disabled {
    background: linear-gradient(145deg, #b0b0b0, #d0d0d0);
    color: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    opacity: 0.7;
}

/* Error Message Styling */
.error-message {
    display: block;
    color: #e65c54;
    font-size: 0.9rem;
    margin-top: -15px;
    margin-bottom: 20px;
    font-style: italic;
}

/* Response Message Styling */
#response-message {
    margin-top: 20px;
    text-align: center;
    font-weight: bold;
    font-size: 1.2rem;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
}

/* Queue Status Message Styling */
#queue-status-message {
    text-align: center;
    font-size: 1.1rem;
    margin: 20px 0;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    font-family: 'Fredoka One', cursive;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

/* Specific states for queue status */
#queue-status-message[style*="color: #4CAF50"] {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4caf50;
}

#queue-status-message[style*="color: #e65c54"] {
    background: rgba(230, 92, 84, 0.1);
    border-color: #e65c54;
}

#queue-status-message[style*="color: red"] {
    animation: pulse 1.5s infinite;
    background: rgba(255, 0, 0, 0.1);
    border-color: red;
}

/* Interactive Elements for Kids */
input:hover, select:hover, textarea:hover {
    border-color: #4caf50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #e65c54;
    box-shadow: 0 0 10px rgba(230, 92, 84, 0.5);
}

/* Additional Playful Elements */
.container::before {
    content: '✨';
    display: block;
    font-size: 3rem;
    color: #e65c54;
    text-align: center;
    margin-bottom: -20px;
    position: relative;
    top: -40px;
}

.container::after {
    content: '🌟';
    position: absolute;
    font-size: 2rem;
    color: #ffd700;
    top: -20px;
    right: -20px;
    animation: sparkle 2s infinite;
}

/* Loading Bar Container */
#loading-bar {
    text-align: center;
    margin-top: 20px;
    position: relative;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Spinning Magical Cube */
.loading-cube {
    width: 50px;
    height: 50px;
    background: linear-gradient(45deg, #e65c54, #ffd700);
    border-radius: 10px;
    margin: 0 auto 15px;
    animation: spinCube 2s infinite ease-in-out, glow 1.5s infinite alternate;
    position: relative;
    transform-style: preserve-3d;
}

/* Progress Bar Container */
.progress-container {
    width: 80%;
    max-width: 400px;
    height: 20px;
    background: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto;
    position: relative;
    border: 2px solid #ffd700;
}

/* Progress Bar (Indeterminate Animation) */
.progress-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, #e65c54, #4caf50, #ffd700);
    border-radius: 10px;
    animation: progressIndeterminate 3s infinite ease-in-out;
    position: relative;
}

/* Sparkles Overlay */
.sparkles {
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 40px;
    pointer-events: none;
}

.sparkles::before,
.sparkles::after {
    content: '✨';
    position: absolute;
    font-size: 1.5rem;
    color: #ffd700;
    animation: sparkleMove 2s infinite;
}

.sparkles::before {
    left: 20%;
    animation-delay: 0s;
}

.sparkles::after {
    left: 60%;
    animation-delay: 1s;
}

/* Loading Text */
.loading-text {
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    color: #e65c54;
    margin-top: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* Sparkle Animation */
@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* Required Field Indicator */
.required {
    color: #e65c54;
}

/* Border Animation */
@keyframes borderGlow {
    0%, 100% { border-color: #e65c54; }
    50% { border-color: #4caf50; }
}

/* Language Selector Styling */
.language-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

#language-btn {
    padding: 8px 12px;
    border-radius: 10px;
    border: 2px solid #e65c54;
    background: linear-gradient(145deg, #fff, #f0f8ff);
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    color: #e65c54;
    cursor: pointer;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23e65c54" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 150px;
}

#language-btn:hover {
    background: linear-gradient(145deg, #f0f8ff, #fff);
    box-shadow: 0 0 8px rgba(230, 92, 84, 0.3);
}

#language-btn:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

/* Story Display Styling */
.banner {
    background: linear-gradient(to right, #e65c54, #ffcc5c);
    color: #fff;
    text-align: center;
    padding: 30px 20px;
    border-bottom: 5px dashed #fff;
    position: relative;
}

.banner::before,
.banner::after {
    content: "✨";
    position: absolute;
    top: 15px;
    font-size: 2rem;
}

.banner::before {
    left: 20px;
}

.banner::after {
    right: 20px;
}

.banner h1 {
    font-family: 'Bubblegum Sans', cursive;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}

.banner h2 {
    margin-top: 10px;
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    font-weight: normal;
    color: #fff9e6;
}

.content {
    padding: 40px 30px;
}

.content > a > img {
    display: block;
    margin: 0 auto 30px;
    max-width: 100%;
    border-radius: 15px;
    border: 4px solid #ffcc5c;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chapter {
    margin-bottom: 40px;
    background: rgba(255, 245, 230, 0.8);
    border-radius: 15px;
    padding: 20px;
    animation: fadeIn 1s ease-in both;
}

.chapter:nth-child(1) { animation-delay: 0.2s; }
.chapter:nth-child(2) { animation-delay: 0.4s; }
.chapter:nth-child(3) { animation-delay: 0.6s; }
.chapter:nth-child(4) { animation-delay: 0.8s; }
.chapter:nth-child(5) { animation-delay: 1.0s; }
.chapter:nth-child(6) { animation-delay: 1.2s; }
.chapter:nth-child(7) { animation-delay: 1.4s; }

.chapter h2 {
    color: #e65c54;
    font-family: 'Bubblegum Sans', cursive;
    font-size: clamp(1.5rem, 4vw, 1.8rem);
    text-align: center;
    border-bottom: 2px dotted #ffcc5c;
    padding-bottom: 12px;
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.chapter h2:hover {
    color: #d14f48;
}

.chapter img {
    display: block;
    margin: 0 auto 20px;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 3px solid #ffcc5c;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.chapter img:hover {
    transform: scale(1.02);
}

.chapter p {
    text-align: justify;
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    color: #444;
    padding: 0 10px;
    font-family: 'Patrick Hand', cursive;
}

.footer {
    background: linear-gradient(to right, #6b48ff, #00ddeb);
    color: #fff;
    text-align: center;
    padding: 20px;
    border-top: 5px dashed #fff;
    font-size: 1.1rem;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.share-btn {
    background: #e65c54;
    color: #fff;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.share-btn:hover {
    background: #d14f48;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Policy Content Styling */
.policy-content {
    padding: 20px 30px;
    font-family: 'Patrick Hand', cursive;
    font-size: 1.125rem;
    color: #444;
    line-height: 1.6;
}

.policy-content p {
    margin-bottom: 15px;
}

.policy-content ul {
    list-style-type: none;
    padding-left: 0;
    margin-bottom: 15px;
}

.policy-content li {
    margin-bottom: 10px;
}

.policy-content li strong {
    color: #e65c54;
    font-family: 'Fredoka One', cursive;
}

.policy-content ul ul {
    list-style-type: disc;
    padding-left: 20px;
    margin-top: 5px;
}

.policy-content ul ul li {
    margin-bottom: 5px;
}

.policy-footer {
    text-align: center;
    padding: 20px;
    background: linear-gradient(to right, #e65c54, #ffcc5c);
    color: #fff;
    border-top: 3px dashed #fff;
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
}

.back-button {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(145deg, #ffd700, #ffcc5c);
    color: #e65c54;
    border: 2px solid #e65c54;
    border-radius: 12px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    text-decoration: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    margin-bottom: 15px;
}

.back-button:hover {
    background: linear-gradient(145deg, #ffcc5c, #ffd700);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
    color: #d14f48;
}

.back-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Animation for chapters */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animations for Loading Bar */
@keyframes spinCube {
    0% { transform: rotate(0deg) rotateX(0deg) rotateY(0deg); }
    50% { transform: rotate(180deg) rotateX(180deg) rotateY(180deg); }
    100% { transform: rotate(360deg) rotateX(360deg) rotateY(360deg); }
}

@keyframes glow {
    0% { box-shadow: 0 0 5px #e65c54; }
    100% { box-shadow: 0 0 15px #ffd700; }
}

@keyframes progressIndeterminate {
    0% { transform: translateX(-100%) scaleX(0.5); }
    50% { transform: translateX(50%) scaleX(1); }
    100% { transform: translateX(200%) scaleX(0.5); }
}

@keyframes sparkleMove {
    0% { opacity: 0; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-20px); }
    100% { opacity: 0; transform: translateY(0); }
}

/* Pulse Animation for Queue Full */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Recent Stories Link Styling */
.recent-stories-link {
    text-align: center;
    margin-top: 30px;
    margin-bottom: 20px;
}

#recent-stories-btn {
    display: inline-block;
    padding: 12px 25px;
    background: linear-gradient(145deg, #ffd700, #ffcc5c);
    color: #e65c54;
    border: 3px solid #e65c54;
    border-radius: 15px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    text-decoration: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#recent-stories-btn:hover {
    background: linear-gradient(145deg, #ffcc5c, #ffd700);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
    color: #d14f48;
}

#recent-stories-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Homepage Link Styling */
.homepage-link {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

#homepage-btn {
    display: inline-block;
    padding: 12px 25px;
    background: linear-gradient(145deg, #ffd700, #ffcc5c);
    color: #e65c54;
    border: 3px solid #e65c54;
    border-radius: 15px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    text-decoration: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#homepage-btn:hover {
    background: linear-gradient(145deg, #ffcc5c, #ffd700);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
    color: #d14f48;
}

#homepage-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Glowing star effect */
#recent-stories-btn::before, #homepage-btn::before {
    content: '🌟';
    position: absolute;
    top: -10px;
    left: -20px;
    font-size: 2rem;
    color: rgba(255, 215, 0, 0.7);
    opacity: 0;
    animation: starGlow 2s infinite ease-in-out;
}

#recent-stories-btn::after, #homepage-btn::after {
    content: '🌟';
    position: absolute;
    bottom: -10px;
    right: -20px;
    font-size: 2rem;
    color: rgba(255, 215, 0, 0.7);
    opacity: 0;
    animation: starGlow 2s infinite ease-in-out 1s;
}

/* Star glow animation */
@keyframes starGlow {
    0% { opacity: 0; transform: translateX(0); }
    50% { opacity: 1; transform: translateX(10px); }
    100% { opacity: 0; transform: translateX(20px); }
}

/* Footer Links Styling */
.container a {
    color: #e65c54;
    text-decoration: none;
    font-family: 'Patrick Hand', cursive;
    font-size: 1rem;
    transition: color 0.3s ease;
}

.container a:hover {
    color: #d14f48;
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        max-width: 90%;
        padding: 20px;
    }
    #story-display .container {
        max-width: 90%;
    }
    .policy-container {
        max-width: 90%;
        margin: 20px auto;
        padding: 20px;
    }
    h1 {
        font-size: 2rem;
    }
    h2 {
        font-size: 1.5rem;
    }
    .subtitle {
        font-size: 1.1rem;
    }
    button {
        font-size: 1.1rem;
        padding: 12px;
    }
    #style, #language-btn {
        max-width: 100%;
    }
    .content {
        padding: 20px;
    }
    .chapter {
        padding: 15px;
    }
    .banner {
        padding: 20px 15px;
    }
    .share-btn {
        padding: 10px 25px;
        font-size: 1rem;
    }
    .progress-container {
        width: 90%;
    }
    .loading-cube {
        width: 40px;
        height: 40px;
    }
    .loading-text {
        font-size: 1rem;
    }
    #queue-status-message {
        font-size: 1rem;
        margin: 15px 0;
    }
    #recent-stories-btn, #homepage-btn {
        font-size: 1.1rem;
        padding: 10px 20px;
    }
    .policy-content {
        font-size: 1rem;
        padding: 15px 20px;
    }
    .policy-footer {
        font-size: 1rem;
        padding: 15px;
    }
    .back-button {
        font-size: 1rem;
        padding: 8px 15px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    .policy-container {
        padding: 15px;
    }
    h1 {
        font-size: 1.8rem;
    }
    h2 {
        font-size: 1.3rem;
    }
    .subtitle {
        font-size: 1rem;
    }
    label {
        font-size: 1rem;
    }
    input, select, textarea {
        padding: 10px;
        font-size: 0.9rem;
    }
    button {
        font-size: 1rem;
        padding: 10px;
    }
    .loading-cube {
        width: 30px;
        height: 30px;
    }
    .loading-text {
        font-size: 0.9rem;
    }
    #queue-status-message {
        font-size: 0.9rem;
        margin: 10px 0;
    }
    #recent-stories-btn, #homepage-btn {
        font-size: 1rem;
        padding: 8px 15px;
    }
    .policy-content {
        font-size: 0.9rem;
        padding: 10px 15px;
    }
    .policy-footer {
        font-size: 0.9rem;
        padding: 10px;
    }
    .back-button {
        font-size: 0.9rem;
        padding: 6px 12px;
    }
    .ad-section {
        margin: 20px 0;
        text-align: center;
    }
    /* Ensure ads are responsive */
    .adsbygoogle {
        max-width: 100%;
    }
    /* Optional: Add a label above the ad */
    .ad-section::before {
        content: "Advertisement";
        display: block;
        font-size: 12px;
        color: #666;
        margin-bottom: 5px;
    }
}
