/* Home page bagel grid and its rolling cubes (cubes.js).
   Shared by the public home page and the admin portal's Cubes preview, so it
   carries its own fallbacks for the site's color variables. */

/* Home page: 6 x 2 grid of bagel close-ups, framed by thin gold lines
   (the grid's gold background shows through 2px gaps and padding). */
.bagel-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 2px;
  width: min(max(56vw, 600px), 1080px);
  margin: 2.5rem 0;
  background: var(--color-gold, #f0a422);
}

.bagel-grid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

@media (max-width: 860px) {
  /* Same 6 x 2 band as desktop, just narrower, so it stays subtle on phones. */
  .bagel-grid {
    width: min(calc(100vw - 2rem), 600px);
    margin: 1.5rem 0;
  }
}


/* Rolling cubes (cubes.js). Each tile becomes a 3D cube whose front face sits
   exactly where the flat photo was, so the resting grid looks unchanged.
   --s is the tile width, kept current by cubes.js. */
.bagel-grid.cubes .cube {
  position: relative;
  aspect-ratio: 1;
  perspective: calc(var(--s, 120px) * 5);
}

.cube .depth,
.cube .spin,
.cube .orient {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.cube .depth {
  transform: translateZ(calc(var(--s, 120px) / -2));
}

.cube .face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.cube .face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cube .front  { transform: translateZ(calc(var(--s, 120px) / 2)); }
.cube .back   { transform: rotateY(180deg) translateZ(calc(var(--s, 120px) / 2)); }
.cube .right  { transform: rotateY(90deg) translateZ(calc(var(--s, 120px) / 2)); }
.cube .left   { transform: rotateY(-90deg) translateZ(calc(var(--s, 120px) / 2)); }
.cube .top    { transform: rotateX(90deg) translateZ(calc(var(--s, 120px) / 2)); }
.cube .bottom { transform: rotateX(-90deg) translateZ(calc(var(--s, 120px) / 2)); }

/* The turning cube draws above its neighbors while it pokes out of the grid. */
.cube.turning {
  z-index: 2;
}

/* Small pause/play button under the grid's bottom-right corner. */
.cube-toggle {
  position: absolute;
  right: 0;
  bottom: -2.4rem;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--color-gold, #f0a422);
  border-radius: 50%;
  background: transparent;
  color: var(--color-paper, #f4efe6);
  opacity: 0.75;
  transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.cube-toggle:hover {
  opacity: 1;
}

.cube-toggle:focus-visible {
  outline: 1px solid var(--color-paper, #f4efe6);
  outline-offset: 3px;
  opacity: 1;
}

.cube-toggle svg {
  width: 0.7rem;
  height: 0.7rem;
  fill: currentColor;
}

.cube-toggle .icon-play,
.bagel-grid.cubes-on .cube-toggle .icon-pause {
  display: block;
}

.cube-toggle .icon-pause,
.bagel-grid.cubes-on .cube-toggle .icon-play {
  display: none;
}

@media (max-width: 860px) {
  .cube-toggle {
    bottom: -2.2rem;
  }
}
