/* ============================================================
   CELEBROLOGY INTERNATIONAL — Responsive Stylesheet
   Breakpoints: 1200 | 992 | 768 | 576 | 400
   html/body overflow-x:hidden is set in style.css (global).
   ============================================================ */

/* =========================================================
   GLOBAL MOBILE SAFETY NET
   Ensures nothing wider than viewport causes side-scroll.
   ========================================================= */
img, video, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

/* Every section and container is contained */
section, .container, .container-sm,
header, footer, nav, main, aside, article {
  max-width: 100%;
}

/* =========================================================
   LARGE DESKTOP  ≤ 1200px
   ========================================================= */
@media (max-width: 1200px) {
  :root { --container-max: 960px; }
  .footer-grid { grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 2rem; }
  .posts-grid { grid-template-columns: repeat(2, 1fr); }
  .publications-grid { grid-template-columns: repeat(2, 1fr); }
}

/* =========================================================
   TABLET LANDSCAPE  ≤ 992px
   Hamburger menu kicks in, sidebar stacks, grids collapse.
   ========================================================= */
@media (max-width: 992px) {
  :root { --header-height: 70px; }

  /* ---------- Navbar → hamburger ---------- */
  .hamburger { display: flex; }
  .navbar-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    max-width: 85vw;       /* never wider than 85% on small screens */
    height: 100vh;
    background: var(--color-dark);
    flex-direction: column;
    align-items: flex-start;
    padding: 5rem 1.5rem 2rem;
    gap: 0;
    z-index: 999;
    transition: right 0.35s ease;
    overflow-y: auto;
    overflow-x: hidden;
    border-left: 2px solid var(--color-gold);
  }
  .navbar-menu.open { right: 0; }
  .nav-item { width: 100%; }
  .nav-link {
    padding: .9rem 0;
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: .9rem;
    white-space: normal;   /* allow wrapping on narrow menu */
  }
  .nav-item.active > .nav-link::after { display: none; }
  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: rgba(255,255,255,.04);
    border-top: none;
    box-shadow: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s;
    padding: 0;
  }
  .nav-item.dropdown-open .dropdown-menu { max-height: 400px; }
  .dropdown-menu li a { padding: .65rem 1rem; font-size: .85rem; }

  /* ---------- About Intro ---------- */
  .about-intro .container { grid-template-columns: 1fr; gap: 2.5rem; }
  .about-intro-image { max-width: 500px; margin: 0 auto; }

  /* ---------- Mission ---------- */
  .mission-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .mission-image { order: -1; }

  /* ---------- Blog main layout (class-based) ---------- */
  .blog-main-grid {
    display: block !important; /* block fallback — no side-by-side at all */
  }
  .blog-main-grid > aside {
    position: static !important;
    top: auto !important;
    width: 100%;
    margin-top: 2rem;
  }

  /* ---------- Blog 2-col post grid ---------- */
  .blog-posts-2col { grid-template-columns: 1fr 1fr !important; }

  /* ---------- Category main layout (class-based) ---------- */
  .cat-main-grid {
    display: block !important;
  }
  .cat-main-grid > aside {
    position: static !important;
    top: auto !important;
    width: 100%;
    margin-top: 2rem;
  }

  /* ---------- Legacy CSS-class based blog grid ---------- */
  .blog-grid { grid-template-columns: 1fr; }
  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
  .post-article-grid { grid-template-columns: 1fr; }
  .post-article-grid .sidebar { display: flex; flex-direction: column; }

  /* ---------- Journal CTA ---------- */
  .journal-cta-grid { grid-template-columns: 1fr !important; gap: 1.5rem !important; }

  /* ---------- Contact ---------- */
  .contact-grid { grid-template-columns: 1fr; }

  /* ---------- Callout ---------- */
  .callout-grid { grid-template-columns: 1fr; gap: 2.5rem; }

  /* ---------- Categories ---------- */
  .categories-grid { grid-template-columns: repeat(2, 1fr); }

  /* ---------- Footer ---------- */
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 2.5rem; }
  .footer-about { grid-column: 1 / -1; }

  /* ---------- Post card wide ---------- */
  .post-card-wide { grid-template-columns: 220px 1fr; }

  /* ---------- Publications preview on home ---------- */
  .pub-preview-grid { grid-template-columns: 1fr 1fr !important; gap: 1.5rem !important; }

  /* ---------- About pages 2-col grids ---------- */
  .about-2col-grid { grid-template-columns: 1fr !important; }

  /* ---------- Pub tabs ---------- */
  .pub-tabs-row { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pub-tab-link { white-space: nowrap; }
}

/* =========================================================
   TABLET PORTRAIT  ≤ 768px
   ========================================================= */
@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.6rem; }

  /* ---------- Top bar hidden ---------- */
  .top-bar { display: none; }

  /* ---------- Hero ---------- */
  .hero { min-height: 75vh; }
  .hero-buttons { flex-direction: column; align-items: flex-start; }
  .hero-buttons .btn { width: 100%; max-width: 300px; justify-content: center; }

  /* ---------- Newsletter ---------- */
  .newsletter-inner { flex-direction: column; align-items: flex-start; gap: 1.5rem; }
  .newsletter-form { min-width: unset; width: 100%; max-width: unset; }
  .newsletter-input-group { flex-direction: column; }
  .newsletter-input-group input { border-radius: var(--radius); }
  .newsletter-input-group .btn-gold {
    border-radius: var(--radius);
    width: 100%;
    justify-content: center;
  }

  /* ---------- Post grid ---------- */
  .posts-grid { grid-template-columns: 1fr; }
  .post-card-wide { grid-template-columns: 1fr; }
  .post-card-wide .post-card-image { height: 220px; }

  /* ---------- Sidebar (legacy class) ---------- */
  .sidebar { grid-template-columns: 1fr; }

  /* ---------- Publications (publication pages) ---------- */
  .publications-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
  }

  /* ---------- Form rows ---------- */
  .form-row { grid-template-columns: 1fr; }

  /* ---------- About stats ---------- */
  .about-stats { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
  .stat-number { font-size: 1.5rem; }

  /* ---------- Section header ---------- */
  .section-header { flex-direction: column; align-items: flex-start; gap: 1rem; }

  /* ---------- Page hero ---------- */
  .page-hero { padding: 3.5rem 0 2.5rem; }

  /* ---------- Footer ---------- */
  .footer-grid { grid-template-columns: 1fr; }
  .footer-about { grid-column: auto; }
  .back-to-top { bottom: 1.25rem; right: 1.25rem; }

  /* ---------- Featured post image (blog.php) ---------- */
  .featured-post-img-wrap { height: 240px !important; }

  /* ---------- Blog 2-col posts → still 2-col until 576px ---------- */
  /* (no change — we collapse at 576px) */

  /* ---------- About page button groups ---------- */
  .about-page-btns { flex-direction: column; align-items: center; }
  .about-page-btns .btn { width: 100%; max-width: 340px; justify-content: center; }
}

/* =========================================================
   MOBILE  ≤ 576px
   Full single-column. NO side scroll.
   ========================================================= */
@media (max-width: 576px) {
  :root { --container-max: 100%; }
  body { font-size: .95rem; }

  /* ---------- Container padding ---------- */
  .container,
  .container-sm { padding: 0 1rem; }

  /* ---------- Logo ---------- */
  .logo-main { font-size: 1.1rem; }

  /* ---------- Categories grid 4→2 ---------- */
  .categories-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }

  /* ---------- Hero ---------- */
  .hero { min-height: 80vh; padding: 2rem 0; }
  .hero-desc { font-size: 1rem; }
  .about-intro-image::after { display: none; }

  /* ---------- About stats ---------- */
  .about-stats { gap: .75rem; }
  .stat-number { font-size: 1.25rem; }
  .stat-label { font-size: .7rem; }

  /* ---------- Mission section ---------- */
  .mission-section { padding: 4rem 0; }
  .mission-section::after { font-size: 10rem; }

  /* ---------- Mission pillars 2-col ---------- */
  .mission-pillars-grid { grid-template-columns: 1fr 1fr !important; gap: .75rem !important; }

  /* ---------- Blog posts 2-col → 1-col ---------- */
  .blog-posts-2col { grid-template-columns: 1fr !important; }

  /* ---------- Featured post image ---------- */
  .featured-post-img-wrap { height: 200px !important; }

  /* ---------- Category cards → vertical stack ---------- */
  .cat-main-grid article {
    flex-direction: column !important;
  }
  .cat-main-grid article > a:first-child {
    width: 100% !important;
    min-height: 200px !important;
    flex-shrink: unset !important;
  }
  .cat-main-grid article > a:first-child img {
    height: 200px !important;
    min-height: 200px !important;
    width: 100% !important;
    object-fit: cover;
  }

  /* ---------- Publications preview (home) → 1 col ---------- */
  .pub-preview-grid {
    grid-template-columns: 1fr !important;
    max-width: 360px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* ---------- Pub tabs ---------- */
  .pub-tab-link { padding: .85rem 1rem !important; font-size: .78rem !important; }

  /* ---------- About pages grids ---------- */
  .about-2col-grid { grid-template-columns: 1fr !important; gap: 1.25rem !important; }

  /* ---------- About founder card → vertical ---------- */
  .about-founder-card { flex-direction: column !important; gap: 1rem !important; }
  .about-founder-card > div:first-child {
    width: 60px !important;
    height: 60px !important;
    font-size: 1.4rem !important;
  }

  /* ---------- About page button groups ---------- */
  .about-page-btns {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .85rem;
    margin-top: 2rem;
  }
  .about-page-btns .btn {
    width: 100%;
    max-width: 100%;
    justify-content: center;
    margin-left: 0 !important;
  }

  /* ---------- Post meta ---------- */
  .post-meta { gap: .75rem; font-size: .8rem; }
  .post-meta-item:nth-child(n+4) { display: none; }

  /* ---------- Share buttons ---------- */
  .post-share span { display: none; }

  /* ---------- Comment form ---------- */
  .comment-avatar { width: 38px; height: 38px; font-size: .85rem; }

  /* ---------- Pagination ---------- */
  .pagination a, .pagination span { width: 36px; height: 36px; font-size: .82rem; }

  /* ---------- Author box ---------- */
  .author-box { flex-direction: column; text-align: center; }
  .author-avatar { margin: 0 auto; }

  /* ---------- Contact ---------- */
  .contact-form-card { padding: 1.5rem; }

  /* ---------- Newsletter ---------- */
  .newsletter-section { padding: 3rem 0; }
  .newsletter-text h3 { font-size: 1.3rem; }

  /* ---------- Callout features ---------- */
  .callout-feature { gap: .75rem; }
  .callout-feature-icon { width: 38px; height: 38px; }

  /* ---------- Section spacing ---------- */
  .about-intro,
  .mission-section,
  .featured-posts,
  .categories-section,
  .celebrology-callout,
  .publications-section,
  .contact-section,
  .blog-layout,
  .post-layout,
  .search-results-page,
  .about-content-section { padding: 3.5rem 0; }
}

/* =========================================================
   AUTO-FILL GRIDS — Safety net for very narrow screens
   Prevents minmax(320px,...) from creating side-scroll.
   ========================================================= */
@media (max-width: 380px) {
  div[style*="minmax(320px"] {
    grid-template-columns: 1fr !important;
  }
}

/* =========================================================
   VERY SMALL PHONES  ≤ 400px
   ========================================================= */
@media (max-width: 400px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.15rem; }

  /* ---------- Container ---------- */
  .container,
  .container-sm { padding: 0 .875rem; }

  /* ---------- Hero ---------- */
  .hero { min-height: 85vh; }
  .hero h1 { font-size: 1.75rem; }
  .hero-desc { font-size: .93rem; }
  .hero-kicker span { font-size: .68rem; }
  .hero-buttons .btn { max-width: 100%; }

  /* ---------- Categories → 1 col on tiny phones ---------- */
  .categories-grid { grid-template-columns: 1fr; gap: 1rem; }
  .category-card { padding: 1.75rem 1rem; }

  /* ---------- Mission pillars → 1 col ---------- */
  .mission-pillars-grid { grid-template-columns: 1fr !important; }

  /* ---------- Featured post image ---------- */
  .featured-post-img-wrap { height: 170px !important; }

  /* ---------- Publications preview ---------- */
  .pub-preview-grid { max-width: 100% !important; }

  /* ---------- Page hero ---------- */
  .page-hero { padding: 2.5rem 0 2rem; }
  .page-hero h1 { font-size: 1.75rem; }

  /* ---------- Footer ---------- */
  .footer-grid { gap: 2rem; }
  .footer-social a { width: 32px; height: 32px; font-size: .8rem; }

  /* ---------- Pagination ---------- */
  .pagination { gap: .3rem; }
  .pagination a, .pagination span { width: 32px; height: 32px; font-size: .78rem; }

  /* ---------- Back to top ---------- */
  .back-to-top { width: 38px; height: 38px; font-size: .8rem; }

  /* ---------- Post ---------- */
  .post-content { font-size: 1rem; }
  .post-title { font-size: 1.55rem; }

  /* ---------- Author box ---------- */
  .author-box { padding: 1.25rem; gap: 1rem; }
  .author-avatar { width: 64px; height: 64px; }

  /* ---------- Contact form ---------- */
  .contact-form-card { padding: 1.25rem; }

  /* ---------- Newsletter ---------- */
  .newsletter-section { padding: 2.5rem 0; }
}

/* =========================================================
   ABOUT PAGE BUTTON GROUPS — all sizes
   The .about-page-btns class handles multi-button rows.
   ========================================================= */
.about-page-btns {
  display: flex;
  flex-wrap: wrap;
  gap: .85rem;
  justify-content: center;
  margin-top: 2.5rem;
}
.about-page-btns .btn {
  margin: 0 !important;  /* override any inline margin-left */
}

/* =========================================================
   BLOG/CATEGORY SIDEBAR — ensure 100% width when stacked
   ========================================================= */
@media (max-width: 992px) {
  /* Sidebar inside blog-main-grid fills full width */
  .blog-main-grid > aside,
  .cat-main-grid  > aside {
    width: 100%;
    box-sizing: border-box;
  }

  /* Sidebar widget containers full width */
  .blog-main-grid > aside > div,
  .cat-main-grid  > aside > div {
    width: 100%;
    box-sizing: border-box;
  }

  /* Recent posts flex items wrap correctly */
  .blog-main-grid > aside > div [style*="display:flex"] {
    min-width: 0;
  }
}

/* =========================================================
   PREVENT BREADCRUMB OVERFLOW
   ========================================================= */
.breadcrumb {
  flex-wrap: wrap;
  overflow: hidden;
}

/* =========================================================
   PREVENT INLINE FLEX HERO BUTTONS OVERFLOW
   ========================================================= */
@media (max-width: 576px) {
  .hero-buttons {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }
  .hero-buttons .btn {
    width: 100%;
    max-width: 100%;
    justify-content: center;
  }
}

/* =========================================================
   PRINT
   ========================================================= */
@media print {
  .top-bar,
  .site-header,
  .newsletter-section,
  .site-footer,
  .back-to-top,
  .sidebar,
  .post-share,
  .comments-section,
  .comment-form,
  .pagination { display: none !important; }
  body { font-size: 12pt; color: #000; background: #fff; }
  .post-content { font-size: 11pt; line-height: 1.6; }
  a { color: #000; text-decoration: none; }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
