/*
Theme Name: FoxyTales Interactive Theme
Theme URI: https://amfoxy.com
Author: Antigravity AI
Description: A premium, state-of-the-art light pastel theme designed for FoxyTales (Interactive Child Tales Generator).
Version: 2.0.0
*/

:root {
    /* Theme color variables from React App */
    --color-surface: #fcf9f2;
    --color-on-surface: #1c1c18;
    --color-on-surface-variant: #54433b;
    --color-primary: #95491f;
    --color-primary-container: #ff9d6c;
    --color-primary-fixed: #ffdbcc;
    --color-primary-fixed-dim: #ffb693;
    --color-secondary: #316579;
    --color-secondary-container: #b4e7ff;
    --color-tertiary: #725c00;
    --color-tertiary-fixed: #ffe081;
    --color-mint-fixed: #a8e6cf;
    --color-deep-fox: #ff6b35;
    
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
    --shadow-clay-primary: inset -4px -4px 8px rgba(149, 73, 31, 0.4), inset 4px 4px 8px rgba(255, 255, 255, 0.4);
    --shadow-clay-secondary: inset -2px -2px 4px rgba(49, 101, 121, 0.2), inset 2px 2px 4px rgba(255, 255, 255, 0.6);
    --shadow-glow-primary: 0 0 15px rgba(255, 107, 53, 0.4);
    --shadow-glow-mint: 0 0 0 2px #a8e6cf;
}

/* Core reset & defaults wrapped in cascade layer to prevent overriding Tailwind utility classes */
@layer theme-reset {
    * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }
}

html, body {
    overflow-x: hidden !important;
}

body {
    background-color: var(--color-surface);
    color: var(--color-on-surface);
    font-family: "Nunito Sans", sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Fonts and Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: "Outfit", sans-serif;
    color: var(--color-on-surface);
    font-weight: 700;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Background Blurred Spheres */
.background-spheres {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}
.sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
}
.sphere-1 {
    top: 10%;
    left: 5%;
    width: 300px;
    height: 300px;
    background-color: var(--color-primary-fixed-dim);
}
.sphere-2 {
    bottom: 20%;
    right: 10%;
    width: 400px;
    height: 400px;
    background-color: var(--color-secondary-container);
}

/* Header & TopNavBar Navigation */
header.site-header {
    background: rgba(252, 249, 242, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0 0 40px 40px;
    box-shadow: var(--shadow-glass);
}

.header-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 20px;
    height: 96px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-group .logo-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-deep-fox);
    font-family: "Outfit", sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-icon {
    font-size: 2.2rem;
    transition: transform 0.3s ease;
}

.logo-link:hover .logo-icon {
    transform: rotate(15deg);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-links a {
    color: var(--color-on-surface-variant);
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.nav-links a:hover {
    color: var(--color-primary);
    transform: scale(1.05);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Language switcher */
.lang-switcher {
    display: flex;
    align-items: center;
    background: rgba(252, 249, 242, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 50px;
    padding: 4px;
    box-shadow: var(--shadow-clay-secondary);
    gap: 4px;
}

.lang-switcher a {
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-on-surface-variant);
    opacity: 0.6;
    transition: all 0.2s ease;
}

.lang-switcher a.active {
    background: white;
    color: var(--color-primary);
    opacity: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.lang-switcher a:hover:not(.active) {
    opacity: 0.9;
}

/* Premium Buttons */
.btn-start-magic, .btn-primary-clay {
    background: linear-gradient(135deg, #ff9d6c 0%, #ff6b35 100%);
    box-shadow: inset -4px -4px 8px rgba(149, 73, 31, 0.4), inset 4px 4px 8px rgba(255, 255, 255, 0.4), 0 4px 6px rgba(0,0,0,0.1);
    color: white;
    border-radius: 50px;
    padding: 10px 24px;
    font-family: "Outfit", sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    border: none;
}

.btn-start-magic:hover, .btn-primary-clay:hover {
    transform: scale(1.02);
    box-shadow: inset -2px -2px 4px rgba(149, 73, 31, 0.4), inset 2px 2px 4px rgba(255, 255, 255, 0.4), 0 0 20px rgba(255, 107, 53, 0.6);
    color: white;
}

.btn-primary-clay {
    padding: 16px 32px;
    font-size: 1.125rem;
}

/* Custom sleek Load More button */
#foxy-load-more-btn {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(8px);
    border: 1.5px solid rgba(149, 73, 31, 0.25);
    color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(149, 73, 31, 0.06);
    border-radius: 30px;
    padding: 12px 36px;
    font-family: "Outfit", sans-serif;
    font-size: 1rem;
    font-weight: 700;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transform: none;
}

#foxy-load-more-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    box-shadow: 0 6px 16px rgba(149, 73, 31, 0.2);
    transform: translateY(-2px);
}

#foxy-load-more-btn:active {
    transform: translateY(0);
}

.btn-secondary-clay {
    background: rgba(252, 249, 242, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: inset -2px -2px 4px rgba(49, 101, 121, 0.2), inset 2px 2px 4px rgba(255, 255, 255, 0.6), 0 4px 6px rgba(0,0,0,0.02);
    color: var(--color-secondary);
    border-radius: 50px;
    padding: 16px 32px;
    font-family: "Outfit", sans-serif;
    font-size: 1.125rem;
    font-weight: 700;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.btn-secondary-clay:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.02);
}

/* Glass Panels */
.glass-panel {
    background: rgba(252, 249, 242, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-glass);
}

/* Hero Section */
.hero-section {
    padding-top: 140px;
    min-height: 70vh;
}

.flex-hero {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 48px;
}

@media (max-width: 768px) {
    .flex-hero {
        flex-direction: column;
        text-align: center;
    }
}

.hero-content {
    flex: 1;
}

.hero-title {
    font-size: 3.5rem;
    color: var(--color-on-surface);
    margin-bottom: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem;
    }
}

.text-deep-fox {
    color: var(--color-deep-fox);
}

.relative-inline {
    position: relative;
    display: inline-block;
    font-weight: 700;
}

.star-badge {
    position: absolute;
    top: -12px;
    right: -24px;
    color: var(--color-tertiary-fixed);
    font-size: 1.5rem;
    filter: drop-shadow(0 0 5px rgba(255,224,129,0.8));
}

.subtitle {
    font-size: 1.25rem;
    color: var(--color-on-surface-variant);
    margin-bottom: 32px;
    line-height: 1.7;
}

.hero-buttons {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .hero-buttons {
        justify-content: center;
    }
}

.hero-artwork {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.hero-artwork::before {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    background: rgba(255, 219, 204, 0.2);
    border-radius: 50%;
    filter: blur(60px);
    z-index: -1;
    top: 10%;
}

.hero-image {
    width: 100%;
    max-width: 440px;
    object-contain: fit;
    filter: drop-shadow(0 20px 30px rgba(0,0,0,0.15));
}

/* Animations */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
    100% { transform: translateY(0px); }
}

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

.scroll-offset {
    scroll-margin-top: 120px;
}

/* Configurator Container */
.configurator-container {
    border-radius: 40px;
    padding: 48px;
    max-width: 896px;
    margin: 80px auto 0;
    position: relative;
    overflow: hidden;
}

.configurator-header {
    text-align: center;
    margin-bottom: 40px;
}

.configurator-header h2 {
    font-size: 2rem;
    font-weight: 700;
}

.configurator-header p {
    color: var(--color-on-surface-variant);
}

.configurator-form {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.form-group-custom {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.label-badge {
    font-family: "Nunito Sans", sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.label-badge span {
    color: var(--color-primary);
    font-size: 1.1rem;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-secondary);
    opacity: 0.7;
    font-size: 1.25rem;
}

.input-cute {
    width: 100%;
    border-radius: 24px;
    padding: 16px 16px 16px 48px;
    background-color: var(--color-surface);
    border: 1px solid rgba(135, 115, 106, 0.2);
    color: var(--color-on-surface);
    font-size: 1.1rem;
    outline: none;
    transition: all 0.2s ease;
}

.input-cute:focus {
    border-color: var(--color-mint-fixed);
    box-shadow: var(--shadow-glow-mint);
}

/* Age selector options */
.age-options-container {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.btn-age-select {
    padding: 12px 24px;
    border-radius: 50px;
    font-family: "Outfit", sans-serif;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: rgba(252, 249, 242, 0.6);
    color: var(--color-on-surface);
    cursor: pointer;
    box-shadow: var(--shadow-glass);
    transition: all 0.3s ease;
}

.btn-age-select:hover {
    background: rgba(255, 255, 255, 0.5);
}

.btn-age-select.active {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-clay-primary);
    transform: scale(1.05);
}

/* Setting Cards Selector */
.setting-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (min-width: 640px) {
    .setting-cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.setting-card-item {
    background: rgba(252, 249, 242, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-glass);
}

.setting-card-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow-primary);
}

.card-image-wrapper {
    aspect-ratio: 1 / 1;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 12px;
    position: relative;
}

.card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.setting-card-item:hover .card-image-wrapper img {
    transform: scale(1.1);
}

.selected-check {
    position: absolute;
    top: 8px;
    right: 8px;
    color: var(--color-primary-fixed-dim);
    filter: drop-shadow(0 0 8px rgba(255,182,147,0.8));
    font-size: 1.5rem;
}

.card-title-text {
    text-align: center;
    font-family: "Outfit", sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
    padding-bottom: 8px;
    color: var(--color-on-surface-variant);
}

.setting-card-item.active {
    border: 2px solid #ffb693;
    box-shadow: 0 0 20px rgba(255, 182, 147, 0.5);
    transform: translateY(-4px);
}

.setting-card-item.active .card-title-text {
    color: var(--color-on-surface);
}

/* Select element */
.select-wrapper {
    position: relative;
}

.select-cute {
    width: 100%;
    border-radius: 24px;
    padding: 16px 48px 16px 24px;
    background-color: var(--color-surface);
    border: 1px solid rgba(135, 115, 106, 0.2);
    color: var(--color-on-surface);
    font-size: 1.1rem;
    outline: none;
    appearance: none;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.select-cute:focus {
    border-color: var(--color-mint-fixed);
    box-shadow: var(--shadow-glow-mint);
}

.select-chevron {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-secondary);
    pointer-events: none;
}

.form-actions-submit {
    text-align: center;
    padding-top: 16px;
}

.btn-submit-generate {
    padding: 20px 48px;
    font-size: 1.125rem;
}

/* Features grid */
.features-section {
    margin-top: 120px;
}

.section-heading-custom {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 40px;
}

.features-grid-custom {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.feature-card-custom {
    border-radius: 24px;
    padding: 32px 24px;
    text-align: center;
}

.feat-icon-custom {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 16px;
}

.feature-card-custom h3 {
    font-size: 1.35rem;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.feature-card-custom p {
    font-size: 0.95rem;
    color: var(--color-on-surface-variant);
    line-height: 1.6;
}

/* Digital Bookshelf */
.library-header {
    margin-top: 120px;
    margin-bottom: 32px;
}

.library-subtitle {
    color: var(--color-on-surface-variant);
    margin-top: 4px;
}

.bookshelf-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
}

@media (min-width: 768px) {
    .bookshelf-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.book-container-perspective {
    perspective: 1000px;
    display: block;
    position: relative;
    text-decoration: none;
}

.book-container-perspective::after {
    content: '';
    display: block;
    height: 8px;
    background: linear-gradient(90deg, #e6d8c4 0%, #cfbfab 100%);
    border-radius: 4px;
    margin-top: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

.book-spine-layout {
    background: white;
    border-radius: 0 16px 16px 0;
    border-left: 5px solid rgba(0,0,0,0.15);
    padding: 4px;
    box-shadow: var(--shadow-glass);
    transition: transform 0.5s ease;
    transform-style: preserve-3d;
    box-shadow: inset 8px 0 10px -4px rgba(0,0,0,0.3), var(--shadow-glass);
}

.book-container-perspective:hover .book-spine-layout {
    transform: rotateY(-18deg) scale(1.05);
    box-shadow: inset 8px 0 10px -4px rgba(0,0,0,0.3), 0 20px 40px rgba(255, 182, 147, 0.4);
}

.book-cover-aspect {
    aspect-ratio: 3 / 4;
    border-radius: 0 12px 12px 0;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.book-cover-aspect img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-cover-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.3) 50%, transparent 100%);
}

.book-cover-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 16px;
    z-index: 2;
}

.book-cover-content h3 {
    color: white;
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.3;
}

.book-footer-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-tag {
    color: rgba(255,255,255,0.8);
    font-size: 0.75rem;
}

.play-btn-circle {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background-color 0.2s ease;
}

.play-btn-circle span {
    font-size: 1.1rem;
}

.book-container-perspective:hover .play-btn-circle {
    background: rgba(255, 255, 255, 0.4);
}

/* Add new book card layout */
.bg-placeholder {
    background-color: var(--color-surface-container);
    height: 100%;
}

.dashed-add-content {
    border: 2px dashed rgba(149, 73, 31, 0.3);
    border-radius: 12px;
    margin: 16px;
    height: calc(100% - 32px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.add-icon {
    color: var(--color-primary);
    font-size: 2.5rem;
}

.dashed-add-content p {
    font-family: "Outfit", sans-serif;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 1rem;
}

.empty-shelf-card {
    grid-column: 1 / -1;
    text-align: center;
    padding: 64px 32px;
    border-radius: 24px;
}

.empty-icon {
    font-size: 4rem;
    color: var(--color-secondary);
    margin-bottom: 16px;
}

/* Parent SEO Articles Section */
.landing-section-articles {
    margin-top: 120px;
    margin-bottom: 80px;
}

.articles-grid-custom {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 32px;
}

.article-card-premium {
    border-radius: 24px;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.article-cover-wrapper {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-bottom: 1px solid rgba(135,115,106,0.1);
}

.article-cover-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.article-card-premium:hover .article-cover-wrapper img {
    transform: scale(1.05);
}

.article-card-details {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.article-card-details h3 {
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.article-card-details h3 a {
    color: var(--color-on-surface);
}

.article-card-details h3 a:hover {
    color: var(--color-deep-fox);
}

.article-description {
    font-size: 0.92rem;
    color: var(--color-on-surface-variant);
    line-height: 1.6;
    margin-bottom: 24px;
    flex-grow: 1;
}

.btn-read-article {
    color: var(--color-secondary);
    font-weight: 700;
    font-size: 0.9rem;
}

.btn-read-article:hover {
    color: var(--color-deep-fox);
}

/* Standard Single Post / SEO Article detail view */
.single-post-article {
    border-radius: 24px;
    padding: 48px;
    margin-top: 120px;
}

.back-link {
    color: var(--color-secondary);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 24px;
}

.back-link:hover {
    color: var(--color-deep-fox);
    transform: translateX(-4px);
}

.post-title {
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 16px;
}

.post-meta {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--color-on-surface-variant);
    margin-bottom: 32px;
    border-bottom: 1px solid rgba(135,115,106,0.15);
    padding-bottom: 16px;
}

.post-thumbnail {
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 32px;
}

.post-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
}

.post-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--color-on-surface);
}

.post-content p {
    margin-bottom: 24px;
}

.post-content h2, .post-content h3 {
    color: var(--color-primary);
    margin-top: 40px;
    margin-bottom: 16px;
}

.post-content ul, .post-content ol {
    margin-left: 24px;
    margin-bottom: 24px;
}

.post-content li {
    margin-bottom: 8px;
}

/* Individual tale reader fallback */
.tale-fallback-content {
    border-radius: 24px;
    padding: 48px;
    margin-top: 120px;
}

.tale-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed rgba(135,115,106,0.2);
    padding-bottom: 24px;
    margin-bottom: 32px;
}

.tale-header h1 {
    font-size: 2rem;
    margin: 0;
}

.btn-download {
    background: white;
    border: 1px solid rgba(135, 115, 106, 0.2);
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 700;
    color: var(--color-primary);
    box-shadow: var(--shadow-clay-secondary);
}

.btn-download:hover {
    background: rgba(255,255,255,0.4);
    transform: scale(1.02);
}

.moral-banner {
    background-color: var(--color-mint-fixed);
    border-radius: 16px;
    padding: 20px;
    color: #1a6b3b;
    margin-bottom: 32px;
}

.moral-banner strong {
    display: block;
    margin-bottom: 4px;
}

.chapter-box {
    background: white;
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 32px;
    border: 1px solid rgba(255,182,147,0.3);
    box-shadow: var(--shadow-glass);
}

.chapter-title {
    color: var(--color-deep-fox);
    font-size: 1.35rem;
    margin-bottom: 16px;
}

.chapter-text {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 24px;
}

.illustration-container {
    background: var(--color-surface);
    border: 2px dashed var(--color-secondary-container);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.illustration-placeholder {
    color: var(--color-on-surface-variant);
    font-weight: 700;
    margin-bottom: 8px;
}

.illustration-prompt {
    font-family: monospace;
    font-size: 0.8rem;
    background: white;
    border: 1px solid rgba(135,115,106,0.15);
    padding: 8px 12px;
    border-radius: 8px;
    text-align: left;
    color: var(--color-secondary);
}

/* Category Collections lists */
.taxonomy-title-block {
    text-align: center;
    margin-top: 120px;
    margin-bottom: 48px;
}

.taxonomy-title-block h1 {
    font-size: 2.5rem;
}

/* Site Footer styling */
footer.site-footer {
    background-color: white;
    border-radius: 60px 60px 0 0;
    margin-top: 120px;
    padding: 48px 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.03);
    border-t: 1px solid #f3f0ea;
}

footer.site-footer p {
    text-align: center;
    color: var(--color-on-surface-variant);
    font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════════════
   PEDAGOGICAL UI ENHANCEMENTS
   ═══════════════════════════════════════════════════════════ */

/* ── 1. Ambient Sound Controller ─────────────────────────── */
.ambient-sound-controller {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ambient-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: rgba(252, 249, 242, 0.6);
    backdrop-filter: blur(12px);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-clay-secondary);
    position: relative;
}

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

.ambient-btn.playing {
    background: var(--color-mint-fixed);
    border-color: var(--color-mint-fixed);
    box-shadow: 0 0 12px rgba(168, 230, 207, 0.6);
}

.ambient-btn.playing .material-symbols-outlined {
    color: #1a6b3b;
}

.ambient-btn .material-symbols-outlined {
    font-size: 1.2rem;
    color: var(--color-on-surface-variant);
}

/* Sound wave animation for playing state */
.ambient-btn.playing::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--color-mint-fixed);
    animation: sound-wave 1.5s ease-out infinite;
    pointer-events: none;
}

@keyframes sound-wave {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* Ambient sound dropdown */
.ambient-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: rgba(252, 249, 242, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.3s ease;
}

.ambient-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ambient-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-on-surface);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.ambient-option:hover {
    background: rgba(168, 230, 207, 0.2);
}

.ambient-option.active {
    background: var(--color-mint-fixed);
    color: #1a6b3b;
}

.ambient-option .sound-emoji {
    font-size: 1.2rem;
}

/* ── 2. Page-Flip Transition for Chapters ────────────────── */
.chapter-flip-container {
    perspective: 1200px;
    overflow: visible;
}

.chapter-page {
    transform-style: preserve-3d;
    backface-visibility: hidden;
    animation: pageFlipIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes pageFlipIn {
    0% {
        transform: rotateY(-90deg) scale(0.95);
        opacity: 0;
    }
    40% {
        opacity: 1;
    }
    100% {
        transform: rotateY(0deg) scale(1);
        opacity: 1;
    }
}

@keyframes pageFlipOut {
    0% {
        transform: rotateY(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: rotateY(90deg) scale(0.95);
        opacity: 0;
    }
}

/* Page corner curl effect */
.chapter-box::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 28px 28px 0;
    border-color: transparent var(--color-surface) transparent transparent;
    z-index: 2;
    transition: border-width 0.3s ease;
}

.chapter-box {
    position: relative;
    overflow: hidden;
}

.chapter-box:hover::before {
    border-width: 0 36px 36px 0;
}

/* ── 3. Reading Progress Bar ─────────────────────────────── */
.reading-progress-bar {
    position: fixed;
    top: 96px; /* below header */
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-deep-fox) 0%, var(--color-tertiary-fixed) 50%, var(--color-mint-fixed) 100%);
    z-index: 99;
    transition: width 0.4s ease;
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 8px rgba(255, 107, 53, 0.4);
}

/* ── 4. Moral Badge Animation (Story Completion) ─────────── */
@keyframes badgeReveal {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
        opacity: 1;
    }
    70% {
        transform: scale(0.9) rotate(-5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

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

.moral-badge-earned {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    animation: badgeReveal 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.badge-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffe081, #ff9d6c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    box-shadow: 0 0 20px rgba(255, 224, 129, 0.6), 0 0 40px rgba(255, 224, 129, 0.3);
    position: relative;
}

.badge-icon::after {
    content: '✨';
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 1.2rem;
    animation: sparkle 1.5s ease-in-out infinite;
}

.badge-label {
    font-family: "Outfit", sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ── 5. Enhanced Chapter Transition ──────────────────────── */
@keyframes fadeSlideIn {
    0% { 
        opacity: 0; 
        transform: translateX(30px); 
    }
    100% { 
        opacity: 1; 
        transform: translateX(0); 
    }
}

@keyframes fadeSlideOut {
    0% { 
        opacity: 1; 
        transform: translateX(0); 
    }
    100% { 
        opacity: 0; 
        transform: translateX(-30px); 
    }
}

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

/* ── 6. Mobile Hamburger Nav ─────────────────────────────── */
.mobile-menu-divider,
.mobile-lang-container,
.mobile-cta-container {
    display: none !important;
}

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: rgba(252, 249, 242, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    color: var(--color-on-surface-variant);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-clay-secondary);
}

.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.mobile-menu-btn .material-symbols-outlined {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-start-magic-mobile {
    background: linear-gradient(135deg, #ff9d6c 0%, #ff6b35 100%);
    box-shadow: inset -4px -4px 8px rgba(149, 73, 31, 0.4), inset 4px 4px 8px rgba(255, 255, 255, 0.4), 0 4px 6px rgba(0,0,0,0.1);
    color: white !important;
    border-radius: 50px;
    padding: 12px 32px;
    font-family: "Outfit", sans-serif;
    font-size: 1rem;
    font-weight: 700;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    border: none;
    width: 100%;
    max-width: 280px;
    text-align: center;
}

.btn-start-magic-mobile:hover {
    transform: scale(1.02);
    box-shadow: inset -2px -2px 4px rgba(149, 73, 31, 0.4), inset 2px 2px 4px rgba(255, 255, 255, 0.4), 0 0 20px rgba(255, 107, 53, 0.6);
}

@media (max-width: 1024px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 72px;
        left: 0;
        right: 0;
        background: rgba(252, 249, 242, 0.96);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 24px 20px;
        gap: 18px;
        border-radius: 0 0 32px 32px;
        border-top: 1px solid rgba(149, 73, 31, 0.1);
        border-bottom: 4px solid var(--color-primary);
        box-shadow: 0 20px 40px rgba(149, 73, 31, 0.12);
        z-index: 99;
    }

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

    .nav-links.open {
        display: flex;
        animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .nav-links a {
        font-family: "Outfit", sans-serif;
        font-size: 1.1rem;
        font-weight: 600;
        padding: 12px 16px;
        width: 100%;
        text-align: center;
        border-radius: 12px;
        color: var(--color-on-surface-variant);
        transition: all 0.2s ease;
    }

    .nav-links a:hover {
        background: rgba(149, 73, 31, 0.05);
        color: var(--color-primary);
    }

    .mobile-menu-btn {
        display: flex;
    }

    .header-container {
        height: 72px;
    }

    .btn-start-magic {
        display: none;
    }

    /* Hide desktop lang switcher on mobile to prevent header row overflow */
    .header-actions .lang-switcher {
        display: none !important;
    }

    .logo-group .logo-link {
        font-size: 1.4rem;
    }
    
    .reading-progress-bar {
        top: 72px;
    }

    .mobile-menu-divider {
        display: block !important;
        width: 100%;
        height: 1px;
        background: rgba(149, 73, 31, 0.1);
        margin: 8px 0;
    }

    .mobile-lang-container {
        display: flex !important;
        justify-content: center;
        width: 100%;
        margin: 8px 0;
    }

    .mobile-cta-container {
        display: flex !important;
        justify-content: center;
        width: 100%;
        margin-top: 8px;
    }

    .tale-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}

/* ── Mobile reader (open book + interactive quest) ──────────
   Tighten the heavy desktop spacing so the story page reads
   comfortably on a phone. */
@media (max-width: 768px) {
    .tale-book,
    .tale-fallback-content {
        padding: 20px 16px;
        margin-top: 92px;
        border-radius: 18px;
    }
    .tale-header h1,
    .tale-header h2 {
        font-size: 1.5rem;
        line-height: 1.2;
    }
    .tale-header .btn-download,
    .tale-header .progress-badge {
        font-size: 0.85rem;
    }
    .chapter-box {
        padding: 18px 16px;
        margin-bottom: 24px;
    }
    .chapter-title {
        font-size: 1.15rem;
    }
    .chapter-text {
        font-size: 1.02rem;
        line-height: 1.6;
    }
    .moral-banner {
        padding: 16px;
        margin-bottom: 24px;
    }
    /* Keep the scratch card a touch-friendly size on phones. */
    .scratch-card-container {
        aspect-ratio: 4 / 3;
        max-height: 56vh;
    }
    .btn-choice {
        padding: 14px 16px;
        font-size: 0.98rem;
    }
    /* Reader header action row can wrap if the read-aloud + progress are wide. */
    .tale-header > div:last-child {
        flex-wrap: wrap;
    }
}

/* ── 7. Interactive Choice Buttons ───────────────────────── */
.btn-choice {
    background: rgba(252, 249, 242, 0.8);
    backdrop-filter: blur(12px);
    border: 2px solid rgba(255, 182, 147, 0.3);
    border-radius: 16px;
    padding: 16px 20px;
    font-family: "Nunito Sans", sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-on-surface);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    line-height: 1.4;
}

.btn-choice:hover {
    background: var(--color-primary-fixed);
    border-color: var(--color-primary-fixed-dim);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 107, 53, 0.2);
}

.btn-choice:active {
    transform: scale(0.98);
}

.choices-buttons-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@keyframes animate-pulse-subtle-kf {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 157, 108, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(255, 157, 108, 0); }
}

.animate-pulse-subtle {
    animation: animate-pulse-subtle-kf 2s ease-in-out infinite;
}

/* ── 8. Scratch Card Styles ──────────────────────────────── */
.scratch-card-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-glass);
}

.scratch-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    border-radius: 16px;
    z-index: 10;
}

.scratch-canvas:active {
    cursor: grabbing;
}

/* Reader layout inside chapter */
.reader-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.illustration-wrapper {
    max-width: 100%;
}

@media (min-width: 768px) {
    .reader-layout {
        flex-direction: row;
        gap: 32px;
    }
    .story-content {
        flex: 1;
    }
    .illustration-wrapper {
        flex: 0 0 40%;
        max-width: 40%;
    }
}

/* Tale book page styling */
.tale-book {
    border-radius: 24px;
    padding: 48px;
    margin-top: 120px;
    position: relative;
}

/* ── 9. Confetti burst for story completion ──────────────── */
@keyframes confetti-fall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti-particle {
    position: fixed;
    top: 0;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    z-index: 1000;
    pointer-events: none;
    animation: confetti-fall 3s ease-in forwards;
}

/* ── 10. Avatar Preview for Reader ───────────────────────── */
.avatar-preview-box {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.avatar-preview-box.large {
    width: 64px;
    height: 64px;
}

.avatar-preview-box.small {
    width: 40px;
    height: 40px;
}

.avatar-animal {
    font-size: 2rem;
}

.avatar-accessory {
    position: absolute;
    font-size: 1rem;
}

.cape-overlay { bottom: -2px; right: -4px; }
.glasses-overlay { top: 25%; left: 50%; transform: translateX(-50%); font-size: 1.2rem; }
.hat-overlay { top: -10px; left: 50%; transform: translateX(-50%); }
.scarf-overlay { bottom: -4px; left: 50%; transform: translateX(-50%); }

/* Journey summary box */
.journey-summary-box {
    background: white;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(255,182,147,0.3);
    box-shadow: var(--shadow-glass);
}

/* ═══════════════════════════════════════════════════════════
   SHARED IMMERSIVE READER (single tale/quest pages + homepage
   generator modal). Lives here so the React reader on the
   homepage renders exactly like a standalone tale/quest page.
   ═══════════════════════════════════════════════════════════ */

/* Fullscreen overlay — triggered by the `book-fullscreen-active`
   body class that both readers add while open. */
body.book-fullscreen-active {
    overflow: hidden !important;
}

body.book-fullscreen-active .site-header,
body.book-fullscreen-active .site-footer,
body.book-fullscreen-active .reading-progress-bar,
body.book-fullscreen-active .background-spheres,
body.book-fullscreen-active .tale-fallback-content {
    display: none !important;
}

body.book-fullscreen-active .tale-book {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 99999 !important;
    overflow-y: auto !important;
    box-shadow: none !important;
    background: rgba(252, 249, 242, 0.98) !important;
    padding: 40px !important;
    display: flex !important;
    flex-direction: column !important;
}

body.book-fullscreen-active .tale-book .tale-header {
    border-bottom: 2px dashed rgba(135, 115, 106, 0.2) !important;
    padding-bottom: 20px !important;
    margin-bottom: 30px !important;
}

@media (max-width: 768px) {
    body.book-fullscreen-active .tale-book {
        padding: 20px 16px !important;
    }
}

/* Quest reader — 1 column on phones, compact 2-column
   (illustration | text+choices) on tablets/laptops with a
   sticky illustration so it stays visible past long text. */
.quest-step-title {
    width: 100%;
    text-align: left;
    margin-bottom: 16px;
}

.quest-layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 4px;
    align-items: start;
}

.quest-media {
    width: 100%;
}

.quest-media .chapter-illustration,
.quest-media .illustration-placeholder {
    width: 100%;
    border-radius: 16px;
}

.quest-media .illustration-placeholder {
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, #022c22 0%, #064e3b 50%, #0f766e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #fff;
}

.quest-text {
    color: var(--color-on-surface);
    font-size: 1.15rem;
    line-height: 1.7;
    margin: 0 0 20px;
    text-align: left;
}

.quest-choices-title {
    color: var(--color-primary);
    margin-bottom: 14px;
    font-weight: 700;
    font-size: 1.15rem;
}

.choices-buttons-grid-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (min-width: 768px) {
    .quest-layout-grid {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
        gap: 28px;
        align-items: start;
    }
    .quest-media {
        position: sticky;
        top: 20px;
        align-self: start;
    }
    .quest-text {
        font-size: 1.2rem;
        margin-bottom: 24px;
    }
}

@media (min-width: 1024px) {
    .quest-layout-grid {
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
        gap: 36px;
    }
}

@media (min-width: 1200px) {
    .quest-layout-grid {
        gap: 44px;
    }
}

/* Tales (linear) reader spacing. */
.tales-chapters-list {
    display: flex;
    flex-direction: column;
    gap: 72px;
    margin-bottom: 40px;
}

.tale-chapter-section {
    min-height: 80vh;
}

@media (max-width: 768px) {
    .tales-chapters-list {
        gap: 36px;
    }
    .tale-chapter-section {
        min-height: 0;
    }
}

