.work-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}

.work-modal.is-open {
  display: flex;
  animation: workModalFadeIn .3s ease both;
}

.work-modal.is-closing {
  animation: workModalFadeOut .3s ease forwards;
}

.admin-bar .work-modal {
  top: 32px;
}

@media (max-width: 782px) {
  .admin-bar .work-modal {
    top: 46px;
  }

  .admin-bar .work-modal-panel {
    height: calc(100vh - 46px);
    min-height: calc(100vh - 46px);
  }
}

@supports (height: 100dvh) {
  @media (max-width: 782px) {
    .admin-bar .work-modal-panel {
      height: calc(100dvh - 46px);
      min-height: calc(100dvh - 46px);
    }
  }
}

@keyframes workModalFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes workModalFadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

.work-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(89 87 87 / 72%);
}

.work-modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 28px 62px;
  gap: 10px;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  align-content: stretch;
  justify-items: center;
  padding: clamp(36px, 5vh, 64px) clamp(24px, 4vw, 64px);
  --work-modal-image-max-height: 100%;
}

.admin-bar .work-modal-panel {
  height: calc(100vh - 32px);
  min-height: calc(100vh - 32px);
}

@supports (height: 100dvh) {
  .work-modal-panel {
    height: 100dvh;
    min-height: 100dvh;
  }

  .admin-bar .work-modal-panel {
    height: calc(100dvh - 32px);
    min-height: calc(100dvh - 32px);
  }
}

@media (max-width: 782px) {
  .admin-bar .work-modal-panel {
    height: calc(100vh - 46px);
    min-height: calc(100vh - 46px);
  }
}

@supports (height: 100dvh) {
  @media (max-width: 782px) {
    .admin-bar .work-modal-panel {
      height: calc(100dvh - 46px);
      min-height: calc(100dvh - 46px);
    }
  }
}

.work-modal-title {
  align-self: end;
  justify-self: center;
  max-width: min(80vw, 92vw);
  margin: 0;
  color: #fff;
  font-family: var(--font-zen);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: .08em;
  line-height: 1.5;
  text-align: center;
}

.work-modal-image-stage {
  position: relative;
  display: flex;
  align-self: stretch;
  justify-self: center;
  width: 80vw;
  height: 100%;
  min-height: 0;
  max-width: 92vw;
  max-height: var(--work-modal-image-max-height);
  margin: 0 auto;
  overflow: hidden;
  padding: 0;
  align-items: flex-start;
  justify-content: center;
  background: transparent;
}

.work-modal-image-stage.is-page-clickable.is-page-prev {
  cursor: w-resize;
}

.work-modal-image-stage.is-page-clickable.is-page-next {
  cursor: e-resize;
}

.work-modal-image {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  backface-visibility: hidden;
  box-shadow: 0 8px 22px rgb(0 0 0 / 18%);
}

.work-modal-page-sheet {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  background: transparent;
  pointer-events: none;
}

.work-modal-page-sheet img {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 8px 22px rgb(0 0 0 / 18%);
}

.work-modal-page-sheet.is-turn-next {
  animation: workModalPageExitLeft .4s ease forwards;
}

.work-modal-page-sheet.is-turn-prev {
  animation: workModalPageOverlayEnterLeft .4s ease both;
}

.work-modal-image.is-enter-from-left {
  animation: workModalImageEnterLeft .38s ease both;
}

.work-modal-image.is-enter-from-right {
  animation: workModalImageEnterRight .38s ease both;
}

.work-modal-image.is-page-turn-next {
  animation: none;
}

@keyframes workModalImageEnterLeft {
  from {
    opacity: 0;
    transform: translateX(-28px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes workModalImageEnterRight {
  from {
    opacity: 0;
    transform: translateX(28px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes workModalPageExitLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(-42px);
  }
}

@keyframes workModalPageOverlayEnterLeft {
  from {
    opacity: 0;
    transform: translateX(-42px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.work-modal-pagination {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  height: 28px;
  min-height: 28px;
  color: #fff;
  font-family: var(--font-urbanist);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .08em;
}

.work-modal-pagination[hidden] {
  display: none;
}

.work-modal-thumbnails {
  display: flex;
  width: min(760px, calc(100vw - 128px));
  height: 62px;
  min-height: 62px;
  gap: 10px;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 2px 2px 8px;
}

.work-modal-thumbnails[hidden] {
  display: none;
}

.work-modal-pagination[hidden] + .work-modal-thumbnails[hidden] {
  display: none;
}

.work-modal-thumbnail {
  position: relative;
  display: block;
  flex: 0 0 76px;
  width: 76px;
  height: 52px;
  padding: 0;
  overflow: hidden;
  background: rgb(255 255 255 / 12%);
  border: 2px solid rgb(255 255 255 / 35%);
  cursor: pointer;
  transition: border-color .18s ease, opacity .18s ease, transform .18s ease;
}

.work-modal-thumbnail:hover,
.work-modal-thumbnail.active {
  border-color: #fff;
  opacity: 1;
  transform: translateY(-2px);
}

.work-modal-thumbnail:not(.active) {
  opacity: .72;
}

.work-modal-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.work-modal-page-arrow {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  padding: 0;
  color: #fff;
  font-size: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.work-modal-page-arrow::before {
  width: 12px;
  height: 12px;
  border-top: 2px solid #fff;
  border-right: 2px solid #fff;
  content: "";
}

.work-modal-page-arrow.prev::before {
  transform: rotate(-135deg);
}

.work-modal-page-arrow.next::before {
  transform: rotate(45deg);
}

.work-modal-page-count {
  min-width: 46px;
  text-align: center;
}

.work-modal-close {
  position: absolute;
  top: 24px;
  right: 24px;
  display: inline-flex;
  gap: 14px;
  align-items: center;
  padding: 0;
  color: #fff;
  font-family: var(--font-urbanist);
  font-size: 16px;
  letter-spacing: .08em;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.work-modal-close::after {
  width: 24px;
  height: 24px;
  background:
    linear-gradient(45deg, transparent calc(50% - .5px), currentColor calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), currentColor calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px));
  content: "";
}

.work-modal-nav {
  position: absolute;
  top: 50%;
  display: flex;
  width: 64px;
  min-height: 54px;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 0;
  cursor: pointer;
  transform: translateY(-50%);
}

.work-modal-nav::before {
  width: 26px;
  height: 26px;
  border-top: 2px solid #fff;
  border-right: 2px solid #fff;
  content: "";
}

.work-modal-nav span {
  display: block;
  font-family: var(--font-zen);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .08em;
  line-height: 1.2;
  white-space: nowrap;
}

.work-modal-nav.prev {
  left: 24px;
}

.work-modal-nav.prev::before {
  transform: rotate(-135deg);
}

.work-modal-nav.next {
  right: 24px;
}

.work-modal-nav.next::before {
  transform: rotate(45deg);
}

.modal-open {
  overflow: hidden;
}

.modal-open .page-top {
  display: none;
}




@media (max-width: 737px) {
  .work-modal-panel {
    grid-template-rows: auto minmax(0, 1fr) 26px 56px;
    gap: 8px;
    padding: 112px 20px 18px;
    --work-modal-image-max-height: 100%;
  }

  .work-modal-title {
    max-width: 100%;
  }

  .work-modal-nav {
    top: 92px;
    width: auto;
    min-height: 0;
    flex-direction: row;
    gap: 8px;
    transform: none;
  }

  .work-modal-nav.prev {
    left: 24px;
  }

  .work-modal-nav.next {
    right: 24px;
  }

  .work-modal-nav::before {
    width: 16px;
    height: 16px;
  }

  .work-modal-nav span {
    font-size: 12px;
  }

  .work-modal-image-stage {
    width: 100%;
    max-width: 100%;
    max-height: var(--work-modal-image-max-height);
  }

  .work-modal-image {
    max-height: 100%;
  }

  .work-modal-page-sheet img {
    max-height: 100%;
  }

  .work-modal-thumbnails {
    height: 56px;
    min-height: 56px;
    width: 100%;
    justify-content: flex-start;
  }

  .work-modal-thumbnail {
    flex-basis: 68px;
    width: 68px;
    height: 46px;
  }}

@media (max-width: 920px) {
  .work-modal-close { top: calc(50px + env(safe-area-inset-top, 0px)); }
}

@media (max-width: 402px) {

  .work-modal-panel {
    grid-template-rows: auto minmax(0, 1fr) 26px 56px;
    gap: 8px;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    padding: 112px 20px 18px;
    --work-modal-image-max-height: 100%;
  }

  .work-modal-image-stage {
    width: 100%;
    max-width: 100%;
    max-height: var(--work-modal-image-max-height);
  }

  .work-modal-image {
    max-height: 100%;
  }

  .work-modal-page-sheet img {
    max-height: 100%;
  }

  .work-modal-thumbnails {
    height: 56px;
    min-height: 56px;
    width: 100%;
    justify-content: flex-start;
  }

  .work-modal-thumbnail {
    flex-basis: 68px;
    width: 68px;
    height: 46px;
  }

  .work-modal-close {
    top: calc(50px + env(safe-area-inset-top, 0px));
    right: 18px;
  }

  .work-modal-nav {
    width: auto;
    min-height: 0;
    gap: 8px;
  }

  .work-modal-nav::before {
    width: 16px;
    height: 16px;
  }

  .work-modal-nav span {
    font-size: 12px;
  }

  .work-modal-nav.prev {
    left: 18px;
  }

  .work-modal-nav.next {
    right: 18px;
  }}
/* Keep the existing tablet layout and lower its controls by the same 20px. */
@media (min-width: 738px) and (max-width: 920px) {
  .work-modal-panel { padding-top: calc(clamp(36px, 5vh, 64px) + 20px); }
  .work-modal-nav { top: calc(50% + 20px); }
}
