/* ==========================================================================
   Base & Reset Styles
   ========================================================================== */

/* Reset margins/paddings on HTML and set base typography and colors on Body */
html {
    margin: 0;
    padding: 0;
}

body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background-color: #e6f7ff; /* light blue page background */
    color: #000000;
}

/* Hide honeypot anti-spam field */
.hidden {
    display: none !important;
    position: absolute !important;
    left: -9999px;
    visibility: hidden;
    opacity: 0;
    height: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ==========================================================================
   Layout Structure
   ========================================================================== */

/* Main content container */
.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    background-color: #ffffff; /* main content background */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    padding: 0 15px;
    box-sizing: border-box;
}

/* Wraps main content and advertisement for responsive layout */
.content-wrapper {
    display: flex;
    flex-direction: column; /* mobile default (stacked) */
    padding: 20px 0;
}

/* Primary content area */
main {
    flex-grow: 1;
}

/* Advertisement block */
.advertisement {
    background-color: #f0f5f5;
    padding: 15px;
    margin-top: 20px;
    border-left: 1px solid #cce6ff;
    border-radius: 5px;
    text-align: center;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

header {
    background-color: #FECA39;
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 0;
    overflow: hidden; /* hides fractional bleed */
}

/* Header image/picture styling (reconciled conflicting definitions) */
header picture,
header img {
    display: block;
    width: 100%;
    max-width: 960px; /* cap width */
    height: auto;
    margin: 0 auto; /* center horizontally */
    padding: 0;
    /* Removed the 101vw and negative margin, as it's typically for full-bleed
       backgrounds and conflicts with max-width: 960px in the container setup.
       This version keeps it contained and centered. */
}

/* ==========================================================================
   Adlib Components (Header Box, Story, Forms)
   ========================================================================== */

#storyTitle {
    display: block;
    text-align: center;
    font-size: 1.5rem;
    margin-top: 1rem;
    color: #003366;
    font-weight: bold;
}

/* Box for ID/Meta info above the story/form */
.adlib-header-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    border: 2px solid #7cb0e3;
    border-radius: 12px;
    background-color: #bdd8f2;
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.adlib-header-box .story-meta {
    display: flex;
    gap: 0.5rem;
}

.adlib-header-box .story-size {
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    background-color: #e3f0fa;
    border: 2px solid #7cb0e3;
    font-weight: 500;
}

.badge {
    background-color: #f0f8ff;
    color: #003366;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: bold;
    border: 1px solid #7cb0e3;
}

/* Display for the adlib number */
#adlibNumber {
    /* Note: '2.5 rem' had a space, corrected to '2.5rem' */
    font-size: 1.4rem;
    font-weight: bold;
}

/* Form structure */
#adlibForm {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

/* General text input styling */
#adlibForm input[type="text"] {
    padding: 10px;
    font-size: 1rem;
    border: 2px solid #cce6ff;
    border-radius: 5px;
}

#adlibForm input[type="text"]:focus {
    border-color: #007acc;
    outline: none;
}

/* Input field container for text/button groups */
.input-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.input-container input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.5rem;
    font-size: 1rem;
    box-sizing: border-box;
}

.input-container .random-btn {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    background-color: #e3f0fa;
    border: 2px solid #7cb0e3;
    color: #003366;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.1s ease;
}

/* Specific styling for the Adlib ID input (if used in the form) */
#adlibIdInput {
    width: 60px;
}

/* Story display container */
#storyContainer {
    display: none;
    border: 2px solid #7cb0e3;
    background-color: #f9f9f9;
    border-radius: 10px;
    padding: 15px 20px;
    margin-top: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

#completedStory {
    white-space: pre-wrap;
    line-height: 1.6;
    color: #000;
}

/* ==========================================================================
   Buttons & Links
   ========================================================================== */

/* Generic button styling for form submission */
#adlibForm button {
    padding: 10px;
    font-size: 1rem;
    background-color: #007acc;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
}

#adlibForm button:hover {
    background-color: #00509e;
}

/* Fetch by ID section layout */
.fetch-by-id {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

/* Styling for fetch ID input field */
.fetch-by-id input[type="number"] {
    flex: 1 1 auto;
    min-width: 100px;
    padding: 0.35rem 0.5rem;
    font-size: 1rem;
}

.fetch-input {
    display: flex;
    gap: 5px;
}

/* Styling for buttons in the fetch-by-id section */
.fetch-by-id button {
    flex: 0 0 auto;
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
}

/* New Story / PDF Buttons (general styling for smaller buttons) */
#fetchAdlibByIdBtn,
#newStoryBtn {
    padding: 8px 13px;
    font-size: 0.95rem;
    border-radius: 8px;
    cursor: pointer;
    margin-left: 5px;
}

/* Complete Story Button (larger, stylized) */
#completeStoryBtn {
    position: relative;
    width: 280px;
    height: 50px;
    display: block;
    margin: 20px auto;
    border: none;
    outline: none;
    color: #fff;
    background: #0d0d0d;
    cursor: pointer;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    z-index: 0;
    overflow: hidden;
    transition: transform 0.1s ease;
}

#completeStoryBtn:active {
    transform: scale(0.97);
    background: #000;
}

/* Button Shine Effect */
#completeStoryBtn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(120deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0.05) 100%);
    transform: skewX(-25deg);
    animation: shine 3s ease-in-out infinite;
}

@keyframes shine {
    0% {
        left: -75%;
    }

    50% {
        left: 125%;
    }

    100% {
        left: 125%;
    }
}

/* Download PDF Button (larger, stylized with glow) */
#downloadPDF {
    width: 280px;
    height: 50px;
    border: none;
    outline: none;
    color: #fff;
    background: #111;
    cursor: pointer;
    position: relative;
    z-index: 0;
    border-radius: 10px;
    font-size: 16px;
    margin: 20px auto;
    display: block;
}

#downloadPDF:after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: #111;
    border-radius: 10px;
    z-index: -1;
}

/* PDF Button Glowing Effect */
#downloadPDF:before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    background: linear-gradient(45deg,
        #ff0000,
        #ff7300,
        #fffb00,
        #48ff00,
        #00ffd5,
        #002bff,
        #7a00ff,
        #ff00c8,
        #ff0000);
    background-size: 400%;
    z-index: -1;
    filter: blur(8px) brightness(1.5);
    opacity: 1;
    border-radius: 10px;
    animation: glowing 20s linear infinite;
}

@keyframes glowing {
    0% {
        background-position: 0 0;
    }

    50% {
        background-position: 400% 0;
    }

    100% {
        background-position: 0 0;
    }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  text-align: center;
  padding: 15px 0;
  margin-top: 40px;
  background-color: black;
  color: white;
  font-size: 1rem;
  border-top: 1px solid #ccc;
  line-height: 1.8;
}

.site-footer .footer-links {
  display: block;
  margin-top: 8px;
  font-size: 1.1rem;
  font-weight: bold;
}

.site-footer a:link,
.site-footer a:visited {
  color: #cce6ff;
  text-decoration: none;
  margin: 0 1rem;
  transition: color 0.3s ease;
}



/* ==========================================================================
   Media Queries (Responsiveness)
   ========================================================================== */

/* Tablet and larger screens (Content Wrapper Layout) */
@media (min-width: 768px) {
    .content-wrapper {
        flex-direction: row; /* Side-by-side layout */
    }

    main {
        flex: 3; /* Main content takes up more space */
        padding-right: 20px;
    }

    .advertisement {
        flex: 1; /* Advertisement section */
        margin-top: 0;
    }

    /* Adjust button spacing in desktop layout */
    #fetchAdlibByIdBtn {
        margin-right: 20px;
    }

    .input-container {
        width: 100%;
    }
}

/* Larger desktop screens (Minor input adjustment) */
@media (min-width: 1024px) {
    .input-container {
        margin-left: 0;
        margin-right: 0;
    }
}

/* Small mobile screens (Max width 480px) */
@media (max-width: 480px) {
    /* Stack fetch-by-id elements vertically */
    .fetch-by-id {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.25rem;
    }

    .fetch-by-id input[type="number"],
    .fetch-by-id button {
        width: 80%;
        max-width: 200px;
    }

    /* Stack adlib-header-box elements vertically */
    .adlib-header-box {
        flex-direction: column;
        align-items: center;
    }

    .adlib-header-box .story-meta {
        flex-direction: row;
        margin-top: 0.25rem;
    }

    /* Stack input container elements vertically */
    .input-container {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .input-container input[type="text"] {
        width: 100%;
        flex: 0 0 auto;
    }

    .input-container .random-btn {
        width: 100%;
        font-size: 1rem;
        padding: 0.6rem;
        flex-shrink: 0;
    }
}

/* Extra small mobile screens (Max width 360px) */
@media (max-width: 360px) {
    .fetch-by-id input[type="number"],
    .fetch-by-id button,
    #newStoryBtn {
        width: 80%;
        max-width: 220px;
    }
}

/* === FAQ PAGE STYLES === */
.faq-container {
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  padding: 1.5rem 2rem;
  margin-top: 2rem;
}

.faq-section {
  margin-top: 2rem;
}

.faq-section h2 {
  color: #0066cc;
  border-bottom: 2px solid #cce6ff;
  padding-bottom: 0.3rem;
  margin-bottom: 0.5rem;
}

.faq-container details {
  margin: 0.75rem 0;
  border: 1px solid #cce6ff;
  border-radius: 8px;
  background-color: #f9fcff;
  padding: 0.6rem 0.9rem;
  transition: all 0.2s ease;
}

.faq-container details:hover {
  background-color: #f1f8ff;
}

.faq-container summary {
  cursor: pointer;
  font-weight: bold;
  color: #004080;
  list-style: none;
}

.faq-container details[open] {
  background-color: #e6f3ff;
  border-color: #99ccff;
}

.faq-container details p {
  margin: 0.5rem 0 0.25rem 0;
  color: #333;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .faq-container {
    padding: 1rem;
  }
}