/* NKY Parks — shared site stylesheet.
   Linked from includes/header.html so every page gets these rules via SSI.
   Do not add per-page inline image styles; put reusable image rules here.

   Mobile hero (below 768px) is intentionally unchanged: 16:9, ~220px cap,
   from the per-page styles. In-content ratio classes work at every
   breakpoint (fluid width, fixed aspect-ratio, object-fit: cover).
   A desktop max-width keeps photos from filling a wide column.
*/

/* --------------------------------------------------------------------------
   Hero banner: <section class="hero"><img class="img-fluid w-100" …></section>

   Desktop (md and up) is a 4:1 full-width banner — about 360px tall at 1440
   wide and 240px at 960 wide. min-height 200px and max-height 400px keep
   the crop reasonable on very narrow md widths and very wide monitors.
   The image fills that box with object-fit: cover. object-position is
   center 30% so the walking couple and playground stay in frame (center
   or center 40% cuts off their heads in a 4:1 crop).

   !important beats the per-page head rule (.hero img { height: auto;
   max-height: 420px }), Bootstrap .img-fluid / .w-100, and the img
   width/height attributes (aspect-ratio 1024/576). The image is
   absolutely positioned so height: 100% reliably fills the aspect-ratio
   box. Mobile (below 768px) is unchanged: 16:9, ~220px cap, from the
   per-page styles.
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  section.hero,
  main .hero,
  .hero {
    position: relative !important;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 4 / 1 !important;
    height: auto !important;
    min-height: 200px !important;
    max-height: 400px !important;
    overflow: hidden !important;
  }

  section.hero img,
  main .hero img,
  .hero img.img-fluid,
  .hero img.w-100,
  .hero img {
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    min-height: 0 !important;
    aspect-ratio: unset !important;
    object-fit: cover !important;
    object-position: center 30% !important;
  }
}

/* --------------------------------------------------------------------------
   In-content photos — reusable aspect-ratio classes

   Preferred markup (set automatically by _fig() in the page generators):

     <figure class="nky-figure nky-ratio-3x2 my-4">
       <img class="img-fluid nky-photo nky-ratio-3x2 rounded shadow-sm"
            src="https://nkyparks.com/art/example.webp"
            alt="…" title="…" width="1600" height="1068" loading="lazy">
       <figcaption class="small text-muted mt-2">Photo: Scott Wells.</figcaption>
     </figure>

   Ratio classes (use on the figure, the img, or both):
     .nky-ratio-16x9   16 / 9
     .nky-ratio-3x2    3 / 2
     .nky-ratio-4x3    4 / 3
     .nky-ratio-1x1    1 / 1

   Each is width 100% of the figure (which itself is capped on desktop),
   aspect-ratio as named, height auto, object-fit: cover, so the photo
   keeps a consistent shape at every breakpoint instead of letterboxing
   under a max-height cap. object-position defaults to center; override
   with a utility if a particular crop needs it.

   Portraits that should not be cropped into a ratio box use
   .nky-figure--portrait / .nky-photo--portrait: natural proportions,
   a narrower max-width, centered. That is the treatment for the dog
   photo, so the face and full pose stay in frame. On desktop the
   portrait cap is 20rem (~320px, so a 3:4 photo is about 320x427).
   Below the md breakpoint, portraits are capped at 80% of the column.

   Fallback selectors also cap older unclassed figures and p > img
   to the same desktop max-width. Logos are not in main .container
   and are not affected.
   -------------------------------------------------------------------------- */
.nky-figure,
main .container figure {
  width: 100%;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.nky-photo,
.nky-figure img,
main .container figure img,
main .container p > img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin-left: auto;
  margin-right: auto;
}

/* Ratio boxes: fluid at every breakpoint. */
.nky-ratio-16x9,
img.nky-ratio-16x9,
.nky-ratio-16x9 img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
}

.nky-ratio-3x2,
img.nky-ratio-3x2,
.nky-ratio-3x2 img {
  aspect-ratio: 3 / 2;
  object-fit: cover;
  object-position: center;
}

.nky-ratio-4x3,
img.nky-ratio-4x3,
.nky-ratio-4x3 img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
}

.nky-ratio-1x1,
img.nky-ratio-1x1,
.nky-ratio-1x1 img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
}

img.nky-ratio-16x9,
img.nky-ratio-3x2,
img.nky-ratio-4x3,
img.nky-ratio-1x1,
.nky-ratio-16x9 img,
.nky-ratio-3x2 img,
.nky-ratio-4x3 img,
.nky-ratio-1x1 img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* Portrait photos kept in natural proportions (no forced ratio crop).
   On small screens the FIGURE is 80% of the column (centered) so a
   tall photo is a little smaller than full width. The img fills that
   figure. The desktop rule below tightens the figure to 20rem.
   The mobile hero is not affected. */
/* Beat main .container figure { max-width: 100% }. */
main .container figure.nky-figure--portrait,
.nky-figure--portrait {
  max-width: 80%;
}
.nky-figure--portrait img,
.nky-photo--portrait,
img.nky-photo--portrait {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center;
}

/* Desktop: cap width, not height, and center the figure in the column.
   Landscape / ratio boxes max out at 48rem (768px): 16:9 → 432px tall,
   3:2 → 512px, 4:3 → 576px. Squares use 28rem (448px). Natural
   portraits use 20rem (~320px; a 3:4 photo is about 320x427). */
@media (min-width: 768px) {
  .nky-figure,
  main .container figure,
  main .container p > img {
    max-width: 48rem;
  }

  /* Selectors must beat main .container figure { max-width: 48rem }. */
  main .container figure.nky-figure.nky-ratio-1x1,
  main .container p > img.nky-ratio-1x1 {
    max-width: 28rem;
  }

  main .container figure.nky-figure--portrait,
  main .container .nky-figure--portrait,
  main .container p > img.nky-photo--portrait {
    max-width: 20rem;
  }

  main .container figure.nky-figure--portrait img,
  main .container img.nky-photo--portrait {
    width: 100%;
    max-width: 100%;
  }
}
