/* Section: GRAPHIC #37 — Cycling grid density viewer */
.s-g37 {
  background-color: #0a3d1f;
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  line-height: 18px;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
  position: relative;
  user-select: none;
}

/* Top title */
.s-g37 .g37-bio-txt {
  position: absolute;
  top: 0; left: 0; width: 100%;
  text-align: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px; font-weight: 500;
  letter-spacing: 0.5px; line-height: 1;
  padding: 14px 24px; color: #fff;
  z-index: 15; pointer-events: none;
  opacity: 1;
  transition: opacity 1.94s cubic-bezier(0.4, 0, 0.2, 1);
}
.s-g37 .g37-bio-txt.hidden { opacity: 0; transition: opacity 1.08s ease; }

.s-g37 .g37-layout { width: 100%; height: 100%; position: relative; perspective: 1200px; }

/* Info — bottom left */
.s-g37 .g37-info {
  position: absolute; bottom: 0; left: 0; z-index: 10;
  width: 480px; padding: 30px;
  pointer-events: none; font-size: 12px; line-height: 17px;
}
.s-g37 .g37-credit { color: #fff; margin-bottom: 8px; }
.s-g37 .g37-contributors { color: #fff; margin-bottom: 12px; }
.s-g37 .g37-nav-hint { color: #fff; opacity: 0.5; }

/* Grid viewer */
.s-g37 .g37-reader {
  width: 100%;
  display: grid;
  /* Uniform tight spacing in both axes — pages flow as a continuous block. */
  column-gap: 2px;
  row-gap: 2px;
  padding: 30px;
  box-sizing: border-box;
  cursor: pointer;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotateY(0deg);
  transform-style: preserve-3d;
  justify-content: center;
  justify-items: center;
  max-width: 80vw;
  transition: transform 0.2s ease-out;
}

/* Each spread: 2 pages side by side with 1px gap */
.s-g37 .g37-spread {
  display: flex;
  gap: 1px;
  opacity: 0;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease-out, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Enter from right (pages increasing) */
.s-g37 .g37-spread.enter-right {
  transform: translateX(100%);
  opacity: 0;
}
.s-g37 .g37-spread.visible {
  opacity: 1;
  transform: translateX(0);
}
/* Exit to left (pages increasing) */
.s-g37 .g37-spread.exit-left {
  transform: translateX(-100%);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.5, 0, 1, 0.5), opacity 0.6s cubic-bezier(0.7, 0, 1, 1);
}
/* Enter from left (pages decreasing) */
.s-g37 .g37-spread.enter-left {
  transform: translateX(-100%);
  opacity: 0;
}
/* Exit to right (pages decreasing) */
.s-g37 .g37-spread.exit-right {
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.5, 0, 1, 0.5), opacity 0.6s cubic-bezier(0.7, 0, 1, 1);
}

/* Cover */
.s-g37 .g37-cover {
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.5s ease-out, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.s-g37 .g37-cover.enter-right { transform: translateX(100%); opacity: 0; }
.s-g37 .g37-cover.enter-left { transform: translateX(-100%); opacity: 0; }
.s-g37 .g37-cover.visible { opacity: 1; transform: translateX(0); }

.s-g37 .g37-spread img {
  height: 100%;
  width: auto;
  object-fit: contain;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

/* Cover — single page, centered */
.s-g37 .g37-cover {
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.s-g37 .g37-cover.visible { opacity: 1; }
.s-g37 .g37-cover img {
  height: 100%;
  width: auto;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

/* Side gradient hints instead of arrows */
.s-g37 .g37-arrow { display: none; }
/* No side gradients */

/* Page counter */
.s-g37 .g37-page-num {
  position: absolute; bottom: 30px; right: 30px;
  font-size: 13px; color: #fff; z-index: 10;
}

/* Hover label — follows cursor, centered on cursor */
.s-g37 .g37-label {
  position: fixed;
  z-index: 25;
  pointer-events: none;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
  color: #000;
  background: #78df71;
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  background-size: 100% 100%;
  transition: opacity 0.1s ease, padding 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: translate(-50%, -50%);
}
.s-g37 .g37-label.visible { opacity: 1; }
.s-g37 .g37-label.shrinking {
  padding: 4px 4px;
  transition: opacity 0.08s ease, padding 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.s-g37 .g37-label.pressed {
  background: #000 !important;
  color: #78df71 !important;
  transition: none;
}
.s-g37 .g37-label.released {
  background: #78df71;
  color: #000;
  transition: background 0.4s ease, color 0.4s ease;
}

@media (max-width: 640px) {
  /* Match Q-section caption (.column3) sizing on mobile */
  .s-g37 .g37-info { max-width: 250px; padding: 16px; font-size: 12px; line-height: 17px; }
  .s-g37 .g37-arrow { display: none; }

  /* Spread (2 pages) on mobile: stack vertically (1, 2) instead of (2, 1).
     Each page takes half the spread height with object-fit: contain so neither crops. */
  .s-g37 .g37-spread {
    flex-direction: column;
    gap: 2px;
    width: 100%;
    height: 100%;
  }
  .s-g37 .g37-spread img {
    width: 100%;
    height: calc(50% - 1px);
    object-fit: contain;
  }

  /* Cover on mobile: align to the same position/size as the TOP page of a (1,2)
     vertical spread — sits in the top half of the row, anchored to the top edge. */
  .s-g37 .g37-cover {
    width: 100%;
    height: 100%;
    align-items: flex-start;
  }
  .s-g37 .g37-cover img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(50% - 1px);  /* matches .g37-spread img on mobile */
    object-fit: contain;
  }
}
