/**
 * Friends of Bulgaria - Responsive Catchall
 * Consolidates remaining responsive adjustments not already handled
 * in section-specific CSS (layout.css, header.css, footer.css, hero.css, sections.css).
 *
 * Mobile-first approach:
 *   Base styles (mobile) → 576px → 768px → 992px → 1200px
 *
 * Requirements: 10.1, 10.2, 10.6
 *
 * @package Friends_of_Bulgaria
 * @since   1.0.0
 */

/* =========================================
   Typography Scaling

   The heading tokens in variables.css are already fluid clamp() values taken
   from the concept, so they need no per-breakpoint overrides — adding fixed
   sizes here would override the clamp and break the intended scale.
   Only the reading measure is adjusted below.
   ========================================= */

@media (min-width: 768px) {
  /* Slightly more air between paragraphs once there is room for it. */
  p {
    margin-bottom: var(--fob-space-lg);
  }

  p:last-child {
    margin-bottom: 0;
  }
}

/* =========================================
   Spacing Adjustments
   Reduce vertical spacing on mobile to
   preserve content density; increase on desktop
   for breathing room.
   ========================================= */

/* Below 576px: tighter spacing globally */
@media (max-width: 575px) {
  .section,
  .homepage-section {
    padding-top: var(--fob-space-xl);
    padding-bottom: var(--fob-space-xl);
  }

  .homepage-section--event-strip,
  .homepage-section--donate-cta,
  .homepage-section--testimonials {
    padding-top: 0;
    padding-bottom: 0;
  }

  .homepage-section--about {
    padding-bottom: 0;
  }

  .section-header {
    margin-bottom: var(--fob-space-xl);
  }

  /* Reduce card body padding on small screens */
  .card__body {
    padding: var(--fob-space-md);
  }

  /* Tighter grid gaps on mobile */
  .grid,
  .pillar-grid,
  .partner-grid {
    gap: var(--fob-space-md);
  }
}

/* Extra-large screens: generous spacing */
@media (min-width: 1200px) {
  .section-lg {
    padding-top: 7rem;
    padding-bottom: 7rem;
  }

  .grid-gap-xl {
    gap: var(--fob-space-xxl);
  }
}

/* =========================================
   Image Sizing & Responsiveness
   Ensures images scale correctly at all
   breakpoints and maintain aspect ratios.
   Requirements: 10.5, 10.8
   ========================================= */

/* Base: all images constrained to container */
img {
  max-width: 100%;
  height: auto;
}

/* Partner logos now live on the flip card's front face, which sizes them
   itself; the pillar photo is a fixed-width flex column rather than an
   aspect-ratio box, so neither needs a breakpoint override here. */

/* Gallery images: fit within viewport at all sizes */
@media (max-width: 575px) {
  .gallery-item img,
  .project-gallery__item img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
  }
}

@media (min-width: 576px) and (max-width: 767px) {
  .gallery-item img,
  .project-gallery__item img {
    aspect-ratio: 16 / 10;
    object-fit: cover;
  }
}

/* =========================================
   Form Layout at Different Breakpoints
   Ensures forms remain usable and within
   viewport on all devices. Payment forms
   and donation buttons render without
   horizontal scrolling.
   Requirements: 10.4, 10.7
   ========================================= */

/* Base (mobile): full-width form elements, stacked layout */
.form-group {
  width: 100%;
}

/* Below 768px: ensure forms don't overflow viewport */
@media (max-width: 767px) {
  form,
  .wpcf7-form,
  .donation-form,
  .gift-aid-form {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Stack form actions vertically on mobile */
  .form-actions,
  .donation-form__actions,
  .wpcf7-form .form-actions {
    display: flex;
    flex-direction: column;
    gap: var(--fob-space-sm);
  }

  .form-actions .btn,
  .donation-form__actions .btn {
    width: 100%;
  }

  /* Donation amount buttons: 2-column grid on mobile */
  .donation-amounts,
  .donation-form__presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--fob-space-sm);
  }

  /* Full-width custom amount input */
  .donation-form__custom,
  .donation-amounts__custom {
    grid-column: 1 / -1;
  }
}

/* Medium (768px+): side-by-side form fields where appropriate */
@media (min-width: 768px) {
  .form-row,
  .form-group--inline {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--fob-space-md);
  }

  /* Donation amount buttons: single row on tablet+ */
  .donation-amounts,
  .donation-form__presets {
    display: flex;
    flex-wrap: wrap;
    gap: var(--fob-space-md);
  }
}

/* Large (992px+): wider form layouts with more breathing room */
@media (min-width: 992px) {
  .form-row,
  .form-group--inline {
    gap: var(--fob-space-lg);
  }

  /* Three-column form layout for short fields (name, city, postcode) */
  .form-row--thirds {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* =========================================
   Table Responsiveness
   WordPress content may include tables that
   need horizontal scrolling on mobile.
   ========================================= */

@media (max-width: 767px) {
  .entry-content table,
  .page-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .entry-content table td,
  .page-content table td {
    min-width: 120px;
  }
}

/* =========================================
   Archive / List Page Layout
   Pagination and post lists adapt across
   breakpoints.
   ========================================= */

/* Below 768px: single-column archive list */
@media (max-width: 767px) {
  .archive-grid,
  .post-list {
    display: flex;
    flex-direction: column;
    gap: var(--fob-space-lg);
  }

  .archive-grid .card,
  .post-list .card {
    width: 100%;
  }
}

/* Medium: 2-column archive grid */
@media (min-width: 768px) {
  .archive-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--fob-space-lg);
  }
}

/* Large: 3-column archive grid */
@media (min-width: 992px) {
  .archive-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Pagination: center-align and increase touch targets on mobile */
@media (max-width: 575px) {
  .pagination,
  .nav-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--fob-space-xs);
  }

  .pagination a,
  .pagination span,
  .nav-links a,
  .nav-links span {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--fob-space-sm);
  }
}

/* =========================================
   Sub-Page Content Adjustments
   Ensure page content areas use appropriate
   widths and spacing at each breakpoint.
   ========================================= */

@media (max-width: 575px) {
  .page-content,
  .entry-content {
    padding-left: var(--fob-space-sm);
    padding-right: var(--fob-space-sm);
  }

  /* Child page nav: full-width list */
  .child-nav__list {
    flex-direction: column;
    gap: var(--fob-space-sm);
  }
}

@media (min-width: 768px) {
  .page-content,
  .entry-content {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (min-width: 992px) {
  .page-content,
  .entry-content {
    max-width: 800px;
  }
}

/* =========================================
   Stat Cards (About Section) — Grid Override
   On very small screens, stack to 1 column;
   2 columns between 576–767px.
   ========================================= */

@media (min-width: 576px) and (max-width: 767px) {
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--fob-space-md);
  }
}

/* =========================================
   Pillar Cards — Responsive Override
   2 columns at 576px, 4 columns at 992px+
   (base 1 column already in layout.css grid)
   ========================================= */

@media (min-width: 576px) and (max-width: 767px) {
  .pillars-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--fob-space-md);
  }
}

/* =========================================
   Print Styles
   Basic print adjustments for accessibility.
   ========================================= */

@media print {
  .site-header,
  .menu-toggle,
  .nav-overlay,
  .fob-carousel__controls,
  .fob-carousel__dots,
  .donate-cta {
    display: none !important;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #555;
  }

  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }
}
