@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400..700&family=EB+Garamond:ital,wght@0,400..800;1,400..800&family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap');

:root {
  --color-wood: #1e1610;
  --color-leather: #5c2c16;
  --color-leather-light: #8b4513;
  --color-leather-dark: #3a1a0c;
  --color-parchment: #fdfbf7;
  --color-parchment-dark: #ecdab3;
  --color-ink: #2c2520;
  --color-ink-muted: #5e5147;
  --font-serif: 'EB Garamond', serif;
  --font-title: 'Playfair Display', serif;
  --font-handwritten: 'Caveat', cursive;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--color-wood);
  /* Textured walnut wood desk background */
  background-image: 
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.7) 100%),
    url('Attachments/desk_texture.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  font-family: var(--font-serif);
  color: var(--color-ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  padding: 20px;
}

/* Site Banner Title */
.site-header {
  width: 100%;
  max-width: 900px;
  text-align: center;
  margin: 15px auto 5px auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.back-link {
  display: inline-block;
  font-family: var(--font-handwritten);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--color-leather-light); /* Leather brown for reading on parchment page */
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
}

.back-link:hover {
  color: var(--color-leather-dark);
  transform: translateX(-4px);
}

.site-title {
  font-family: var(--font-title);
  font-size: 2.2rem;
  color: #f7ebd3; /* Warm ivory to pop off the wood desk */
  text-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.9),
    0 4px 12px rgba(0, 0, 0, 0.5);
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 2px dashed rgba(247, 235, 211, 0.15);
  padding-bottom: 12px;
}

/* Scrollbar styling for travel journal feel */
::-webkit-scrollbar {
  width: 12px;
}
::-webkit-scrollbar-track {
  background: var(--color-wood);
}
::-webkit-scrollbar-thumb {
  background: var(--color-leather);
  border: 3px solid var(--color-wood);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-leather-light);
}

/* Journal Wrapper */
.journal-container {
  width: 100%;
  max-width: 900px;
  margin: 20px auto;
  position: relative;
}

/* Journal Leaf / Page */
.journal-page {
  background-color: var(--color-parchment);
  /* Aged paper effect */
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(240, 225, 200, 0.3), transparent 60%),
    radial-gradient(circle at 90% 90%, rgba(220, 200, 170, 0.3), transparent 60%);
  border-radius: 4px 16px 16px 4px;
  box-shadow: 
    0 15px 35px rgba(0, 0, 0, 0.4),
    0 5px 15px rgba(0, 0, 0, 0.2),
    inset 0 0 80px rgba(139, 69, 19, 0.08);
  border: 1px solid rgba(139, 69, 19, 0.15);
  padding: 40px 50px 50px 75px; /* Extra left padding for binding */
  position: relative;
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  transition: transform 0.5s ease, opacity 0.3s ease;
}

#journalWatermarkContainer {
  display: contents;
}

/* Vintage travel postmark watermark background */
.vintage-watermark {
  position: absolute;
  top: 120px; /* Fixed distance below the header line */
  right: 40px; /* Positioned in the upper right corner */
  width: 210px; /* Compact size to fit elegantly in the corner */
  height: 210px;
  opacity: 0.15; /* Clear visibility on all monitors */
  transform: rotate(-12deg);
  pointer-events: none; /* allow clicks to pass through */
  z-index: 1; /* behind content text and images */
  user-select: none;
}

/* Page spine binder */
.journal-page::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(
    to right, 
    var(--color-leather-dark) 0%, 
    var(--color-leather) 25%, 
    var(--color-leather-light) 50%, 
    var(--color-leather) 75%, 
    var(--color-leather-dark) 100*
  );
  border-right: 2px solid rgba(0,0,0,0.3);
  box-shadow: 3px 0 10px rgba(0,0,0,0.3);
  border-radius: 4px 0 0 4px;
  z-index: 5;
}

/* Stitched binder line */
.journal-page::after {
  content: '';
  position: absolute;
  top: 0;
  left: 36px;
  bottom: 0;
  width: 1px;
  border-left: 1px dashed rgba(139, 69, 19, 0.25);
  z-index: 4;
}

/* Header & Dropdown navigation */
.journal-header {
  display: flex;
  flex-direction: column;
  border-bottom: 2px double rgba(139, 69, 19, 0.25);
  padding-bottom: 15px;
  margin-bottom: 30px;
  gap: 12px;
}

.journal-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}



.journal-title-main {
  font-family: var(--font-title);
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--color-leather-dark);
  text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.8);
  line-height: 1.25;
  width: 100%;
  margin-top: 5px;
}

/* Top Navigation Dropdown Styling */
.nav-dropdown-container {
  position: relative;
  display: inline-block;
}

.nav-select {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-ink);
  background-color: rgba(253, 251, 247, 0.9);
  border: 1px solid var(--color-leather);
  padding: 8px 32px 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  appearance: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b4513' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: all 0.3s ease;
}

.nav-select:hover, .nav-select:focus {
  outline: none;
  border-color: var(--color-leather-light);
  box-shadow: 0 4px 8px rgba(139, 69, 19, 0.15);
  background-color: #fff;
}

/* Dynamic Page Content Area */
.journal-content {
  flex-grow: 1;
  line-height: 1.7;
  font-size: 1.15rem;
  position: relative;
  z-index: 2; /* Render above the background watermark */
}

.journal-content h1, 
.journal-content h2, 
.journal-content h3 {
  font-family: var(--font-title);
  color: var(--color-leather-dark);
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
  text-wrap: balance;
}

.journal-content h1 {
  font-size: 1.8rem;
  border-bottom: 1px dashed rgba(139, 69, 19, 0.2);
  padding-bottom: 6px;
}

.journal-content h2 {
  font-size: 1.5rem;
}

.journal-content p {
  margin-bottom: 1.2rem;
  text-align: justify;
  text-wrap: pretty;
}

.journal-content strong {
  color: var(--color-leather);
}

.journal-content blockquote {
  font-family: var(--font-serif);
  font-style: italic;
  border-left: 3px solid var(--color-leather-light);
  padding: 8px 0 8px 20px;
  margin: 1.5rem 0 1.5rem 10px;
  color: var(--color-ink-muted);
  background-color: rgba(139, 69, 19, 0.02);
  border-radius: 0 8px 8px 0;
  text-wrap: pretty;
}

/* Lists styling */
.journal-content ul, 
.journal-content ol {
  margin: 1rem 0 1.5rem 25px;
  text-wrap: pretty;
}

.journal-content li {
  margin-bottom: 0.5rem;
}

/* Polaroid image containers */
.polaroid-frame {
  background: #fff;
  padding: 14px 14px 36px 14px; /* Thicker bottom margin for classic Polaroid aesthetic */
  box-shadow: 
    0 8px 20px rgba(0, 0, 0, 0.15),
    0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid #eaeaea;
  margin: 2rem auto;
  max-width: 85%;
  display: table; /* Auto width based on image size */
  transform: rotate(var(--rotation, 0deg));
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
  position: relative;
  z-index: 2;
  cursor: zoom-in; /* Indicate zoom interaction */
}

/* Alternating rotation tags */
.polaroid-frame:nth-of-type(even) {
  --rotation: -1.8deg;
}
.polaroid-frame:nth-of-type(odd) {
  --rotation: 1.5deg;
}
.polaroid-frame:nth-of-type(3n) {
  --rotation: 0.8deg;
}
.polaroid-frame:nth-of-type(3n+1) {
  --rotation: -1.2deg;
}

.polaroid-frame:hover {
  transform: rotate(0deg) scale(1.03);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

.polaroid-frame img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid #dcdcdc;
  object-fit: cover;
  max-height: 480px;
}

.polaroid-caption {
  font-family: var(--font-handwritten);
  font-size: 1.45rem;
  color: #333;
  text-align: center;
  margin-top: 14px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.polaroid-spacer {
  height: 12px;
}

/* Custom Styled Audio Player */
.audio-container {
  background-color: #f6efe0;
  border: 1px dashed var(--color-leather-light);
  border-radius: 8px;
  padding: 16px;
  margin: 2rem 0;
  max-width: 450px;
  box-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.04),
    inset 0 0 20px rgba(139, 69, 19, 0.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audio-title {
  font-family: var(--font-handwritten);
  font-size: 1.35rem;
  color: var(--color-leather);
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
}

.audio-container audio {
  width: 100%;
  height: 40px;
  border-radius: 4px;
}

/* Next / Prev Navigation Buttons at Page Bottom */
.journal-footer {
  border-top: 2px double rgba(139, 69, 19, 0.25);
  padding-top: 25px;
  margin-top: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-btn {
  font-family: var(--font-handwritten);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-leather);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-btn:hover {
  color: var(--color-leather-light);
  transform: translateY(-2px);
}

.nav-btn.disabled {
  opacity: 0.15;
  cursor: not-allowed;
  pointer-events: none;
}

/* Date / Weather display */
.date-header {
  font-family: var(--font-handwritten);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-leather-light);
  margin-bottom: 20px;
  text-align: right;
  border-bottom: 1px dotted rgba(139, 69, 19, 0.15);
  padding-bottom: 8px;
}

/* Page Transition animation state */
.fade-out {
  opacity: 0;
  transform: scale(0.98) rotateX(-5deg);
}

.fade-in {
  opacity: 1;
  transform: scale(1) rotateX(0deg);
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  .journal-page {
    padding: 25px 25px 35px 45px; /* Shrink padding, binding narrower */
    border-radius: 4px 8px 8px 4px;
  }
  
  .journal-page::before {
    width: 18px; /* Thinner binder spine */
  }
  
  .journal-page::after {
    left: 22px;
  }
  
  .journal-title-main {
    font-size: 1.3rem;
  }
  
  .journal-content {
    font-size: 1.05rem;
  }
  
  .polaroid-frame {
    max-width: 100%;
    padding: 10px 10px 20px 10px;
  }
  
  .polaroid-caption {
    font-size: 1.25rem;
    margin-top: 10px;
  }
  
  .nav-btn {
    font-size: 1.35rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0;
  }
  
  .journal-container {
    margin: 0;
  }
  
  .journal-page {
    padding: 20px 15px 25px 25px; /* Minimal padding for mobile screens */
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    border: none;
  }
  
  .journal-page::before {
    width: 8px; /* Very narrow binding overlay */
  }
  
  .journal-page::after {
    left: 12px;
  }
  
  .journal-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 20px;
  }
  
  .journal-title-main {
    text-align: center;
    font-size: 1.15rem;
  }
  
  .nav-select {
    width: 100%;
    text-align: center;
    background-position: right 16px center;
  }
  
  .date-header {
    text-align: left;
    font-size: 1.3rem;
  }
  
  .audio-container {
    max-width: 100%;
  }
  
  .polaroid-frame {
    margin: 1.5rem 0;
    transform: none !important; /* No rotations on small screens */
  }

  .vintage-watermark {
    width: 140px;
    height: 140px;
    top: 155px; /* Positioned below mobile header elements */
    right: 15px;
    opacity: 0.12; /* Softer contrast for smaller viewports */
  }
}

/* Lightbox Modal for Zooming Photos */
.lightbox-modal {
  display: none;
  position: fixed;
  z-index: 9999; /* Topmost overlay */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(18, 15, 12, 0.95); /* Extremely dark brown-black vignette */
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox-modal.active {
  display: flex;
  opacity: 1;
}

.lightbox-modal img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  border: 8px solid #fff;
  border-radius: 4px;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

.lightbox-modal.active img {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: #fff;
  font-size: 50px;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease;
}

.lightbox-close:hover {
  color: var(--color-parchment-dark);
}
