/* Card-style Base Styles */
:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --secondary-color: #2ecc71;
    --secondary-dark: #27ae60;
    --accent-color: #f39c12;
    --text-color: #2c3e50;
    --light-text: #7f8c8d;
    --background-color: #f5f7fa;
    --card-background: #ffffff;
    --card-border: #e0e6ed;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --gradient-primary: linear-gradient(135deg, #3498db, #2574a9);
    --gradient-secondary: linear-gradient(135deg, #2ecc71, #27ae60);
    --border-radius: 12px;
    --transition-speed: 0.3s;
    --card-width: 800px;
    --card-height: 600px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Lato', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    background-image: linear-gradient(to bottom, #f5f7fa, #e4e7eb);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

.container {
    width: 100%;
    max-width: var(--card-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden; /* Ensure no overflow */
}

h1, h2, h3 {
    font-family: 'Montserrat', sans-serif;
    margin-bottom: 20px;
    color: var(--text-color);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-top: 0;
    color: var(--primary-color);
}

h2 {
    font-size: 1.8rem;
    font-weight: 600;
    position: relative;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

.subtitle {
    text-align: center;
    font-size: 1.3rem;
    color: var(--light-text);
    margin-bottom: 20px;
    font-weight: 300;
}

/* Card Container and Pages */
.card-container {
    width: 100%;
    max-width: var(--card-width);
    height: var(--card-height);
    position: relative;
    perspective: 1500px;
    margin-bottom: 40px;
    overflow: hidden; /* Hide overflow */
}

.card-page {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    background-color: var(--card-background);
    overflow: hidden;
    backface-visibility: hidden;
}

.card-content {
    padding: 40px;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Cover Page */
#cover {
    background: var(--gradient-primary);
    z-index: 4;
    transform-origin: left center;
    left: 0;
    top: 0;
}

.cover-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}

.cover-content h1 {
    font-size: 3rem;
    color: white;
    margin-bottom: 30px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    font-family: 'Dancing Script', cursive;
}

.cover-image {
    font-size: 8rem;
    margin: 30px 0;
    color: rgba(255, 255, 255, 0.9);
    animation: pulse 2s infinite;
}

.cover-content .subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.5rem;
    margin-bottom: 40px;
}

.page-corner {
    position: absolute;
    bottom: 30px;
    right: 30px;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.page-corner:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Introduction Page */
#intro {
    z-index: 3;
    background-color: #fff;
    background-image: 
        radial-gradient(#e6e6e6 1px, transparent 1px),
        radial-gradient(#e6e6e6 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    transform: translateX(200%); /* Position far off-screen initially */
    left: 0;
    top: 0;
}

.intro-text {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 20px;
    color: var(--text-color);
}

/* Messages Page */
#messages-container {
    z-index: 2;
    background-color: #fff;
    background-image: 
        linear-gradient(90deg, rgba(200,200,200,.1) 1px, transparent 1px),
        linear-gradient(rgba(200,200,200,.1) 1px, transparent 1px);
    background-size: 20px 20px;
    transform: translateX(300%); /* Position far off-screen initially */
    left: 0;
    top: 0;
}

.messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    margin-bottom: 20px;
}

.message-card {
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-color);
    transition: all var(--transition-speed);
}

.message-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.message-header {
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-color);
}

.message-relationship {
    font-size: 0.9rem;
    color: var(--light-text);
    font-style: italic;
}

.message-content {
    margin-bottom: 15px;
    line-height: 1.6;
    color: var(--text-color);
    font-size: 1rem;
}

.message-date {
    font-size: 0.8rem;
    color: var(--light-text);
    text-align: right;
}

.loading {
    text-align: center;
    padding: 30px;
    color: var(--light-text);
    font-size: 1.1rem;
    animation: pulse 1.5s infinite;
}

/* Add Message Page */
#add-message {
    z-index: 1;
    background-color: #fff;
    background-image: 
        linear-gradient(45deg, #f9f9f9 25%, transparent 25%, transparent 75%, #f9f9f9 75%, #f9f9f9),
        linear-gradient(45deg, #f9f9f9 25%, transparent 25%, transparent 75%, #f9f9f9 75%, #f9f9f9);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    transform: translateX(400%); /* Position far off-screen initially */
    left: 0;
    top: 0;
}

/* Improved Form Styling */
#add-message .card-content {
    padding: 30px;
}

#add-message h2 {
    font-size: 1.6rem;
    margin-bottom: 20px;
}

#wellWishesForm {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 0;
    position: relative;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color);
    transition: color var(--transition-speed);
}

input, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--card-border);
    border-radius: 8px;
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    color: var(--text-color);
    background-color: #fff;
    transition: all var(--transition-speed);
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.form-group:focus-within label {
    color: var(--primary-color);
}

textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 150px;
}

.btn-submit {
    background: var(--gradient-secondary);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-speed);
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.3);
    display: inline-block;
    text-align: center;
    margin-bottom: 10px;
    align-self: flex-start;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(46, 204, 113, 0.4);
}

.btn-submit:active {
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(46, 204, 113, 0.4);
}

.form-status {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 8px;
    display: none;
    font-weight: 500;
    animation: fadeIn 0.5s;
    font-size: 0.9rem;
}

.form-status.success {
    display: block;
    background-color: rgba(46, 204, 113, 0.1);
    color: #27ae60;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.form-status.error {
    display: block;
    background-color: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

/* Page Navigation */
.page-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 15px;
}

.nav-btn {
    background: none;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.nav-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Page Turning Animation Classes */
.turn-to-right {
    transform: rotateY(-180deg);
}

.move-to-left {
    transform: translateX(0) !important;
}

.move-to-right {
    transform: translateX(200%) !important;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 20px;
    padding: 20px 0;
    color: var(--light-text);
    font-size: 0.9rem;
    width: 100%;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.6; transform: scale(1); }
}

/* Responsive Styles */
@media (max-width: 850px) {
    :root {
        --card-width: 90vw;
        --card-height: 80vh;
    }
    
    h1 {
        font-size: 2.2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .card-content {
        padding: 25px;
    }
    
    .cover-image {
        font-size: 6rem;
    }
}

@media (max-width: 500px) {
    h1 {
        font-size: 1.8rem;
    }
    
    .cover-image {
        font-size: 5rem;
    }
    
    .card-content {
        padding: 20px;
    }
    
    .page-navigation {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-btn {
        width: 100%;
    }
}

/* Modern Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}


/* Additional Status Styles (Success, Error, Loading) */
.form-status.loading {
    display: block;
    background-color: rgba(52, 152, 219, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(52, 152, 219, 0.3);
}

/* Messages Layout Enhancements */
.message-card {
    background-color: #fff;
    border-left: 4px solid var(--primary-color);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.message-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.message-text {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-color);
}

.message-meta {
    font-size: 0.9rem;
    color: var(--light-text);
    font-style: italic;
}

.jump-to-form {
  margin-top: 1.5rem;
  text-align: center;
}

.btn-jump-form {
  background-color: #ff69b4;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.btn-jump-form:hover {
  background-color: #e055a1;
}

.external-form-button {
  margin-top: 1.5rem;
  text-align: center;
}

.external-form-button button {
  background-color: #ff69b4;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.external-form-button button:hover {
  background-color: #e055a1;
}

.jump-to-form {
  margin-top: 1.5rem;
  text-align: center;
}

.btn-jump-form {
  background-color: #ff69b4;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.btn-jump-form:hover {
  background-color: #e055a1;
}

.bottom-fixed-form-button {
  margin: 2rem auto;
  text-align: center;
}

.bottom-fixed-form-button button {
  background-color: #ff69b4;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.bottom-fixed-form-button button:hover {
  background-color: #e055a1;
}

.jump-to-form {
  margin-top: 1.5rem;
  text-align: center;
}

.btn-jump-form {
  background-color: #ff69b4;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.btn-jump-form:hover {
  background-color: #e055a1;
}

