/* --- Base Setup --- */
html {
    box-sizing: border-box;
}
*, *:before, *:after {
    box-sizing: inherit;
}

body {
    margin: 0;
    background-color: #fce4ec;
    overflow: auto; /* changed from hidden -> auto so pages can scroll across separate files */
    font-family: 'Montserrat', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    /* Heart cursor is moved to main content to not interfere with login */
}

/* --- Login Screen Styles --- */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fce4ec; /* Match body background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-family: 'Montserrat', sans-serif;
}
#login-box {
    background: #ffffff;
    padding: 2.5em;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    text-align: center;
    width: 90%;
    max-width: 400px;
}
#login-box h2 {
    font-family: 'Dancing Script', cursive;
    font-size: 2.5em;
    color: #b01250;
    margin-top: 0;
    margin-bottom: 0.5em;
}
.login-input {
    font-family: 'Montserrat', sans-serif;
    width: 100%;
    padding: 12px;
    margin-bottom: 1em;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 1em;
    box-sizing: border-box;
}
.login-button {
    font-family: 'Montserrat', sans-serif;
    font-size: 1em;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    background-image: linear-gradient(45deg, #e91e63, #c2185b);
    color: white;
    box-shadow: 0 4px 15px rgba(216, 27, 96, 0.3);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
}
.login-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(216, 27, 96, 0.4);
}
#login-error {
    color: red;
    font-size: 0.9em;
    margin-top: 1em;
    display: none; /* Hidden by default */
}
/* --- END LOGIN --- */


/* --- Hide content by default --- */
header, main, #open-chat-btn {
    display: none; /* Content is hidden until login */
}
#main-content-wrapper {
     cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 24 24"><path fill="red" d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>') 15 15, auto; /* Custom heart cursor */
}
/* --- END HIDE --- */


/* --- Header / Navigation --- */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    padding: 0 2em;
    /* display: flex; -- moved to new rule */
    justify-content: space-between;
    align-items: center;
}

nav {
    display: flex;
    gap: 1.5em;
    align-items: center; /* <-- ADDED to align all links */
}

nav a {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.9em;
    text-decoration: none;
    color: #c2185b;
    padding: 1.5em 0.5em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    transition: color 0.3s ease;
}

nav a:hover {
    color: #e91e63;
}

/* --- Special style for the chat link --- */
nav a#nav-chat-link-js {
    color: #e91e63;
    font-weight: 700;
    background: #fce4ec;
    padding: 0.8em 1.2em;
    border-radius: 50px;
    transition: all 0.3s ease;
}
nav a#nav-chat-link-js:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(233, 30, 99, 0.2);
}
/* --- END NEW --- */


/* Active link highlight */
nav a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: #e91e63;
    border-radius: 2px 2px 0 0;
}

/* --- Page Content --- */
main {
    padding-top: 60px; /* Height of the header */
    height: 100vh;
    box-sizing: border-box; /* Include padding in height */
}

.page {
    display: none; /* Hide all pages by default */
    height: calc(100vh - 60px); /* Fill remaining height */
    overflow-y: auto; /* Allow scrolling within the page */
    animation: fadeIn 0.5s ease-in-out;
    padding: 2em;
}

.page.active {
    display: block; /* Show only the active page */
}

/* Center content for Home page */
#home-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Custom Scrollbar for pages */
.page::-webkit-scrollbar {
    width: 10px;
}
.page::-webkit-scrollbar-track {
    background: rgba(255, 228, 236, 0.5);
}
.page::-webkit-scrollbar-thumb {
    background-color: #c2185b;
    border-radius: 10px;
}
.page {
    scrollbar-width: thin;
    scrollbar-color: #c2185b rgba(255, 228, 236, 0.5);
}


/* --- Card (used for all pages) --- */
.card {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 0;
    max-width: 700px;
    width: 100%;
    margin: 0 auto; /* Center the card */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Card for other pages (Note, Memories) */
.content-card {
    background-color: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 2.5em 3em;
    max-width: 800px;
    width: 95%;
    margin: 0 auto 2em auto; /* Center card with bottom margin */
}


/* --- Inline Slideshow (inside card) --- */
#inline-slideshow-container {
    width: 100%;
    height: 350px; /* Height of the slideshow */
    position: relative;
    border-radius: 20px 20px 0 0; /* Match top corners of card */
    overflow: hidden; /* Clip the slides */
    flex-shrink: 0; /* Don't shrink */
}

.inline-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center center;
    opacity: 0;
    animation: inlineImageFade 125s infinite;
}

/* --- Card Content --- */
.card-content-wrapper {
    padding: 2.5em 3em;
    text-align: center;
}

h1 {
    font-family: 'Dancing Script', cursive;
    font-size: 5em;
    margin-bottom: 0;
    margin-top: 0;
    color: #b01250;
    text-shadow: none;
}

/* h2 for page titles */
h2 {
    font-family: 'Dancing Script', cursive;
    font-size: 3.5em;
    margin-bottom: 0.5em;
    margin-top: 0;
    color: #b01250;
    text-align: center;
}

p {
    font-size: 1.5em;
    margin-top: 0;
    font-style: italic;
    text-shadow: none;
    color: #333;
}

.counter-text {
    font-size: 1.2em;
    margin-top: 1em;
    font-style: normal;
    font-weight: 600;
    color: #c2185b;
}

.heart-message {
    position: absolute;
    color: red;
    font-size: 2em;
    font-weight: bold;
    pointer-events: none; /* Allows clicks to go through */
    animation: fadeOutUp 1.5s ease-out forwards;
    white-space: nowrap; /* Keep "I Love You" on one line */
    z-index: 2000;
}

/* --- Personal Letter Page --- */
.personal-letter {
    font-size: 1.2em; /* Made letter text larger */
    font-style: italic;
    margin-top: 1em;
    color: #555;
    font-weight: 500;
    line-height: 1.8;
    text-align: left;
}

/* --- Buttons --- */
.button-container {
    margin-top: 25px;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-button {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9em;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 50px; /* Pill shape */
    border: none;
    cursor: pointer;
    background-image: linear-gradient(45deg, #e91e63, #c2185b);
    color: white;
    box-shadow: 0 4px 15px rgba(216, 27, 96, 0.3);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.action-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(216, 27, 96, 0.4);
}

/* Music button in header */
#music-btn {
    font-size: 0.8em;
    padding: 10px 20px;
}

/* --- Memories Page --- */
.memories-list ul {
    list-style: '💖';
    padding-left: 25px;
    margin-top: 20px;
}
.memories-list li {
    font-size: 1.2em;
    color: #333;
    padding-left: 10px;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* --- Photo Gallery Page --- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Larger images */
    gap: 15px;
}

.grid-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: transform 0.2s ease;
}
.grid-image:hover {
    transform: scale(1.05);
}

/* --- Falling Hearts --- */
#falling-hearts-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1999; /* Below header */
}

.heart-fall {
    position: absolute;
    font-size: 1.5em;
    color: red;
    opacity: 0.7;
    animation: fall 10s linear infinite;
}


/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOutUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-50px) scale(1.2); }
}

@keyframes inlineImageFade {
    /* This will be filled by JS */
    0% { opacity: 0; }
    100% { opacity: 0; }
}

@keyframes fall {
    0% { transform: translateY(-10vh) translateX(0); opacity: 0; }
    10% { opacity: 0.7; } /* Fade in */
    100% { transform: translateY(110vh) translateX(10vw); opacity: 0; } /* Fade out */
}
/* --- End Animations --- */


/* --- Responsive adjustments --- */
@media (max-width: 768px) {
    header { padding: 0 1em; }
    nav { gap: 0.5em; }
    nav a { padding: 1.5em 0.3em; font-size: 0.8em; }
    /* --- Responsive chat link --- */
    nav a#nav-chat-link-js { padding: 0.6em 1em; font-size: 0.7em; }
    #music-btn { padding: 8px 12px; font-size: 0.7em; }
    
    .page { padding: 1em; }
    .card { width: 95%; max-height: calc(100vh - 80px); }
    .content-card { width: 95%; padding: 1.5em; }

    .card-content-wrapper { padding: 1.5em; }
    #inline-slideshow-container { height: 250px; }
    
    h1 { font-size: 3.5em; }
    h2 { font-size: 2.5em; }
    p { font-size: 1.1em; }
    .counter-text { font-size: 1em; }
    
    .personal-letter { font-size: 1em; line-height: 1.6; }
    .memories-list li { font-size: 1em; }

    .button-container { flex-direction: column; align-items: center; }
    
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 5px; }
    .grid-image { height: 120px; }
}

@media (max-width: 480px) {
    h1 { font-size: 2.5em; }
    h2 { font-size: 2em; }
    p { font-size: 1em; }
    #inline-slideshow-container { height: 200px; }
    .content-card { padding: 1em; }
    .card-content-wrapper { padding: 1.5em 1em; }
    .personal-letter { font-size: 0.9em; }
}

/* ----------------------- CHAT + MOBILE PATCH (added below) ----------------------- */
/* Scoped, minimal changes — only affects the chat widget and open button. */

/* ensure chat sits above header and other content when visible */
#chat-widget-container {
  z-index: 110000 !important;
  transition: transform 220ms ease, opacity 180ms ease;
  transform-origin: right bottom;
  opacity: 1;
  /* keep display controlled by inline style or JS (.open toggles display below) */
  position: fixed !important;
  right: 20px;
  bottom: 80px;
  width: 350px;
  height: 540px;
  max-width: 92%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0,0,0,0.18);
  display: none; /* JS should add .open to show */
}

/* show via JS by adding .open (non-destructive) */
#chat-widget-container.open {
  display: flex !important;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* floating open button must stay above everything too */
#open-chat-btn {
  z-index: 110001 !important;
}

/* compact header so it doesn't eat vertical space on mobile */
#chat-widget-container > header {
  padding: 10px 12px;
  gap: 10px;
  min-height: 48px;
  align-items: center;
  display: flex;
}

/* header text scaled for small screens */
#chat-widget-container h1 { font-size: 1rem; margin: 0; line-height: 1; }
#chat-widget-container p#chat-status { font-size: 0.75rem; margin: 0; opacity: 0.95; }

/* chat messages area — fill available space and scroll smoothly */
#chat-messages-widget {
  background: #071023; /* keep same dark bg you used */
  padding: 12px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  box-sizing: border-box;
}

/* make message text slightly smaller on mobile, easier to read */
#chat-messages-widget .p-3,
#chat-messages-widget > div {
  font-size: 0.95rem;
  line-height: 1.35;
}

/* sticky footer/input so it stays above keyboard */
#chat-widget-container footer {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px;
  gap: 8px;
  background: linear-gradient(180deg, rgba(7,16,35,0.92), rgba(7,16,35,0.98));
  z-index: 3;
  display: flex;
  align-items: center;
}

/* bigger tap targets and nicer rounded input */
#message-input-widget {
  padding: 12px 14px !important;
  font-size: 16px !important;
  border-radius: 28px !important;
  min-height: 44px;
  box-sizing: border-box;
}

#send-button-widget {
  padding: 10px 12px !important;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* reduce heavy outer shadow on small screens */
@media (max-width: 640px) {
  #chat-widget-container {
    width: calc(100% - 32px) !important;
    left: 16px !important;
    right: 16px !important;
    bottom: calc(env(safe-area-inset-bottom, 16px) + 12px) !important;
    height: 62vh !important;
    max-height: calc(100vh - 120px) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.16);
  }

  /* preserve header smallness */
  #chat-widget-container > header { padding: 8px 10px; min-height: 44px; }
  #chat-widget-container h1 { font-size: 0.95rem; }
  #chat-widget-container p#chat-status { font-size: 0.72rem; }

  /* message body: leave room for header + input, allow keyboard handling */
  #chat-messages-widget {
    max-height: calc(62vh - 110px);
    padding-bottom: 8px;
  }

  /* ensure footer doesn't get pushed entirely off-screen by the keyboard */
  #chat-widget-container footer { padding: 10px 10px 14px 10px; }

  /* floating open button smaller and tucked in */
  #open-chat-btn {
    right: 16px !important;
    bottom: 16px !important;
    padding: 10px !important;
    font-size: 18px !important;
  }
}

/* Optional: allow closing chat by adding .closing (smoothness) */
#chat-widget-container.closing {
  transition: transform 180ms ease, opacity 140ms ease;
  opacity: 0;
  transform: translateY(6px) scale(0.995);
  display: none !important;
}

/* ------------------------------------------------------------------------------ */
/* End patch. Only chat/mobile-specific rules above.                                */
/* ------------------------------------------------------------------------------ */
