/* General Variables */
:root {
    --primary: #ff4b6e;
    --secondary: #ff8fa3;
    --bg: #fff0f3;
    --text: #4a4a4a;
    --book-paper: #fdfaf7; /* Slightly warmer paper color */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
    text-align: center;
}

/* Rogue Button Page */
.rogue-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden; /* Important so button doesn't scroll page */
}

button {
    padding: 15px 30px;
    font-size: 1.2rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    margin: 10px;
    transition: transform 0.2s;
}

#yes-btn {
    background-color: var(--primary);
    color: white;
}

#no-btn {
    background-color: #ddd;
    color: #555;
    position: relative; /* Needed for movement */
}

/* --- Floating Hearts Background --- */
.bg-hearts {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1; /* Behind everything */
    pointer-events: none;
}

.heart-particle {
    position: absolute;
    bottom: -10vh;
    font-size: 20px;
    color: rgba(255, 75, 110, 0.4);
    animation: floatUp 10s linear infinite;
}

@keyframes floatUp {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

/* Menu Page */
.menu-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Cute gradient background */
    background: linear-gradient(135deg, #fff0f3 0%, #ffe3e8 100%); 
}

.menu-container {
    text-align: center;
    width: 90%;
    max-width: 800px;
}

/* The Counter Section */
/* --- Dual Timer Styles --- */

.timer-box {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    padding: 20px; /* Reduced padding slightly */
    border-radius: 20px;
    margin-bottom: 40px;
    box-shadow: 0 8px 32px rgba(255, 75, 110, 0.1);
}

.timer-grid {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap; /* Allows stacking on small phones */
}

.timer-item {
    flex: 1;
    min-width: 200px; /* Ensures they don't get too squashed */
    padding: 10px;
}

.timer-title {
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    font-size: 0.8rem;
    margin-bottom: 5px;
}

.timer-digits {
    font-size: 1.8rem; /* Slightly smaller to fit two side-by-side */
    font-weight: bold;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.timer-divider {
    width: 1px;
    height: 50px;
    background-color: rgba(0,0,0,0.1);
    display: block;
}

/* On mobile, hide the divider and just stack them */
@media (max-width: 600px) {
    .timer-divider {
        display: none;
    }
    .timer-item {
        margin-bottom: 15px;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        padding-bottom: 15px;
    }
    .timer-item:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }
}

/* The Cards Grid */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 20px;
}

.card {
    background: rgba(255, 255, 255, 0.6); /* More opaque than timer */
    backdrop-filter: blur(10px);
    border: 1px solid white;
    padding: 40px 20px;
    border-radius: 20px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.3s ease;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card:hover {
    transform: translateY(-10px) scale(1.02);
    background: white;
    box-shadow: 0 15px 40px rgba(255, 75, 110, 0.2);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    transition: transform 0.3s;
}

.card:hover .card-icon {
    transform: scale(1.2) rotate(10deg);
}

.card h2 {
    margin: 10px 0 5px 0;
    font-size: 1.5rem;
    color: var(--primary);
}

.card p {
    color: #666;
    font-size: 0.9rem;
}

/* Picture Book */
.book-container {
    perspective: 2000px; /* Increased perspective for bigger book */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 90vh;
    margin-top: 20px;
}

.book {
    /* BIGGER SIZE */
    width: 600px;  /* Was 400px */
    height: 800px; /* Was 500px */
    position: relative;
    transform-style: preserve-3d;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2); /* Stronger shadow for realism */
}

.page {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: left;
    transition: transform 1.2s cubic-bezier(0.645, 0.045, 0.355, 1); /* Smoother flip */
    transform-style: preserve-3d;
    cursor: pointer;
    background-color: var(--book-paper);
    border: 1px solid #e0d8d0;
}

.page.flipped {
    transform: rotateY(-180deg);
}

.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.back {
    transform: rotateY(180deg);
    background-color: #f8f1e9; /* Slightly different color for back of pages */
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23d4c5b9' fill-opacity='0.2' fill-rule='evenodd'/%3E%3C/svg%3E");
}

/* --- Cover Page specific styles --- */
.cover-front {
    background-color: var(--primary);
    color: white;
    border: 10px solid #ff8fa3;
}

.heart-container {
    background-color: white;
    width: 300px;
    height: 280px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    /* CSS Heart Shape */
    position: relative;
    transform: rotate(-45deg);
    margin-top: -50px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}
.heart-container:before,
.heart-container:after {
  content: "";
  width: 300px;
  height: 300px;
  background-color: white;
  border-radius: 50%;
  position: absolute;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}
.heart-container:before { top: -150px; left: 0; }
.heart-container:after { left: 150px; top: 0; }

.cover-text {
    position: absolute;
    z-index: 10; /* Text on top of heart */
    transform: rotate(45deg); /* Counteract heart rotation */
    color: var(--primary);
    font-family: 'Georgia', serif;
}

.cover-text h1 {
    font-size: 3rem;
    line-height: 1.2;
    margin: 0;
}

.cover-text span {
    font-size: 1.5rem;
    font-style: italic;
}

/* --- Introduction Page styles --- */
.intro-content {
    text-align: left;
    padding: 60px;
    font-family: 'Georgia', serif;
    line-height: 1.8;
    color: #5a4a42;
    background-image: linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px);
    background-size: 100% 2em; /* Lined paper effect */
}

.intro-content h2 {
    color: var(--primary);
    text-align: center;
    margin-bottom: 30px;
}

.signature {
    text-align: right;
    margin-top: 50px;
    font-style: italic;
    font-weight: bold;
    color: var(--primary);
}

/* Image styling */
img {
    max-width: 95%;
    max-height: 85%;
    border-radius: 5px;
    border: 10px solid white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    object-fit: cover;
}

/* Insights Dashboard */
.dashboard {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-box {
    /* THE WHITE BOX LOOK */
    background: #ffffff; 
    border-radius: 15px; /* Rounded corners */
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); /* Soft shadow to make it pop */
    
    /* Layout */
    display: flex;
    flex-direction: column;
    align-items: center; 
    justify-content: center;
    padding: 25px; /* Space inside the box */
    text-align: center;
    transition: transform 0.2s ease; /* Subtle hover effect */
}

/* Optional: Slight lift on hover */
.stat-box:hover {
    transform: translateY(-5px);
}

/* The Icon (Emoji) */
.stat-icon {
    font-size: 2.5rem; 
    margin-bottom: 10px;
}

/* The Number */
.stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: #333;
    line-height: 1.2;
}

/* The Label */
.stat-label {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 5px;
    font-weight: 600;
}

/* Heart Animation */
.heart-beat {
    display: inline-block;
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.2); }
    28% { transform: scale(1); }
    42% { transform: scale(1.2); }
    70% { transform: scale(1); }
}

.big-number {
    font-size: 2.5rem;
    color: var(--primary);
    font-weight: bold;
    margin: 10px 0;
}

.quote {
    font-style: italic;
    color: #666;
}

.emojis {
    font-size: 2rem;
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
}

.chart-box {
    background: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    
    /* --- RESPONSIVE FIXES --- */
    min-width: 0;           /* <--- CRITICAL: Allows grid item to shrink on mobile */
    width: 100%;            /* <--- Forces it to fill available space, not more */
    box-sizing: border-box; /* <--- Keeps padding inside the width */
    overflow: hidden;       /* <--- Cuts off any rogue pixels */
}

/* THE FIX: A strict container for the canvas */
.canvas-container {
    position: relative;
    height: 300px;
    width: 100%;
    max-width: 100%;        /* <--- Ensure it never exceeds parent width */
    overflow: hidden;
}

.back-link {
    position: fixed; /* Changed from absolute to fixed so it stays in corner even if you scroll */
    top: 30px;
    left: 30px;
    z-index: 10000; /* This forces it above the 3D book layers */
    text-decoration: none;
    color: var(--primary);
    font-weight: bold;
    font-size: 1.2rem;
    background-color: rgba(255, 255, 255, 0.8); /* Optional: slight background to make it readable if it overlaps something */
    padding: 10px 20px;
    border-radius: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.back-link:hover {
    transform: scale(1.1);
    background-color: white;
}

/* Specific styles for the Spotify Card */
.spotify-card {
    /* THIS LINE MAKES IT FULL WIDTH */
    grid-column: 1 / -1; 
    
    padding: 0 !important;
    overflow: hidden;
    height: 400px; /* Increased height slightly for better list view */
    background: transparent;
    border: none;
    box-shadow: none; /* Optional: looks cleaner without shadow for embeds */
}

/* Optional: If you want the iframe to be fully interactive */
.spotify-card iframe {
    height: 100%;
    width: 100%;
}

/* By default, hide the content sections */
#picturebook-section, #insights-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg); /* Match background color */
    z-index: 9000; /* Sit on top of the menu */
    overflow-y: auto; /* Allow scrolling */
    
    /* Animation for appearing */
    transform: translateY(100%); /* Start hidden below screen */
    transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1);
    visibility: hidden;
}

/* Class to activate a section */
.section-active {
    transform: translateY(0) !important;
    visibility: visible !important;
}

/* Adjust the Back Button to work with JS */
.close-btn {
    position: fixed;
    top: 30px;
    left: 30px;
    z-index: 10000;
    background: white;
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    font-weight: bold;
    color: var(--primary);
}

/* --- Loading Screen Styles --- */

/* Update the existing overlay to center the loader */
#transition-overlay {
    /* Keep existing styles */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff0f3;
    opacity: 0;
    pointer-events: none;
    z-index: 9998;
    transition: opacity 2s ease-in-out;
    
    /* NEW: Center the content */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* The Heart Shape */
.loader-heart {
    position: relative;
    width: 60px;
    height: 60px;
    background-color: #ff4b6e;
    transform: rotate(-45deg);
    animation: heartbeat 1.2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
    box-shadow: 0 0 20px rgba(255, 75, 110, 0.5); /* Glow */
}

.loader-heart::before,
.loader-heart::after {
    content: "";
    position: absolute;
    width: 60px;
    height: 60px;
    background-color: #ff4b6e;
    border-radius: 50%;
}

.loader-heart::before {
    top: -30px;
    left: 0;
}

.loader-heart::after {
    left: 30px;
    top: 0;
}

/* Loading Text */
.loading-text {
    margin-top: 60px; /* Space below the heart */
    font-family: 'Courier New', Courier, monospace;
    color: #ff4b6e;
    font-size: 1.2rem;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: fadeText 1.2s infinite alternate;
}

/* Animations */
@keyframes heartbeat {
    0% { transform: rotate(-45deg) scale(0.8); }
    5% { transform: rotate(-45deg) scale(0.9); }
    10% { transform: rotate(-45deg) scale(0.8); }
    15% { transform: rotate(-45deg) scale(1); }
    50% { transform: rotate(-45deg) scale(0.8); }
    100% { transform: rotate(-45deg) scale(0.8); }
}

@keyframes fadeText {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

/* --- Chat Box Styling --- */

.chat-stat-box {
    /* Match the visual style of .stat-box */
    background: white;
    padding: 30px;
    border-radius: 20px; /* Same rounded corners */
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); /* Same shadow */
    
    /* Layout specific to the chat section */
    margin: 40px auto; /* Center it vertically and horizontally */
    text-align: center; /* Center the title "The Beginning" */
}

.chat-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 80%; /* limit width so they look like bubbles */
}

.chat-wrapper.left {
    align-items: flex-start;
    align-self: flex-start;
    text-align: left;
}

.chat-wrapper.right {
    align-items: flex-end;
    align-self: flex-end;
    text-align: right; /* Align text inside his bubble to right */
}

.chat-name {
    font-size: 0.8rem;
    color: #999;
    margin-bottom: 5px;
    margin-left: 10px;
}

.right .chat-name {
    margin-right: 10px;
}

.chat-bubble {
    padding: 15px 25px;
    border-radius: 20px;
    font-size: 1.1rem;
    line-height: 1.5;
    position: relative;
    /* Inner shadow for depth */
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.05); 
}

.chat-time {
    display: block;
    font-size: 0.7rem;
    margin-top: 8px;
    text-align: right;
    opacity: 0.7; /* Makes it slightly see-through */
    font-weight: 400;
}

/* Specific colors for readability */
.received .chat-time {
    color: #888; /* Grey text on the grey bubble */
}

.sent .chat-time {
    color: rgba(255, 255, 255, 0.9); /* White text on the pink bubble */
}

/* Her Bubble Style */
.received {
    background-color: #f0f2f5; /* Light gray like Messenger/WhatsApp */
    color: #4a4a4a;
    border-bottom-left-radius: 2px;
}

/* His Bubble Style */
.sent {
    background-color: var(--primary); /* Pink */
    color: white;
    border-bottom-right-radius: 2px;
}

/* Make Emoji Chart Full Width */
.full-width {
    grid-column: 1 / -1;
}

.full-width .canvas-container {
    height: 500px !important; /* Overrides the default 300px */
}

/* --- Click Hint Styling --- */
.click-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    animation: pulseHint 2s infinite;
    pointer-events: none; /* Allows click to pass through to the page */
}

@keyframes pulseHint {
    0% { opacity: 0.4; transform: translateX(-50%) translateY(0); }
    50% { opacity: 1; transform: translateX(-50%) translateY(-5px); }
    100% { opacity: 0.4; transform: translateX(-50%) translateY(0); }
}

/* Hide the hint once the page is flipped */
.page.flipped .click-hint {
    display: none;
}

/* --- End Page Styles --- */
.end-page-front {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff; /* White paper background */
    text-align: center;
}

.end-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.tbc-text {
    font-family: 'Courier New', Courier, monospace; /* Typewriter font */
    font-size: 1.4rem;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0;
}

.tbc-subtitle {
    font-family: 'Georgia', serif;
    font-style: italic;
    color: #666;
    font-size: 0.9rem;
    margin: 0;
}

/* Animated Dots (...) */
.dots {
    display: inline-block;
    animation: dotFade 2s infinite;
}

@keyframes dotFade {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

/* --- Back Cover Styles --- */
.cover-back {
    /* 1. MATCH THE THEME: Use a Pink/Red Gradient instead of Blue */
    background: linear-gradient(135deg, #ff4b6e 0%, #ff4b6e 100%); 
    
    /* Option: If you want a solid dark red instead, use this: */
    /* background-color: #d6336c; */

    /* 2. Layout & Shape */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 40px;
    border-radius: 0 10px 10px 0;
    
    /* 3. Flip Logic */
    transform: rotateY(180deg);
    
    /* 4. Book Texture (Subtle Shadow) */
    box-shadow: inset 5px 0 10px rgba(0,0,0,0.1); 
    border-left: 2px solid rgba(255,255,255,0.2); /* Spine detail */
}

/* Ensure text stands out on the pink background */
.back-names {
    font-family: 'Sacramento', cursive; 
    color: white;
    font-size: 2rem;
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.back-edition {
    font-family: 'Arial', sans-serif;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.6rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.tiny-heart {
    color: white; /* White heart looks better on pink */
    font-size: 1.5rem;
    margin-bottom: 15px;
    animation: pulseHint 2s infinite ease-in-out;
}

/* --- MOBILE OPTIMIZATIONS --- */
@media (max-width: 600px) {
    
    /* 1. Reduce Dashboard Padding */
    .dashboard {
        padding: 10px; /* Was 20px */
        width: 100%;
        box-sizing: border-box;
    }

    /* 2. Reduce Chart Box Padding */
    .chart-box {
        padding: 10px; /* Was 20px. Gives charts 20px more width! */
    }

    /* 3. Adjust Grid Gap */
    .charts-container {
        gap: 20px; /* Was 40px. Brings charts closer vertically */
    }

    /* 4. Fix Emoji Chart Height on small screens */
    /* On mobile, 500px might be too tall and force scrolling */
    .full-width .canvas-container {
        height: 400px !important; 
    }

    /* 5. Make Metrics Grid 2 columns instead of squished */
    .stats-grid {
        grid-template-columns: 1fr 1fr; /* 2 columns on mobile */
        gap: 10px;
    }
    
    /* 6. Adjust Font Sizes for Mobile */
    .stat-number { font-size: 1.4rem; }
    .stat-icon { font-size: 2rem; }
}