/* ------------------------------------------------------------------
   hy Bakery — product thumbnails inside menu rows, plus the full-screen
   image viewer.

   Loads AFTER site.css and only adds new selectors: .menu-item rows opt
   in with the .has-photo class, so any menu row without a photo keeps
   the original two-column layout untouched.
   ------------------------------------------------------------------ */

/* Tile colour behind a cut-out image. Set per item with style="--tile:#..." */
.menu-item.has-photo {
  --tile: var(--white);

  align-items: center;
  column-gap: 1.3rem;
  grid-template-columns: 7.15rem minmax(0, 1fr) auto;
}

.menu-item-media {
  display: grid;
  overflow: hidden;
  width: 7.15rem;
  aspect-ratio: 1;
  border-radius: 999px;
  background: var(--tile);
  cursor: zoom-in;
  place-items: center;
  text-decoration: none;
  /* The photo carries its own white studio background, so it fills the
     circle; a cut-out sits inside its tile with a little air around it. */
}

.menu-item-media img {
  width: 100%;
  height: auto;
  transition: transform 320ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.menu-item-media.is-cutout img {
  width: 88%;
}

.menu-item-media:hover img,
.menu-item-media:focus-visible img {
  transform: scale(1.07);
}

.menu-item-media:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

/* Rows in a photographed section that have no photo yet: the empty tile
   keeps the column rhythm so prices and names stay aligned. */
.menu-item-media.is-empty {
  background: var(--paper-deep);
  cursor: default;
}

/* ==================================================================
   Full-screen image viewer
   ================================================================== */
body.m-lock {
  overflow: hidden;
}

.m-lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  padding: 0;
  border: 0;
  /* The scrim is painted on the dialog itself rather than only on
     ::backdrop: the dialog covers the viewport anyway, and this renders
     consistently across engines. */
  background: rgba(15, 73, 52, 0.94);
  backdrop-filter: blur(6px);
  color: var(--paper);
}

.m-lightbox::backdrop {
  background: rgba(15, 73, 52, 0.94);
}

.m-lightbox[open],
.m-lightbox[open]::backdrop {
  animation: m-fade-in 220ms ease both;
}

@keyframes m-fade-in {
  from {
    opacity: 0;
  }
}

.m-lightbox-inner {
  display: grid;
  height: 100%;
  padding: clamp(3.5rem, 7vh, 5rem) clamp(1rem, 5vw, 4rem) clamp(1.5rem, 4vh, 3rem);
  align-content: center;
  justify-items: center;
  gap: clamp(1rem, 3vh, 2rem);
}

.m-lightbox-figure {
  display: grid;
  overflow: hidden;
  width: min(100%, 34rem);
  aspect-ratio: 1;
  max-height: 58vh;
  border-radius: var(--radius-md);
  background: var(--tile, var(--white));
  place-items: center;
}

.m-lightbox-figure img {
  width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.m-lightbox-figure.is-cutout img {
  width: 86%;
  max-height: 86%;
}

.m-lightbox-caption {
  max-width: 36rem;
  text-align: center;
}

.m-lightbox-caption h2 {
  margin: 0 0 0.35rem;
  font-size: var(--step-2);
}

.m-lightbox-caption p {
  margin: 0 0 0.6rem;
  color: rgba(246, 242, 233, 0.72);
  font-size: var(--step--1);
}

.m-lightbox-caption .menu-price {
  font-size: var(--step-0);
  font-weight: 800;
}

/* Controls */
.m-lightbox button {
  display: grid;
  border: 1px solid var(--line-light);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  place-items: center;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.m-lightbox button:hover,
.m-lightbox button:focus-visible {
  border-color: var(--paper);
  background: rgba(246, 242, 233, 0.14);
}

.m-lightbox-close {
  position: absolute;
  z-index: 2;
  top: clamp(0.9rem, 2.5vh, 1.75rem);
  right: clamp(0.9rem, 2.5vw, 1.75rem);
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.25rem;
  line-height: 1;
}

.m-lightbox-nav {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 3rem;
  height: 3rem;
  font-size: 1.1rem;
  line-height: 1;
  translate: 0 -50%;
}

.m-lightbox-prev {
  left: clamp(0.5rem, 2vw, 2rem);
}

.m-lightbox-next {
  right: clamp(0.5rem, 2vw, 2rem);
}

.m-lightbox-count {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  opacity: 0.6;
  text-transform: uppercase;
}

/* ==================================================================
   Responsive
   ================================================================== */
@media (max-width: 46rem) {
  .menu-item.has-photo {
    column-gap: 1rem;
    grid-template-columns: 5.5rem minmax(0, 1fr) auto;
  }

  .menu-item-media {
    width: 5.5rem;
  }

  .m-lightbox-figure {
    max-height: 46vh;
  }

  .m-lightbox-nav {
    top: auto;
    bottom: clamp(1rem, 4vh, 2rem);
    translate: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .m-lightbox[open],
  .m-lightbox[open]::backdrop {
    animation: none;
  }

  .menu-item-media img {
    transition: none;
  }
}

@media print {
  .menu-item.has-photo {
    grid-template-columns: 1fr auto;
  }

  .menu-item-media {
    display: none;
  }
}

/* ==================================================================
   Signature cards — the four-up "favourites" grids on the home and
   breakfast & lunch pages. The card is a flex column with the index
   and price pinned to the top and the name to the bottom, so the
   photo simply becomes the middle child.
   ================================================================== */
.signature-media {
  display: grid;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1;
  margin-block: 1.1rem;
  border-radius: var(--radius-sm);
  /* Photos carry their own white studio background, so they sit on a
     white tile; a cut-out floats straight on the card colour. */
  background: var(--white);
  cursor: zoom-in;
  place-items: center;
  text-decoration: none;
}

.signature-media img {
  width: 100%;
  height: auto;
  transition: transform 420ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.signature-media.is-cutout {
  background: transparent;
}

.signature-media.is-cutout img {
  width: 82%;
}

.signature-card:hover .signature-media img,
.signature-media:focus-visible img {
  transform: scale(1.05);
}

.signature-media:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

@media (max-width: 46rem) {
  .signature-media {
    max-width: 15rem;
  }
}

@media print {
  .signature-media {
    display: none;
  }
}

/* The card is a flex column with space-between, so the photo drifts up or
   down depending on how many lines the index and the title take. Turning
   each card into a subgrid of the strip sizes the index row, the photo row
   and the text row once for all four cards, so the photos line up. */
@media (min-width: 46.01rem) {
  @supports (grid-template-rows: subgrid) {
    .signature-grid:has(.signature-media) {
      /* Below 68rem the strip drops to two columns, so the pattern has to
         repeat for the implicit rows of the second pair as well. */
      grid-template-rows: auto auto 1fr;
      grid-auto-rows: auto auto 1fr;
    }

    .signature-grid:has(.signature-media) > .signature-card {
      display: grid;
      grid-row: span 3;
      grid-template-rows: subgrid;
      row-gap: 1.1rem;
    }

    .signature-grid:has(.signature-media) > .signature-card > .signature-media {
      margin-block: 0;
    }

    /* Keep the name and description pinned to the bottom of the card. */
    .signature-grid:has(.signature-media) > .signature-card > div:last-child {
      align-self: end;
    }
  }
}
