/* Homepage hero: the display rack (rack.js), in place of the website kiosk.

   Printed pieces set out against the dawn sky in two rows, with nothing
   holding them: site maps on top, rack cards and brochures below, all to one
   scale (rack.js sets --u, pixels per inch, and each piece's size in inches;
   the pieces come from the editor's Home Page tab, via cms_rack()). Each sits
   in a "pocket", its place in the row.
   Pointing at a piece raises it slightly; clicking brings it forward, larger.
   Wide screens show what fits; narrow ones swipe sideways through them all. */

.hero--rack {
  padding: 22px 0 30px;
}
.rack {
  --u: 30px;                         /* pixels per inch (rack.js) */
  position: relative;
  z-index: 2;                        /* above the sky and the hero's grain */
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 360px;
  animation: hero-wake 1.6s ease-in-out 0.6s both;
}
@media (prefers-reduced-motion: reduce) {
  .rack { animation: none; }
}

/* the stage centres the rack, or scrolls it sideways on narrow screens */
.rack-stage {
  display: flex;
  justify-content: center;
  padding: 0 16px;
}
.rack.is-scroll .rack-stage {
  justify-content: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scroll-padding-inline: calc(16px + var(--u) * 0.7);   /* the stage's gutter and the board's own padding */
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding-top: calc(var(--u) * 1.2);  /* room for a lifted piece */
  margin-top: calc(var(--u) * -1.2);
}
.rack.is-scroll .rack-stage::-webkit-scrollbar { display: none; }
.rack.is-scroll .rack-row { justify-content: flex-start; }   /* swiping: both shelves start at the left */
.rack.is-scroll .rack-stage::after { content: ""; flex: 0 0 1px; }  /* keeps the right-hand gutter when scrolled to the end */

/* the rack: two rows of pieces, nothing behind or under them */
.rack-board {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 0.85);
  margin: 0;
  padding: calc(var(--u) * 0.95) calc(var(--u) * 0.7) calc(var(--u) * 0.55);
}

/* a row of pieces */
.rack-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;          /* a shorter shelf sits in the middle of the board */
  gap: calc(var(--u) * 0.32);
  margin: 0;
  padding: 0 0 calc(var(--u) * 0.18);
  list-style: none;
}

/* a piece's place in its row */
.rack-pocket {
  --w: 4; --h: 9;                    /* the piece's size in inches (rack.js) */
  position: relative;
  flex: none;
  width: calc(var(--w) * var(--u) + 10px);
  height: calc(var(--h) * var(--u) + 6px);
  scroll-snap-align: start;
}
.rack-pocket[hidden] { display: none; }

.rack-card {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 3px;
  z-index: 1;
  height: calc(var(--h) * var(--u));
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.rack-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 1px;
  box-shadow: 0 1px 2px rgba(20, 14, 4, 0.25), 0 6px 12px -6px rgba(20, 14, 4, 0.35);
  transition: box-shadow 0.45s ease;
}
/* a gentle rise, now that nothing holds the pieces: about 2.5% of their height */
@media (hover: hover) {
  .rack-card:hover { transform: translateY(calc(var(--h) * var(--u) * -0.025)); }
  .rack-card:hover img { box-shadow: 0 2px 4px rgba(20, 14, 4, 0.22), 0 14px 22px -10px rgba(20, 14, 4, 0.45); }
}
.rack-card:focus-visible {
  outline: 3px solid var(--accent, #DF7D01);
  outline-offset: 3px;
  transform: translateY(calc(var(--h) * var(--u) * -0.025));
}
.rack-card.is-peek { transform: translateY(calc(var(--h) * var(--u) * -0.02)); }
.rack-card.is-out { visibility: hidden; }       /* out of its pocket, in the viewer */

/* on arrival, the pieces settle into place */
.rack.is-arriving .rack-card {
  animation: rack-drop 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  animation-delay: calc(0.9s + var(--i, 0) * 45ms);
}
@keyframes rack-drop {
  from { transform: translateY(calc(var(--h) * var(--u) * -0.06)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .rack-card,
  .rack-card img { transition: none; }
  .rack.is-arriving .rack-card { animation: none; }
}

/* ---- the viewer: a piece pulled out of the rack ------------------------------ */

.rack-viewer[hidden] { display: none; }
.rack-viewer {
  position: fixed;
  inset: 0;
  z-index: 90;
}
.rack-viewer-shade {
  position: absolute;
  inset: 0;
  background: rgba(16, 20, 32, 0.78);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.rack-viewer.is-open .rack-viewer-shade { opacity: 1; }
.rack-fly {
  position: fixed;
  z-index: 91;
  display: block;
  margin: 0;
  object-fit: contain;
  transform-origin: 0 0;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.6), 0 4px 14px rgba(0, 0, 0, 0.25);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-drag: none;
}
.rack-viewer-cap {
  position: fixed;
  z-index: 92;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: calc(100vw - 40px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(16, 20, 32, 0.66);
  color: #f4f0e8;
  font-size: 14.5px;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease 0.2s;
}
.rack-viewer.is-open .rack-viewer-cap { opacity: 1; }
.rack-viewer-cap a { color: #f6d4a8; font-weight: 600; white-space: nowrap; }
.rack-viewer-cap a:hover { color: #fff; }
.rack-viewer-btn {
  position: fixed;
  z-index: 92;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #22293a;
  cursor: pointer;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease 0.15s, transform 0.15s ease;
}
.rack-viewer.is-open .rack-viewer-btn { opacity: 1; }
.rack-viewer-btn:hover { transform: scale(1.06); }
.rack-viewer-btn:focus-visible { outline: 3px solid var(--accent, #DF7D01); outline-offset: 3px; }
.rack-viewer-close { top: 18px; right: 18px; }
.rack-viewer-prev { left: 18px; top: 50%; margin-top: -23px; }
.rack-viewer-next { right: 18px; top: 50%; margin-top: -23px; }
@media (max-width: 620px) {
  .rack-viewer-prev,
  .rack-viewer-next { top: auto; bottom: 64px; margin-top: 0; }
  .rack-viewer-cap { font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .rack-viewer-shade,
  .rack-viewer-cap,
  .rack-viewer-btn { transition: none; }
}
