/* CSS Custom Variables for Siyoon's Toy Land Storybook */
:root {
    --clay-bg-pastel: #fdf5eb;
    --clay-card-bg: #fffcf8;
    --clay-primary: #ffb13b; /* Siyoon's warm yellow */
    --clay-secondary: #ff7597; /* Heart pink */
    --clay-accent: #6cdbf2; /* Toy blue */
    --clay-border: #6b4d3a;
    --clay-shadow-soft: 0 10px 20px rgba(107, 77, 58, 0.12);
    --clay-shadow-heavy: 0 15px 30px rgba(107, 77, 58, 0.22);
    
    --font-heading: 'Jua', sans-serif;
    --font-body: 'Gaegu', sans-serif;
}

/* Reset & Setup */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background: radial-gradient(circle, #fff0df 0%, #ffd8be 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    user-select: none;
}

/* Clouds Background */
.clouds-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 100px;
    filter: blur(3px);
    animation: floatClouds 35s linear infinite;
}

.cloud::before, .cloud::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
}

.cloud-1 {
    width: 160px;
    height: 60px;
    top: 8%;
    left: -200px;
    animation-duration: 48s;
}
.cloud-1::before { width: 80px; height: 80px; top: -35px; left: 25px; }
.cloud-1::after { width: 60px; height: 60px; top: -25px; right: 25px; }

.cloud-2 {
    width: 220px;
    height: 80px;
    top: 25%;
    left: -250px;
    animation-duration: 65s;
    animation-delay: -15s;
}
.cloud-2::before { width: 110px; height: 110px; top: -50px; left: 35px; }
.cloud-2::after { width: 80px; height: 80px; top: -35px; right: 35px; }

.cloud-3 {
    width: 130px;
    height: 50px;
    top: 55%;
    left: -150px;
    animation-duration: 38s;
    animation-delay: -8s;
}
.cloud-3::before { width: 60px; height: 60px; top: -30px; left: 15px; }
.cloud-3::after { width: 45px; height: 45px; top: -20px; right: 15px; }

@keyframes floatClouds {
    0% { transform: translateX(-100px); }
    100% { transform: translateX(calc(100vw + 250px)); }
}

/* Floating Bubbles */
#bubble-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
}

.bubble {
    position: absolute;
    bottom: -100px;
    background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.45) 0%, rgba(255, 177, 59, 0.15) 60%, rgba(255, 117, 151, 0.15) 100%);
    border-radius: 50%;
    box-shadow: inset -4px -4px 12px rgba(0,0,0,0.04), inset 4px 4px 8px rgba(255,255,255,0.7), 0 5px 12px rgba(0,0,0,0.04);
    animation: riseUp 9s ease-in infinite;
}

@keyframes riseUp {
    0% { transform: translateY(0) scale(1) rotate(0deg); opacity: 0; }
    10% { opacity: 0.8; }
    90% { opacity: 0.8; }
    100% { transform: translateY(-110vh) scale(1.25) rotate(360deg); opacity: 0; }
}

/* Header */
.app-header {
    width: 100%;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    position: relative;
}

.main-title {
    font-family: var(--font-heading);
    color: #543929;
    font-size: 2.2rem;
    text-shadow: 2px 2px 0px #fff, 4px 4px 0px rgba(107, 77, 58, 0.1);
}

.controls-panel {
    display: flex;
    gap: 12px;
}

.btn-round {
    background: var(--clay-card-bg);
    border: 3px solid var(--clay-border);
    border-radius: 30px;
    padding: 8px 16px;
    font-family: var(--font-heading);
    font-size: 1rem;
    color: #543929;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--clay-border), var(--clay-shadow-soft);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease-out;
}

.btn-round:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--clay-border), var(--clay-shadow-heavy);
}

.btn-round:active {
    transform: translateY(4px);
    box-shadow: 0 0px 0 var(--clay-border);
}

.btn-round.active {
    background: #e4f9e4;
    border-color: #388a3b;
    color: #205c22;
    box-shadow: 0 4px 0 #388a3b, var(--clay-shadow-soft);
}

/* Book Layout Container & Book Wrapper */
.book-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px 40px;
    z-index: 5;
}

.book-wrapper {
    position: relative;
    width: 1020px;
    height: 600px;
}

.book-container {
    width: 100%;
    height: 100%;
    background: #876249; /* Wooden outer shelf texture */
    border: 12px solid #573e2e;
    border-radius: 24px;
    position: relative;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    overflow: hidden;
}

.book-page {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: var(--clay-card-bg);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    transform: translateX(100px) rotate(1.5deg);
}

.book-page.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0) rotate(0deg);
}

.book-page.exit-left {
    transform: translateX(-100px) rotate(-1.5deg);
    opacity: 0;
}

.page-spread {
    display: flex;
    width: 100%;
    height: 100%;
}

.page-left, .page-right {
    flex: 1;
    height: 100%;
    padding: 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.page-left {
    border-right: 2px dashed rgba(107, 77, 58, 0.15); /* Spine binding line */
}

/* Cover Styling */
.cover-design {
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #fff 0%, #fff2e0 100%);
}

.cover-img-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cover-title-page {
    background: radial-gradient(circle at center, #fffcf6 0%, #ffe9c4 100%);
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
}

.badge {
    background: #ff5e84;
    color: white;
    font-family: var(--font-heading);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 1.1rem;
    border: 3px solid var(--clay-border);
    box-shadow: 0 4px 0 var(--clay-border);
}

.book-title {
    font-family: var(--font-heading);
    font-size: 3.3rem;
    color: #4a3324;
    line-height: 1.25;
    text-shadow: 2px 2px 0px #fff;
}

.book-title .highlight {
    color: #ff5e84;
    font-size: 3.6rem;
    display: inline-block;
    animation: wiggle 2s ease-in-out infinite;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg) scale(1.05); }
}

.author {
    font-size: 1.3rem;
    color: #7d5940;
    font-weight: bold;
}

.start-btn {
    background: var(--clay-primary);
    border: 4px solid var(--clay-border);
    border-radius: 50px;
    padding: 12px 28px;
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: white;
    text-shadow: 2px 2px 0 var(--clay-border);
    cursor: pointer;
    box-shadow: 0 6px 0 var(--clay-border), var(--clay-shadow-soft);
    transition: all 0.15s ease-out;
}

.start-btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 9px 0 var(--clay-border), var(--clay-shadow-heavy);
}

.start-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0px 0 var(--clay-border);
}

/* Page Illustration Containers */
.illustration-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 18px;
}

.illustration-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 18px;
    border: 6px solid var(--clay-border);
}

.clay-shadow {
    box-shadow: 0 12px 24px rgba(107, 77, 58, 0.25);
}

/* Page Text Alignment */
.text-layout {
    display: flex;
    flex-direction: column;
    background: #fffdfb;
    padding: 25px 30px;
    height: 100%;
}

.page-top-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.page-number {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: #9c7b64;
}

.tts-btn {
    background: #eef7ff;
    border: 2px solid #5fa1de;
    color: #275d8c;
    border-radius: 20px;
    padding: 6px 14px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 3px 0 #5fa1de;
    transition: all 0.1s ease;
}

.tts-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #5fa1de;
}

.tts-btn:active {
    transform: translateY(3px);
    box-shadow: 0 0px 0 #5fa1de;
}

.story-text {
    font-size: 1.48rem;
    color: #423024;
    line-height: 1.7;
    text-align: center;
    word-break: keep-all;
    margin: auto 0;
    font-weight: 700;
    width: 100%;
    display: block;
}

.story-text .char-siyoon {
    color: #ffa217;
    font-weight: bold;
    border-bottom: 3px dashed #ffa217;
    display: inline-block;
    padding-bottom: 1px;
}

.story-text .char-dust {
    color: #79808a;
    font-weight: bold;
    border-bottom: 3px dashed #79808a;
    display: inline-block;
    padding-bottom: 1px;
}

.story-text .char-robot {
    color: #ff5277;
    font-weight: bold;
    border-bottom: 3px dashed #ff5277;
    display: inline-block;
    padding-bottom: 1px;
}

.story-text .keyword {
    color: #ff5277;
    background: #ffeff3;
    padding: 2px 7px;
    border-radius: 8px;
    border: 2px solid #ffb8c7;
}

.story-text .sound-effect {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    color: #9254de;
    text-shadow: 2px 2px 0px #fff;
    display: inline-block;
    animation: bounce 0.6s ease infinite alternate;
}

.story-text .speech {
    color: #2b7bc4;
    font-style: italic;
    background: #f2f8fc;
    border-left: 5px solid #6cdbf2;
    padding: 8px 12px;
    border-radius: 0 8px 8px 0;
    display: inline-block;
    margin: 8px 0;
}

.story-text .highlight {
    background: linear-gradient(180deg, rgba(255,255,255,0) 50%, #ffe066 50%);
    padding: 0 4px;
    color: #8c7300;
}

@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-8px); }
}

/* Page 5: Dust Clearing Interaction Style */
.dust-interactive-wrapper {
    position: relative;
    cursor: pointer;
}

.dust-overlay-canvas {
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    border-radius: 12px;
    pointer-events: auto;
    z-index: 10;
}

.dust-hint-text {
    position: absolute;
    bottom: 20px;
    background: rgba(0,0,0,0.65);
    color: white;
    padding: 6px 14px;
    border-radius: 15px;
    font-family: var(--font-heading);
    font-size: 1rem;
    z-index: 20;
    pointer-events: none;
    animation: pulseHint 1.5s infinite ease-in-out;
}

/* Page 7: Winding Key Widget Style */
.robot-heart-widget {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 140px;
    height: 120px;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid var(--clay-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    padding: 10px;
    z-index: 20;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.heart-key {
    font-size: 2.8rem;
    cursor: pointer;
    transition: transform 0.2s ease;
    user-select: none;
}

.heart-key.winding {
    transform: rotate(360deg);
}

.charge-gauge-container {
    width: 100%;
    height: 12px;
    background: #eedfd3;
    border: 2px solid var(--clay-border);
    border-radius: 6px;
    overflow: hidden;
}

.charge-gauge {
    width: 0%;
    height: 100%;
    background: var(--clay-secondary);
    transition: width 0.3s ease;
}

.robot-hint-text {
    font-size: 0.75rem;
    color: #705443;
    font-weight: bold;
    text-align: center;
    font-family: var(--font-heading);
}

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

/* Navigation Buttons */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #fff0d9;
    border: 4px solid var(--clay-border);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--clay-border), var(--clay-shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.nav-btn:hover {
    background: #ffecd4;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 8px 0 var(--clay-border), var(--clay-shadow-heavy);
}

.nav-btn:active {
    transform: translateY(-50%) scale(0.95);
    box-shadow: 0 1px 0 var(--clay-border);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: translateY(-50%) scale(1);
    box-shadow: 0 4px 0 var(--clay-border);
}

.prev-btn { left: -35px; }
.next-btn { right: -35px; }

.nav-icon { font-size: 1.6rem; }
.nav-text {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: #543929;
    margin-top: -2px;
}

/* Footer & Progress Mascot */
.app-footer {
    width: 100%;
    padding: 20px 40px;
    display: flex;
    justify-content: center;
    z-index: 10;
    position: relative;
}

.progress-bar-container {
    width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.progress-line {
    width: 100%;
    height: 12px;
    background: #d9bfad;
    border: 3px solid var(--clay-border);
    border-radius: 10px;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

.mascot-slider {
    position: absolute;
    top: -16px;
    left: 0%;
    font-size: 1.8rem;
    transform: translateX(-50%);
    transition: left 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    text-shadow: 0 3px 5px rgba(0,0,0,0.15);
}

.progress-text {
    font-family: var(--font-heading);
    color: #543929;
    font-size: 1.1rem;
}

/* Visual cue for reading speaker state */
.story-text.speaking-active {
    background: #fdfae6;
    border-radius: 12px;
    padding: 4px;
    box-shadow: inset 0 0 10px rgba(255, 177, 59, 0.15);
}

/* Click Sparkles */
.particle {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    animation: explode 0.8s ease-out forwards;
}

@keyframes explode {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(var(--mx), var(--my)) scale(0); opacity: 0; }
}

/* Responsive Scaling for Storybook */
@media (max-width: 1080px) {
    .book-viewport { padding: 10px; }
    .book-wrapper {
        width: 100%;
        max-width: 800px;
        height: 500px;
    }
    .prev-btn { left: -15px; }
    .next-btn { right: -15px; }
    .story-text { font-size: 1.25rem; }
}

@media (max-width: 720px) {
    .app-header { flex-direction: column; gap: 10px; padding: 10px; }
    .main-title { font-size: 1.8rem; }
    .book-wrapper {
        width: 100%;
        height: 580px;
    }
    .page-spread { flex-direction: column; }
    .page-left {
        flex: 1.1;
        border-right: none;
        border-bottom: 2px dashed rgba(107, 77, 58, 0.15);
        padding: 15px;
    }
    .page-right {
        flex: 1.2;
        padding: 15px;
    }
    .illustration-wrapper { border-radius: 12px; }
    .story-text {
        font-size: 1.15rem;
        line-height: 1.5;
    }
    .progress-bar-container { width: 80%; }
    .cover-title-page { padding: 20px; }
    .book-title { font-size: 2.2rem; }
    .book-title .highlight { font-size: 2.5rem; }
    .nav-btn { width: 50px; height: 50px; }
    .prev-btn { left: -10px; }
    .next-btn { right: -10px; }
}
