/* Global Styles */
body {
    font-family: 'Noto Serif SC', serif;
    background-color: #f4f6f8;
    /* Light gray/blueish background */
    margin: 0;
    padding: 0;
    color: #333;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

/* Header */
header {
    background-image: url('../assets/images/banner.jpg');
    background-size: cover;
    background-position: center;
    padding: 60px 0;
    /* Increased padding */
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    /* Changed from sticky to allow scrolling if needed, or keep sticky but with z-index */
    /* position: sticky; top: 0; z-index: 100; */
    /* Let's keep it normal flow for big banner */
    color: white;
    /* Default text color for banner */
}

/* Overlay for better text readability */
header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    /* Dark overlay */
    z-index: 1;
}

.banner-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    height: 300px;
}

h1 {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 3rem;
    /* Larger title */
    margin: 0;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.banner-text {
    font-family: 'Noto Serif SC', serif;
    font-size: 2rem;
    margin: 10px 0;
    color: #f0f0f0;
    letter-spacing: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.banner-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Unified Button Styles */
.btn,
.btn-secret {
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 25px;
    cursor: pointer;
    font-family: 'Noto Serif SC', serif;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    /* Use flex for perfect centering */
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    backdrop-filter: blur(5px);
    margin: 0;
    width: 140px;
    /* Fixed width */
    height: 45px;
    /* Fixed height */
    box-sizing: border-box;
}

/* Remove separate btn-secret style block to avoid conflicts */
/* ... (ensure no other .btn-secret definition exists) ... */

.btn:hover,
.btn-secret:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    border-color: #fff;
    color: #fff;
}

/* Specific overrides if needed, but user asked for unified style */
/* .btn-today {
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
} */

/* Remove old nav-buttons styles since we moved them */
.nav-buttons {
    display: none;
}

/* Main Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Timeline Styles */
.timeline {
    position: relative;
    padding: 70px 0 20px;
    /* Space for the absolute Now badge */
}

/* Central Line */
.timeline::after {
    content: '';
    position: absolute;
    width: 2px;
    background-color: #e0e0e0;
    /* Light gray line */
    top: 0;
    bottom: 0;
    left: 50%;
    /* Center */
    margin-left: -1px;
}

/* Timeline Entry Item */
.entry {
    padding: 10px 52px;
    /* 12px gap to avatar margin from box */
    position: relative;
    background-color: inherit;
    width: 50%;
    box-sizing: border-box;
    /* Include padding/border in width */
}

/* Left Entry */
.entry.left {
    left: 0;
    text-align: right;
    /* Content aligns right towards the center */
}

/* Right Entry */
.entry.right {
    left: 50%;
    text-align: left;
    /* Content aligns left towards the center */
}

/* The Dots on the Line (Hidden in favor of marker) */
.entry::after {
    display: none;
}

/* Timeline "Now" Top Badge */
.timeline-now {
    text-align: center;
    background-color: #A365B6;
    /* Purple color matching screenshot */
    color: white;
    padding: 8px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    border-radius: 2px;
}

/* Timeline Marker (Avatar + Date) */
.timeline-marker {
    position: absolute;
    top: 0;
    width: 48px;
    /* Slightly smaller */
    text-align: center;
    background-color: #f4f6f8;
    z-index: 2;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.entry.left .timeline-marker {
    right: -24px;
    /* Half of 48px */
}

.entry.right .timeline-marker {
    left: -24px;
}

.marker-avatar {
    width: 48px;
    /* Scaled down slightly */
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 8px;
    border: 3px solid #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.marker-day {
    font-size: 1.5rem;
    /* Scaled down slightly */
    font-weight: bold;
    color: #6a7f8e;
    line-height: 1;
    font-family: Arial, sans-serif;
}

.marker-month {
    font-size: 0.85rem;
    /* Scaled down slightly */
    font-weight: bold;
    color: #8da2af;
    margin-top: 4px;
    white-space: nowrap;
    font-family: Arial, sans-serif;
}

.timeline-total {
    text-align: center;
    padding: 30px 0 50px;
    color: #444;
    font-size: 1rem;
    position: relative;
    z-index: 2;
    background-color: #f4f6f8;
    width: 100%;
}

/* Card Content */
.content {
    padding: 20px;
    background-color: white;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease;
}

.content:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

/* Arrow for left entry (box is on the left, arrow points right) */
.entry.left .content::before {
    content: '';
    position: absolute;
    top: 10px;
    right: -10px;
    border-width: 10px 0 10px 10px;
    border-style: solid;
    border-color: transparent transparent transparent white;
    z-index: 1;
}

/* Arrow for right entry (box is on the right, arrow points left) */
.entry.right .content::before {
    content: '';
    position: absolute;
    top: 10px;
    left: -10px;
    border-width: 10px 10px 10px 0;
    border-style: solid;
    border-color: transparent white transparent transparent;
    z-index: 1;
}

/* Time Header inside Card */
.time-header {
    margin-bottom: 10px;
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
}

.write-down {
    color: #8F9EA6;
    margin-right: 6px;
    font-family: Arial, sans-serif;
}

.time-text {
    color: #4D627B;
    font-family: Arial, sans-serif;
}

/* Text Content */
.text {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 10px;
    white-space: pre-wrap;
    /* Preserve line breaks */
    color: #444;
}

/* Image inside Card */
.image-container {
    margin-top: 10px;
    border-radius: 4px;
    overflow: hidden;
}

.image-container img {
    max-width: 100%;
    display: block;
    border-radius: 4px;
    cursor: pointer;
    /* Click to enlarge? */
}

/* Add New Modal / Page Overlay */
#add-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f4f6f8;
    z-index: 200;
    display: none;
    /* Hidden by default */
    overflow-y: auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

#add-page.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.form-header {
    display: flex;
    justify-content: space-between;
    /* Back button left, Title center/right */
    align-items: center;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

input[type="date"],
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

input[type="date"]:focus,
textarea:focus {
    border-color: #333;
    outline: none;
}

textarea {
    min-height: 150px;
    resize: vertical;
}

/* Custom File Upload */
.file-upload {
    border: 2px dashed #ddd;
    padding: 30px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    color: #888;
}

.file-upload:hover {
    border-color: #999;
    background-color: #fafafa;
}

#image-preview {
    max-width: 100%;
    max-height: 300px;
    margin-top: 20px;
    border-radius: 8px;
    display: none;
    /* Hidden until image selected */
}

.btn-submit {
    width: 100%;
    padding: 15px;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-submit:hover {
    background-color: #555;
}

.btn-back {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    /* Back arrow size */
    color: #333;
    padding: 5px 10px;
}

/* Remove standalone btn-secret block */

/* Secret Modal & Book Animation */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    /* Darker background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.modal-overlay.hidden {
    display: none;
}

.book-wrapper {
    perspective: 1500px;
    width: 90%;
    max-width: 600px;
    /* Increased width */
    height: 85vh;
    /* Fixed height relative to viewport */
    position: relative;
}

.book-page {
    background: #fff9f0;
    padding: 50px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    position: relative;
    transform-origin: left center;
    animation: openBook 0.8s cubic-bezier(0.15, 0.75, 0.5, 1) forwards;
    overflow-y: auto;
    height: 100%;
    /* Fill wrapper */
    box-sizing: border-box;
}

@keyframes openBook {
    0% {
        transform: rotateY(-90deg) scale(0.9);
        opacity: 0;
    }

    100% {
        transform: rotateY(0deg) scale(1);
        opacity: 1;
    }
}

.letter-content {
    font-family: 'Noto Serif SC', serif;
    line-height: 1.4;
    /* Significantly reduced line height */
    color: #444;
    font-size: 1.1rem;
    white-space: pre-wrap;
    text-align: justify;
}

.letter-content p {
    margin-bottom: 0;
    /* Remove margin bottom for p tags */
    margin-top: 0;
    /* Remove margin top */
}

/* Close Button Outside */
.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    /* Fixed position relative to viewport or overlay, NOT page */
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 1010;
    /* Above book */
}

/* Since close-btn is inside book-page in HTML, we need to move it out in HTML or use fixed positioning relative to window */
/* Better approach: Move close-btn in HTML to be a sibling of book-wrapper */

.close-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(90deg);
}

/* Custom Scrollbar for Letter */
.book-page::-webkit-scrollbar {
    width: 6px;
}

.book-page::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.book-page::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

/* Responsive Design */
@media screen and (max-width: 600px) {

    header {
        padding: 30px 0;
    }

    .banner-content {
        height: 180px;
        gap: 10px;
    }

    h1 {
        font-size: 2rem;
    }

    .banner-text {
        font-size: 1.2rem;
    }

    .btn,
    .btn-secret {
        width: 40vw;
        /* Make buttons dynamic */
        max-width: 120px;
        min-width: 90px;
        height: 40px;
        font-size: 0.9rem;
    }

    /* Move timeline line to left */
    .timeline::after {
        left: 31px;
    }

    /* Make all entries right-aligned relative to the line */
    .entry {
        width: 100%;
        padding-left: 83px;
        /* 31 + 30 + 12 (gap) + 10 (arrow) */
        padding-right: 20px;
    }

    .entry.left,
    .entry.right {
        left: 0;
        text-align: left;
        /* Always left align text on mobile */
    }

    .entry.left .timeline-marker,
    .entry.right .timeline-marker {
        left: 7px;
        /* 31px (timeline line) - 24px (half marker width) */
        right: auto;
    }

    /* Adjust Now Badge for Mobile */
    .timeline-now {
        left: 31px;
        transform: translateX(-50%);
        padding: 6px 20px;
        font-size: 1rem;
    }

    /* Make left entry's arrow point left on mobile too */
    .entry.left .content::before {
        right: auto;
        left: -10px;
        border-width: 10px 10px 10px 0;
        border-color: transparent white transparent transparent;
    }

    .nav-buttons {
        flex-direction: column;
        padding: 0 40px;
    }
}

/* Click Effect Styles */
.click-text {
    position: absolute;
    z-index: 9999;
    font-size: 1.2rem;
    font-weight: bold;
    pointer-events: none;
    /* Let clicks pass through */
    user-select: none;
    animation: floatUp 1s ease-out forwards;
    white-space: nowrap;
}

@keyframes floatUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-100px);
        /* Float up */
        opacity: 0;
    }
}

/* Secret Trigger (Top Right Corner of Banner) */
#secret-trigger {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 10px;
    height: 10px;
    z-index: 9999;
    /* Keep it subtle but discoverable */
    background-color: transparent;
    /* Transparent */
}

/* Visitor Modal Styles */
.visitor-container {
    background: white;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.visitor-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f9f9f9;
}

.visitor-header h3 {
    margin: 0;
    font-family: 'Noto Serif SC', serif;
}

.visitor-content {
    padding: 20px;
    overflow-y: auto;
}

.close-btn-simple {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
}

.close-btn-simple:hover {
    color: #333;
}

#visitor-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Noto Serif SC', serif;
    font-size: 0.9rem;
}

#visitor-table th,
#visitor-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

#visitor-table th {
    background-color: #f4f6f8;
    font-weight: bold;
    color: #555;
}

#visitor-table tr:hover {
    background-color: #fafafa;
}