/* The Rose Farm page (farm.html). The header, footer, menu and night mode come from styles.css and
 * dark-mode.css; this adds the story blocks, the photo gallery and the photo viewer.
 * Mobile-first, like styles.css.
 */

/* ---------- Photos in the story ---------- */
.farm-photo {
  position: relative; overflow: hidden; aspect-ratio: 4 / 5;
  border-radius: var(--r); background: var(--paper-3);
}
.farm-photo img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Opening: title and first paragraph beside the hero photo ---------- */
.farm-hero { padding: 24px 0 64px; }
.farm-hero-grid { display: grid; gap: 28px; }
.farm-lead { max-width: 40ch; margin-top: 18px; color: var(--ink-2); font-size: 19px; line-height: 1.65; }
@media (min-width: 600px) { .farm-hero-photo { width: 100%; max-width: 560px; margin-inline: auto; } }
@media (min-width: 960px) {
  .farm-hero { padding: 48px 0 112px; }
  .farm-hero-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: clamp(40px, 6vw, 88px); }
  /* Fits the first screen: as tall as there's room for, cropped a little top and bottom. */
  .farm-hero-photo { max-width: none; aspect-ratio: auto; height: clamp(440px, calc(100vh - var(--header-h) - 96px), 680px); }
  .farm-hero-photo img { object-position: 50% 35%; }
}

/* ---------- The story, a part at a time, each beside a photo ---------- */
.farm-story { display: grid; gap: 64px; padding-bottom: 80px; }
.farm-block { display: grid; gap: 22px; align-items: center; }
.farm-text p { max-width: 58ch; color: var(--ink-2); font-size: 18px; line-height: 1.7; }
@media (min-width: 600px) and (max-width: 767px) { .farm-block .farm-photo { width: 100%; max-width: 520px; margin-inline: auto; } }
@media (min-width: 768px) {
  .farm-story { gap: 104px; padding-bottom: 112px; }
  /* Photo on the left, then on the right, and so on. */
  .farm-block { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(36px, 6vw, 96px); }
  .farm-block--flip { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
  .farm-block--flip .farm-photo { order: 2; }
  .farm-text p { font-size: 19px; }
}

/* A single sentence on its own gets the pull-quote look from the main page's story. */
.farm-block--quote .farm-text p {
  padding: 4px 0 4px 22px; border-left: 3px solid var(--rose);
  color: var(--ink); font-family: var(--font-display); font-size: clamp(1.45rem, 5.6vw, 2.1rem);
  font-style: italic; line-height: 1.3; letter-spacing: -0.01em;
}

/* ---------- Closing note, then the snippets ---------- */
.farm-snippets { padding-bottom: 96px; }
.farm-closing { display: grid; justify-items: center; gap: 14px; max-width: 36rem; margin: 0 auto 40px; text-align: center; }
/* Upright and a little smaller than the italic pull quote above it, like the closing line of a letter. */
.farm-closing p:first-child {
  color: var(--ink-2); font-family: var(--font-display); font-size: clamp(1.2rem, 4.2vw, 1.45rem);
  line-height: 1.5;
}
.farm-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .farm-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }
@media (min-width: 960px) { .farm-gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; } .farm-snippets { padding-bottom: 120px; } }

/* Each photo is a button that opens the viewer. */
.farm-tile {
  position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; padding: 0; overflow: hidden;
  border: 0; border-radius: var(--r-sm); background: var(--paper-3); cursor: zoom-in;
}
.farm-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .7s var(--ease-out); }
@media (hover: hover) { .farm-tile:hover img { transform: scale(1.04); } }
/* A caption on the photo: cream lettering over a soft shade at the bottom, readable on any photo. */
.farm-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 10px 8px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(24, 17, 12, 0), rgba(24, 17, 12, 0.6));
  color: #fbf6ee; font-family: var(--font-display); font-size: 14px; font-style: italic; line-height: 1.2; text-align: right;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
@media (min-width: 960px) { .farm-caption { padding: 36px 12px 10px; font-size: 15px; } }

/* ---------- Photo viewer ---------- */
.viewer { position: fixed; inset: 0; width: 100%; height: 100%; margin: 0; background: rgba(20, 15, 12, 0.96); color: #fbf6ee; }
.viewer::backdrop { background: transparent; }
.viewer[open] { animation: fade-in .25s ease both; }
.viewer.closing { animation: fade-out .2s ease both; }
.viewer-track {
  display: flex; width: 100%; height: 100%; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; overscroll-behavior: contain; scrollbar-width: none;
}
.viewer-track::-webkit-scrollbar { display: none; }
.viewer-slide {
  flex: 0 0 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  height: 100%; margin: 0; padding: calc(64px + env(safe-area-inset-top, 0px)) 16px calc(56px + var(--safe-b));
  scroll-snap-align: center; scroll-snap-stop: always;
}
.viewer-slide img {
  width: auto; height: auto; max-width: 100%; max-height: 100%; min-height: 0;
  border-radius: var(--r-sm); object-fit: contain; background: rgba(251, 246, 238, 0.04);
}
.viewer-slide figcaption { flex: none; font-family: var(--font-display); font-size: 17px; font-style: italic; }
.viewer-btn {
  position: absolute; display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 1.5px solid transparent; border-radius: 50%; background: rgba(251, 246, 238, 0.12); color: #fbf6ee;
  transition: border-color .3s var(--ease-out), opacity .2s ease;
}
.viewer-btn:hover, .viewer-btn:focus-visible { border-color: var(--rose); outline: none; }
.viewer-close { top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; }
.viewer-nav { top: 50%; margin-top: -22px; }
.viewer-nav--prev { left: 16px; }
.viewer-nav--prev .icon { transform: rotate(180deg); }
.viewer-nav--next { right: 16px; }
.viewer-nav:disabled { opacity: 0; pointer-events: none; }
@media (hover: none) { .viewer-nav { display: none; } } /* phones swipe instead */
@media (min-width: 960px) {
  .viewer-slide { padding: 56px 96px 64px; }
  .viewer-close { top: 20px; right: 24px; }
  .viewer-nav--prev { left: 28px; }
  .viewer-nav--next { right: 28px; }
}
.viewer-count {
  position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%);
  color: rgba(251, 246, 238, 0.72); font-size: 14px; letter-spacing: 0.06em; font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) {
  .farm-tile img, .viewer[open], .viewer.closing { transition: none; animation: none; }
}
