/* styles.css */

/* --- General & Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&display=swap');

:root {
    /* Slightly refined palette with smooth, non-jarring blends */
    --primary-gradient: linear-gradient(135deg, #5b6ee1 0%, #7a5eb6 100%);
    --secondary-gradient: linear-gradient(135deg, #eea0ff 0%, #f4717f 100%);
    --accent-gradient: linear-gradient(135deg, #57b3ff 0%, #53f3ff 100%);
    --success-gradient: linear-gradient(135deg, #46e68c 0%, #3ef0d3 100%);
    --warning-gradient: linear-gradient(135deg, #fb87a3 0%, #ffe071 100%);
    --dark-gradient: linear-gradient(135deg, #27384b 0%, #33455e 100%);
    --light-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--light-bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}

/* --- Utility Classes --- */
.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

.animate-slide-in-left {
    animation: slideInLeft 0.6s ease-out;
}

.animate-slide-in-right {
    animation: slideInRight 0.6s ease-out;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* --- Header & Hero Banner --- */
.brand-gradient {
    /* Layered gradient with subtle vignette for depth */
    background: 
        radial-gradient(120% 140% at 0% 0%, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0) 60%),
        radial-gradient(120% 140% at 100% 0%, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 60%),
        var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.navbar-brand {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: white !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-nav .nav-link {
    color: white !important;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
}

.navbar-nav .nav-link:hover {
    color: rgba(255, 255, 255, 0.9) !important;
    transform: translateY(-2px);
}

.navbar-nav .nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 50%;
    background-color: white;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.navbar-nav .nav-link:hover::after {
    width: 100%;
}

/* --- Enhanced Cards --- */
.card {
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    background: var(--card-bg);
    overflow: hidden;
}

.card-interactive {
    transition: all 0.3s ease;
    cursor: pointer;
}

.card-interactive:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

/* --- Story Setup Specific Styles --- */
.story-setup-container {
    background: linear-gradient(135deg, #6b62ea 0%, #8a59ba 100%);
    min-height: 100vh;
    padding: 2rem 0;
}

.story-setup-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* When the story is being displayed, remove the white frame card */
.story-setup-container.story-active .story-setup-card {
    background: transparent;
    border: none;
    box-shadow: none;
}

.story-info-section {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.story-info-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/><circle cx="50" cy="10" r="0.5" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    pointer-events: none;
}

.story-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: var(--shadow-md);
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.story-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

/* --- Enhanced Form Styles --- */
.form-section {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.settings-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-md);
}

.form-section:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.form-section h4 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.form-section h4::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

.form-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control, .form-select {
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-control:focus, .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
    transform: translateY(-1px);
}

.form-control::placeholder {
    color: #a0aec0;
    font-style: italic;
}

/* --- Student Entry Styles --- */
.student-entry {
    background: #f7fafc;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.student-entry::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-gradient);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.student-entry:hover::before {
    transform: scaleY(1);
}

.student-entry:hover {
    border-color: #667eea;
    transform: translateX(5px);
    box-shadow: var(--shadow-md);
}

.remove-student-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-student-btn:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: var(--shadow-lg);
}

/* --- Enhanced Buttons --- */
.btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease;
    border: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.btn-outline-secondary {
    background: white;
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.btn-outline-secondary:hover {
    background: var(--light-bg);
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 16px;
}

/* --- Story Display Styles --- */
.story-display-area {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 24px;
    padding: 3rem;
    color: white;
    position: relative;
    overflow: hidden;
    min-height: 60vh;
    box-shadow: var(--shadow-xl);
}

/* Story Header and Controls */
.story-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 1.5rem;
    text-align: center;
}

.story-display-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-align: center;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Bottom Navigation Controls */
.story-bottom-controls {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 1.5rem;
}

.story-bottom-controls .btn {
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    font-weight: 500;
}

.story-bottom-controls .btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Progress Bar Styling */
.story-progress-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 1rem;
}

.progress {
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.6s ease;
    background: linear-gradient(90deg, #fff 0%, #f8f9fa 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Story Statistics */
.story-stats {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-item {
    padding: 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.stat-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.stat-item h5 {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #fff;
}

.stat-item small {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.stat-item i {
    color: rgba(255, 255, 255, 0.9);
}

/* Enhanced Story Output */
.story-output {
    background: #ffffff;
    color: #1f2937; /* dark gray for comfortable reading */
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    font-size: 1.1rem;
    line-height: 1.8;
    position: relative;
    max-width: 800px; /* wider column for less receipt-like feel */
    margin-left: auto;
    margin-right: auto;
}

.story-output::before {
    content: none; /* remove light overlay on text container */
}

.story-output p {
    margin-bottom: 1rem;
    animation: fadeInUp 0.6s ease-out;
    position: relative;
    z-index: 1;
}

/* Enhanced Choice Buttons */
.story-choice-btn {
    /* Light, purple-tinted base (between original purple and white) */
    background: linear-gradient(135deg, #f4efff 0%, #efe9ff 55%, #ebf0ff 100%),
                linear-gradient(135deg, rgba(102,126,234,0.22) 0%, rgba(118,75,162,0.18) 100%);
    background-blend-mode: normal, multiply;
    backdrop-filter: blur(8px);
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 1.5rem 2rem;
    color: #0f172a; /* darker text for readability */
    font-weight: 600;
    font-size: 1.1rem;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease;
    text-align: left;
    position: relative;
    z-index: 0; /* establish stacking context so overlays can sit behind text */
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06),
                inset 0 1px 0 rgba(255,255,255,0.55), /* top glossy edge */
                inset 0 -12px 24px rgba(102,126,234,0.10); /* bottom glow */
}

.story-choice-btn::before {
    /* Soft inner highlight to suggest glassy surface */
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.15) 40%, rgba(255,255,255,0.05) 100%);
    pointer-events: none;
    z-index: 0;
}

.story-choice-btn::after {
    /* Iridescent sheen behind content; stronger but non-distracting */
    content: '';
    position: absolute;
    inset: -1px;
    background:
        radial-gradient(120% 80% at 10% 0%, rgba(255,255,255,0.65) 0%, rgba(255,255,255,0.18) 42%, rgba(255,255,255,0) 72%),
        radial-gradient(120% 80% at 90% 0%, rgba(126,144,255,0.22) 0%, rgba(126,144,255,0.08) 48%, rgba(126,144,255,0) 78%),
        radial-gradient(120% 80% at 0% 100%, rgba(195,150,255,0.18) 0%, rgba(195,150,255,0.06) 50%, rgba(195,150,255,0) 80%);
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.25s ease, filter 0.25s ease;
    z-index: 0;
}

.story-choice-btn:hover::after {
    opacity: 0.8;
    filter: saturate(1.1) brightness(1.02);
}

.story-choice-btn:hover {
    background: linear-gradient(135deg, #f1eaff 0%, #ebe5ff 50%, #e7edff 100%),
                linear-gradient(135deg, rgba(102,126,234,0.28) 0%, rgba(118,75,162,0.22) 100%);
    background-blend-mode: normal, multiply;
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255,255,255,0.65),
                inset 0 -16px 28px rgba(102,126,234,0.16);
    border-color: #d3d9e3;
    color: #111827; /* force dark text even on hover */
}

/* Ensure inner text elements stay readable on hover */
.story-choice-btn .choice-text,
.story-choice-btn .choice-destination,
.story-choice-btn .choice-number {
    color: inherit;
}

/* Ensure button contents remain above overlays */
.story-choice-btn > * { position: relative; z-index: 1; }

/* Removed sweeping animation to avoid distraction */

/* Story Choices Container */
.story-choices {
    display: grid;
    gap: 1rem;
    margin-top: 2rem;
    max-width: 800px; /* align with story text width */
    margin-left: auto;
    margin-right: auto;
}

/* Choice Number Indicator */
.choice-number {
    background: var(--primary-gradient);
    color: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    border: none;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.choice-text {
    flex-grow: 1;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Destination page hint on choice buttons */
.choice-destination {
    margin-left: auto;
    color: #6c757d; /* muted gray */
    font-size: 0.95rem;
    white-space: nowrap;
}

/* Subtle current page indicator inside story output */
.page-badge {
    position: absolute;
    top: 10px;
    right: 12px;
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Story Text */
.story-text {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 0;
    text-indent: 2em;
    font-family: 'Merriweather', Georgia, serif;
}

/* Story Display Background Pattern */
.story-display-area::before {
    content: none; /* remove subtle dot pattern to avoid ghost circles */
}

/* Story Display Title */
.story-display-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-align: center;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Story End Screen */
.story-end {
    text-align: center;
    padding: 3rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeInUp 0.8s ease-out;
}

.story-end h4 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, #fff, #f8f9fa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Loading Spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .story-display-area {
        padding: 2rem 1.5rem;
        min-height: 50vh;
    }
    
    .story-display-title {
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }
    
    .story-output {
        padding: 1.5rem;
        font-size: 1rem;
        max-width: 100%;
    }
    
    .story-choice-btn {
        padding: 1.25rem 1.5rem;
        font-size: 1rem;
    }
    
    .story-controls {
        text-align: center;
        margin-top: 1rem;
    }
    
    .story-controls .btn {
        margin: 0.25rem;
    }
    
    .stat-item {
        margin-bottom: 1rem;
    }
}

/* --- Helper Classes --- */
.section-space {
    padding: 80px 0;
}

.text-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-effect {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}