/* --- 1. Imports and Variables --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@700&family=Merriweather:ital,wght@0,400;0,700;1,400&display=swap');

:root {
    --bg-light: #FDFDFD;
    --surface-light: #FFFFFF;
    --text-light: #1a1a1a;
    --accent-light: #007BFF;
    --shadow-light: rgba(0, 0, 0, 0.08);

    --bg-dark: #121212;
    --surface-dark: #1E1E1E;
    --text-dark: #EAEAEA;
    --accent-dark: #259DFF;
    --shadow-dark: rgba(0, 0, 0, 0.25);

    --transition-speed: 0.4s;
}

/* --- 2. Global Styles & Resets --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Merriweather', serif;
    background-color: var(--bg-light);
    color: var(--text-light);
    margin: 0;
    /* This combination ensures the app fills the screen without scrolling */
    height: 100vh; /* Fallback for older browsers */
    height: 100dvh; /* <<< KEY FIX: Uses dynamic height to account for browser UI */
    overflow: hidden;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* --- 3. Intro Animation --- */
.intro-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--bg-light);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: slideUp 0.8s cubic-bezier(0.65, 0, 0.35, 1) 2.2s forwards;
}

.intro-title {
    font-family: 'Poppins', sans-serif;
    font-size: clamp(2.5rem, 10vw, 4rem);
    opacity: 0;
    animation: fadeIn 1s ease-in 0.5s forwards, fadeOut 0.5s ease-out 2s forwards;
}

@keyframes fadeIn { to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes slideUp { to { transform: translateY(-100%); } }

/* --- 4. Main Layout --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%; /* <<< KEY FIX: Makes the container fill the body's dynamic height */
    padding: 1rem;
    /* Adds padding for device notches (like on iPhone) */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    opacity: 0;
    animation: fadeIn 1s ease-in 2.5s forwards;
}

.header, .footer {
    flex-shrink: 0; /* Prevents header/footer from shrinking */
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.header {
    justify-content: space-between;
    padding-bottom: 0.5rem;
    gap: 0.5rem;
}

.footer {
    justify-content: center;
    gap: 1.5rem;
    padding-top: 0.5rem;
}

.main-content {
    flex-grow: 1; /* Allows this section to fill all available space */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    overflow: hidden; /* <<< KEY FIX: Prevents content from overflowing its container */
}

.site-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.75rem;
    margin: 0;
}

/* --- 5. Components --- */

/* Buttons */
.icon-btn, .nav-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.icon-btn:hover, .nav-btn:hover {
    background-color: var(--shadow-light);
    transform: scale(1.1);
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
}

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

/* Quote Box */
.quote-container {
    perspective: 1200px;
    width: 100%;
    max-width: 500px;
    margin: 0 3.5rem;
}

.quote-box {
    width: 100%;
    min-height: 250px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.25, 1, 0.5, 1);
    cursor: pointer;
    touch-action: pan-y;
}

.quote-front, .quote-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    background-color: var(--surface-light);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--shadow-light);
}

.quote-back { transform: rotateY(180deg); }
.quote-box.is-flipped { transform: rotateY(180deg); }

.quote {
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    text-align: center;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.author {
    font-size: clamp(1rem, 3vw, 1.1rem);
    font-weight: 700;
}

/* --- 6. Modal --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 200;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface-light);
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}
.modal.show .modal-content {
    transform: scale(1);
}

#close-tutorial {
    margin-top: 1.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    background: var(--accent-light);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color var(--transition-speed) ease;
}

/* --- 7. Dark Mode --- */
body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}
body.dark-mode .intro-overlay { background-color: var(--bg-dark); }
body.dark-mode .icon-btn, body.dark-mode .nav-btn { color: var(--text-dark); }
body.dark-mode .icon-btn:hover, body.dark-mode .nav-btn:hover { background-color: var(--shadow-dark); }
body.dark-mode .quote-front, body.dark-mode .quote-back { background-color: var(--surface-dark); box-shadow: 0 10px 30px var(--shadow-dark); }
body.dark-mode .modal { background: rgba(0, 0, 0, 0.5); }
body.dark-mode .modal-content { background: var(--surface-dark); }
body.dark-mode #close-tutorial { background: var(--accent-dark); }
/*fix*/
/* --- 2. Global Styles & Resets --- */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* <<< ADD THIS LINE */
}
/* --- 4. Main Layout --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Replaced padding with more robust rules for better spacing */
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: max(1.5rem, env(safe-area-inset-top));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    opacity: 0;
    animation: fadeIn 1s ease-in 2.5s forwards;
}