:root {
  --spear-gallery-google: cubic-bezier(0.4, 0, 0.2, 1);
}

.spear-project-detail__media-field[data-spear-gallery-source="true"] {
  cursor: pointer;
  transform-origin: center;
  transition:
    transform 360ms var(--spear-gallery-google),
    box-shadow 360ms var(--spear-gallery-google);
}

.spear-project-detail__media-field[data-spear-gallery-source="true"]
  .spear-project-detail__checker-image {
  transform-origin: center;
  opacity: 1;
  transition:
    transform 360ms var(--spear-gallery-google),
    opacity 300ms var(--spear-gallery-google),
    filter 420ms var(--spear-gallery-google);
}

.spear-project-detail__media-field[data-spear-gallery-source="true"]:hover,
.spear-project-detail__media-field[data-spear-gallery-source="true"]:focus-visible,
.spear-project-detail__media-field.is-gallery-source-previewing {
  transform: translate3d(0, -10px, 0) scale(1.016);
  box-shadow:
    0 0 0 1px rgba(244, 248, 250, 0.58),
    0 0 28px rgba(238, 246, 250, 0.27),
    0 0 62px rgba(238, 246, 250, 0.12);
}

.spear-project-detail__media-field[data-spear-gallery-source="true"]:hover
  .spear-project-detail__checker-image,
.spear-project-detail__media-field[data-spear-gallery-source="true"]:focus-visible
  .spear-project-detail__checker-image,
.spear-project-detail__media-field.is-gallery-source-previewing
  .spear-project-detail__checker-image {
  transform: scale(1.026);
}

.spear-project-detail__media-field[data-spear-gallery-source="true"]:focus-visible {
  outline: 1px solid rgba(244, 248, 250, 0.62);
  outline-offset: 5px;
}

.spear-project-detail__media-field.is-gallery-source-settling,
.spear-project-detail__media-field.is-gallery-source-settling:hover {
  transform: none;
  box-shadow: none;
}

.spear-project-detail__media-field.is-gallery-source-settling
  .spear-project-detail__checker-image,
.spear-project-detail__media-field.is-gallery-source-settling:hover
  .spear-project-detail__checker-image {
  transform: none;
}

.spear-project-detail__media-field.is-gallery-source-hidden
  .spear-project-detail__checker-image {
  opacity: 1;
  filter: blur(30px) brightness(0.54) contrast(0.76);
  transform: scale(1.07);
}

.spear-project-detail__scroll.is-spear-gallery-locked {
  overflow-y: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.spear-media-gallery {
  position: absolute;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  isolation: isolate;
  contain: layout paint style;
}

.spear-media-gallery.is-active {
  visibility: visible;
  pointer-events: auto;
}

.spear-media-gallery.is-source-previewing {
  visibility: visible;
  pointer-events: none;
}

.spear-media-gallery__blur {
  position: absolute;
  inset: -10px;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.035);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transform: translateZ(0);
  transition: opacity 820ms var(--spear-gallery-google);
  will-change: opacity;
}

.spear-media-gallery.is-focus-active .spear-media-gallery__blur {
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.spear-media-gallery--portal {
  z-index: 80;
}

/* Character galleries live beside a WebGL iframe. Backdrop-filter across that
   compositor boundary can flash an opaque driver surface, so the portal uses
   the same 7px focus blur on the two stable source layers instead. */
.spear-media-gallery--portal.is-focus-active .spear-media-gallery__blur {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: rgba(0, 0, 0, 0.52);
}

.tectonic-character-project-detail.is-project-gallery-focus-active,
.tectonic-character-detail-model.is-project-gallery-focus-active {
  filter: blur(7px) brightness(0.58);
  transform: translateZ(0) scale(1.012);
}

.spear-media-gallery.is-focus-active .spear-media-gallery__blur {
  opacity: 1;
}

.spear-media-gallery__guides {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: 0;
  pointer-events: none;
  transform: translateZ(0);
  will-change: opacity;
  visibility: hidden;
}

.spear-media-gallery__guide-path,
.spear-media-gallery__guide-reveal {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.spear-media-gallery__guide-path--solid {
  stroke: rgba(239, 246, 249, 0.52);
  stroke-width: 0.9;
}

.spear-media-gallery__guide-path--dashed {
  stroke: rgba(224, 235, 240, 0.3);
  stroke-width: 0.72;
  stroke-dasharray: 5 9;
}

.spear-media-gallery__guide-reveal {
  stroke: #fff;
  stroke-width: 64;
  stroke-linecap: round;
}

.spear-media-gallery__guide-tick {
  stroke: rgba(224, 235, 240, 0.3);
  stroke-width: 0.72;
  vector-effect: non-scaling-stroke;
}

.spear-media-gallery__guide-tick--major {
  stroke: rgba(239, 246, 249, 0.56);
  stroke-width: 0.9;
}

.spear-media-gallery__guide-label {
  fill: rgba(231, 239, 242, 0.48);
  font-family: var(--tectonic-ui-small-en, "Bahnschrift", "Arial", sans-serif);
  font-size: 7px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-anchor: middle;
}

.spear-media-gallery__stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  perspective: 6000px;
  perspective-origin: 50% 50%;
  transform-style: flat;
}

.spear-media-gallery__spatial-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.spear-media-gallery__spatial-guides {
  z-index: 1;
  opacity: 0;
  will-change: opacity;
}

.spear-media-gallery__spatial-segment {
  position: absolute;
  /* The cards use an explicit 200–400 paint-order range. A positive world Z
     alone cannot win that flattened stacking order, so the real 3D guide
     segments must also live in the foreground compositor band. */
  z-index: 600;
  top: 0;
  left: 0;
  height: 1px;
  opacity: 0;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
}

.spear-media-gallery__spatial-line-solid,
.spear-media-gallery__spatial-line-dashed {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  pointer-events: none;
}

.spear-media-gallery__spatial-line-solid {
  top: 0;
  background: rgba(239, 246, 249, 0.54);
  box-shadow: 0 0 7px rgba(229, 239, 243, 0.1);
}

.spear-media-gallery__spatial-line-dashed {
  top: var(--spear-guide-secondary-offset);
  height: 0.75px;
  opacity: 0.62;
  background: repeating-linear-gradient(
    90deg,
    rgba(224, 235, 240, 0.58) 0 5px,
    transparent 5px 12px
  );
}

.spear-media-gallery__spatial-mark {
  position: absolute;
  z-index: 600;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  opacity: 0;
  transform-style: preserve-3d;
}

.spear-media-gallery__spatial-tick {
  position: absolute;
  left: 0;
  width: 0.75px;
  background: rgba(224, 235, 240, 0.38);
}

.spear-media-gallery__spatial-tick--major {
  width: 1px;
  background: rgba(239, 246, 249, 0.62);
}

.spear-media-gallery__spatial-mark[data-guide-edge="top"]
  .spear-media-gallery__spatial-tick {
  bottom: 0;
}

.spear-media-gallery__spatial-mark[data-guide-edge="bottom"]
  .spear-media-gallery__spatial-tick {
  top: 0;
}

.spear-media-gallery__spatial-label {
  position: absolute;
  left: 0;
  color: rgba(231, 239, 242, 0.52);
  font-family: var(--tectonic-ui-small-en, "Bahnschrift", "Arial", sans-serif);
  font-size: 7px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.12em;
  white-space: nowrap;
  transform: translateX(-50%);
}

.spear-media-gallery__spatial-mark[data-guide-edge="top"]
  .spear-media-gallery__spatial-label {
  bottom: 22px;
}

.spear-media-gallery__spatial-mark[data-guide-edge="bottom"]
  .spear-media-gallery__spatial-label {
  top: 22px;
}

.spear-media-gallery__focus-caption {
  position: absolute;
  z-index: 3;
  margin: 0;
  opacity: 0;
  color: rgba(247, 250, 251, 0.92);
  font-family: var(--tectonic-ui-small-en, "Bahnschrift", "Arial", sans-serif);
  font-size: clamp(10px, 0.62vw, 13px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.18em;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 14px rgba(240, 248, 251, 0.22);
  transform: translateZ(0);
  will-change: opacity;
}

.spear-media-gallery__slot {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  transform-origin: center;
  transform-style: preserve-3d;
  will-change: transform, opacity;
}

/* Resting pages sit behind the engineering guides. A selected page becomes
   the active reading plane and must cover the guides until it has returned to
   the fan completely. */
.spear-media-gallery__slot.is-hovered,
.spear-media-gallery__slot.is-focused {
  z-index: 700 !important;
}

/* Pages 01/06 are the rear-most visible leaves at the two fan edges. Raising
   either slot above the whole book while it lifts makes it jump across its
   inner neighbours. Keep both approved ring depths during hover; focus still
   promotes either page normally. */
.spear-media-gallery[data-state="ring"]
  .spear-media-gallery__slot[data-gallery-index="0"].is-hovered:not(.is-focused) {
  z-index: 200 !important;
}

.spear-media-gallery[data-state="ring"]
  .spear-media-gallery__slot[data-gallery-index="5"].is-hovered:not(.is-focused) {
  z-index: 201 !important;
}

.spear-media-gallery.is-source-previewing .spear-media-gallery__card {
  box-shadow:
    18px 5px 30px rgba(0, 0, 0, 0.94),
    8px 1px 12px rgba(0, 0, 0, 0.98),
    0 0 0 1px rgba(246, 249, 250, 0.3),
    0 0 42px rgba(244, 249, 252, 0.12),
    inset 0 0 0 1px rgba(246, 249, 250, 0.2);
}

.spear-media-gallery[data-state="ring"] .spear-media-gallery__hit {
  pointer-events: auto;
}

.spear-media-gallery__card {
  --spear-gallery-stack-shadow-x: 0px;
  --spear-gallery-depth-shade: 0;
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(242, 247, 249, 0.23);
  background: #000;
  color: inherit;
  cursor: pointer;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
  transform-origin: center;
  transform-style: preserve-3d;
  transition:
    transform 340ms var(--spear-gallery-google),
    box-shadow 340ms var(--spear-gallery-google);
  box-shadow:
    var(--spear-gallery-stack-shadow-x) 5px 34px rgba(0, 0, 0, 0.94),
    var(--spear-gallery-stack-shadow-x) 1px 12px rgba(0, 0, 0, 0.98),
    inset 0 0 0 1px rgba(246, 249, 250, 0.21);
  will-change: transform;
}

.spear-media-gallery__slot[data-gallery-index="0"] .spear-media-gallery__card,
.spear-media-gallery__slot[data-gallery-index="5"] .spear-media-gallery__card {
  --spear-gallery-depth-shade: 0.3;
}

.spear-media-gallery__slot[data-gallery-index="1"] .spear-media-gallery__card,
.spear-media-gallery__slot[data-gallery-index="4"] .spear-media-gallery__card {
  --spear-gallery-depth-shade: 0.14;
}

.spear-media-gallery__slot[data-gallery-index="0"] .spear-media-gallery__card,
.spear-media-gallery__slot[data-gallery-index="1"] .spear-media-gallery__card,
.spear-media-gallery__slot[data-gallery-index="2"] .spear-media-gallery__card {
  --spear-gallery-stack-shadow-x: 30px;
}

.spear-media-gallery__slot[data-gallery-index="3"] .spear-media-gallery__card,
.spear-media-gallery__slot[data-gallery-index="4"] .spear-media-gallery__card,
.spear-media-gallery__slot[data-gallery-index="5"] .spear-media-gallery__card {
  --spear-gallery-stack-shadow-x: -30px;
}

.spear-media-gallery__card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: rgba(0, 0, 0, var(--spear-gallery-depth-shade));
  transition: background-color 340ms var(--spear-gallery-google);
}

.spear-media-gallery__card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: var(--spear-gallery-image) center / cover no-repeat;
  transform: rotateY(180deg) translateZ(0.2px);
  backface-visibility: hidden;
}

.spear-media-gallery[data-state="ring"] .spear-media-gallery__card:hover,
.spear-media-gallery[data-state="ring"] .spear-media-gallery__card:focus-visible,
.spear-media-gallery__slot.is-hovered .spear-media-gallery__card {
  transform:
    translate3d(0, clamp(-112px, -8vh, -64px), 0);
  box-shadow:
    var(--spear-gallery-stack-shadow-x) 4px 32px rgba(0, 0, 0, 0.92),
    var(--spear-gallery-stack-shadow-x) 1px 10px rgba(0, 0, 0, 0.98),
    0 0 0 1px rgba(248, 250, 251, 0.92),
    0 0 26px rgba(244, 249, 252, 0.42),
    0 0 68px rgba(244, 249, 252, 0.22),
    0 0 118px rgba(244, 249, 252, 0.1),
    inset 0 0 0 1px rgba(248, 250, 251, 0.34);
}

.spear-media-gallery__slot.is-hovered .spear-media-gallery__card::after,
.spear-media-gallery__slot.is-focused .spear-media-gallery__card::after {
  background: transparent;
}

.spear-media-gallery__card:focus-visible {
  outline: 1px solid rgba(248, 250, 251, 0.82);
  outline-offset: 5px;
}

.spear-media-gallery__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 1;
  backface-visibility: hidden;
}

.spear-media-gallery__hit {
  position: absolute;
  z-index: 80;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: none;
  transform: translateZ(1px);
}

@media (prefers-reduced-motion: reduce) {
  .spear-project-detail__media-field[data-spear-gallery-source="true"],
  .spear-project-detail__media-field[data-spear-gallery-source="true"]
    .spear-project-detail__checker-image,
  .spear-media-gallery__blur,
  .spear-media-gallery__card {
    transition-duration: 1ms !important;
  }

  .spear-project-detail__media-field.is-gallery-source-hidden
    .spear-project-detail__checker-image {
    filter: blur(30px) brightness(0.54) contrast(0.76) !important;
    transform: scale(1.07) !important;
  }
}
