/* =============================================
   CLIMBERS PHOTO THEME — MAIN STYLESHEET
   ============================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #0d0d0d;
  --color-surface: #111;
  --color-text: #e8e8e8;
  --color-muted: #888;
  --color-accent: #fff;
  --color-border: rgba(255,255,255,0.08);
  --font-heading: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
  --font-body: 'Jost', 'Helvetica Neue', Arial, sans-serif;
  --grid-gap: 3px;
  --transition: 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.7;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* =============================================
   SITE HEADER
   ============================================= */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 28px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  mix-blend-mode: normal;
}

.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(13,13,13,0.7) 0%, transparent 100%);
  pointer-events: none;
}

.site-branding {
  position: relative;
  z-index: 1;
}

.site-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.site-title a {
  color: inherit;
}

/* --- Navigation --- */

.main-navigation {
  position: relative;
  z-index: 1;
}

.nav-menu {
  list-style: none;
  display: flex;
  gap: 32px;
}

.nav-menu a {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
  transition: color 0.25s;
}

.nav-menu a:hover,
.nav-menu .current-menu-item a {
  color: var(--color-accent);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  position: relative;
  z-index: 1;
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 1px;
  background: var(--color-accent);
  margin: 5px 0;
  transition: var(--transition);
}

/* =============================================
   SITE MAIN
   ============================================= */

.site-main {
  min-height: 100vh;
}

/* =============================================
   POST GRID (INDEX / ARCHIVE) — justified layout
   ============================================= */

/*
 * Justified gallery: flex-grow + flex-basis are set inline via PHP
 * using the real image aspect ratio, so each row fills the full
 * width naturally with 3-5 images depending on their proportions.
 */
.posts-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--grid-gap);
  align-content: flex-start;
}

/* --- Post Card --- */

.post-card {
  position: relative;
  overflow: hidden;
  background: #1a1a1a;
  /* height + flex values come from inline styles set by PHP */
  height: var(--card-height, 300px);
  min-width: 120px; /* prevent slivers on very narrow aspect ratios */
}

.post-card__link {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
}

.post-card__image-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.post-card__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform var(--transition);
  will-change: transform;
}

.post-card:hover .post-card__image-wrap img {
  transform: scale(1.04);
}

/* Gradient overlay — only at bottom for title readability */
.post-card__overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 20px 20px;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.65) 0%,
    rgba(0, 0, 0, 0.2) 50%,
    transparent 100%
  );
  transition: opacity var(--transition);
}

.post-card__title {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.4;
  text-align: center;
}

/* No-image fallback: square placeholder */
.post-card--no-image {
  flex-grow: 1;
  flex-basis: 300px;
}

.post-card--no-image .post-card__overlay {
  position: static;
  background: none;
  padding: 24px;
  display: flex;
  align-items: flex-end;
  height: 100%;
}

.post-card--no-image .post-card__title {
  color: var(--color-text);
}

/* =============================================
   INFINITE SCROLL
   ============================================= */

/* Invisible element watched by IntersectionObserver */
.scroll-sentinel {
  height: 1px;
  pointer-events: none;
  visibility: hidden;
}

/* Banner card — full-width row in the justified flex grid */
.post-card--banner {
  flex-basis: 100%;   /* forces a new row, filling the full width */
  height: auto;
  min-height: 90px;
  background: rgba(255, 255, 255, 0.025);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;  /* ad networks may render slightly outside bounds */
  padding: 16px;
  animation: none;    /* skip the card fade-in for banners */
}

/* Empty placeholder while the banner fetches */
.post-card--banner:empty {
  min-height: 0;
  padding: 0;
  border: none;
}

/* Three-dot pulsing loader */
.posts-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 48px 0 60px;
}

.posts-loading__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-muted);
  animation: dotPulse 1.2s ease-in-out infinite;
}

.posts-loading__dot:nth-child(2) { animation-delay: 0.2s; }
.posts-loading__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.15; transform: scale(0.7); }
  40%           { opacity: 1;    transform: scale(1);   }
}

/* =============================================
   SINGLE POST
   ============================================= */

.single-post {
  padding-top: 0;
}

/* Full-width featured image — shown complete, no crop, no padding */
.single-post__hero {
  width: 100%;
  background: var(--color-bg);
  /* The fixed header floats over the image with its gradient,
     so no padding-top needed here. */
}

.single-post__hero img {
  width: 100%;
  height: auto;
  display: block;
}

/* Post content area */
.single-post__content {
  max-width: 680px;
  margin: 0 auto;
  padding: 70px 40px 60px;
}

.single-post__meta {
  display: flex;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
}

.single-post__category {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.single-post__date {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--color-muted);
}

.single-post__title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 400;
  line-height: 1.15;
  color: var(--color-accent);
  margin-bottom: 36px;
  letter-spacing: 0.02em;
}

.single-post__body {
  font-size: 0.95rem;
  font-weight: 300;
  line-height: 1.9;
  color: rgba(232, 232, 232, 0.75);
}

.single-post__body p {
  margin-bottom: 1.5em;
}

.single-post__body p:last-child {
  margin-bottom: 0;
}

.single-post__body h2,
.single-post__body h3 {
  font-family: var(--font-heading);
  font-weight: 400;
  color: var(--color-accent);
  margin: 2em 0 0.8em;
}

.single-post__body h2 { font-size: 1.6rem; }
.single-post__body h3 { font-size: 1.25rem; }

.single-post__body a {
  color: var(--color-accent);
  border-bottom: 1px solid rgba(255,255,255,0.2);
  transition: border-color 0.2s;
}

.single-post__body a:hover {
  border-color: rgba(255,255,255,0.7);
}

/* =============================================
   POST NAVIGATION (PREV / NEXT)
   ============================================= */

.post-navigation {
  border-top: 1px solid var(--color-border);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.post-navigation__item {
  padding: 40px;
}

.post-navigation__item--next {
  border-left: 1px solid var(--color-border);
  text-align: right;
}

.post-navigation__label {
  display: block;
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 10px;
}

.post-navigation__title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 400;
  color: rgba(255,255,255,0.6);
  transition: color 0.25s;
  line-height: 1.3;
}

.post-navigation__item a:hover .post-navigation__title {
  color: var(--color-accent);
}

/* =============================================
   BACK LINK
   ============================================= */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-muted);
  padding: 40px 40px 0;
  transition: color 0.25s;
}

.back-link:hover {
  color: var(--color-accent);
}

.back-link::before {
  content: '';
  display: block;
  width: 28px;
  height: 1px;
  background: currentColor;
  transition: width 0.3s;
}

.back-link:hover::before {
  width: 40px;
}

/* =============================================
   404 PAGE
   ============================================= */

.error-404 {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}

.error-404__code {
  font-family: var(--font-heading);
  font-size: clamp(6rem, 20vw, 14rem);
  font-weight: 300;
  color: rgba(255,255,255,0.05);
  line-height: 1;
  margin-bottom: -2rem;
}

.error-404__title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: 16px;
}

.error-404__text {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--color-muted);
  margin-bottom: 40px;
}

.btn {
  display: inline-block;
  padding: 12px 32px;
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--color-accent);
  border: 1px solid rgba(255,255,255,0.25);
  transition: all 0.25s;
}

.btn:hover {
  background: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
}

/* =============================================
   SITE FOOTER
   ============================================= */

.site-footer {
  padding: 40px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.site-footer__copy {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--color-muted);
}

.site-footer__links {
  display: flex;
  gap: 24px;
  list-style: none;
}

.site-footer__links a {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-muted);
  transition: color 0.25s;
}

.site-footer__links a:hover {
  color: var(--color-accent);
}

/* =============================================
   NO POSTS
   ============================================= */

.no-posts {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 40px;
}

.no-posts__title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--color-muted);
  margin-bottom: 12px;
}

.no-posts__text {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: rgba(136,136,136,0.6);
}

/* =============================================
   RESPONSIVE
   ============================================= */

/* Tablet: slightly shorter rows so 3+ images still fit */
@media (max-width: 1024px) {
  .posts-grid {
    --card-height: 220px;
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 20px 24px;
  }

  .main-navigation {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(13,13,13,0.97);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99;
  }

  .main-navigation.is-open {
    display: flex;
  }

  .nav-menu {
    flex-direction: column;
    gap: 24px;
    text-align: center;
  }

  .nav-menu a {
    font-size: 0.85rem;
    letter-spacing: 0.3em;
  }

  .menu-toggle {
    display: block;
  }

  /* ---- Mobile grid: single column, full natural image size ---- */

  /* Stack cards vertically, no flex row-filling needed */
  .posts-grid {
    display: block;
  }

  .posts-grid .post-card + .post-card {
    margin-top: 2px;
  }

  /* Card height is driven by the image, not a fixed value */
  .post-card {
    height: auto;
  }

  .post-card__link {
    /* Keep position:relative so the overlay can be absolute inside */
    height: auto;
  }

  /* Remove absolute positioning — image now flows in normal document */
  .post-card__image-wrap {
    position: static;
  }

  /* Image at 100% width, natural height — no crop at all */
  .post-card__image-wrap img {
    width: 100%;
    height: auto;
    object-fit: unset;
  }

  /* Overlay stays pinned to the bottom of the image via the
     position:relative on .post-card__link */
  .post-card__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
  }

  /* ---- Single post ---- */
  .single-post__content {
    padding: 48px 24px 40px;
  }

  .back-link {
    padding: 24px 24px 0;
  }

  /* ---- Post navigation ---- */
  .post-navigation {
    grid-template-columns: 1fr;
  }

  .post-navigation__item {
    padding: 28px 24px;
  }

  .post-navigation__item--next {
    border-left: none;
    border-top: 1px solid var(--color-border);
    text-align: left;
  }

  /* ---- Footer ---- */
  .site-footer {
    flex-direction: column;
    text-align: center;
    padding: 28px 24px;
    gap: 16px;
  }
}

/* =============================================
   LOADING FADE-IN
   ============================================= */

.post-card {
  animation: fadeIn 0.6s ease both;
}

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

/* Stagger cards */
.post-card:nth-child(2) { animation-delay: 0.05s; }
.post-card:nth-child(3) { animation-delay: 0.1s; }
.post-card:nth-child(4) { animation-delay: 0.05s; }
.post-card:nth-child(5) { animation-delay: 0.1s; }
.post-card:nth-child(6) { animation-delay: 0.15s; }
