/* GLOBAL */
:root {
  /* Colors */
  --color-dark: #333333;      /* Primary text / Navbar links */
  --color-medium: #444444;    /* Intro text / Captions */
  --color-muted: #666666;     /* Secondary text / Index */
  --color-light: #777777;     /* Separators (cap-sep) */
  --color-border: #eaeaea;    /* Navbar/Footer borders */
  --color-accent: #007bff;    /* Follow-up links */
  --color-white: #ffffff;
  
  /* Typography and Typography Scale */
  --font-primary: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-headers: "Outfit", sans-serif;
  --weight-medium: 500;
  --weight-regular: 400;
  --weight-high: 600;
  
  /* Layout */
  --max-width-site: 1400px;
  --max-width-text: 800px;    /* Used for About page/Intros */
  --border-radius-sm: 6px;
  --border-radius-md: 12px;

  /* gaps, border radii etc */
  --gap-standard: 20px;       /* The "Master" spacing for the whole site */
  --transition-speed: 0.5s;
  --transition-curve: ease-in-out;
  
  --target-height: clamp(250px, 15vh + 10vw, 450px);
}

/* standard pad across all the elements */
.standard-pad {
  box-sizing: border-box;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--gap-standard);
  padding-right: var(--gap-standard);
}

body {
  margin: 0;
  font-family: var(--font-primary);
  color: var(--color-dark);
  background-color: var(--color-white);
}

h1, h2, h3, h4 {
  font-family: var(--font-headers);
  font-weight: var(--weight-medium);
  text-align: center;
}

/* Utility Class to replace repetitive 1400px blocks */
.container {
  max-width: var(--max-width-site);
  margin: 0 auto;
  padding: 0 1rem;
}

/* NAVBAR */
.navbar {
  background: var(--color-white);
  padding: 1rem 0px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: var(--max-width-site);
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center; 
}

.logo img {
  height: clamp(40px, 6vh, 70px); /* 40px on small screens, up to 70px on large */
  width: auto;
  display: block;
  transition: height 0.3s ease;
}

.nav-links {
  list-style: none;
  display: flex;
  margin: 0;
  padding: 0;
  gap: clamp(1rem, 3vw, 3rem);
}

.nav-links a {
  text-decoration: none;
  color: var(--color-dark);
  font-weight: var(--weight-medium);
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--color-accent);
}

/* -------------------------------------------- */
/* HOMEPAGE GRID                        */
/* -------------------------------------------- */

.intro {
  max-width: var(--max-width-site);
  margin: 0 auto;
  text-align: center;
}

.intro h1 {
  padding: 0 10px;
}

.intro p {
  text-align: left;
  color: var(--color-medium);
  line-height: var(--line-height-base);
}

.grid {
  display: grid;
  gap: var(--gap-standard); 
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(350px, 30vw, 400px)), 1fr));
}

.panel {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
}

.panel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-speed) var(--transition-curve);
  image-rendering: -webkit-optimize-contrast; /* For Safari/iOS sharpness */
  image-rendering: high-quality;             /* Standard for high-end scaling */
}

.panel:hover img {
  transform: scale(1.1);
}

.caption {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 0.5rem 0;
  text-align: center;
  
  /* Use your site's dark variable or a solid semi-black */
  background: rgba(15, 20, 30, 0.5); 
  
  color: var(--color-white);
  font-size: 1rem;
  font-weight: var(--weight-high);
  text-shadow: 0 0 2px rgba(0, 0, 0, 1);
  letter-spacing: 0.3px;
  pointer-events: none;

  white-space: nowrap;      /* Forces the text to stay on one line */
  overflow: hidden;         /* Hides anything that pokes out */
  text-overflow: ellipsis;  /* Adds '...' if the title is truly too long */

  opacity: 0;
  animation: fadeIn 0.7s var(--transition-curve) forwards;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

@media (max-width: 768px) {
  .intro {
    /* Controls the gap between the Navbar and the Title */
    margin-top: 1rem; 
    padding-bottom: var(--gap-standard);
  }

  .intro h1 {
    font-size: 1.4rem;
    margin-bottom: 0.75rem; /* Zero top margin, small bottom margin */
    text-align: center;
    line-height: 1.2;
  }

  .intro p {
    max-height: 75px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.6;
  
    border-left: 4px solid var(--color-accent);
    margin: 0;
    padding-left: 5px;
    /* Improves scrolling feel on iOS */
    -webkit-overflow-scrolling: touch; 
  }

  .caption {
    font-size: 0.85rem;
    background: rgba(15, 20, 30, 0.6); 
  }
}

/* ---------------------------------------------------------- */
/* ARTICLE/GALLERY PAGE – TITLE + INTRO.                      */
/* ---------------------------------------------------------- */

.article-intro {
  max-width: 100%;
}

#article-intro-text {
  max-width: var(--max-width-site);
  text-align: left;
  margin: 0 auto;
  padding-bottom: var(--gap-standard);
}

.section-block {
    padding: 0;
    margin-bottom: var(--gap-standard);
    /* This is the secret sauce: */
    overflow: hidden; 
}

.section-block:last-child {
    margin-bottom: 0;
}

#article-sections {
    display: flex;
    flex-direction: column;
}

.section-block h2 {
    /* Kill the browser defaults */
    margin-top: 0;
    
    /* Apply your specific design gap */
    margin-bottom: var(--gap-standard); 
    
    /* Ensure it aligns with your text-heavy sections */
    line-height: 1.2; 
}

.article-section {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-standard);
    
    /* Pull the bottom of the GRID up */
    margin-bottom: calc(var(--gap-standard) * -1); 
}

/* THE LAST ROW FIX: Prevents 1 bird from stretching 100% wide */
.article-section::after {
    content: "";
    flex-grow: 10;
    flex-basis: var(--target-height);
    /* Ensure the ghost doesn't have its own height */
    height: 0;
    display: block;
}

.section-intro {
    max-width: var(--max-width-site);
    margin: 0 auto 20px auto;
    line-height: 1.6;
}

.article-panel {
    flex: var(--aspect-ratio) 1 calc(var(--target-height) * var(--aspect-ratio));
    position: relative;
    overflow: hidden;
    background: #1a1a1a; /* Darker for your photography */
    border-radius: 8px;
}

.article-panel::before {
    content: "";
    display: block;
    padding-bottom: calc(100% / (var(--aspect-ratio)));
}

/* --- The "Big Four" Variable Definitions --- */
.ratio-square    { --aspect-ratio: 1; }
.ratio-landscape { --aspect-ratio: 1.5; }
.ratio-portrait  { --aspect-ratio: 0.6666; }
.ratio-wide      { --aspect-ratio: 1.7777; }

.article-panel img {
    position: absolute;
    background-color: #f0f0f0;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    display: block; /* Change from vertical-align to block */
    cursor: pointer;
} 

/* --- THE BREAKPOINT TUNER --- */
@media (max-width: 768px) {
    #article-title{
      font-size: 1.5rem;
    }

    .section-block h2 {
      font-size: 1.3rem;
    }
    
    .article-panel {
        flex: 1 1 100% !important;
        max-height: 70vh; 
    }
    
    .article-section::after { 
      display: none; 
    }

    .article-intro {
      padding-bottom: var(--gap-standard) !important;
    }

    #article-intro-text {
      max-height: 75px;
      overflow-y: auto;
      font-size: 0.95rem;
      line-height: 1.6;
      border-left: 4px solid var(--color-accent);
      padding-left: 5px;
      margin: 0;
      /* Improves scrolling feel on iOS */
      -webkit-overflow-scrolling: touch; 
    }

    .section-intro {
      display: none;
    }

    /* Disable the hand pointer and the click interaction */
    .article-panel {
      cursor: default !important;
      pointer-events: none; 
      transform: none !important; /* Disables any 'zoom' on tap */
      filter: none !important;    /* Disables any brightness change on tap */
    }

    /* Ensure the lightbox elements stay hidden */
    .lightbox, 
    .lightbox-content, 
    .lightbox-caption, 
    .lightbox-followup,
    .close-lightbox,
    .lightbox-prev,
    .lightbox-next,
    #lightbox-img {
      display: none !important;
    }
}

/* ---------------------------------------------------------- */
/* GALLERY SPECIFIC OVERLAYS                                  */
/* ---------------------------------------------------------- */

/* Ensure the panel can anchor the metadata */
.gallery .article-panel {
    overflow: visible; /* Allows metadata to sit slightly cleaner if needed */
}

.gallery .article-panel img {
    border-radius: inherit;
}

body.gallery {
    --target-height: clamp(350px, 20vh + 15vw, 550px);
}

.gallery-label {
    position: absolute;
    bottom: 0;
    left: auto !important; 
    right: 0 !important;
    width: auto;
    padding: 15px 10px 5px 10px;
    color: white;
    z-index: 2; /* Sits above the image */
    font-size: 0.85rem;
    pointer-events: none; /* Clicks go through to the image/lightbox */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    margin: 0;
}

/* Variant: Black text for light/high-key backgrounds */
.gallery-label.light-bg {
    color: #000000;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
}

/* Horizontal flip for composition correction */
.flip-h {
    transform: scaleX(-1);
}

.lightbox-context-link {
    color: #ffd700; /* A nice gold or a bright accent color */
    text-decoration: underline;
    margin-left: 5px;
}

.lightbox-context-link:hover {
    color: #fff;
}

/* 📱 Mobile adjustment for metadata */
@media (max-width: 768px) {
    .gallery-label {
        font-size: 0.75rem;
        bottom: 0px;
        right: 10px;
        padding: 4px 8px;
    }
}

/* -------------------------------------------- */
/* FOOTER                                       */
/* -------------------------------------------- */

.footer {
  text-align: center;
  padding: 2rem 0; 
  margin-top: 2rem; /* Generous space after the last bird photo */
  color: var(--color-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--color-border);
  width: 100%;
}

.footer p {
  margin: 0.5rem 0;
  letter-spacing: 0.3px;
}

/* -------------------------------------------- */
/* ABOUT PAGE                                   */
/* -------------------------------------------- */

.about-container {
  max-width: var(--max-width-text);
  margin: 4rem auto 0 auto; 
  text-align: center;
  padding: 0 var(--gap-standard) 0 var(--gap-standard);   /* Keep side padding, but ensure bottom padding is 0 */
}

.about-container h2 {
  font-size: 2.2rem;
  margin-bottom: 2rem;
  font-weight: var(--weight-medium);
  color: var(--color-dark);
}

.about-portrait {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 2rem;
  /* Adds a little 'lift' from the white background */
  border: 4px solid var(--color-white);
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Explicitly targeting your text class */
.about-text {
  text-align: left;
  line-height: var(--line-height-base);
  color: var(--color-medium);
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

.about-text strong {
  color: var(--color-dark);
  font-weight: var(--weight-medium);
}

/* Container for the featured bird image and its caption */
.about-image-block {
  margin: 3rem auto 0 auto; 
  text-align: center;
}

.about-feature-image {
  display: block;
  width: 100%;
  /* Cinematic 3:2 ratio for your travel memories */
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--border-radius-md); 
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.about-image-caption {
  font-size: 0.95rem;
  color: var(--color-muted);
  font-style: italic;
  margin-top: 0.75rem;
}

/* -------------------------------------------- */
/* ABOUT PAGE - MOBILE ADJUSTMENTS              */
/* -------------------------------------------- */

@media (max-width: 600px) {
  .about-container {
    margin: 2rem auto;
  }
  
  .about-container h2 {
    font-size: 1.8rem;
  }
  
  .about-portrait {
    width: 160px;
    height: 160px;
  }
}

/* ---------------------------------------------------------- */
/* LIGHTBOX (MODAL)                                           */
/* ---------------------------------------------------------- */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  /* Keeping your signature white-blur style */
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  justify-content: center;
  align-items: center;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) var(--transition-curve);
}

/* JS toggles this class */
.lightbox.show {
  display: flex;
  opacity: 1;
  pointer-events: all;
}

.lightbox-content {
  display: block;
  margin: 0 auto;
  width: min-content; /* Your magic fix for caption alignment */
  max-width: 88vw;
}

#lightbox-img {
  display: block;
  max-width: 88vw;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--border-radius-sm); /* Using your 6px radius */
}

/* ---------------------------------------------------------- */
/* LIGHTBOX TEXT & CAPTIONS                                   */
/* ---------------------------------------------------------- */

.lightbox-caption, 
.lightbox-followup {
  display: block;
  text-align: center;
  width: auto;
  word-wrap: break-word;
  overflow-wrap: break-word;
  opacity: 0;
  animation: fadeIn 0.5s ease-in-out forwards;
  animation-delay: 0.1s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px); /* Subtle slide up for a pro feel */
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lightbox-caption {
  padding: 15px 10px 5px 10px;
  font-size: 1.2rem;
  line-height: var(--line-height-base);
  color: var(--color-dark);
  text-align: left;
  max-height: 25vh;
  overflow-y: auto;
}

.cap-sep {
  margin: 0 12px;
  color: var(--color-muted);
  user-select: none;
}

.lightbox-followup {
  padding: 5px 10px 15px 10px;
  font-size: 0.9rem;
  color: var(--color-medium);
}

.lightbox-followup a {
  color: var(--color-dark); /* Subtle link */
  text-decoration: underline;
  font-weight: var(--weight-medium);
}

/* ---------------------------------------------------------- */
/* NAVIGATION & CONTROLS                                      */
/* ---------------------------------------------------------- */

.close-lightbox {
  position: absolute;
  top: 20px;
  right: 30px;
  color: var(--color-dark);
  font-size: 40px;
  cursor: pointer;
  z-index: 3001;
  -webkit-user-select: none; /* Safari */
  -ms-user-select: none;      /* IE 10 and 11 */
  user-select: none;          /* Standard syntax */
  -webkit-touch-callout: none;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  cursor: pointer;
  color: var(--color-dark);
  opacity: 0.6;
  user-select: none;
  transition: opacity 0.3s ease;
  -webkit-user-select: none; /* Safari */
  -ms-user-select: none;      /* IE 10 and 11 */
  user-select: none;          /* Standard syntax */
  -webkit-touch-callout: none;
}

.lightbox-prev:hover, .lightbox-next:hover { opacity: 1; }
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

.lightbox-index {
  position: absolute;
  bottom: 20px;
  left: 20px;
  color: var(--color-muted);
  font-size: 1.1rem;
}

/* ---------------------------------------------------------- */
/* RESPONSIVE FIXES                                           */
/* ---------------------------------------------------------- */

/* Tablet/iPad - Keep font sizes readable but compact */
@media (max-width: 1366px) {
  .lightbox-caption {
    font-size: 0.9rem !important; 
    max-height: 15vh;
    line-height: 1.3 !important; /* Tighter spacing for tablet captions */
    padding: 10px 10px 5px 10px; /* Reducing top padding slightly */
  }
  .lightbox-followup {
    font-size: 0.85rem !important; 
  }
}

/* Phones - Final Safety Guards */
@media (max-width: 600px) {
  .cap-sep {
    margin: 0 6px;
  }
  
  #lightbox-img {
    max-height: 60vh; /* More room for text on vertical phones */
  }

  .lightbox-prev, .lightbox-next {
    font-size: 2.5rem;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* -------------------------------------------- */
/* BACK TO TOP                                  */
/* -------------------------------------------- */
#back-to-top {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 15px 25px;
  font-size: 24px;
  background-color: var(--color-dark);
  color: var(--color-white);
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  z-index: 5000; /* Match the progress bar's priority */
  
  /* Reset visibility logic to ensure transitions work */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

#back-to-top.show {
  opacity: 1;
  visibility: visible;
}

/* -------------------------------------------- */
/* PROGRESS BAR                                 */
/* -------------------------------------------- */
#progress-container {
  position: fixed;
  top: 0;
  left: 0;
  height: 8px;
  width: 100%;
  background: rgba(0, 0, 0, 0.1);
  /* Use a very high number to stay above the Navbar (1000) and Body */
  z-index: 5000; 
  display: block !important; /* Ensures it's not hidden by a parent's display logic */
}

#progress-bar {
  height: 100%;
  background: #e74c3c;
  width: 0%;
  border-radius: var(--border-radius-sm);
  transition: width 0.15s ease-out;
} 